From 01a5fe18dd9654f9a2170860783f5a30853eb131 Mon Sep 17 00:00:00 2001 From: Flashfyre Date: Thu, 14 Dec 2023 09:35:15 -0500 Subject: [PATCH] Remove arena tags before a trainer battle or new biome --- src/arena.ts | 7 +++++++ src/battle-scene.ts | 5 +++-- 2 files changed, 10 insertions(+), 2 deletions(-) diff --git a/src/arena.ts b/src/arena.ts index 0d6587b47..fc1ee4893 100644 --- a/src/arena.ts +++ b/src/arena.ts @@ -353,6 +353,13 @@ export class Arena { }); } + removeAllTags(): void { + for (let t of this.tags) { + t.onRemove(this); + this.tags.splice(this.tags.indexOf(t), 1); + } + } + preloadBgm(): void { this.scene.loadBgm(this.bgm); } diff --git a/src/battle-scene.ts b/src/battle-scene.ts index 8eaf96285..bf885a020 100644 --- a/src/battle-scene.ts +++ b/src/battle-scene.ts @@ -694,11 +694,12 @@ export default class BattleScene extends Phaser.Scene { if (!waveIndex) { const isNewBiome = !lastBattle || !(lastBattle.waveIndex % 10); - const showTrainer = isNewBiome || this.currentBattle.battleType === BattleType.TRAINER; + const resetArenaState = isNewBiome || this.currentBattle.battleType === BattleType.TRAINER; if (lastBattle) { this.getEnemyParty().forEach(enemyPokemon => enemyPokemon.destroy()); this.trySpreadPokerus(); - if (showTrainer) { + if (resetArenaState) { + this.arena.removeAllTags(); playerField.forEach((_, p) => this.unshiftPhase(new ReturnPhase(this, p))); this.unshiftPhase(new ShowTrainerPhase(this)); for (let pokemon of this.getParty()) {