mirror of
https://github.com/smogon/pokemon-showdown.git
synced 2026-08-27 19:44:50 -05:00
Clear timer after battle end
This should fix the bug where timer messages would sometimes still show up after the end of the game.
This commit is contained in:
@@ -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);
|
||||
|
||||
Reference in New Issue
Block a user