]> git.localhorst.tv Git - alttp.git/blobdiff - resources/js/helpers/Round.js
open tournament type
[alttp.git] / resources / js / helpers / Round.js
index 086517e2f897ec1a79bc709800a0c4b08114b5ad..c7bb811a9c581f80cea1224db8d7d1c35e8d87d8 100644 (file)
@@ -1,8 +1,16 @@
+import Participant from './Participant';
+import Tournament from './Tournament';
+
 export const isComplete = (tournament, round) => {
        if (!tournament || !tournament.participants) return false;
        if (!round || !round.results) return false;
-       return tournament.participants.length === round.results.length &&
-               round.results.filter(r => !r.has_finished).length === 0;
+       const runners = Tournament.getRunners(tournament);
+       if (!runners.length) return false;
+       for (let i = 0; i < runners.length; ++i) {
+               const result = Participant.findResult(runners[i], round);
+               if (!result || !result.has_finished) return false;
+       }
+       return true;
 };
 
 export const patchResult = (round, result) => {