Fixed remaining old methods

This commit is contained in:
Bertie690 2025-06-18 19:27:55 -04:00
parent 194ced277b
commit 105f39088e
10 changed files with 21 additions and 30 deletions

View File

@ -204,7 +204,7 @@ export async function skipBattleRunMysteryEncounterRewardsPhase(game: GameManage
game.scene.field.remove(p); game.scene.field.remove(p);
}); });
game.scene.phaseManager.pushPhase(new VictoryPhase(0)); game.scene.phaseManager.pushPhase(new VictoryPhase(0));
game.phaseInterceptor.superEndPhase(); game.phaseInterceptor.shiftPhase();
game.setMode(UiMode.MESSAGE); game.setMode(UiMode.MESSAGE);
await game.phaseInterceptor.to("MysteryEncounterRewardsPhase", runRewardsPhase); await game.phaseInterceptor.to("MysteryEncounterRewardsPhase", runRewardsPhase);
} }

View File

@ -186,7 +186,7 @@ describe("The Expert Pokémon Breeder - Mystery Encounter", () => {
expect(eggsAfter.filter(egg => egg.tier === EggTier.COMMON).length).toBe(commonEggs); expect(eggsAfter.filter(egg => egg.tier === EggTier.COMMON).length).toBe(commonEggs);
expect(eggsAfter.filter(egg => egg.tier === EggTier.RARE).length).toBe(rareEggs); expect(eggsAfter.filter(egg => egg.tier === EggTier.RARE).length).toBe(rareEggs);
game.phaseInterceptor.superEndPhase(); game.phaseInterceptor.shiftPhase();
await game.phaseInterceptor.to("PostMysteryEncounterPhase"); await game.phaseInterceptor.to("PostMysteryEncounterPhase");
const friendshipAfter = scene.currentBattle.mysteryEncounter!.misc.pokemon1.friendship; const friendshipAfter = scene.currentBattle.mysteryEncounter!.misc.pokemon1.friendship;
@ -271,7 +271,7 @@ describe("The Expert Pokémon Breeder - Mystery Encounter", () => {
expect(eggsAfter.filter(egg => egg.tier === EggTier.COMMON).length).toBe(commonEggs); expect(eggsAfter.filter(egg => egg.tier === EggTier.COMMON).length).toBe(commonEggs);
expect(eggsAfter.filter(egg => egg.tier === EggTier.RARE).length).toBe(rareEggs); expect(eggsAfter.filter(egg => egg.tier === EggTier.RARE).length).toBe(rareEggs);
game.phaseInterceptor.superEndPhase(); game.phaseInterceptor.shiftPhase();
await game.phaseInterceptor.to("PostMysteryEncounterPhase"); await game.phaseInterceptor.to("PostMysteryEncounterPhase");
const friendshipAfter = scene.currentBattle.mysteryEncounter!.misc.pokemon2.friendship; const friendshipAfter = scene.currentBattle.mysteryEncounter!.misc.pokemon2.friendship;
@ -353,7 +353,7 @@ describe("The Expert Pokémon Breeder - Mystery Encounter", () => {
expect(eggsAfter.filter(egg => egg.tier === EggTier.COMMON).length).toBe(commonEggs); expect(eggsAfter.filter(egg => egg.tier === EggTier.COMMON).length).toBe(commonEggs);
expect(eggsAfter.filter(egg => egg.tier === EggTier.RARE).length).toBe(rareEggs); expect(eggsAfter.filter(egg => egg.tier === EggTier.RARE).length).toBe(rareEggs);
game.phaseInterceptor.superEndPhase(); game.phaseInterceptor.shiftPhase();
await game.phaseInterceptor.to("PostMysteryEncounterPhase"); await game.phaseInterceptor.to("PostMysteryEncounterPhase");
const friendshipAfter = scene.currentBattle.mysteryEncounter!.misc.pokemon3.friendship; const friendshipAfter = scene.currentBattle.mysteryEncounter!.misc.pokemon3.friendship;

View File

@ -365,9 +365,8 @@ async function skipBattleToNextBattle(game: GameManager, isFinalBattle = false)
p.status = new Status(StatusEffect.FAINT); p.status = new Status(StatusEffect.FAINT);
game.scene.field.remove(p); game.scene.field.remove(p);
}); });
game.phaseInterceptor["onHold"] = [];
game.scene.phaseManager.pushPhase(new VictoryPhase(0)); game.scene.phaseManager.pushPhase(new VictoryPhase(0));
game.phaseInterceptor.superEndPhase(); game.phaseInterceptor.shiftPhase();
if (isFinalBattle) { if (isFinalBattle) {
await game.phaseInterceptor.to("MysteryEncounterRewardsPhase"); await game.phaseInterceptor.to("MysteryEncounterRewardsPhase");
} else { } else {

View File

@ -36,7 +36,6 @@ import type { MysteryEncounterType } from "#enums/mystery-encounter-type";
import { PlayerGender } from "#enums/player-gender"; import { PlayerGender } from "#enums/player-gender";
import type { SpeciesId } from "#enums/species-id"; import type { SpeciesId } from "#enums/species-id";
import { UiMode } from "#enums/ui-mode"; import { UiMode } from "#enums/ui-mode";
import ErrorInterceptor from "#test/testUtils/errorInterceptor";
import { generateStarter, waitUntil } from "#test/testUtils/gameManagerUtils"; import { generateStarter, waitUntil } from "#test/testUtils/gameManagerUtils";
import GameWrapper from "#test/testUtils/gameWrapper"; import GameWrapper from "#test/testUtils/gameWrapper";
import { ChallengeModeHelper } from "#test/testUtils/helpers/challengeModeHelper"; import { ChallengeModeHelper } from "#test/testUtils/helpers/challengeModeHelper";
@ -83,7 +82,6 @@ export default class GameManager {
*/ */
constructor(phaserGame: Phaser.Game, bypassLogin = true) { constructor(phaserGame: Phaser.Game, bypassLogin = true) {
localStorage.clear(); localStorage.clear();
ErrorInterceptor.getInstance().clear();
BattleScene.prototype.randBattleSeedInt = (range, min = 0) => min + range - 1; // This simulates a max roll BattleScene.prototype.randBattleSeedInt = (range, min = 0) => min + range - 1; // This simulates a max roll
this.gameWrapper = new GameWrapper(phaserGame, bypassLogin); this.gameWrapper = new GameWrapper(phaserGame, bypassLogin);
@ -268,7 +266,7 @@ export default class GameManager {
true, true,
); );
await this.phaseInterceptor.run(EncounterPhase); await this.phaseInterceptor.to("EncounterPhase");
if (!isNullOrUndefined(encounterType)) { if (!isNullOrUndefined(encounterType)) {
expect(this.scene.currentBattle?.mysteryEncounter?.encounterType).toBe(encounterType); expect(this.scene.currentBattle?.mysteryEncounter?.encounterType).toBe(encounterType);
} }
@ -500,7 +498,7 @@ export default class GameManager {
* @param inPhase - Which phase to expect the selection to occur in. Defaults to `SwitchPhase` * @param inPhase - Which phase to expect the selection to occur in. Defaults to `SwitchPhase`
* (which is where the majority of non-command switch operations occur). * (which is where the majority of non-command switch operations occur).
*/ */
doSelectPartyPokemon(slot: number, inPhase = "SwitchPhase") { doSelectPartyPokemon(slot: number, inPhase: PhaseString = "SwitchPhase") {
this.onNextPrompt(inPhase, UiMode.PARTY, () => { this.onNextPrompt(inPhase, UiMode.PARTY, () => {
const partyHandler = this.scene.ui.getHandler() as PartyUiHandler; const partyHandler = this.scene.ui.getHandler() as PartyUiHandler;

View File

@ -49,7 +49,7 @@ export class ChallengeModeHelper extends GameManagerHelper {
selectStarterPhase.initBattle(starters); selectStarterPhase.initBattle(starters);
}); });
await this.game.phaseInterceptor.run(EncounterPhase); await this.game.phaseInterceptor.to("EncounterPhase");
if (overrides.OPP_HELD_ITEMS_OVERRIDE.length === 0 && this.game.override.removeEnemyStartingItems) { if (overrides.OPP_HELD_ITEMS_OVERRIDE.length === 0 && this.game.override.removeEnemyStartingItems) {
this.game.removeEnemyHeldItems(); this.game.removeEnemyHeldItems();
} }

View File

@ -64,7 +64,9 @@ export default class PhaseInterceptor {
// Mock the private startCurrentPhase method to do nothing to let us // Mock the private startCurrentPhase method to do nothing to let us
// handle starting phases manually in the `run` method. // handle starting phases manually in the `run` method.
vi.fn(this.scene.phaseManager["startCurrentPhase"]).mockImplementation(() => {}); vi.fn(this.scene.phaseManager["startCurrentPhase"]).mockImplementation(() => {
console.log("Did nothing!!!!");
});
} }
/** /**

View File

@ -71,7 +71,7 @@ describe("UI - Pokedex", () => {
// Open the pokedex UI. // Open the pokedex UI.
await game.runToTitle(); await game.runToTitle();
await game.phaseInterceptor.setOverlayMode(UiMode.POKEDEX); await game.scene.ui.setOverlayMode(UiMode.POKEDEX);
// Get the handler for the current UI. // Get the handler for the current UI.
const handler = game.scene.ui.getHandler(); const handler = game.scene.ui.getHandler();
@ -91,7 +91,7 @@ describe("UI - Pokedex", () => {
// Open the pokedex UI. // Open the pokedex UI.
await game.runToTitle(); await game.runToTitle();
await game.phaseInterceptor.setOverlayMode(UiMode.POKEDEX_PAGE, species, starterAttributes); await game.scene.ui.setOverlayMode(UiMode.POKEDEX_PAGE, species, starterAttributes);
// Get the handler for the current UI. // Get the handler for the current UI.
const handler = game.scene.ui.getHandler(); const handler = game.scene.ui.getHandler();

View File

@ -2,7 +2,6 @@ import { Gender } from "#app/data/gender";
import { Nature } from "#enums/nature"; import { Nature } from "#enums/nature";
import { allSpecies } from "#app/data/data-lists"; import { allSpecies } from "#app/data/data-lists";
import { GameModes } from "#enums/game-modes"; import { GameModes } from "#enums/game-modes";
import { EncounterPhase } from "#app/phases/encounter-phase";
import type { TitlePhase } from "#app/phases/title-phase"; import type { TitlePhase } from "#app/phases/title-phase";
import type { OptionSelectItem } from "#app/ui/abstact-option-select-ui-handler"; import type { OptionSelectItem } from "#app/ui/abstact-option-select-ui-handler";
import type SaveSlotSelectUiHandler from "#app/ui/save-slot-select-ui-handler"; import type SaveSlotSelectUiHandler from "#app/ui/save-slot-select-ui-handler";
@ -86,7 +85,7 @@ describe("UI - Starter select", () => {
resolve(); resolve();
}); });
}); });
await game.phaseInterceptor.whenAboutToRun(EncounterPhase); await game.phaseInterceptor.to("EncounterPhase", false);
expect(game.scene.getPlayerParty()[0].species.speciesId).toBe(SpeciesId.BULBASAUR); expect(game.scene.getPlayerParty()[0].species.speciesId).toBe(SpeciesId.BULBASAUR);
expect(game.scene.getPlayerParty()[0].shiny).toBe(true); expect(game.scene.getPlayerParty()[0].shiny).toBe(true);
@ -209,7 +208,7 @@ describe("UI - Starter select", () => {
resolve(); resolve();
}); });
}); });
await game.phaseInterceptor.whenAboutToRun(EncounterPhase); await game.phaseInterceptor.to("EncounterPhase", false);
expect(game.scene.getPlayerParty()[0].species.speciesId).toBe(SpeciesId.BULBASAUR); expect(game.scene.getPlayerParty()[0].species.speciesId).toBe(SpeciesId.BULBASAUR);
expect(game.scene.getPlayerParty()[0].shiny).toBe(true); expect(game.scene.getPlayerParty()[0].shiny).toBe(true);
@ -271,7 +270,7 @@ describe("UI - Starter select", () => {
resolve(); resolve();
}); });
}); });
await game.phaseInterceptor.whenAboutToRun(EncounterPhase); await game.phaseInterceptor.to("EncounterPhase", false);
expect(game.scene.getPlayerParty()[0].species.speciesId).toBe(SpeciesId.BULBASAUR); expect(game.scene.getPlayerParty()[0].species.speciesId).toBe(SpeciesId.BULBASAUR);
expect(game.scene.getPlayerParty()[0].shiny).toBe(true); expect(game.scene.getPlayerParty()[0].shiny).toBe(true);
@ -331,7 +330,7 @@ describe("UI - Starter select", () => {
resolve(); resolve();
}); });
}); });
await game.phaseInterceptor.whenAboutToRun(EncounterPhase); await game.phaseInterceptor.to("EncounterPhase", false);
expect(game.scene.getPlayerParty()[0].species.speciesId).toBe(SpeciesId.BULBASAUR); expect(game.scene.getPlayerParty()[0].species.speciesId).toBe(SpeciesId.BULBASAUR);
expect(game.scene.getPlayerParty()[0].shiny).toBe(false); expect(game.scene.getPlayerParty()[0].shiny).toBe(false);
@ -392,7 +391,7 @@ describe("UI - Starter select", () => {
resolve(); resolve();
}); });
}); });
await game.phaseInterceptor.whenAboutToRun(EncounterPhase); await game.phaseInterceptor.to("EncounterPhase", false);
expect(game.scene.getPlayerParty()[0].species.speciesId).toBe(SpeciesId.BULBASAUR); expect(game.scene.getPlayerParty()[0].species.speciesId).toBe(SpeciesId.BULBASAUR);
expect(game.scene.getPlayerParty()[0].shiny).toBe(true); expect(game.scene.getPlayerParty()[0].shiny).toBe(true);
@ -452,7 +451,7 @@ describe("UI - Starter select", () => {
resolve(); resolve();
}); });
}); });
await game.phaseInterceptor.whenAboutToRun(EncounterPhase); await game.phaseInterceptor.to("EncounterPhase", false);
expect(game.scene.getPlayerParty()[0].species.speciesId).toBe(SpeciesId.BULBASAUR); expect(game.scene.getPlayerParty()[0].species.speciesId).toBe(SpeciesId.BULBASAUR);
expect(game.scene.getPlayerParty()[0].shiny).toBe(true); expect(game.scene.getPlayerParty()[0].shiny).toBe(true);
@ -518,7 +517,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.getPlayerParty()[0].species.speciesId).toBe(SpeciesId.CATERPIE); expect(game.scene.getPlayerParty()[0].species.speciesId).toBe(SpeciesId.CATERPIE);
}); });
@ -583,7 +582,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.getPlayerParty()[0].species.speciesId).toBe(SpeciesId.NIDORAN_M); expect(game.scene.getPlayerParty()[0].species.speciesId).toBe(SpeciesId.NIDORAN_M);
}); });
}); });

View File

@ -72,8 +72,6 @@ describe("UI - Transfer Items", () => {
expect( expect(
handler.optionsContainer.list.some(option => RegExp(/Lum Berry\[color.*(2)/).exec((option as BBCodeText).text)), handler.optionsContainer.list.some(option => RegExp(/Lum Berry\[color.*(2)/).exec((option as BBCodeText).text)),
).toBe(true); ).toBe(true);
game.phaseInterceptor.unlock();
}); });
await game.phaseInterceptor.to("SelectModifierPhase"); await game.phaseInterceptor.to("SelectModifierPhase");
@ -93,8 +91,6 @@ describe("UI - Transfer Items", () => {
expect(handler.optionsContainer.list.some(option => (option as BBCodeText).text?.includes("Transfer"))).toBe( expect(handler.optionsContainer.list.some(option => (option as BBCodeText).text?.includes("Transfer"))).toBe(
true, true,
); );
game.phaseInterceptor.unlock();
}); });
await game.phaseInterceptor.to("SelectModifierPhase"); await game.phaseInterceptor.to("SelectModifierPhase");

View File

@ -45,7 +45,6 @@ describe("UI - Type Hints", () => {
const { ui } = game.scene; const { ui } = game.scene;
const handler = ui.getHandler<FightUiHandler>(); const handler = ui.getHandler<FightUiHandler>();
handler.processInput(Button.ACTION); // select "Fight" handler.processInput(Button.ACTION); // select "Fight"
game.phaseInterceptor.unlock();
}); });
game.onNextPrompt("CommandPhase", UiMode.FIGHT, () => { game.onNextPrompt("CommandPhase", UiMode.FIGHT, () => {
@ -70,7 +69,6 @@ describe("UI - Type Hints", () => {
const { ui } = game.scene; const { ui } = game.scene;
const handler = ui.getHandler<FightUiHandler>(); const handler = ui.getHandler<FightUiHandler>();
handler.processInput(Button.ACTION); // select "Fight" handler.processInput(Button.ACTION); // select "Fight"
game.phaseInterceptor.unlock();
}); });
game.onNextPrompt("CommandPhase", UiMode.FIGHT, () => { game.onNextPrompt("CommandPhase", UiMode.FIGHT, () => {
@ -106,7 +104,6 @@ describe("UI - Type Hints", () => {
const { ui } = game.scene; const { ui } = game.scene;
const handler = ui.getHandler<FightUiHandler>(); const handler = ui.getHandler<FightUiHandler>();
handler.processInput(Button.ACTION); // select "Fight" handler.processInput(Button.ACTION); // select "Fight"
game.phaseInterceptor.unlock();
}); });
game.onNextPrompt("CommandPhase", UiMode.FIGHT, () => { game.onNextPrompt("CommandPhase", UiMode.FIGHT, () => {