From 47f9372d2a4c12ea7fad00cede31c19e26d0650e Mon Sep 17 00:00:00 2001 From: Guangcong Luo Date: Tue, 16 Jul 2019 08:54:27 -0500 Subject: [PATCH] Clear timer after battle end This should fix the bug where timer messages would sometimes still show up after the end of the game. --- server/room-battle.js | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/server/room-battle.js b/server/room-battle.js index 80d6999e17..0fa17c3bca 100644 --- a/server/room-battle.js +++ b/server/room-battle.js @@ -239,10 +239,17 @@ class RoomBattleTimer { this.battle.room.add(`|inactive|${requester.name} no longer wants the timer on, but the timer is staying on because ${[...this.timerRequesters].join(', ')} still does.`).update(); return false; } + if (this.end()) { + this.battle.room.add(`|inactiveoff|Battle timer is now OFF.`).update(); + return true; + } + return false; + } + end() { + this.timerRequesters.clear(); if (!this.timer) return false; clearTimeout(this.timer); this.timer = null; - this.battle.room.add(`|inactiveoff|Battle timer is now OFF.`).update(); return true; } waitingForChoice(/** @type {SideID} */ slot) { @@ -729,6 +736,7 @@ class RoomBattle extends RoomGames.RoomGame { * @param {any} winner */ async onEnd(winner) { + this.timer.end(); // Declare variables here in case we need them for non-rated battles logging. let p1score = 0.5; const winnerid = toID(winner);