@@ -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