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,
|
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();
|
const enemyPokemon = game.field.getEnemyPokemon();
|
||||||
expect(enemyPokemon).toBeDefined();
|
enemyPokemon.setStatStage(Stat.ATK, -6);
|
||||||
|
enemyPokemon.setStatStage(Stat.SPATK, -6);
|
||||||
expect(enemyPokemon.getStatStage(Stat.ATK)).toBe(-6);
|
|
||||||
expect(enemyPokemon.getStatStage(Stat.SPATK)).toBe(-6);
|
|
||||||
|
|
||||||
// now parting shot should fail
|
// now parting shot should fail
|
||||||
game.move.select(MoveId.PARTING_SHOT);
|
game.move.select(MoveId.PARTING_SHOT);
|
||||||
|
@ -61,6 +61,9 @@ export class PromptHandler extends GameManagerHelper {
|
|||||||
).mockImplementation((...args) => this.setMode(args));
|
).mockImplementation((...args) => this.setMode(args));
|
||||||
|
|
||||||
// Set an interval to repeatedly check the current prompt.
|
// 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());
|
PromptHandler.runInterval = setInterval(() => this.doPromptCheck());
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -94,7 +97,6 @@ export class PromptHandler extends GameManagerHelper {
|
|||||||
}
|
}
|
||||||
|
|
||||||
const prompt = this.prompts[0];
|
const prompt = this.prompts[0];
|
||||||
this.doLog("Checking prompts...");
|
|
||||||
|
|
||||||
// remove expired prompts
|
// remove expired prompts
|
||||||
if (prompt.expireFn?.()) {
|
if (prompt.expireFn?.()) {
|
||||||
|
@ -74,15 +74,17 @@ export class PhaseInterceptor {
|
|||||||
// TODO: remove bangs once signature is updated
|
// TODO: remove bangs once signature is updated
|
||||||
let currentPhase: Phase = pm.getCurrentPhase()!;
|
let currentPhase: Phase = pm.getCurrentPhase()!;
|
||||||
|
|
||||||
|
let didLog = false;
|
||||||
|
|
||||||
// NB: This has to use an interval to wait for UI prompts to activate.
|
// NB: This has to use an interval to wait for UI prompts to activate.
|
||||||
// TODO: Rework after UI rework
|
// TODO: Rework after UI rework
|
||||||
await vi.waitUntil(
|
await vi.waitUntil(
|
||||||
async () => {
|
async () => {
|
||||||
// If we were interrupted by a UI prompt, we assume that the calling code will queue inputs to
|
// 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.
|
// 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!");
|
this.doLog("PhaseInterceptor.to: Waiting for phase to end after being interrupted!");
|
||||||
await setTimeout(50);
|
didLog = true;
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -8,7 +8,7 @@ import type { PhaseInterceptor } from "#test/test-utils/phase-interceptor";
|
|||||||
import type { UI } from "#ui/ui";
|
import type { UI } from "#ui/ui";
|
||||||
import { beforeAll, beforeEach, describe, expect, it, type Mock, vi } from "vitest";
|
import { beforeAll, beforeEach, describe, expect, it, type Mock, vi } from "vitest";
|
||||||
|
|
||||||
describe("Utils - PromptHandler", () => {
|
describe("Test Utils - PromptHandler", () => {
|
||||||
let promptHandler: PromptHandler;
|
let promptHandler: PromptHandler;
|
||||||
let handler: AwaitableUiHandler;
|
let handler: AwaitableUiHandler;
|
||||||
|
|
||||||
|
@ -52,7 +52,7 @@ describe("Utils - Phase Interceptor - Integration", () => {
|
|||||||
|
|
||||||
it("should not break when phase ended early via prompt", async () => {
|
it("should not break when phase ended early via prompt", async () => {
|
||||||
await game.classicMode.startBattle([SpeciesId.REGIELEKI]);
|
await game.classicMode.startBattle([SpeciesId.REGIELEKI]);
|
||||||
game.onNextPrompt("CommandPhase", UiMode.FIGHT, () => {
|
game.onNextPrompt("CommandPhase", UiMode.COMMAND, () => {
|
||||||
game.endPhase();
|
game.endPhase();
|
||||||
});
|
});
|
||||||
|
|
||||||
|
@ -60,14 +60,17 @@ afterAll(() => {
|
|||||||
|
|
||||||
afterEach(() => {
|
afterEach(() => {
|
||||||
clearInterval(PromptHandler.runInterval);
|
clearInterval(PromptHandler.runInterval);
|
||||||
|
PromptHandler.runInterval = undefined;
|
||||||
});
|
});
|
||||||
|
|
||||||
process.on("uncaughtException", err => {
|
process.on("uncaughtException", err => {
|
||||||
clearInterval(PromptHandler.runInterval);
|
clearInterval(PromptHandler.runInterval);
|
||||||
|
PromptHandler.runInterval = undefined;
|
||||||
throw err;
|
throw err;
|
||||||
});
|
});
|
||||||
|
|
||||||
process.on("unhandledRejection", err => {
|
process.on("unhandledRejection", err => {
|
||||||
clearInterval(PromptHandler.runInterval);
|
clearInterval(PromptHandler.runInterval);
|
||||||
|
PromptHandler.runInterval = undefined;
|
||||||
throw err;
|
throw err;
|
||||||
});
|
});
|
||||||
|
Loading…
Reference in New Issue
Block a user