X-Git-Url: https://git.localhorst.tv/?a=blobdiff_plain;ds=sidebyside;f=resources%2Fjs%2Fhelpers%2FTournament.js;fp=resources%2Fjs%2Fhelpers%2FTournament.js;h=38750e7379bd32da27fa3b032506c4fe4bf141d8;hb=c9f99f9ad642f6c387b36b640c3c17cdfe58988a;hp=792b593091b70ba62a24414325420e8645100786;hpb=33cc4da565ffb07ee4f8d9cbafb248629b85e65a;p=alttp.git diff --git a/resources/js/helpers/Tournament.js b/resources/js/helpers/Tournament.js index 792b593..38750e7 100644 --- a/resources/js/helpers/Tournament.js +++ b/resources/js/helpers/Tournament.js @@ -2,11 +2,13 @@ import Participant from './Participant'; import Round from './Round'; export const calculateScores = tournament => { - const scores = getRunners(tournament).map(participant => ({ participant, score: 0 })); + const runners = getRunners(tournament); + const scores = runners.map(participant => ({ participant, score: 0 })); + if (!scores.length) return scores; if (!tournament.rounds || !tournament.rounds.length) return scores; tournament.rounds.forEach(round => { const filtered = Participant - .sortByResult(tournament.participants, round) + .sortByResult(runners, round) .map(p => ({ participant: p, result: Participant.findResult(p, round) })) .filter(r => r.result && (r.result.time || r.result.forfeit)) .reverse();