[Bug][Ability] Fix wimp out and emergency exit skipping waves in double battles (#5261)

Fix wimp out causing battles to skip
This commit is contained in:
Sirz Benjie 2025-04-04 16:39:53 -05:00 committed by GitHub
parent 68f10dc199
commit b364bb1899
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
3 changed files with 48 additions and 0 deletions

View File

@ -17,6 +17,23 @@ export class BattleEndPhase extends BattlePhase {
start() {
super.start();
// cull any extra `BattleEnd` phases from the queue.
globalScene.phaseQueue = globalScene.phaseQueue.filter(phase => {
if (phase instanceof BattleEndPhase) {
this.isVictory ||= phase.isVictory;
return false;
}
return true;
});
// `phaseQueuePrepend` is private, so we have to use this inefficient loop.
while (globalScene.tryRemoveUnshiftedPhase(phase => {
if (phase instanceof BattleEndPhase) {
this.isVictory ||= phase.isVictory;
return true;
}
return false;
})) {}
globalScene.gameData.gameStats.battles++;
if (
globalScene.gameMode.isEndless &&

View File

@ -5,6 +5,11 @@ export class NewBattlePhase extends BattlePhase {
start() {
super.start();
// cull any extra `NewBattle` phases from the queue.
globalScene.phaseQueue = globalScene.phaseQueue.filter(phase => !(phase instanceof NewBattlePhase));
// `phaseQueuePrepend` is private, so we have to use this inefficient loop.
while (globalScene.tryRemoveUnshiftedPhase(phase => phase instanceof NewBattlePhase)) {}
globalScene.newBattle();
this.end();

View File

@ -498,6 +498,7 @@ describe("Abilities - Wimp Out", () => {
const hasFled = enemyPokemon.switchOutStatus;
expect(isVisible && !hasFled).toBe(true);
});
it("wimp out will not skip battles when triggered in a double battle", async () => {
const wave = 2;
game.override
@ -525,4 +526,29 @@ describe("Abilities - Wimp Out", () => {
await game.toNextWave();
expect(game.scene.currentBattle.waveIndex).toBe(wave + 1);
});
it("wimp out should not skip battles when triggering the same turn as another enemy faints", async () => {
const wave = 2;
game.override
.enemySpecies(Species.WIMPOD)
.enemyAbility(Abilities.WIMP_OUT)
.startingLevel(50)
.enemyLevel(1)
.enemyMoveset([ Moves.SPLASH, Moves.ENDURE ])
.battleType("double")
.moveset([ Moves.DRAGON_ENERGY, Moves.SPLASH ])
.startingWave(wave);
await game.classicMode.startBattle([ Species.REGIDRAGO, Species.MAGIKARP ]);
// turn 1
game.move.select(Moves.DRAGON_ENERGY, 0);
game.move.select(Moves.SPLASH, 1);
await game.forceEnemyMove(Moves.SPLASH);
await game.forceEnemyMove(Moves.ENDURE);
await game.phaseInterceptor.to("SelectModifierPhase");
expect(game.scene.currentBattle.waveIndex).toBe(wave + 1);
});
});