From a005c7c850dfdfecf9179422d09a96f650966596 Mon Sep 17 00:00:00 2001 From: Flashfyre Date: Wed, 5 Jul 2023 16:13:00 -0400 Subject: [PATCH] Fix crash when returning shiny --- src/battle-phases.ts | 31 ++++++++++++++++++++----------- 1 file changed, 20 insertions(+), 11 deletions(-) diff --git a/src/battle-phases.ts b/src/battle-phases.ts index 8b5f90453e7..87a0c21f448 100644 --- a/src/battle-phases.ts +++ b/src/battle-phases.ts @@ -550,11 +550,7 @@ export class SummonPhase extends PartyMemberPokemonPhase { }); } - queuePostSummon() { - this.scene.pushPhase(new PostSummonPhase(this.scene, this.getPokemon().getBattlerIndex())); - } - - end() { + onEnd(): void { const pokemon = this.getPokemon(); if (pokemon.shiny) @@ -563,6 +559,14 @@ export class SummonPhase extends PartyMemberPokemonPhase { pokemon.resetTurnData(); this.queuePostSummon(); + } + + queuePostSummon(): void { + this.scene.pushPhase(new PostSummonPhase(this.scene, this.getPokemon().getBattlerIndex())); + } + + end() { + this.onEnd(); super.end(); } @@ -632,19 +636,19 @@ export class SwitchSummonPhase extends SummonPhase { this.end(); } - queuePostSummon() { - this.scene.unshiftPhase(new PostSummonPhase(this.scene, this.getPokemon().getBattlerIndex())); - } + onEnd(): void { + super.onEnd(); - end() { const pokemon = this.getPokemon(); if (this.batonPass && pokemon) pokemon.transferSummon(this.lastPokemon); this.lastPokemon?.resetSummonData(); + } - super.end(); + queuePostSummon(): void { + this.scene.unshiftPhase(new PostSummonPhase(this.scene, this.getPokemon().getBattlerIndex())); } } @@ -659,7 +663,12 @@ export class ReturnPhase extends SwitchSummonPhase { summon(): void { } - queuePostSummon() { } + onEnd(): void { + const pokemon = this.getPokemon(); + + pokemon.resetTurnData(); + pokemon.resetSummonData(); + } } export class ToggleDoublePositionPhase extends BattlePhase {