Fixed didLog to not start phases again when interrupted

This commit is contained in:
Bertie690 2025-08-06 23:16:17 -04:00
parent 99a5f0d9ba
commit 62aea1ad8d
2 changed files with 9 additions and 7 deletions

View File

@ -82,9 +82,11 @@ export class PhaseInterceptor {
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" && !didLog) {
this.doLog("PhaseInterceptor.to: Waiting for phase to end after being interrupted!");
didLog = true;
if (this.state === "interrupted") {
if (!didLog) {
this.doLog("PhaseInterceptor.to: Waiting for phase to end after being interrupted!");
didLog = true;
}
return false;
}
@ -102,7 +104,7 @@ export class PhaseInterceptor {
await this.run(currentPhase);
return false;
},
{ interval: 0, timeout: 5_000 },
{ interval: 0, timeout: 20_000 },
);
// We hit the target; run as applicable and wrap up.

View File

@ -44,7 +44,7 @@ describe("Test Utils - PromptHandler", () => {
phaseManager: {
getCurrentPhase: () =>
({
phaseName: "testDialoguePhase",
phaseName: "CommandPhase",
}) as unknown as Phase,
},
},
@ -67,7 +67,7 @@ describe("Test Utils - PromptHandler", () => {
}
describe("setMode", () => {
it("should wrap and pass along original function arguments", async () => {
it("should wrap and pass along original function arguments from setModeInternal", async () => {
const setModeSpy = vi.spyOn(promptHandler as any, "setMode");
promptHandler["game"].scene.ui["setModeInternal"](UiMode.PARTY, false, false, false, []);
@ -75,7 +75,7 @@ describe("Test Utils - PromptHandler", () => {
expect(setModeCallback).toHaveBeenCalledAfter(setModeSpy);
});
it("should call PhaseInterceptor.checkMode", async () => {
it("should call PhaseInterceptor.checkMode if current phase in `endBySetMode`", async () => {
promptHandler["game"].scene.ui["setModeInternal"](UiMode.PARTY, false, false, false, []);
expect(checkModeCallback).toHaveBeenCalledOnce();