From 7ed11879a323f38b632c4a31d0856f7a7798ac26 Mon Sep 17 00:00:00 2001 From: 0zuzu Date: Thu, 16 May 2024 22:01:53 +0100 Subject: [PATCH] Check available pkmn before asking to switch, disabled unecessary move text. --- src/phases.ts | 32 ++++++++++++++++++++------------ 1 file changed, 20 insertions(+), 12 deletions(-) diff --git a/src/phases.ts b/src/phases.ts index f44b4bcaa0b..d7132ce58ec 100644 --- a/src/phases.ts +++ b/src/phases.ts @@ -364,10 +364,13 @@ export class TitlePhase extends Phase { this.scene.pushPhase(new SummonPhase(this.scene, 0, true, true)); if (this.scene.currentBattle.double && availablePartyMembers > 1) this.scene.pushPhase(new SummonPhase(this.scene, 1, true, true)); - if (this.scene.currentBattle.waveIndex > 1 && this.scene.currentBattle.battleType !== BattleType.TRAINER) { - this.scene.pushPhase(new CheckSwitchPhase(this.scene, 0, this.scene.currentBattle.double)); - if (this.scene.currentBattle.double && availablePartyMembers > 1) - this.scene.pushPhase(new CheckSwitchPhase(this.scene, 1, this.scene.currentBattle.double)); + if (this.scene.currentBattle.battleType !== BattleType.TRAINER) { + const minPartySize = this.scene.currentBattle.double ? 2 : 1; + if (availablePartyMembers > minPartySize) { + this.scene.pushPhase(new CheckSwitchPhase(this.scene, 0, this.scene.currentBattle.double)); + if (this.scene.currentBattle.double) + this.scene.pushPhase(new CheckSwitchPhase(this.scene, 1, this.scene.currentBattle.double)); + } } } @@ -953,10 +956,13 @@ export class EncounterPhase extends BattlePhase { this.scene.pushPhase(new ToggleDoublePositionPhase(this.scene, false)); } - if (this.scene.currentBattle.waveIndex > startingWave && this.scene.currentBattle.battleType !== BattleType.TRAINER) { - this.scene.pushPhase(new CheckSwitchPhase(this.scene, 0, this.scene.currentBattle.double)); - if (this.scene.currentBattle.double && availablePartyMembers.length > 1) - this.scene.pushPhase(new CheckSwitchPhase(this.scene, 1, this.scene.currentBattle.double)); + if (this.scene.currentBattle.battleType !== BattleType.TRAINER) { + const minPartySize = this.scene.currentBattle.double ? 2 : 1; + if (availablePartyMembers.length > minPartySize) { + this.scene.pushPhase(new CheckSwitchPhase(this.scene, 0, this.scene.currentBattle.double)); + if (this.scene.currentBattle.double) + this.scene.pushPhase(new CheckSwitchPhase(this.scene, 1, this.scene.currentBattle.double)); + } } } @@ -2316,12 +2322,8 @@ export class MovePhase extends BattlePhase { this.scene.triggerPokemonFormChange(this.pokemon, SpeciesFormChangePreMoveTrigger); - if (this.move.moveId) - this.showMoveText(); - // This should only happen when there are no valid targets left on the field if ((moveQueue.length && moveQueue[0].move === Moves.NONE) || !targets.length) { - this.showFailedText(); this.cancel(); // Record a failed move so Abilities like Truant don't trigger next turn and soft-lock @@ -2333,6 +2335,12 @@ export class MovePhase extends BattlePhase { return this.end(); } + // Display move text as long as it wasn't cancelled + if (this.move.moveId && !this.cancelled) + this.showMoveText(); + if (this.failed) + this.showFailedText(); + if (!moveQueue.length || !moveQueue.shift().ignorePP) // using .shift here clears out two turn moves once they've been used this.move.usePp(ppUsed);