Skip to content

Commit 87015c0

Browse files
committed
standings fix
1 parent 6dddcfa commit 87015c0

File tree

4 files changed

+20
-11
lines changed

4 files changed

+20
-11
lines changed

dist/components/Tournament.d.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -57,12 +57,13 @@ export declare class Tournament {
5757
private computeScores;
5858
/**
5959
* Sort players by points and tiebreaks
60+
* @hidden
6061
* @param a The points and tiebreaks of one player
6162
* @param b The points and tiebreaks of another player
6263
* @param r The maximum round number to consider for versus tiebreaks
6364
* @returns A positive or negative number for sorting
6465
*/
65-
private sortForStandings;
66+
sortForStandings(a: StandingsValues, b: StandingsValues, r: TournamentValues['round']): number;
6667
/**
6768
* Adjusts seating for elimination if seating matters
6869
* @param p1 First player in a match

dist/components/Tournament.js

Lines changed: 8 additions & 4 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

dist/components/Tournament.js.map

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/components/Tournament.ts

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -411,12 +411,13 @@ export class Tournament {
411411

412412
/**
413413
* Sort players by points and tiebreaks
414+
* @hidden
414415
* @param a The points and tiebreaks of one player
415416
* @param b The points and tiebreaks of another player
416417
* @param r The maximum round number to consider for versus tiebreaks
417418
* @returns A positive or negative number for sorting
418419
*/
419-
private sortForStandings(a: StandingsValues, b: StandingsValues, r: TournamentValues['round']): number {
420+
sortForStandings(a: StandingsValues, b: StandingsValues, r: TournamentValues['round']): number {
420421
if (a.matchPoints !== b.matchPoints) {
421422
return b.matchPoints - a.matchPoints;
422423
}
@@ -1268,9 +1269,12 @@ export class Tournament {
12681269
eliminationMatches.filter(m => m.getRoundNumber() === finalsRoundNumber).sort((a, b) => a.getMatchNumber() - b.getMatchNumber()).forEach(match => {
12691270
if (match.hasEnded()) {
12701271
const winningPlayer = players.find(p => p.player.getId() === match.getWinner().id);
1272+
if (winningPlayer !== undefined && !eliminatedPlayers.includes(winningPlayer)) {
1273+
eliminatedPlayers.push(winningPlayer);
1274+
}
12711275
const losingPlayer = players.find(p => p.player.getId() === match.getLoser().id);
1272-
if (!eliminatedPlayers.includes(winningPlayer) && !eliminatedPlayers.includes(losingPlayer)) {
1273-
eliminatedPlayers.push(winningPlayer, losingPlayer);
1276+
if (losingPlayer !== undefined && !eliminatedPlayers.includes(losingPlayer)) {
1277+
eliminatedPlayers.push(losingPlayer);
12741278
}
12751279
}
12761280
});
@@ -1307,7 +1311,7 @@ export class Tournament {
13071311
*/
13081312
endTournament(): void {
13091313
this.status = 'complete';
1310-
this.players.forEach(player => player.set({ active: false }));
1311-
this.matches.forEach(match => match.set({ active: false }));
1314+
this.getPlayers().forEach(player => player.set({ active: false }));
1315+
this.getMatches().forEach(match => match.set({ active: false }));
13121316
}
13131317
}

0 commit comments

Comments
 (0)