From 67d5532d153f39d84d288fedc60849dbae24bc3d Mon Sep 17 00:00:00 2001 From: 0zuzu <63069680+0zuzu@users.noreply.github.com> Date: Tue, 21 May 2024 08:16:17 +0100 Subject: [PATCH] Check available Pkmn before asking to switch (#1194) * Create Start Server.bat idk anymore * Update .gitignore * Delete Start Server.bat * Update .gitignore * Update phases.ts Check available party before asking to switch --- src/phases.ts | 23 +++++++++++++++-------- 1 file changed, 15 insertions(+), 8 deletions(-) diff --git a/src/phases.ts b/src/phases.ts index de40e1abe6b..c560fd5daa0 100644 --- a/src/phases.ts +++ b/src/phases.ts @@ -366,10 +366,14 @@ 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 && (this.scene.currentBattle.waveIndex > 1 || !this.scene.gameMode.isDaily)) { + 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)); + } } } @@ -955,10 +959,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 && (this.scene.currentBattle.waveIndex > 1 || !this.scene.gameMode.isDaily)) { + 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)); + } } }