]> git.localhorst.tv Git - alttp.git/blobdiff - resources/js/helpers/Round.js
open tournament type
[alttp.git] / resources / js / helpers / Round.js
index 8a8b6ade939cc16e16347ab580ecbeec685f6bf0..c7bb811a9c581f80cea1224db8d7d1c35e8d87d8 100644 (file)
@@ -1,3 +1,18 @@
+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;
+       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) => {
        if (!round) return round;
        if (!round.results || !round.results.length) {
@@ -13,5 +28,6 @@ export const patchResult = (round, result) => {
 };
 
 export default {
+       isComplete,
        patchResult,
 };