]> git.localhorst.tv Git - alttp.git/commitdiff
fix scoring bug when non-runners are participating
authorDaniel Karbach <daniel.karbach@localhorst.tv>
Wed, 23 Mar 2022 15:46:32 +0000 (16:46 +0100)
committerDaniel Karbach <daniel.karbach@localhorst.tv>
Wed, 23 Mar 2022 15:46:32 +0000 (16:46 +0100)
resources/js/helpers/Tournament.js

index 792b593091b70ba62a24414325420e8645100786..38750e7379bd32da27fa3b032506c4fe4bf141d8 100644 (file)
@@ -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();