diff --git a/src/battle-phases.ts b/src/battle-phases.ts index ee9d11acd81..9b79ca95ccc 100644 --- a/src/battle-phases.ts +++ b/src/battle-phases.ts @@ -379,6 +379,12 @@ export class CheckSwitchPhase extends BattlePhase { start() { super.start(); + if (this.scene.field.getAll().indexOf(this.scene.getPlayerPokemon()) === -1) { + this.scene.unshiftPhase(new SummonMissingPhase(this.scene)); + super.end(); + return; + } + this.scene.ui.showText('Will you switch\nPOKéMON?', null, () => { this.scene.ui.setMode(Mode.CONFIRM, () => { this.scene.unshiftPhase(new SwitchPhase(this.scene, false, true)); @@ -388,6 +394,17 @@ export class CheckSwitchPhase extends BattlePhase { } } +export class SummonMissingPhase extends SummonPhase { + constructor(scene: BattleScene) { + super(scene); + } + + preSummon(): void { + this.scene.ui.showText(`Go! ${this.scene.getPlayerPokemon().name}!`); + this.scene.time.delayedCall(250, () => this.summon()); + } +} + export class CommandPhase extends BattlePhase { constructor(scene: BattleScene) { super(scene) @@ -1375,6 +1392,7 @@ export class AttemptCapturePhase extends BattlePhase { }); }); }, () => { + this.scene.ui.setMode(Mode.MESSAGE); pokemon.hp = 0; end(); }); diff --git a/src/pokemon.ts b/src/pokemon.ts index 1e33bc18424..2e282f8e351 100644 --- a/src/pokemon.ts +++ b/src/pokemon.ts @@ -15,7 +15,7 @@ import { initMoveAnim, loadMoveAnimAssets } from './battle-anims'; import { Status, StatusEffect } from './status-effect'; import { tmSpecies } from './tms'; import { pokemonEvolutions, SpeciesEvolution, SpeciesEvolutionCondition } from './pokemon-evolutions'; -import { MessagePhase, StatChangePhase } from './battle-phases'; +import { MessagePhase } from './battle-phases'; import { BattleStat } from './battle-stat'; import { BattleTag, BattleTagLapseType, BattleTagType } from './battle-tag'; @@ -716,6 +716,11 @@ export default abstract class Pokemon extends Phaser.GameObjects.Container { this.scene.sound.play('sparkle'); } } + + destroy(): void { + this.battleInfo.destroy(); + super.destroy(); + } } export class PlayerPokemon extends Pokemon { diff --git a/src/ui/party-ui-handler.ts b/src/ui/party-ui-handler.ts index 3a09121ae79..6875d3a95c1 100644 --- a/src/ui/party-ui-handler.ts +++ b/src/ui/party-ui-handler.ts @@ -1,4 +1,4 @@ -import { CommandPhase } from "../battle-phases"; +import { CommandPhase, SummonMissingPhase } from "../battle-phases"; import BattleScene, { Button } from "../battle-scene"; import { PlayerPokemon, PokemonMove } from "../pokemon"; import { addTextObject, TextStyle } from "../text"; @@ -411,7 +411,8 @@ export default class PartyUiHandler extends MessageUiHandler { this.showText(this.getReleaseMessage(this.scene.getParty()[slotIndex].name), null, () => { this.clearPartySlots(); this.scene.removePartyMemberModifiers(slotIndex); - this.scene.getParty().splice(slotIndex, 1); + const releasedPokemon = this.scene.getParty().splice(slotIndex, 1)[0]; + releasedPokemon.destroy(); this.populatePartySlots(); if (this.cursor >= this.scene.getParty().length) this.setCursor(this.cursor - 1);