Best-of: Check for overall winner after ties
Some checks are pending
Node.js CI / build (18.x) (push) Waiting to run

This commit is contained in:
Karthik99999 2025-08-13 22:26:16 -04:00
parent 9e13a9eec3
commit 7143879536

View File

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