mirror of
https://github.com/pagefaultgames/pokerogue.git
synced 2025-01-19 15:31:01 +00:00
[Bug] Make on-summon abilities trigger after the switch check (#3118)
* Make on-summon abilities trigger after the switch check * Add test
This commit is contained in:
parent
79e2b1215c
commit
5111c916a8
@ -2056,8 +2056,8 @@ export default class BattleScene extends SceneBase {
|
|||||||
const conditionalPhase = this.conditionalQueue.shift();
|
const conditionalPhase = this.conditionalQueue.shift();
|
||||||
// Evaluate the condition associated with the phase
|
// Evaluate the condition associated with the phase
|
||||||
if (conditionalPhase[0]()) {
|
if (conditionalPhase[0]()) {
|
||||||
// If the condition is met, add the phase to the front of the phase queue
|
// If the condition is met, add the phase to the phase queue
|
||||||
this.unshiftPhase(conditionalPhase[1]);
|
this.pushPhase(conditionalPhase[1]);
|
||||||
} else {
|
} else {
|
||||||
// If the condition is not met, re-add the phase back to the front of the conditional queue
|
// If the condition is not met, re-add the phase back to the front of the conditional queue
|
||||||
this.conditionalQueue.unshift(conditionalPhase);
|
this.conditionalQueue.unshift(conditionalPhase);
|
||||||
|
53
src/test/abilities/ability_timing.test.ts
Normal file
53
src/test/abilities/ability_timing.test.ts
Normal file
@ -0,0 +1,53 @@
|
|||||||
|
import { afterEach, beforeAll, beforeEach, describe, expect, it, vi } from "vitest";
|
||||||
|
import Phaser from "phaser";
|
||||||
|
import GameManager from "#app/test/utils/gameManager";
|
||||||
|
import Overrides from "#app/overrides";
|
||||||
|
import { CommandPhase, MessagePhase, TurnInitPhase } from "#app/phases";
|
||||||
|
import { Mode } from "#app/ui/ui";
|
||||||
|
import { Abilities } from "#enums/abilities";
|
||||||
|
import { Moves } from "#enums/moves";
|
||||||
|
import { Species } from "#enums/species";
|
||||||
|
import i18next, { initI18n } from "#app/plugins/i18n";
|
||||||
|
|
||||||
|
|
||||||
|
describe("Ability Timing", () => {
|
||||||
|
let phaserGame: Phaser.Game;
|
||||||
|
let game: GameManager;
|
||||||
|
|
||||||
|
beforeAll(() => {
|
||||||
|
phaserGame = new Phaser.Game({
|
||||||
|
type: Phaser.HEADLESS,
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
afterEach(() => {
|
||||||
|
game.phaseInterceptor.restoreOg();
|
||||||
|
});
|
||||||
|
|
||||||
|
beforeEach(() => {
|
||||||
|
game = new GameManager(phaserGame);
|
||||||
|
vi.spyOn(Overrides, "BATTLE_TYPE_OVERRIDE", "get").mockReturnValue("single");
|
||||||
|
|
||||||
|
vi.spyOn(Overrides, "OPP_SPECIES_OVERRIDE", "get").mockReturnValue(Species.PIDGEY);
|
||||||
|
vi.spyOn(Overrides, "OPP_ABILITY_OVERRIDE", "get").mockReturnValue(Abilities.INTIMIDATE);
|
||||||
|
vi.spyOn(Overrides, "OPP_MOVESET_OVERRIDE", "get").mockReturnValue(Array(4).fill(Moves.SPLASH));
|
||||||
|
|
||||||
|
vi.spyOn(Overrides, "ABILITY_OVERRIDE", "get").mockReturnValue(Abilities.BALL_FETCH);
|
||||||
|
vi.spyOn(Overrides, "MOVESET_OVERRIDE", "get").mockReturnValue([Moves.SPLASH, Moves.ICE_BEAM]);
|
||||||
|
});
|
||||||
|
|
||||||
|
it("should trigger after switch check", async() => {
|
||||||
|
initI18n();
|
||||||
|
i18next.changeLanguage("en");
|
||||||
|
await game.runToSummon([Species.EEVEE, Species.FEEBAS]);
|
||||||
|
|
||||||
|
game.onNextPrompt("CheckSwitchPhase", Mode.CONFIRM, () => {
|
||||||
|
game.setMode(Mode.MESSAGE);
|
||||||
|
game.endPhase();
|
||||||
|
}, () => game.isCurrentPhase(CommandPhase) || game.isCurrentPhase(TurnInitPhase));
|
||||||
|
|
||||||
|
await game.phaseInterceptor.to(MessagePhase);
|
||||||
|
const message = game.textInterceptor.getLatestMessage();
|
||||||
|
expect(message).toContain("Attack fell");
|
||||||
|
}, 5000);
|
||||||
|
});
|
Loading…
x
Reference in New Issue
Block a user