X-Git-Url: https://git.localhorst.tv/?a=blobdiff_plain;f=resources%2Fjs%2Fhelpers%2FRound.js;h=c7bb811a9c581f80cea1224db8d7d1c35e8d87d8;hb=90922f8595a8d4fd7780a0b137eed66eaf7d6c49;hp=086517e2f897ec1a79bc709800a0c4b08114b5ad;hpb=c59d0714d62f9028135cc9cff829d16b91e5fb4f;p=alttp.git diff --git a/resources/js/helpers/Round.js b/resources/js/helpers/Round.js index 086517e..c7bb811 100644 --- a/resources/js/helpers/Round.js +++ b/resources/js/helpers/Round.js @@ -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) => {