diff --git a/server/room-battle.ts b/server/room-battle.ts index 0c482a5a48..398b58b726 100644 --- a/server/room-battle.ts +++ b/server/room-battle.ts @@ -1239,7 +1239,10 @@ export class RoomBattle extends RoomGame { } override destroy() { - this.setEnded(); + if (!this.ended) { + this.setEnded(); + this.room.parent?.game?.onBattleWin?.(this.room, ''); + } for (const player of this.players) { player.destroy(); } diff --git a/server/rooms.ts b/server/rooms.ts index e1fe8998cf..24f692e285 100644 --- a/server/rooms.ts +++ b/server/rooms.ts @@ -1106,9 +1106,10 @@ export abstract class BasicRoom { destroy(): void { // deallocate ourself - if (this.battle && this.tour) { - // resolve state of the tournament; - if (!this.battle.ended) this.tour.onBattleWin(this as any as GameRoom, ''); + if (this.game) { + this.game.destroy(); + this.game = null; + this.battle = null; this.tour = null; } @@ -1132,11 +1133,6 @@ export abstract class BasicRoom { } } - if (this.game) { - this.game.destroy(); - this.game = null; - this.battle = null; - } this.active = false; // Ensure there aren't any pending messages that could restart the expire timer