From 2b514ec5f78a82fcb1c02780f97cf6f21ce37eb3 Mon Sep 17 00:00:00 2001 From: dot-Comfey <84290266+dot-Comfey@users.noreply.github.com> Date: Tue, 16 Apr 2024 19:31:28 -0700 Subject: [PATCH] Chansey's Egg Toss: fix ending on player removal (#84) --- src/games/chanseys-egg-toss.ts | 16 +++++++--------- 1 file changed, 7 insertions(+), 9 deletions(-) diff --git a/src/games/chanseys-egg-toss.ts b/src/games/chanseys-egg-toss.ts index 052b3c9f..540fa6ce 100644 --- a/src/games/chanseys-egg-toss.ts +++ b/src/games/chanseys-egg-toss.ts @@ -30,8 +30,8 @@ class ChanseysEggToss extends ScriptedGame { this.currentHolder = player; this.explodeEgg(reason); } else { - this.eliminatePlayer(player); this.say(player.name + " was DQed " + reason + "!"); + this.eliminatePlayer(player); } } @@ -44,12 +44,16 @@ class ChanseysEggToss extends ScriptedGame { } onRemovePlayer(player: Player): void { - if (this.currentHolder && this.getRemainingPlayerCount() < 2) { + if (this.getRemainingPlayerCount() < 2) { this.say(player.name + " left the game!"); this.end(); } } + onEliminatePlayer(): void { + if (this.getRemainingPlayerCount() < 2) this.end(); + } + giveEgg(player: Player): void { const previousHolder = this.currentHolder; @@ -77,16 +81,10 @@ class ChanseysEggToss extends ScriptedGame { this.currentHolder = null; } - if (this.getRemainingPlayerCount() < 2) return this.end(); this.setTimeout(() => void this.nextRound(), 5000); } async onNextRound(): Promise { // eslint-disable-line @typescript-eslint/require-await - const remainingPlayerCount = this.getRemainingPlayerCount(); - if (remainingPlayerCount < 2) { - return this.end(); - } - this.spamTosses.clear(); const html = this.getRoundHtml(players => this.getPlayerNames(players)); @@ -97,7 +95,7 @@ class ChanseysEggToss extends ScriptedGame { const eggText = "Chansey handed the egg to **" + holder.name + "**!"; this.on(eggText, () => { let time: number; - if (remainingPlayerCount === 2) { + if (this.getRemainingPlayerCount() === 2) { time = 5000; } else { time = this.sampleOne(this.roundTimes);