X-Git-Url: https://git.localhorst.tv/?a=blobdiff_plain;f=resources%2Fjs%2Fhelpers%2FRound.js;h=f662defaa4d5f23bc476127b55a458ab6fc4a04e;hb=cd36cb0ba2718e6bfa08765e7702d57dfe7fd733;hp=8a8b6ade939cc16e16347ab580ecbeec685f6bf0;hpb=d748feb96453d74aeffec648d6f5f68d9ef3b520;p=alttp.git diff --git a/resources/js/helpers/Round.js b/resources/js/helpers/Round.js index 8a8b6ad..f662def 100644 --- a/resources/js/helpers/Round.js +++ b/resources/js/helpers/Round.js @@ -1,3 +1,17 @@ +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); + 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 +27,6 @@ export const patchResult = (round, result) => { }; export default { + isComplete, patchResult, };