mirror of
https://github.com/pagefaultgames/pokerogue.git
synced 2025-08-11 09:59:28 +02:00
Maybe fixed things a guess
This commit is contained in:
parent
69fff96089
commit
99a5f0d9ba
@ -73,31 +73,9 @@ describe("Moves - Parting Shot", () => {
|
||||
SpeciesId.ABRA,
|
||||
]);
|
||||
|
||||
// use Memento 3 times to debuff enemy
|
||||
game.move.select(MoveId.MEMENTO);
|
||||
await game.phaseInterceptor.to("FaintPhase");
|
||||
expect(game.scene.getPlayerParty()[0].isFainted()).toBe(true);
|
||||
game.doSelectPartyPokemon(1);
|
||||
|
||||
await game.phaseInterceptor.to("TurnInitPhase", false);
|
||||
game.move.select(MoveId.MEMENTO);
|
||||
await game.phaseInterceptor.to("FaintPhase");
|
||||
expect(game.scene.getPlayerParty()[0].isFainted()).toBe(true);
|
||||
game.doSelectPartyPokemon(2);
|
||||
|
||||
await game.phaseInterceptor.to("TurnInitPhase", false);
|
||||
game.move.select(MoveId.MEMENTO);
|
||||
await game.phaseInterceptor.to("FaintPhase");
|
||||
expect(game.scene.getPlayerParty()[0].isFainted()).toBe(true);
|
||||
game.doSelectPartyPokemon(3);
|
||||
|
||||
// set up done
|
||||
await game.phaseInterceptor.to(TurnInitPhase, false);
|
||||
const enemyPokemon = game.field.getEnemyPokemon();
|
||||
expect(enemyPokemon).toBeDefined();
|
||||
|
||||
expect(enemyPokemon.getStatStage(Stat.ATK)).toBe(-6);
|
||||
expect(enemyPokemon.getStatStage(Stat.SPATK)).toBe(-6);
|
||||
enemyPokemon.setStatStage(Stat.ATK, -6);
|
||||
enemyPokemon.setStatStage(Stat.SPATK, -6);
|
||||
|
||||
// now parting shot should fail
|
||||
game.move.select(MoveId.PARTING_SHOT);
|
||||
|
@ -61,6 +61,9 @@ export class PromptHandler extends GameManagerHelper {
|
||||
).mockImplementation((...args) => this.setMode(args));
|
||||
|
||||
// Set an interval to repeatedly check the current prompt.
|
||||
if (PromptHandler.runInterval) {
|
||||
throw new Error("Prompt handler run interval was not properly cleared on test end!");
|
||||
}
|
||||
PromptHandler.runInterval = setInterval(() => this.doPromptCheck());
|
||||
}
|
||||
|
||||
@ -94,7 +97,6 @@ export class PromptHandler extends GameManagerHelper {
|
||||
}
|
||||
|
||||
const prompt = this.prompts[0];
|
||||
this.doLog("Checking prompts...");
|
||||
|
||||
// remove expired prompts
|
||||
if (prompt.expireFn?.()) {
|
||||
|
@ -74,15 +74,17 @@ export class PhaseInterceptor {
|
||||
// TODO: remove bangs once signature is updated
|
||||
let currentPhase: Phase = pm.getCurrentPhase()!;
|
||||
|
||||
let didLog = false;
|
||||
|
||||
// NB: This has to use an interval to wait for UI prompts to activate.
|
||||
// TODO: Rework after UI rework
|
||||
await vi.waitUntil(
|
||||
async () => {
|
||||
// If we were interrupted by a UI prompt, we assume that the calling code will queue inputs to
|
||||
// end the current phase manually, so we just wait for the phase to end from the caller.
|
||||
if (this.state === "interrupted") {
|
||||
if (this.state === "interrupted" && !didLog) {
|
||||
this.doLog("PhaseInterceptor.to: Waiting for phase to end after being interrupted!");
|
||||
await setTimeout(50);
|
||||
didLog = true;
|
||||
return false;
|
||||
}
|
||||
|
||||
|
@ -8,7 +8,7 @@ import type { PhaseInterceptor } from "#test/test-utils/phase-interceptor";
|
||||
import type { UI } from "#ui/ui";
|
||||
import { beforeAll, beforeEach, describe, expect, it, type Mock, vi } from "vitest";
|
||||
|
||||
describe("Utils - PromptHandler", () => {
|
||||
describe("Test Utils - PromptHandler", () => {
|
||||
let promptHandler: PromptHandler;
|
||||
let handler: AwaitableUiHandler;
|
||||
|
||||
|
@ -52,7 +52,7 @@ describe("Utils - Phase Interceptor - Integration", () => {
|
||||
|
||||
it("should not break when phase ended early via prompt", async () => {
|
||||
await game.classicMode.startBattle([SpeciesId.REGIELEKI]);
|
||||
game.onNextPrompt("CommandPhase", UiMode.FIGHT, () => {
|
||||
game.onNextPrompt("CommandPhase", UiMode.COMMAND, () => {
|
||||
game.endPhase();
|
||||
});
|
||||
|
||||
|
@ -60,14 +60,17 @@ afterAll(() => {
|
||||
|
||||
afterEach(() => {
|
||||
clearInterval(PromptHandler.runInterval);
|
||||
PromptHandler.runInterval = undefined;
|
||||
});
|
||||
|
||||
process.on("uncaughtException", err => {
|
||||
clearInterval(PromptHandler.runInterval);
|
||||
PromptHandler.runInterval = undefined;
|
||||
throw err;
|
||||
});
|
||||
|
||||
process.on("unhandledRejection", err => {
|
||||
clearInterval(PromptHandler.runInterval);
|
||||
PromptHandler.runInterval = undefined;
|
||||
throw err;
|
||||
});
|
||||
|
Loading…
Reference in New Issue
Block a user