mirror of
https://github.com/pagefaultgames/pokerogue.git
synced 2025-08-07 07:59:26 +02:00
[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:
parent
68f10dc199
commit
b364bb1899
@ -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 &&
|
||||
|
@ -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();
|
||||
|
@ -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);
|
||||
|
||||
});
|
||||
});
|
||||
|
Loading…
Reference in New Issue
Block a user