Fix bug with releasing first party member

This commit is contained in:
Flashfyre 2023-04-13 23:50:48 -04:00
parent 1b8c8b5a3f
commit 618128dd00
3 changed files with 27 additions and 3 deletions

View File

@ -379,6 +379,12 @@ export class CheckSwitchPhase extends BattlePhase {
start() { start() {
super.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.showText('Will you switch\nPOKéMON?', null, () => {
this.scene.ui.setMode(Mode.CONFIRM, () => { this.scene.ui.setMode(Mode.CONFIRM, () => {
this.scene.unshiftPhase(new SwitchPhase(this.scene, false, true)); 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 { export class CommandPhase extends BattlePhase {
constructor(scene: BattleScene) { constructor(scene: BattleScene) {
super(scene) super(scene)
@ -1375,6 +1392,7 @@ export class AttemptCapturePhase extends BattlePhase {
}); });
}); });
}, () => { }, () => {
this.scene.ui.setMode(Mode.MESSAGE);
pokemon.hp = 0; pokemon.hp = 0;
end(); end();
}); });

View File

@ -15,7 +15,7 @@ import { initMoveAnim, loadMoveAnimAssets } from './battle-anims';
import { Status, StatusEffect } from './status-effect'; import { Status, StatusEffect } from './status-effect';
import { tmSpecies } from './tms'; import { tmSpecies } from './tms';
import { pokemonEvolutions, SpeciesEvolution, SpeciesEvolutionCondition } from './pokemon-evolutions'; import { pokemonEvolutions, SpeciesEvolution, SpeciesEvolutionCondition } from './pokemon-evolutions';
import { MessagePhase, StatChangePhase } from './battle-phases'; import { MessagePhase } from './battle-phases';
import { BattleStat } from './battle-stat'; import { BattleStat } from './battle-stat';
import { BattleTag, BattleTagLapseType, BattleTagType } from './battle-tag'; 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'); this.scene.sound.play('sparkle');
} }
} }
destroy(): void {
this.battleInfo.destroy();
super.destroy();
}
} }
export class PlayerPokemon extends Pokemon { export class PlayerPokemon extends Pokemon {

View File

@ -1,4 +1,4 @@
import { CommandPhase } from "../battle-phases"; import { CommandPhase, SummonMissingPhase } from "../battle-phases";
import BattleScene, { Button } from "../battle-scene"; import BattleScene, { Button } from "../battle-scene";
import { PlayerPokemon, PokemonMove } from "../pokemon"; import { PlayerPokemon, PokemonMove } from "../pokemon";
import { addTextObject, TextStyle } from "../text"; 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.showText(this.getReleaseMessage(this.scene.getParty()[slotIndex].name), null, () => {
this.clearPartySlots(); this.clearPartySlots();
this.scene.removePartyMemberModifiers(slotIndex); this.scene.removePartyMemberModifiers(slotIndex);
this.scene.getParty().splice(slotIndex, 1); const releasedPokemon = this.scene.getParty().splice(slotIndex, 1)[0];
releasedPokemon.destroy();
this.populatePartySlots(); this.populatePartySlots();
if (this.cursor >= this.scene.getParty().length) if (this.cursor >= this.scene.getParty().length)
this.setCursor(this.cursor - 1); this.setCursor(this.cursor - 1);