mirror of
https://github.com/smogon/pokemon-showdown.git
synced 2026-03-21 17:25:10 -05:00
Best-of: Check for overall winner after ties
Some checks are pending
Node.js CI / build (18.x) (push) Waiting to run
Some checks are pending
Node.js CI / build (18.x) (push) Waiting to run
This commit is contained in:
parent
9e13a9eec3
commit
7143879536
|
|
@ -364,17 +364,15 @@ export class BestOfGame extends RoomGame<BestOfPlayer> {
|
|||
return this.forfeit(loserPlayer.name, ` lost the series due to inactivity.`);
|
||||
}
|
||||
this.room.add(Utils.html`|html|${winner.name} won game ${this.games.length}!`).update();
|
||||
if (winner.wins >= this.winThreshold) {
|
||||
return this.end(winner.id);
|
||||
}
|
||||
} else {
|
||||
this.ties++;
|
||||
this.winThreshold = Math.floor((this.bestOf - this.ties) / 2) + 1;
|
||||
this.room.add(`|html|Game ${this.games.length} was a tie.`).update();
|
||||
}
|
||||
if (this.games.length >= this.bestOf) {
|
||||
return this.end(''); // overall tie
|
||||
}
|
||||
|
||||
const overallWinner = this.players.find(p => p.wins >= this.winThreshold);
|
||||
if (overallWinner) return this.end(overallWinner.id);
|
||||
if (this.games.length >= this.bestOf) return this.end(''); // overall tie
|
||||
|
||||
// no one has won, skip onwards
|
||||
this.promptNextGame(room);
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user