remove whenAboutToRun

This commit is contained in:
snoozbuster 2024-08-13 21:10:08 -07:00
parent 9d721f6610
commit 8a4a297cd6
3 changed files with 10 additions and 25 deletions

View File

@ -89,7 +89,7 @@ describe("UI - Starter select", () => {
resolve(); resolve();
}); });
}); });
await game.phaseInterceptor.whenAboutToRun(EncounterPhase); await game.phaseInterceptor.to(EncounterPhase, false);
expect(game.scene.getParty()[0].species.speciesId).toBe(Species.BULBASAUR); expect(game.scene.getParty()[0].species.speciesId).toBe(Species.BULBASAUR);
expect(game.scene.getParty()[0].shiny).toBe(true); expect(game.scene.getParty()[0].shiny).toBe(true);
@ -153,7 +153,7 @@ describe("UI - Starter select", () => {
resolve(); resolve();
}); });
}); });
await game.phaseInterceptor.whenAboutToRun(EncounterPhase); await game.phaseInterceptor.to(EncounterPhase, false);
expect(game.scene.getParty()[0].species.speciesId).toBe(Species.BULBASAUR); expect(game.scene.getParty()[0].species.speciesId).toBe(Species.BULBASAUR);
expect(game.scene.getParty()[0].shiny).toBe(true); expect(game.scene.getParty()[0].shiny).toBe(true);
@ -220,7 +220,7 @@ describe("UI - Starter select", () => {
resolve(); resolve();
}); });
}); });
await game.phaseInterceptor.whenAboutToRun(EncounterPhase); await game.phaseInterceptor.to(EncounterPhase, false);
expect(game.scene.getParty()[0].species.speciesId).toBe(Species.BULBASAUR); expect(game.scene.getParty()[0].species.speciesId).toBe(Species.BULBASAUR);
expect(game.scene.getParty()[0].shiny).toBe(true); expect(game.scene.getParty()[0].shiny).toBe(true);
@ -285,7 +285,7 @@ describe("UI - Starter select", () => {
resolve(); resolve();
}); });
}); });
await game.phaseInterceptor.whenAboutToRun(EncounterPhase); await game.phaseInterceptor.to(EncounterPhase, false);
expect(game.scene.getParty()[0].species.speciesId).toBe(Species.BULBASAUR); expect(game.scene.getParty()[0].species.speciesId).toBe(Species.BULBASAUR);
expect(game.scene.getParty()[0].shiny).toBe(true); expect(game.scene.getParty()[0].shiny).toBe(true);
@ -345,7 +345,7 @@ describe("UI - Starter select", () => {
resolve(); resolve();
}); });
}); });
await game.phaseInterceptor.whenAboutToRun(EncounterPhase); await game.phaseInterceptor.to(EncounterPhase, false);
expect(game.scene.getParty()[0].species.speciesId).toBe(Species.BULBASAUR); expect(game.scene.getParty()[0].species.speciesId).toBe(Species.BULBASAUR);
expect(game.scene.getParty()[0].shiny).toBe(false); expect(game.scene.getParty()[0].shiny).toBe(false);
@ -406,7 +406,7 @@ describe("UI - Starter select", () => {
resolve(); resolve();
}); });
}); });
await game.phaseInterceptor.whenAboutToRun(EncounterPhase); await game.phaseInterceptor.to(EncounterPhase, false);
expect(game.scene.getParty()[0].species.speciesId).toBe(Species.BULBASAUR); expect(game.scene.getParty()[0].species.speciesId).toBe(Species.BULBASAUR);
expect(game.scene.getParty()[0].shiny).toBe(true); expect(game.scene.getParty()[0].shiny).toBe(true);
@ -468,7 +468,7 @@ describe("UI - Starter select", () => {
resolve(); resolve();
}); });
}); });
await game.phaseInterceptor.whenAboutToRun(EncounterPhase); await game.phaseInterceptor.to(EncounterPhase, false);
expect(game.scene.getParty()[0].species.speciesId).toBe(Species.BULBASAUR); expect(game.scene.getParty()[0].species.speciesId).toBe(Species.BULBASAUR);
expect(game.scene.getParty()[0].shiny).toBe(true); expect(game.scene.getParty()[0].shiny).toBe(true);
@ -535,7 +535,7 @@ describe("UI - Starter select", () => {
const saveSlotSelectUiHandler = game.scene.ui.getHandler() as SaveSlotSelectUiHandler; const saveSlotSelectUiHandler = game.scene.ui.getHandler() as SaveSlotSelectUiHandler;
saveSlotSelectUiHandler.processInput(Button.ACTION); saveSlotSelectUiHandler.processInput(Button.ACTION);
}); });
await game.phaseInterceptor.whenAboutToRun(EncounterPhase); await game.phaseInterceptor.to(EncounterPhase, false);
expect(game.scene.getParty()[0].species.speciesId).toBe(Species.CATERPIE); expect(game.scene.getParty()[0].species.speciesId).toBe(Species.CATERPIE);
}, 20000); }, 20000);
@ -601,7 +601,7 @@ describe("UI - Starter select", () => {
const saveSlotSelectUiHandler = game.scene.ui.getHandler() as SaveSlotSelectUiHandler; const saveSlotSelectUiHandler = game.scene.ui.getHandler() as SaveSlotSelectUiHandler;
saveSlotSelectUiHandler.processInput(Button.ACTION); saveSlotSelectUiHandler.processInput(Button.ACTION);
}); });
await game.phaseInterceptor.whenAboutToRun(EncounterPhase); await game.phaseInterceptor.to(EncounterPhase, false);
expect(game.scene.getParty()[0].species.speciesId).toBe(Species.NIDORAN_M); expect(game.scene.getParty()[0].species.speciesId).toBe(Species.NIDORAN_M);
}, 20000); }, 20000);
}); });

View File

@ -108,7 +108,7 @@ export default class GameManager {
* @returns A promise that resolves when the title phase is reached. * @returns A promise that resolves when the title phase is reached.
*/ */
async runToTitle(): Promise<void> { async runToTitle(): Promise<void> {
await this.phaseInterceptor.whenAboutToRun(LoginPhase); await this.phaseInterceptor.to(LoginPhase, false);
this.phaseInterceptor.pop(); this.phaseInterceptor.pop();
await this.phaseInterceptor.run(TitlePhase); await this.phaseInterceptor.run(TitlePhase);

View File

@ -213,21 +213,6 @@ export default class PhaseInterceptor {
}); });
} }
whenAboutToRun(phaseTarget, skipFn?): Promise<void> {
const targetName = typeof phaseTarget === "string" ? phaseTarget : phaseTarget.name;
this.scene.moveAnimations = null; // Mandatory to avoid crash
return new Promise(async (resolve, reject) => {
ErrorInterceptor.getInstance().add(this);
const interval = setInterval(async () => {
const currentPhase = this.onHold[0];
if (currentPhase?.name === targetName) {
clearInterval(interval);
resolve();
}
});
});
}
pop() { pop() {
this.onHold.pop(); this.onHold.pop();
this.scene.shiftPhase(); this.scene.shiftPhase();