[Bug] Fix CheckSwitchPhase on single -> double and reload (#6594)

This commit is contained in:
Dean 2025-09-28 18:34:11 -07:00 committed by GitHub
parent 985b0ea483
commit abf2df5147
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
3 changed files with 22 additions and 22 deletions

View File

@ -579,21 +579,22 @@ export class EncounterPhase extends BattlePhase {
currentBattle.battleType !== BattleType.TRAINER
&& (currentBattle.waveIndex > 1 || !globalScene.gameMode.isDaily)
&& availablePartyMembers.length > minPartySize;
const checkSwitchIndices: number[] = [];
const phaseManager = globalScene.phaseManager;
if (!availablePartyMembers[0].isOnField()) {
phaseManager.pushNew("SummonPhase", 0, true, false, checkSwitch);
} else if (checkSwitch) {
globalScene.phaseManager.pushNew("CheckSwitchPhase", 0, globalScene.currentBattle.double);
checkSwitchIndices.push(0);
}
if (currentBattle.double) {
if (availablePartyMembers.length > 1) {
phaseManager.pushNew("ToggleDoublePositionPhase", true);
if (!availablePartyMembers[1].isOnField()) {
phaseManager.pushNew("SummonPhase", 1);
phaseManager.pushNew("SummonPhase", 1, true, false, checkSwitch);
} else if (checkSwitch) {
globalScene.phaseManager.pushNew("CheckSwitchPhase", 1, globalScene.currentBattle.double);
checkSwitchIndices.push(1);
}
}
} else {
@ -602,6 +603,9 @@ export class EncounterPhase extends BattlePhase {
}
phaseManager.pushNew("ToggleDoublePositionPhase", false);
}
checkSwitchIndices.forEach(i => {
phaseManager.pushNew("CheckSwitchPhase", i, globalScene.currentBattle.double);
});
}
handleTutorial(Tutorial.Access_Menu).then(() => super.end());
}

View File

@ -414,11 +414,12 @@ export class MysteryEncounterBattlePhase extends Phase {
encounterMode !== MysteryEncounterMode.TRAINER_BATTLE
&& !this.disableSwitch
&& availablePartyMembers.length > minPartySize;
const checkSwitchIndices: number[] = [];
if (!availablePartyMembers[0].isOnField()) {
globalScene.phaseManager.pushNew("SummonPhase", 0, true, false, checkSwitch);
} else if (checkSwitch) {
globalScene.phaseManager.pushNew("CheckSwitchPhase", 0, globalScene.currentBattle.double);
checkSwitchIndices.push(0);
}
if (globalScene.currentBattle.double) {
@ -427,7 +428,7 @@ export class MysteryEncounterBattlePhase extends Phase {
if (!availablePartyMembers[1].isOnField()) {
globalScene.phaseManager.pushNew("SummonPhase", 1, true, false, checkSwitch);
} else if (checkSwitch) {
globalScene.phaseManager.pushNew("CheckSwitchPhase", 0, globalScene.currentBattle.double);
checkSwitchIndices.push(1);
}
}
} else {
@ -438,16 +439,9 @@ export class MysteryEncounterBattlePhase extends Phase {
globalScene.phaseManager.pushNew("ToggleDoublePositionPhase", false);
}
if (encounterMode !== MysteryEncounterMode.TRAINER_BATTLE && !this.disableSwitch) {
const minPartySize = globalScene.currentBattle.double ? 2 : 1;
if (availablePartyMembers.length > minPartySize) {
globalScene.phaseManager.pushNew("CheckSwitchPhase", 0, globalScene.currentBattle.double);
if (globalScene.currentBattle.double) {
globalScene.phaseManager.pushNew("CheckSwitchPhase", 1, globalScene.currentBattle.double);
}
}
}
checkSwitchIndices.forEach(i => {
globalScene.phaseManager.pushNew("CheckSwitchPhase", i, globalScene.currentBattle.double);
});
this.end();
}

View File

@ -279,6 +279,14 @@ export class SummonPhase extends PartyMemberPokemonPhase {
pokemon.resetTurnData();
if (this.checkSwitch) {
globalScene.phaseManager.pushNew(
"CheckSwitchPhase",
this.getPokemon().getFieldIndex(),
globalScene.currentBattle.double,
);
}
if (
!this.loaded
|| [BattleType.TRAINER, BattleType.MYSTERY_ENCOUNTER].includes(globalScene.currentBattle.battleType)
@ -290,13 +298,7 @@ export class SummonPhase extends PartyMemberPokemonPhase {
}
queuePostSummon(): void {
if (this.checkSwitch) {
globalScene.phaseManager.pushNew(
"CheckSwitchPhase",
this.getPokemon().getFieldIndex(),
globalScene.currentBattle.double,
);
} else {
if (!this.checkSwitch) {
globalScene.phaseManager.pushNew("PostSummonPhase", this.getPokemon().getBattlerIndex(), this.phaseName);
}