]> git.localhorst.tv Git - alttp.git/blobdiff - resources/js/helpers/Round.js
allow admins to lock/unlock rounds
[alttp.git] / resources / js / helpers / Round.js
index 086517e2f897ec1a79bc709800a0c4b08114b5ad..f662defaa4d5f23bc476127b55a458ab6fc4a04e 100644 (file)
@@ -1,8 +1,15 @@
+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);
+       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) => {