[Refactor] Remove null from PhaseManager.currentPhase signature

https://github.com/pagefaultgames/pokerogue/pull/6243

* Added `toBeAtPhase` + removed `null` from phase manager current phase signature

* Removed bangs from various calls to phase manager

* Update phase-manager.ts

Co-authored-by: NightKev <34855794+DayKev@users.noreply.github.com>

* ran biome

* Fix missing bang

* Simplify TSDoc

---------

Co-authored-by: NightKev <34855794+DayKev@users.noreply.github.com>
This commit is contained in:
Bertie690 2025-09-05 12:28:35 -04:00 committed by GitHub
parent fce317a87a
commit d5e6670456
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
46 changed files with 229 additions and 199 deletions

View File

@ -1561,9 +1561,9 @@ export class BattleScene extends SceneBase {
return 0;
}
const isEggPhase: boolean = ["EggLapsePhase", "EggHatchPhase"].includes(
this.phaseManager.getCurrentPhase()?.phaseName ?? "",
);
const isEggPhase =
this.phaseManager.getCurrentPhase().is("EggLapsePhase") ||
this.phaseManager.getCurrentPhase().is("EggHatchPhase");
if (
// Give trainers with specialty types an appropriately-typed form for Wormadam, Rotom, Arceus, Oricorio, Silvally, or Paldean Tauros.

View File

@ -471,7 +471,7 @@ const QuickGuardConditionFunc: ProtectConditionFunc = (_arena, moveId) => {
const move = allMoves[moveId];
const effectPhase = globalScene.phaseManager.getCurrentPhase();
if (effectPhase?.is("MoveEffectPhase")) {
if (effectPhase.is("MoveEffectPhase")) {
const attacker = effectPhase.getUserPokemon();
if (attacker) {
return move.getPriority(attacker) > 0;

View File

@ -228,26 +228,27 @@ interface GenericSerializableBattlerTag<T extends BattlerTagType> extends Serial
* Descendants can override {@linkcode isMoveRestricted} to restrict moves that
* match a condition. A restricted move gets cancelled before it is used.
* Players and enemies should not be allowed to select restricted moves.
* @todo Require descendant subclasses to inherit a `PRE_MOVE` lapse type
*/
export abstract class MoveRestrictionBattlerTag extends SerializableBattlerTag {
public declare readonly tagType: MoveRestrictionBattlerTagType;
override lapse(pokemon: Pokemon, lapseType: BattlerTagLapseType): boolean {
if (lapseType === BattlerTagLapseType.PRE_MOVE) {
// Cancel the affected pokemon's selected move
const phase = globalScene.phaseManager.getCurrentPhase() as MovePhase;
const move = phase.move;
if (this.isMoveRestricted(move.moveId, pokemon)) {
if (this.interruptedText(pokemon, move.moveId)) {
globalScene.phaseManager.queueMessage(this.interruptedText(pokemon, move.moveId));
}
phase.cancel();
}
return true;
if (lapseType !== BattlerTagLapseType.PRE_MOVE) {
return super.lapse(pokemon, lapseType);
}
return super.lapse(pokemon, lapseType);
// Cancel the affected pokemon's selected move
const phase = globalScene.phaseManager.getCurrentPhase() as MovePhase;
const move = phase.move;
if (this.isMoveRestricted(move.moveId, pokemon)) {
if (this.interruptedText(pokemon, move.moveId)) {
globalScene.phaseManager.queueMessage(this.interruptedText(pokemon, move.moveId));
}
phase.cancel();
}
return true;
}
/**

View File

@ -1252,7 +1252,7 @@ export abstract class Pokemon extends Phaser.GameObjects.Container {
}
// During the Pokemon's MoveEffect phase, the offset is removed to put the Pokemon "in focus"
const currentPhase = globalScene.phaseManager.getCurrentPhase();
return !(currentPhase?.is("MoveEffectPhase") && currentPhase.getPokemon() === this);
return !(currentPhase.is("MoveEffectPhase") && currentPhase.getPokemon() === this);
}
/** If this Pokemon has a Substitute on the field, removes its sprite from the field. */
@ -4969,7 +4969,7 @@ export abstract class Pokemon extends Phaser.GameObjects.Container {
*/
if (effect === StatusEffect.SLEEP || effect === StatusEffect.FREEZE) {
const currentPhase = globalScene.phaseManager.getCurrentPhase();
if (currentPhase?.is("MoveEffectPhase") && currentPhase.getUserPokemon() === this) {
if (currentPhase.is("MoveEffectPhase") && currentPhase.getUserPokemon() === this) {
this.turnData.hitCount = 1;
this.turnData.hitsLeft = 1;
}

View File

@ -236,7 +236,7 @@ export class PhaseManager {
/** Parallel array to {@linkcode dynamicPhaseQueues} - matches phase types to their queues */
private dynamicPhaseTypes: Constructor<Phase>[];
private currentPhase: Phase | null = null;
private currentPhase: Phase;
private standbyPhase: Phase | null = null;
constructor() {
@ -260,7 +260,9 @@ export class PhaseManager {
}
/* Phase Functions */
getCurrentPhase(): Phase | null {
/** @returns The currently running {@linkcode Phase}. */
getCurrentPhase(): Phase {
return this.currentPhase;
}
@ -370,20 +372,28 @@ export class PhaseManager {
unactivatedConditionalPhases.push([condition, phase]);
}
}
this.conditionalQueue = unactivatedConditionalPhases;
// If no phases are left, unshift phases to start a new turn.
if (!this.phaseQueue.length) {
this.populatePhaseQueue();
// Clear the conditionalQueue if there are no phases left in the phaseQueue
this.conditionalQueue = [];
}
this.currentPhase = this.phaseQueue.shift() ?? null;
// Bang is justified as `populatePhaseQueue` ensures we always have _something_ in the queue at all times
this.currentPhase = this.phaseQueue.shift()!;
if (this.currentPhase) {
console.log(`%cStart Phase ${this.currentPhase.constructor.name}`, "color:green;");
this.currentPhase.start();
}
this.startCurrentPhase();
}
/**
* Helper method to start and log the current phase.
*/
private startCurrentPhase(): void {
console.log(`%cStart Phase ${this.currentPhase.phaseName}`, "color:green;");
this.currentPhase.start();
}
overridePhase(phase: Phase): boolean {
@ -393,8 +403,7 @@ export class PhaseManager {
this.standbyPhase = this.currentPhase;
this.currentPhase = phase;
console.log(`%cStart Phase ${phase.constructor.name}`, "color:green;");
phase.start();
this.startCurrentPhase();
return true;
}

View File

@ -383,14 +383,14 @@ export class GameChallengesUiHandler extends UiHandler {
this.updateChallengeArrows(this.startCursor.visible);
} else {
globalScene.phaseManager.toTitleScreen();
globalScene.phaseManager.getCurrentPhase()?.end();
globalScene.phaseManager.getCurrentPhase().end();
}
success = true;
} else if (button === Button.SUBMIT || button === Button.ACTION) {
if (this.hasSelectedChallenge) {
if (this.startCursor.visible) {
globalScene.phaseManager.unshiftNew("SelectStarterPhase");
globalScene.phaseManager.getCurrentPhase()?.end();
globalScene.phaseManager.getCurrentPhase().end();
} else {
this.startCursor.setVisible(true);
this.cursorObj?.setVisible(false);

View File

@ -45,7 +45,7 @@ export class EggHatchSceneHandler extends UiHandler {
processInput(button: Button): boolean {
if (button === Button.ACTION || button === Button.CANCEL) {
const phase = globalScene.phaseManager.getCurrentPhase();
if (phase?.is("EggHatchPhase") && phase.trySkip()) {
if (phase.is("EggHatchPhase") && phase.trySkip()) {
return true;
}
}

View File

@ -222,7 +222,7 @@ export class EggSummaryUiHandler extends MessageUiHandler {
if (button === Button.CANCEL) {
if (!this.blockExit) {
const phase = globalScene.phaseManager.getCurrentPhase();
if (phase?.is("EggSummaryPhase")) {
if (phase.is("EggSummaryPhase")) {
phase.end();
}
success = true;

View File

@ -126,7 +126,7 @@ export class MenuUiHandler extends MessageUiHandler {
const ui = this.getUi();
this.excludedMenus = () => [
{
condition: !!globalScene.phaseManager.getCurrentPhase()?.is("SelectModifierPhase"),
condition: globalScene.phaseManager.getCurrentPhase().is("SelectModifierPhase"),
options: [MenuOptions.EGG_GACHA],
},
{ condition: bypassLogin, options: [MenuOptions.LOG_OUT] },

View File

@ -862,7 +862,7 @@ export class PartyUiHandler extends MessageUiHandler {
// TODO: This risks hitting the other options (.MOVE_i and ALL) so does it? Do we need an extra check?
if (
option >= PartyOption.FORM_CHANGE_ITEM &&
globalScene.phaseManager.getCurrentPhase()?.is("SelectModifierPhase") &&
globalScene.phaseManager.getCurrentPhase().is("SelectModifierPhase") &&
this.partyUiMode === PartyUiMode.CHECK
) {
const formChangeItemModifiers = this.getFormChangeItemsModifiers(pokemon);
@ -1556,7 +1556,7 @@ export class PartyUiHandler extends MessageUiHandler {
break;
case PartyUiMode.CHECK:
this.addCommonOptions(pokemon);
if (globalScene.phaseManager.getCurrentPhase()?.is("SelectModifierPhase")) {
if (globalScene.phaseManager.getCurrentPhase().is("SelectModifierPhase")) {
const formChangeItemModifiers = this.getFormChangeItemsModifiers(pokemon);
for (let i = 0; i < formChangeItemModifiers.length; i++) {
this.options.push(PartyOption.FORM_CHANGE_ITEM + i);

View File

@ -710,7 +710,7 @@ export class PokedexPageUiHandler extends MessageUiHandler {
show(args: any[]): boolean {
// Allow the use of candies if we are in one of the whitelisted phases
this.canUseCandies = ["TitlePhase", "SelectStarterPhase", "CommandPhase"].includes(
globalScene.phaseManager.getCurrentPhase()?.phaseName ?? "",
globalScene.phaseManager.getCurrentPhase().phaseName,
);
if (args.length >= 1 && args[0] === "refresh") {

View File

@ -340,7 +340,7 @@ export class StarterSelectUiHandler extends MessageUiHandler {
private teraLabel: Phaser.GameObjects.Text;
private goFilterLabel: Phaser.GameObjects.Text;
/** Group holding the UI elements appearing in the instructionsContainer */
/* TODO: Uncomment this once our testing infra supports mocks of `Phaser.GameObject.Group`
/* TODO: Uncomment this once our testing infra supports mocks of `Phaser.GameObject.Group`
private instructionElemGroup: Phaser.GameObjects.Group;
*/
@ -4419,7 +4419,7 @@ export class StarterSelectUiHandler extends MessageUiHandler {
globalScene.phaseManager.pushNew("EncounterPhase");
}
this.clearText();
globalScene.phaseManager.getCurrentPhase()?.end();
globalScene.phaseManager.getCurrentPhase().end();
},
cancel,
null,

View File

@ -1,8 +1,9 @@
import "vitest";
import type { TerrainType } from "#app/data/terrain";
import type { Phase } from "#app/phase";
import type Overrides from "#app/overrides";
import type { ArenaTag } from "#data/arena-tag";
import type { TerrainType } from "#data/terrain";
import type { PositionalTag } from "#data/positional-tags/positional-tag";
import type { AbilityId } from "#enums/ability-id";
import type { ArenaTagSide } from "#enums/arena-tag-side";
@ -22,6 +23,7 @@ import type { toHaveEffectiveStatOptions } from "#test/test-utils/matchers/to-ha
import type { toHavePositionalTagOptions } from "#test/test-utils/matchers/to-have-positional-tag";
import type { expectedStatusType } from "#test/test-utils/matchers/to-have-status-effect";
import type { toHaveTypesOptions } from "#test/test-utils/matchers/to-have-types";
import type { PhaseString } from "#types/phase-types";
import type { TurnMove } from "#types/turn-move";
import type { AtLeastOne } from "#types/type-helpers";
import type { toDmgValue } from "utils/common";
@ -40,6 +42,12 @@ declare module "vitest" {
*/
toEqualArrayUnsorted(expected: T[]): void;
/**
* Check if the currently-running {@linkcode Phase} is of the given type.
* @param expectedPhase - The expected {@linkcode PhaseString}
*/
toBeAtPhase(expectedPhase: PhaseString): void;
// #region Arena Matchers
/**

View File

@ -196,7 +196,7 @@ describe("Abilities - Disguise", () => {
game.move.select(MoveId.SHADOW_SNEAK);
await game.toNextWave();
expect(game.scene.phaseManager.getCurrentPhase()?.constructor.name).toBe("CommandPhase");
expect(game).toBeAtPhase("CommandPhase");
expect(game.scene.currentBattle.waveIndex).toBe(2);
});

View File

@ -36,62 +36,62 @@ describe("Test Battle Phase", () => {
game.override.battleStyle("single").startingWave(10);
await game.classicMode.startBattle([SpeciesId.BLASTOISE, SpeciesId.CHARIZARD]);
expect(game.scene.ui?.getMode()).toBe(UiMode.COMMAND);
expect(game.scene.phaseManager.getCurrentPhase()?.phaseName).toBe("CommandPhase");
expect(game).toBeAtPhase("CommandPhase");
});
it("startBattle 2vs2 boss", async () => {
game.override.battleStyle("double").startingWave(10);
await game.classicMode.startBattle([SpeciesId.BLASTOISE, SpeciesId.CHARIZARD]);
expect(game.scene.ui?.getMode()).toBe(UiMode.COMMAND);
expect(game.scene.phaseManager.getCurrentPhase()?.phaseName).toBe("CommandPhase");
expect(game).toBeAtPhase("CommandPhase");
});
it("startBattle 2vs2 trainer", async () => {
game.override.battleStyle("double").startingWave(5);
await game.classicMode.startBattle([SpeciesId.BLASTOISE, SpeciesId.CHARIZARD]);
expect(game.scene.ui?.getMode()).toBe(UiMode.COMMAND);
expect(game.scene.phaseManager.getCurrentPhase()?.phaseName).toBe("CommandPhase");
expect(game).toBeAtPhase("CommandPhase");
});
it("startBattle 2vs1 trainer", async () => {
game.override.battleStyle("single").startingWave(5);
await game.classicMode.startBattle([SpeciesId.BLASTOISE, SpeciesId.CHARIZARD]);
expect(game.scene.ui?.getMode()).toBe(UiMode.COMMAND);
expect(game.scene.phaseManager.getCurrentPhase()?.phaseName).toBe("CommandPhase");
expect(game).toBeAtPhase("CommandPhase");
});
it("startBattle 2vs1 rival", async () => {
game.override.battleStyle("single").startingWave(8);
await game.classicMode.startBattle([SpeciesId.BLASTOISE, SpeciesId.CHARIZARD]);
expect(game.scene.ui?.getMode()).toBe(UiMode.COMMAND);
expect(game.scene.phaseManager.getCurrentPhase()?.phaseName).toBe("CommandPhase");
expect(game).toBeAtPhase("CommandPhase");
});
it("startBattle 2vs2 rival", async () => {
game.override.battleStyle("double").startingWave(8);
await game.classicMode.startBattle([SpeciesId.BLASTOISE, SpeciesId.CHARIZARD]);
expect(game.scene.ui?.getMode()).toBe(UiMode.COMMAND);
expect(game.scene.phaseManager.getCurrentPhase()?.phaseName).toBe("CommandPhase");
expect(game).toBeAtPhase("CommandPhase");
});
it("startBattle 1vs1 trainer", async () => {
game.override.battleStyle("single").startingWave(5);
await game.classicMode.startBattle([SpeciesId.BLASTOISE]);
expect(game.scene.ui?.getMode()).toBe(UiMode.COMMAND);
expect(game.scene.phaseManager.getCurrentPhase()?.phaseName).toBe("CommandPhase");
expect(game).toBeAtPhase("CommandPhase");
});
it("startBattle 2vs2 trainer", async () => {
game.override.battleStyle("double").startingWave(5);
await game.classicMode.startBattle([SpeciesId.BLASTOISE, SpeciesId.CHARIZARD]);
expect(game.scene.ui?.getMode()).toBe(UiMode.COMMAND);
expect(game.scene.phaseManager.getCurrentPhase()?.phaseName).toBe("CommandPhase");
expect(game).toBeAtPhase("CommandPhase");
});
it("startBattle 4vs2 trainer", async () => {
game.override.battleStyle("double").startingWave(5);
await game.classicMode.startBattle([SpeciesId.BLASTOISE, SpeciesId.CHARIZARD, SpeciesId.DARKRAI, SpeciesId.GABITE]);
expect(game.scene.ui?.getMode()).toBe(UiMode.COMMAND);
expect(game.scene.phaseManager.getCurrentPhase()?.phaseName).toBe("CommandPhase");
expect(game).toBeAtPhase("CommandPhase");
});
});

View File

@ -1,3 +1,4 @@
import { toBeAtPhase } from "#test/test-utils/matchers/to-be-at-phase";
import { toEqualArrayUnsorted } from "#test/test-utils/matchers/to-equal-array-unsorted";
import { toHaveAbilityApplied } from "#test/test-utils/matchers/to-have-ability-applied";
import { toHaveArenaTag } from "#test/test-utils/matchers/to-have-arena-tag";
@ -24,6 +25,7 @@ import { expect } from "vitest";
expect.extend({
toEqualArrayUnsorted,
toBeAtPhase,
toHaveWeather,
toHaveTerrain,
toHaveArenaTag,

View File

@ -212,7 +212,7 @@ describe("Transforming Effects", () => {
await game.setTurnOrder([BattlerIndex.PLAYER, BattlerIndex.ENEMY]);
await game.toNextWave();
expect(game.scene.phaseManager.getCurrentPhase()?.phaseName).toBe("CommandPhase");
expect(game).toBeAtPhase("CommandPhase");
expect(game.scene.currentBattle.waveIndex).toBe(2);
await game.reload.reloadSession();
@ -242,7 +242,7 @@ describe("Transforming Effects", () => {
await game.setTurnOrder([BattlerIndex.PLAYER, BattlerIndex.ENEMY]);
await game.toNextWave();
expect(game.scene.phaseManager.getCurrentPhase()?.phaseName).toBe("CommandPhase");
expect(game).toBeAtPhase("CommandPhase");
expect(game.scene.currentBattle.waveIndex).toBe(2);
expect(player.getSpeciesForm().speciesId).toBe(enemy.getSpeciesForm().speciesId);

View File

@ -9,7 +9,6 @@ import { ATrainersTestEncounter } from "#mystery-encounters/a-trainers-test-enco
import * as EncounterPhaseUtils from "#mystery-encounters/encounter-phase-utils";
import * as MysteryEncounters from "#mystery-encounters/mystery-encounters";
import { HUMAN_TRANSITABLE_BIOMES } from "#mystery-encounters/mystery-encounters";
import { CommandPhase } from "#phases/command-phase";
import { PartyHealPhase } from "#phases/party-heal-phase";
import { SelectModifierPhase } from "#phases/select-modifier-phase";
import {
@ -106,7 +105,7 @@ describe("A Trainer's Test - Mystery Encounter", () => {
await runMysteryEncounterToEnd(game, 1, undefined, true);
const enemyField = scene.getEnemyField();
expect(scene.phaseManager.getCurrentPhase()?.constructor.name).toBe(CommandPhase.name);
expect(game).toBeAtPhase("CommandPhase");
expect(enemyField.length).toBe(1);
expect(scene.currentBattle.trainer).toBeDefined();
expect(
@ -131,7 +130,7 @@ describe("A Trainer's Test - Mystery Encounter", () => {
await runMysteryEncounterToEnd(game, 1, undefined, true);
await skipBattleRunMysteryEncounterRewardsPhase(game);
await game.phaseInterceptor.to(SelectModifierPhase, false);
expect(scene.phaseManager.getCurrentPhase()?.constructor.name).toBe(SelectModifierPhase.name);
expect(game).toBeAtPhase("SelectModifierPhase");
const eggsAfter = scene.gameData.eggs;
expect(eggsAfter).toBeDefined();
@ -179,7 +178,7 @@ describe("A Trainer's Test - Mystery Encounter", () => {
await runMysteryEncounterToEnd(game, 2);
await game.phaseInterceptor.to(SelectModifierPhase, false);
expect(scene.phaseManager.getCurrentPhase()?.constructor.name).toBe(SelectModifierPhase.name);
expect(game).toBeAtPhase("SelectModifierPhase");
const eggsAfter = scene.gameData.eggs;
expect(eggsAfter).toBeDefined();

View File

@ -10,7 +10,6 @@ import { BerryModifier, PokemonHeldItemModifier } from "#modifiers/modifier";
import { AbsoluteAvariceEncounter } from "#mystery-encounters/absolute-avarice-encounter";
import * as EncounterPhaseUtils from "#mystery-encounters/encounter-phase-utils";
import * as MysteryEncounters from "#mystery-encounters/mystery-encounters";
import { CommandPhase } from "#phases/command-phase";
import { MovePhase } from "#phases/move-phase";
import { SelectModifierPhase } from "#phases/select-modifier-phase";
import {
@ -132,7 +131,7 @@ describe("Absolute Avarice - Mystery Encounter", () => {
await runMysteryEncounterToEnd(game, 1, undefined, true);
const enemyField = scene.getEnemyField();
expect(scene.phaseManager.getCurrentPhase()?.constructor.name).toBe(CommandPhase.name);
expect(game).toBeAtPhase("CommandPhase");
expect(enemyField.length).toBe(1);
expect(enemyField[0].species.speciesId).toBe(SpeciesId.GREEDENT);
const moveset = enemyField[0].moveset.map(m => m.moveId);
@ -148,7 +147,7 @@ describe("Absolute Avarice - Mystery Encounter", () => {
await runMysteryEncounterToEnd(game, 1, undefined, true);
await skipBattleRunMysteryEncounterRewardsPhase(game);
await game.phaseInterceptor.to(SelectModifierPhase, false);
expect(scene.phaseManager.getCurrentPhase()?.constructor.name).toBe(SelectModifierPhase.name);
expect(game).toBeAtPhase("SelectModifierPhase");
for (const partyPokemon of scene.getPlayerParty()) {
const pokemonId = partyPokemon.id;

View File

@ -11,8 +11,6 @@ import { BerriesAboundEncounter } from "#mystery-encounters/berries-abound-encou
import * as EncounterDialogueUtils from "#mystery-encounters/encounter-dialogue-utils";
import * as EncounterPhaseUtils from "#mystery-encounters/encounter-phase-utils";
import * as MysteryEncounters from "#mystery-encounters/mystery-encounters";
import { CommandPhase } from "#phases/command-phase";
import { SelectModifierPhase } from "#phases/select-modifier-phase";
import {
runMysteryEncounterToEnd,
skipBattleRunMysteryEncounterRewardsPhase,
@ -114,7 +112,7 @@ describe("Berries Abound - Mystery Encounter", () => {
await runMysteryEncounterToEnd(game, 1, undefined, true);
const enemyField = scene.getEnemyField();
expect(scene.phaseManager.getCurrentPhase()?.constructor.name).toBe(CommandPhase.name);
expect(game).toBeAtPhase("CommandPhase");
expect(enemyField.length).toBe(1);
expect(enemyField[0].species.speciesId).toBe(speciesToSpawn);
});
@ -135,7 +133,7 @@ describe("Berries Abound - Mystery Encounter", () => {
await runMysteryEncounterToEnd(game, 1, undefined, true);
await skipBattleRunMysteryEncounterRewardsPhase(game);
await game.phaseInterceptor.to("SelectModifierPhase", false);
expect(scene.phaseManager.getCurrentPhase()?.constructor.name).toBe(SelectModifierPhase.name);
expect(game).toBeAtPhase("SelectModifierPhase");
const berriesAfter = scene.findModifiers(m => m instanceof BerryModifier) as BerryModifier[];
const berriesAfterCount = berriesAfter.reduce((a, b) => a + b.stackCount, 0);
@ -186,7 +184,7 @@ describe("Berries Abound - Mystery Encounter", () => {
await runMysteryEncounterToEnd(game, 2, undefined, true);
const enemyField = scene.getEnemyField();
expect(scene.phaseManager.getCurrentPhase()?.constructor.name).toBe(CommandPhase.name);
expect(game).toBeAtPhase("CommandPhase");
expect(enemyField.length).toBe(1);
expect(enemyField[0].species.speciesId).toBe(speciesToSpawn);
@ -210,7 +208,7 @@ describe("Berries Abound - Mystery Encounter", () => {
await runMysteryEncounterToEnd(game, 2, undefined, true);
const enemyField = scene.getEnemyField();
expect(scene.phaseManager.getCurrentPhase()?.constructor.name).toBe(CommandPhase.name);
expect(game).toBeAtPhase("CommandPhase");
expect(enemyField.length).toBe(1);
expect(enemyField[0].species.speciesId).toBe(speciesToSpawn);
@ -230,8 +228,6 @@ describe("Berries Abound - Mystery Encounter", () => {
});
await runMysteryEncounterToEnd(game, 2);
await game.phaseInterceptor.to("SelectModifierPhase", false);
expect(scene.phaseManager.getCurrentPhase()?.constructor.name).toBe(SelectModifierPhase.name);
await game.phaseInterceptor.to("SelectModifierPhase");
expect(scene.ui.getMode()).to.equal(UiMode.MODIFIER_SELECT);

View File

@ -12,9 +12,7 @@ import { PokemonMove } from "#moves/pokemon-move";
import { BugTypeSuperfanEncounter } from "#mystery-encounters/bug-type-superfan-encounter";
import * as encounterPhaseUtils from "#mystery-encounters/encounter-phase-utils";
import * as MysteryEncounters from "#mystery-encounters/mystery-encounters";
import { CommandPhase } from "#phases/command-phase";
import { MysteryEncounterPhase, MysteryEncounterRewardsPhase } from "#phases/mystery-encounter-phases";
import { SelectModifierPhase } from "#phases/select-modifier-phase";
import { MysteryEncounterPhase } from "#phases/mystery-encounter-phases";
import {
runMysteryEncounterToEnd,
runSelectMysteryEncounterOption,
@ -231,7 +229,7 @@ describe("Bug-Type Superfan - Mystery Encounter", () => {
await runMysteryEncounterToEnd(game, 1, undefined, true);
const enemyParty = scene.getEnemyParty();
expect(scene.phaseManager.getCurrentPhase()?.constructor.name).toBe(CommandPhase.name);
expect(game).toBeAtPhase("CommandPhase");
expect(enemyParty.length).toBe(2);
expect(scene.currentBattle.trainer?.config.trainerType).toBe(TrainerType.BUG_TYPE_SUPERFAN);
expect(enemyParty[0].species.speciesId).toBe(SpeciesId.BEEDRILL);
@ -244,7 +242,7 @@ describe("Bug-Type Superfan - Mystery Encounter", () => {
await runMysteryEncounterToEnd(game, 1, undefined, true);
const enemyParty = scene.getEnemyParty();
expect(scene.phaseManager.getCurrentPhase()?.constructor.name).toBe(CommandPhase.name);
expect(game).toBeAtPhase("CommandPhase");
expect(enemyParty.length).toBe(3);
expect(scene.currentBattle.trainer?.config.trainerType).toBe(TrainerType.BUG_TYPE_SUPERFAN);
expect(enemyParty[0].species.speciesId).toBe(SpeciesId.BEEDRILL);
@ -258,7 +256,7 @@ describe("Bug-Type Superfan - Mystery Encounter", () => {
await runMysteryEncounterToEnd(game, 1, undefined, true);
const enemyParty = scene.getEnemyParty();
expect(scene.phaseManager.getCurrentPhase()?.constructor.name).toBe(CommandPhase.name);
expect(game).toBeAtPhase("CommandPhase");
expect(enemyParty.length).toBe(4);
expect(scene.currentBattle.trainer?.config.trainerType).toBe(TrainerType.BUG_TYPE_SUPERFAN);
expect(enemyParty[0].species.speciesId).toBe(SpeciesId.BEEDRILL);
@ -273,7 +271,7 @@ describe("Bug-Type Superfan - Mystery Encounter", () => {
await runMysteryEncounterToEnd(game, 1, undefined, true);
const enemyParty = scene.getEnemyParty();
expect(scene.phaseManager.getCurrentPhase()?.constructor.name).toBe(CommandPhase.name);
expect(game).toBeAtPhase("CommandPhase");
expect(enemyParty.length).toBe(5);
expect(scene.currentBattle.trainer?.config.trainerType).toBe(TrainerType.BUG_TYPE_SUPERFAN);
expect(enemyParty[0].species.speciesId).toBe(SpeciesId.BEEDRILL);
@ -289,7 +287,7 @@ describe("Bug-Type Superfan - Mystery Encounter", () => {
await runMysteryEncounterToEnd(game, 1, undefined, true);
const enemyParty = scene.getEnemyParty();
expect(scene.phaseManager.getCurrentPhase()?.constructor.name).toBe(CommandPhase.name);
expect(game).toBeAtPhase("CommandPhase");
expect(enemyParty.length).toBe(5);
expect(scene.currentBattle.trainer?.config.trainerType).toBe(TrainerType.BUG_TYPE_SUPERFAN);
expect(enemyParty[0].species.speciesId).toBe(SpeciesId.BEEDRILL);
@ -307,7 +305,7 @@ describe("Bug-Type Superfan - Mystery Encounter", () => {
await runMysteryEncounterToEnd(game, 1, undefined, true);
const enemyParty = scene.getEnemyParty();
expect(scene.phaseManager.getCurrentPhase()?.constructor.name).toBe(CommandPhase.name);
expect(game).toBeAtPhase("CommandPhase");
expect(enemyParty.length).toBe(5);
expect(scene.currentBattle.trainer?.config.trainerType).toBe(TrainerType.BUG_TYPE_SUPERFAN);
expect(enemyParty[0].species.speciesId).toBe(SpeciesId.BEEDRILL);
@ -325,7 +323,7 @@ describe("Bug-Type Superfan - Mystery Encounter", () => {
await runMysteryEncounterToEnd(game, 1, undefined, true);
const enemyParty = scene.getEnemyParty();
expect(scene.phaseManager.getCurrentPhase()?.constructor.name).toBe(CommandPhase.name);
expect(game).toBeAtPhase("CommandPhase");
expect(enemyParty.length).toBe(5);
expect(scene.currentBattle.trainer?.config.trainerType).toBe(TrainerType.BUG_TYPE_SUPERFAN);
expect(enemyParty[0].species.speciesId).toBe(SpeciesId.BEEDRILL);
@ -343,7 +341,7 @@ describe("Bug-Type Superfan - Mystery Encounter", () => {
await runMysteryEncounterToEnd(game, 1, undefined, true);
const enemyParty = scene.getEnemyParty();
expect(scene.phaseManager.getCurrentPhase()?.constructor.name).toBe(CommandPhase.name);
expect(game).toBeAtPhase("CommandPhase");
expect(enemyParty.length).toBe(5);
expect(scene.currentBattle.trainer?.config.trainerType).toBe(TrainerType.BUG_TYPE_SUPERFAN);
expect(enemyParty[0].species.speciesId).toBe(SpeciesId.BEEDRILL);
@ -365,7 +363,7 @@ describe("Bug-Type Superfan - Mystery Encounter", () => {
await runMysteryEncounterToEnd(game, 1, undefined, true);
await skipBattleRunMysteryEncounterRewardsPhase(game, false);
expect(scene.phaseManager.getCurrentPhase()?.constructor.name).toBe(MysteryEncounterRewardsPhase.name);
expect(game).toBeAtPhase("MysteryEncounterRewardsPhase");
game.phaseInterceptor["prompts"] = []; // Clear out prompt handlers
game.onNextPrompt("MysteryEncounterRewardsPhase", UiMode.OPTION_SELECT, () => {
game.endPhase();
@ -406,7 +404,7 @@ describe("Bug-Type Superfan - Mystery Encounter", () => {
await runSelectMysteryEncounterOption(game, 2);
expect(scene.phaseManager.getCurrentPhase()?.constructor.name).toBe(MysteryEncounterPhase.name);
expect(game).toBeAtPhase("MysteryEncounterPhase");
expect(scene.ui.playError).not.toHaveBeenCalled(); // No error sfx, option is disabled
expect(mysteryEncounterPhase.handleOptionSelect).not.toHaveBeenCalled();
expect(mysteryEncounterPhase.continueEncounter).not.toHaveBeenCalled();
@ -416,7 +414,7 @@ describe("Bug-Type Superfan - Mystery Encounter", () => {
await game.runToMysteryEncounter(MysteryEncounterType.BUG_TYPE_SUPERFAN, defaultParty);
await runMysteryEncounterToEnd(game, 2);
expect(scene.phaseManager.getCurrentPhase()?.constructor.name).toBe(SelectModifierPhase.name);
expect(game).toBeAtPhase("SelectModifierPhase");
await game.phaseInterceptor.to("SelectModifierPhase");
expect(scene.ui.getMode()).to.equal(UiMode.MODIFIER_SELECT);
@ -435,7 +433,7 @@ describe("Bug-Type Superfan - Mystery Encounter", () => {
]);
await runMysteryEncounterToEnd(game, 2);
expect(scene.phaseManager.getCurrentPhase()?.constructor.name).toBe(SelectModifierPhase.name);
expect(game).toBeAtPhase("SelectModifierPhase");
await game.phaseInterceptor.to("SelectModifierPhase");
expect(scene.ui.getMode()).to.equal(UiMode.MODIFIER_SELECT);
@ -457,7 +455,7 @@ describe("Bug-Type Superfan - Mystery Encounter", () => {
]);
await runMysteryEncounterToEnd(game, 2);
expect(scene.phaseManager.getCurrentPhase()?.constructor.name).toBe(SelectModifierPhase.name);
expect(game).toBeAtPhase("SelectModifierPhase");
await game.phaseInterceptor.to("SelectModifierPhase");
expect(scene.ui.getMode()).to.equal(UiMode.MODIFIER_SELECT);
@ -481,7 +479,7 @@ describe("Bug-Type Superfan - Mystery Encounter", () => {
]);
await runMysteryEncounterToEnd(game, 2);
expect(scene.phaseManager.getCurrentPhase()?.constructor.name).toBe(SelectModifierPhase.name);
expect(game).toBeAtPhase("SelectModifierPhase");
await game.phaseInterceptor.to("SelectModifierPhase");
expect(scene.ui.getMode()).to.equal(UiMode.MODIFIER_SELECT);
@ -542,7 +540,7 @@ describe("Bug-Type Superfan - Mystery Encounter", () => {
await runSelectMysteryEncounterOption(game, 3);
expect(scene.phaseManager.getCurrentPhase()?.constructor.name).toBe(MysteryEncounterPhase.name);
expect(game).toBeAtPhase("MysteryEncounterPhase");
expect(scene.ui.playError).not.toHaveBeenCalled(); // No error sfx, option is disabled
expect(mysteryEncounterPhase.handleOptionSelect).not.toHaveBeenCalled();
expect(mysteryEncounterPhase.continueEncounter).not.toHaveBeenCalled();
@ -557,7 +555,7 @@ describe("Bug-Type Superfan - Mystery Encounter", () => {
await runMysteryEncounterToEnd(game, 3, { pokemonNo: 1, optionNo: 1 });
expect(scene.phaseManager.getCurrentPhase()?.constructor.name).toBe(SelectModifierPhase.name);
expect(game).toBeAtPhase("SelectModifierPhase");
await game.phaseInterceptor.to("SelectModifierPhase");
expect(scene.ui.getMode()).to.equal(UiMode.MODIFIER_SELECT);

View File

@ -22,10 +22,7 @@ import { ClowningAroundEncounter } from "#mystery-encounters/clowning-around-enc
import * as EncounterPhaseUtils from "#mystery-encounters/encounter-phase-utils";
import { generateModifierType } from "#mystery-encounters/encounter-phase-utils";
import * as MysteryEncounters from "#mystery-encounters/mystery-encounters";
import { CommandPhase } from "#phases/command-phase";
import { MovePhase } from "#phases/move-phase";
import { PostMysteryEncounterPhase } from "#phases/mystery-encounter-phases";
import { SelectModifierPhase } from "#phases/select-modifier-phase";
import {
runMysteryEncounterToEnd,
skipBattleRunMysteryEncounterRewardsPhase,
@ -171,7 +168,7 @@ describe("Clowning Around - Mystery Encounter", () => {
await runMysteryEncounterToEnd(game, 1, undefined, true);
const enemyField = scene.getEnemyField();
expect(scene.phaseManager.getCurrentPhase()?.constructor.name).toBe(CommandPhase.name);
expect(game).toBeAtPhase("CommandPhase");
expect(enemyField.length).toBe(2);
expect(enemyField[0].species.speciesId).toBe(SpeciesId.MR_MIME);
expect(enemyField[0].moveset).toEqual([
@ -199,9 +196,6 @@ describe("Clowning Around - Mystery Encounter", () => {
await game.runToMysteryEncounter(MysteryEncounterType.CLOWNING_AROUND, defaultParty);
await runMysteryEncounterToEnd(game, 1, undefined, true);
await skipBattleRunMysteryEncounterRewardsPhase(game);
await game.phaseInterceptor.to("SelectModifierPhase", false);
expect(scene.phaseManager.getCurrentPhase()?.constructor.name).toBe(SelectModifierPhase.name);
await game.phaseInterceptor.to("SelectModifierPhase");
const abilityToTrain = scene.currentBattle.mysteryEncounter?.misc.ability;
game.onNextPrompt("PostMysteryEncounterPhase", UiMode.MESSAGE, () => {
@ -215,7 +209,7 @@ describe("Clowning Around - Mystery Encounter", () => {
vi.spyOn(partyUiHandler, "show");
game.endPhase();
await game.phaseInterceptor.to("PostMysteryEncounterPhase");
expect(scene.phaseManager.getCurrentPhase()?.constructor.name).toBe(PostMysteryEncounterPhase.name);
expect(game).toBeAtPhase("PostMysteryEncounterPhase");
// Wait for Yes/No confirmation to appear
await vi.waitFor(() => expect(optionSelectUiHandler.show).toHaveBeenCalled());

View File

@ -9,11 +9,9 @@ import { UiMode } from "#enums/ui-mode";
import { DancingLessonsEncounter } from "#mystery-encounters/dancing-lessons-encounter";
import * as EncounterPhaseUtils from "#mystery-encounters/encounter-phase-utils";
import * as MysteryEncounters from "#mystery-encounters/mystery-encounters";
import { CommandPhase } from "#phases/command-phase";
import { LearnMovePhase } from "#phases/learn-move-phase";
import { MovePhase } from "#phases/move-phase";
import { MysteryEncounterPhase } from "#phases/mystery-encounter-phases";
import { SelectModifierPhase } from "#phases/select-modifier-phase";
import {
runMysteryEncounterToEnd,
runSelectMysteryEncounterOption,
@ -105,7 +103,7 @@ describe("Dancing Lessons - Mystery Encounter", () => {
await runMysteryEncounterToEnd(game, 1, undefined, true);
const enemyField = scene.getEnemyField();
expect(scene.phaseManager.getCurrentPhase()?.constructor.name).toBe(CommandPhase.name);
expect(game).toBeAtPhase("CommandPhase");
expect(enemyField.length).toBe(1);
expect(enemyField[0].species.speciesId).toBe(SpeciesId.ORICORIO);
expect(enemyField[0].summonData.statStages).toEqual([1, 1, 1, 1, 0, 0, 0]);
@ -126,7 +124,7 @@ describe("Dancing Lessons - Mystery Encounter", () => {
await runMysteryEncounterToEnd(game, 1, undefined, true);
await skipBattleRunMysteryEncounterRewardsPhase(game);
await game.phaseInterceptor.to("SelectModifierPhase", false);
expect(scene.phaseManager.getCurrentPhase()?.constructor.name).toBe(SelectModifierPhase.name);
expect(game).toBeAtPhase("SelectModifierPhase");
await game.phaseInterceptor.to("SelectModifierPhase");
expect(scene.ui.getMode()).to.equal(UiMode.MODIFIER_SELECT);
@ -226,7 +224,7 @@ describe("Dancing Lessons - Mystery Encounter", () => {
await runSelectMysteryEncounterOption(game, 3);
const partyCountAfter = scene.getPlayerParty().length;
expect(scene.phaseManager.getCurrentPhase()?.constructor.name).toBe(MysteryEncounterPhase.name);
expect(game).toBeAtPhase("MysteryEncounterPhase");
expect(scene.ui.playError).not.toHaveBeenCalled(); // No error sfx, option is disabled
expect(mysteryEncounterPhase.handleOptionSelect).not.toHaveBeenCalled();
expect(mysteryEncounterPhase.continueEncounter).not.toHaveBeenCalled();

View File

@ -161,7 +161,7 @@ describe("Delibird-y - Mystery Encounter", () => {
await runSelectMysteryEncounterOption(game, 1);
expect(scene.phaseManager.getCurrentPhase()?.constructor.name).toBe(MysteryEncounterPhase.name);
expect(game).toBeAtPhase("MysteryEncounterPhase");
expect(scene.ui.playError).not.toHaveBeenCalled(); // No error sfx, option is disabled
expect(mysteryEncounterPhase.handleOptionSelect).not.toHaveBeenCalled();
expect(mysteryEncounterPhase.continueEncounter).not.toHaveBeenCalled();
@ -316,7 +316,7 @@ describe("Delibird-y - Mystery Encounter", () => {
await runSelectMysteryEncounterOption(game, 2);
expect(scene.phaseManager.getCurrentPhase()?.constructor.name).toBe(MysteryEncounterPhase.name);
expect(game).toBeAtPhase("MysteryEncounterPhase");
expect(scene.ui.playError).not.toHaveBeenCalled(); // No error sfx, option is disabled
expect(mysteryEncounterPhase.handleOptionSelect).not.toHaveBeenCalled();
expect(mysteryEncounterPhase.continueEncounter).not.toHaveBeenCalled();
@ -449,7 +449,7 @@ describe("Delibird-y - Mystery Encounter", () => {
await runSelectMysteryEncounterOption(game, 3);
expect(scene.phaseManager.getCurrentPhase()?.constructor.name).toBe(MysteryEncounterPhase.name);
expect(game).toBeAtPhase("MysteryEncounterPhase");
expect(scene.ui.playError).not.toHaveBeenCalled(); // No error sfx, option is disabled
expect(mysteryEncounterPhase.handleOptionSelect).not.toHaveBeenCalled();
expect(mysteryEncounterPhase.continueEncounter).not.toHaveBeenCalled();

View File

@ -9,7 +9,6 @@ import { DepartmentStoreSaleEncounter } from "#mystery-encounters/department-sto
import * as EncounterPhaseUtils from "#mystery-encounters/encounter-phase-utils";
import * as MysteryEncounters from "#mystery-encounters/mystery-encounters";
import { CIVILIZATION_ENCOUNTER_BIOMES } from "#mystery-encounters/mystery-encounters";
import { SelectModifierPhase } from "#phases/select-modifier-phase";
import { runMysteryEncounterToEnd } from "#test/mystery-encounter/encounter-test-utils";
import { GameManager } from "#test/test-utils/game-manager";
import { ModifierSelectUiHandler } from "#ui/modifier-select-ui-handler";
@ -93,7 +92,7 @@ describe("Department Store Sale - Mystery Encounter", () => {
it("should have shop with only TMs", async () => {
await game.runToMysteryEncounter(MysteryEncounterType.DEPARTMENT_STORE_SALE, defaultParty);
await runMysteryEncounterToEnd(game, 1);
expect(scene.phaseManager.getCurrentPhase()?.constructor.name).toBe(SelectModifierPhase.name);
expect(game).toBeAtPhase("SelectModifierPhase");
await game.phaseInterceptor.to("SelectModifierPhase");
expect(scene.ui.getMode()).to.equal(UiMode.MODIFIER_SELECT);
@ -130,7 +129,7 @@ describe("Department Store Sale - Mystery Encounter", () => {
it("should have shop with only Vitamins", async () => {
await game.runToMysteryEncounter(MysteryEncounterType.DEPARTMENT_STORE_SALE, defaultParty);
await runMysteryEncounterToEnd(game, 2);
expect(scene.phaseManager.getCurrentPhase()?.constructor.name).toBe(SelectModifierPhase.name);
expect(game).toBeAtPhase("SelectModifierPhase");
await game.phaseInterceptor.to("SelectModifierPhase");
expect(scene.ui.getMode()).to.equal(UiMode.MODIFIER_SELECT);
@ -170,7 +169,7 @@ describe("Department Store Sale - Mystery Encounter", () => {
it("should have shop with only X Items", async () => {
await game.runToMysteryEncounter(MysteryEncounterType.DEPARTMENT_STORE_SALE, defaultParty);
await runMysteryEncounterToEnd(game, 3);
expect(scene.phaseManager.getCurrentPhase()?.constructor.name).toBe(SelectModifierPhase.name);
expect(game).toBeAtPhase("SelectModifierPhase");
await game.phaseInterceptor.to("SelectModifierPhase");
expect(scene.ui.getMode()).to.equal(UiMode.MODIFIER_SELECT);
@ -210,7 +209,7 @@ describe("Department Store Sale - Mystery Encounter", () => {
it("should have shop with only Pokeballs", async () => {
await game.runToMysteryEncounter(MysteryEncounterType.DEPARTMENT_STORE_SALE, defaultParty);
await runMysteryEncounterToEnd(game, 4);
expect(scene.phaseManager.getCurrentPhase()?.constructor.name).toBe(SelectModifierPhase.name);
expect(game).toBeAtPhase("SelectModifierPhase");
await game.phaseInterceptor.to("SelectModifierPhase");
expect(scene.ui.getMode()).to.equal(UiMode.MODIFIER_SELECT);

View File

@ -16,7 +16,6 @@ import { AttackTypeBoosterModifier, PokemonHeldItemModifier } from "#modifiers/m
import * as EncounterPhaseUtils from "#mystery-encounters/encounter-phase-utils";
import { FieryFalloutEncounter } from "#mystery-encounters/fiery-fallout-encounter";
import * as MysteryEncounters from "#mystery-encounters/mystery-encounters";
import { CommandPhase } from "#phases/command-phase";
import { MovePhase } from "#phases/move-phase";
import { MysteryEncounterPhase } from "#phases/mystery-encounter-phases";
import { SelectModifierPhase } from "#phases/select-modifier-phase";
@ -161,7 +160,7 @@ describe("Fiery Fallout - Mystery Encounter", () => {
await runMysteryEncounterToEnd(game, 1, undefined, true);
const enemyField = scene.getEnemyField();
expect(scene.phaseManager.getCurrentPhase()?.constructor.name).toBe(CommandPhase.name);
expect(game).toBeAtPhase("CommandPhase");
expect(enemyField.length).toBe(2);
expect(enemyField[0].species.speciesId).toBe(SpeciesId.VOLCARONA);
expect(enemyField[1].species.speciesId).toBe(SpeciesId.VOLCARONA);
@ -177,7 +176,7 @@ describe("Fiery Fallout - Mystery Encounter", () => {
await runMysteryEncounterToEnd(game, 1, undefined, true);
await skipBattleRunMysteryEncounterRewardsPhase(game);
await game.phaseInterceptor.to(SelectModifierPhase, false);
expect(scene.phaseManager.getCurrentPhase()?.constructor.name).toBe(SelectModifierPhase.name);
expect(game).toBeAtPhase("SelectModifierPhase");
const leadPokemonId = scene.getPlayerParty()?.[0].id;
const leadPokemonItems = scene.findModifiers(
@ -266,7 +265,7 @@ describe("Fiery Fallout - Mystery Encounter", () => {
await game.runToMysteryEncounter(MysteryEncounterType.FIERY_FALLOUT, defaultParty);
await runMysteryEncounterToEnd(game, 3);
await game.phaseInterceptor.to(SelectModifierPhase, false);
expect(scene.phaseManager.getCurrentPhase()?.constructor.name).toBe(SelectModifierPhase.name);
expect(game).toBeAtPhase("SelectModifierPhase");
const leadPokemonItems = scene.getPlayerParty()[0].getHeldItems() as PokemonHeldItemModifier[];
const item = leadPokemonItems.find(i => i instanceof AttackTypeBoosterModifier);
@ -292,7 +291,7 @@ describe("Fiery Fallout - Mystery Encounter", () => {
await runSelectMysteryEncounterOption(game, 3);
expect(scene.phaseManager.getCurrentPhase()?.constructor.name).toBe(MysteryEncounterPhase.name);
expect(game).toBeAtPhase("MysteryEncounterPhase");
expect(continueEncounterSpy).not.toHaveBeenCalled();
});
});

View File

@ -9,9 +9,7 @@ import { UiMode } from "#enums/ui-mode";
import * as EncounterPhaseUtils from "#mystery-encounters/encounter-phase-utils";
import { FightOrFlightEncounter } from "#mystery-encounters/fight-or-flight-encounter";
import * as MysteryEncounters from "#mystery-encounters/mystery-encounters";
import { CommandPhase } from "#phases/command-phase";
import { MysteryEncounterPhase } from "#phases/mystery-encounter-phases";
import { SelectModifierPhase } from "#phases/select-modifier-phase";
import {
runMysteryEncounterToEnd,
runSelectMysteryEncounterOption,
@ -109,7 +107,7 @@ describe("Fight or Flight - Mystery Encounter", () => {
await runMysteryEncounterToEnd(game, 1, undefined, true);
const enemyField = scene.getEnemyField();
expect(scene.phaseManager.getCurrentPhase()?.constructor.name).toBe(CommandPhase.name);
expect(game).toBeAtPhase("CommandPhase");
expect(enemyField.length).toBe(1);
expect(enemyField[0].species.speciesId).toBe(speciesToSpawn);
});
@ -122,8 +120,9 @@ describe("Fight or Flight - Mystery Encounter", () => {
await runMysteryEncounterToEnd(game, 1, undefined, true);
await skipBattleRunMysteryEncounterRewardsPhase(game);
await game.phaseInterceptor.to("SelectModifierPhase", false);
expect(scene.phaseManager.getCurrentPhase()?.constructor.name).toBe(SelectModifierPhase.name);
expect(game).toBeAtPhase("SelectModifierPhase");
await game.phaseInterceptor.to("SelectModifierPhase");
expect(scene.ui.getMode()).to.equal(UiMode.MODIFIER_SELECT);
const modifierSelectHandler = scene.ui.handlers.find(
@ -165,7 +164,7 @@ describe("Fight or Flight - Mystery Encounter", () => {
await runSelectMysteryEncounterOption(game, 2);
expect(scene.phaseManager.getCurrentPhase()?.constructor.name).toBe(MysteryEncounterPhase.name);
expect(game).toBeAtPhase("MysteryEncounterPhase");
expect(scene.ui.playError).not.toHaveBeenCalled(); // No error sfx, option is disabled
expect(mysteryEncounterPhase.handleOptionSelect).not.toHaveBeenCalled();
expect(mysteryEncounterPhase.continueEncounter).not.toHaveBeenCalled();
@ -182,7 +181,7 @@ describe("Fight or Flight - Mystery Encounter", () => {
await runMysteryEncounterToEnd(game, 2);
await game.phaseInterceptor.to("SelectModifierPhase", false);
expect(scene.phaseManager.getCurrentPhase()?.constructor.name).toBe(SelectModifierPhase.name);
expect(game).toBeAtPhase("SelectModifierPhase");
await game.phaseInterceptor.to("SelectModifierPhase");
expect(scene.ui.getMode()).to.equal(UiMode.MODIFIER_SELECT);

View File

@ -14,9 +14,8 @@ import { FunAndGamesEncounter } from "#mystery-encounters/fun-and-games-encounte
import { MysteryEncounter } from "#mystery-encounters/mystery-encounter";
import * as MysteryEncounters from "#mystery-encounters/mystery-encounters";
import { HUMAN_TRANSITABLE_BIOMES } from "#mystery-encounters/mystery-encounters";
import { CommandPhase } from "#phases/command-phase";
import type { CommandPhase } from "#phases/command-phase";
import { MysteryEncounterPhase } from "#phases/mystery-encounter-phases";
import { SelectModifierPhase } from "#phases/select-modifier-phase";
import {
runMysteryEncounterToEnd,
runSelectMysteryEncounterOption,
@ -131,7 +130,7 @@ describe("Fun And Games! - Mystery Encounter", () => {
await runSelectMysteryEncounterOption(game, 1);
expect(scene.phaseManager.getCurrentPhase()?.constructor.name).toBe(MysteryEncounterPhase.name);
expect(game).toBeAtPhase("MysteryEncounterPhase");
expect(scene.ui.playError).not.toHaveBeenCalled(); // No error sfx, option is disabled
expect(mysteryEncounterPhase.handleOptionSelect).not.toHaveBeenCalled();
expect(mysteryEncounterPhase.continueEncounter).not.toHaveBeenCalled();
@ -143,7 +142,7 @@ describe("Fun And Games! - Mystery Encounter", () => {
await game.runToMysteryEncounter(MysteryEncounterType.FUN_AND_GAMES, defaultParty);
await runMysteryEncounterToEnd(game, 1, { pokemonNo: 1 }, true);
expect(scene.phaseManager.getCurrentPhase()?.constructor.name).toBe(CommandPhase.name);
expect(game).toBeAtPhase("CommandPhase");
expect(game.field.getEnemyPokemon().species.speciesId).toBe(SpeciesId.WOBBUFFET);
expect(game.field.getEnemyPokemon().ivs).toEqual([0, 0, 0, 0, 0, 0]);
expect(game.field.getEnemyPokemon().nature).toBe(Nature.MILD);
@ -165,7 +164,7 @@ describe("Fun And Games! - Mystery Encounter", () => {
await game.phaseInterceptor.to("SelectModifierPhase", false);
// Rewards
expect(scene.phaseManager.getCurrentPhase()?.constructor.name).toBe(SelectModifierPhase.name);
expect(game).toBeAtPhase("SelectModifierPhase");
});
it("should have no items in rewards if Wubboffet doesn't take enough damage", async () => {
@ -173,7 +172,7 @@ describe("Fun And Games! - Mystery Encounter", () => {
await game.runToMysteryEncounter(MysteryEncounterType.FUN_AND_GAMES, defaultParty);
await runMysteryEncounterToEnd(game, 1, { pokemonNo: 1 }, true);
expect(scene.phaseManager.getCurrentPhase()?.constructor.name).toBe(CommandPhase.name);
expect(game).toBeAtPhase("CommandPhase");
game.onNextPrompt("MessagePhase", UiMode.MESSAGE, () => {
game.endPhase();
});
@ -184,7 +183,7 @@ describe("Fun And Games! - Mystery Encounter", () => {
await game.phaseInterceptor.to("SelectModifierPhase", false);
// Rewards
expect(scene.phaseManager.getCurrentPhase()?.constructor.name).toBe(SelectModifierPhase.name);
expect(game).toBeAtPhase("SelectModifierPhase");
await game.phaseInterceptor.to("SelectModifierPhase");
expect(scene.ui.getMode()).to.equal(UiMode.MODIFIER_SELECT);
@ -200,7 +199,7 @@ describe("Fun And Games! - Mystery Encounter", () => {
await game.runToMysteryEncounter(MysteryEncounterType.FUN_AND_GAMES, defaultParty);
await runMysteryEncounterToEnd(game, 1, { pokemonNo: 1 }, true);
expect(scene.phaseManager.getCurrentPhase()?.constructor.name).toBe(CommandPhase.name);
expect(game).toBeAtPhase("CommandPhase");
game.onNextPrompt("MessagePhase", UiMode.MESSAGE, () => {
game.endPhase();
});
@ -213,7 +212,7 @@ describe("Fun And Games! - Mystery Encounter", () => {
await game.phaseInterceptor.to("SelectModifierPhase", false);
// Rewards
expect(scene.phaseManager.getCurrentPhase()?.constructor.name).toBe(SelectModifierPhase.name);
expect(game).toBeAtPhase("SelectModifierPhase");
await game.phaseInterceptor.to("SelectModifierPhase");
expect(scene.ui.getMode()).to.equal(UiMode.MODIFIER_SELECT);
@ -230,7 +229,7 @@ describe("Fun And Games! - Mystery Encounter", () => {
await game.runToMysteryEncounter(MysteryEncounterType.FUN_AND_GAMES, defaultParty);
await runMysteryEncounterToEnd(game, 1, { pokemonNo: 1 }, true);
expect(scene.phaseManager.getCurrentPhase()?.constructor.name).toBe(CommandPhase.name);
expect(game).toBeAtPhase("CommandPhase");
game.onNextPrompt("MessagePhase", UiMode.MESSAGE, () => {
game.endPhase();
});
@ -243,7 +242,7 @@ describe("Fun And Games! - Mystery Encounter", () => {
await game.phaseInterceptor.to("SelectModifierPhase", false);
// Rewards
expect(scene.phaseManager.getCurrentPhase()?.constructor.name).toBe(SelectModifierPhase.name);
expect(game).toBeAtPhase("SelectModifierPhase");
await game.phaseInterceptor.to("SelectModifierPhase");
expect(scene.ui.getMode()).to.equal(UiMode.MODIFIER_SELECT);
@ -260,7 +259,7 @@ describe("Fun And Games! - Mystery Encounter", () => {
await game.runToMysteryEncounter(MysteryEncounterType.FUN_AND_GAMES, defaultParty);
await runMysteryEncounterToEnd(game, 1, { pokemonNo: 1 }, true);
expect(scene.phaseManager.getCurrentPhase()?.constructor.name).toBe(CommandPhase.name);
expect(game).toBeAtPhase("CommandPhase");
game.onNextPrompt("MessagePhase", UiMode.MESSAGE, () => {
game.endPhase();
});
@ -273,7 +272,7 @@ describe("Fun And Games! - Mystery Encounter", () => {
await game.phaseInterceptor.to("SelectModifierPhase", false);
// Rewards
expect(scene.phaseManager.getCurrentPhase()?.constructor.name).toBe(SelectModifierPhase.name);
expect(game).toBeAtPhase("SelectModifierPhase");
await game.phaseInterceptor.to("SelectModifierPhase");
expect(scene.ui.getMode()).to.equal(UiMode.MODIFIER_SELECT);

View File

@ -13,7 +13,6 @@ import { generateModifierType } from "#mystery-encounters/encounter-phase-utils"
import { GlobalTradeSystemEncounter } from "#mystery-encounters/global-trade-system-encounter";
import * as MysteryEncounters from "#mystery-encounters/mystery-encounters";
import { CIVILIZATION_ENCOUNTER_BIOMES } from "#mystery-encounters/mystery-encounters";
import { SelectModifierPhase } from "#phases/select-modifier-phase";
import { runMysteryEncounterToEnd } from "#test/mystery-encounter/encounter-test-utils";
import { GameManager } from "#test/test-utils/game-manager";
import { ModifierSelectUiHandler } from "#ui/modifier-select-ui-handler";
@ -226,7 +225,7 @@ describe("Global Trade System - Mystery Encounter", () => {
await scene.updateModifiers(true);
await runMysteryEncounterToEnd(game, 3, { pokemonNo: 1, optionNo: 1 });
expect(scene.phaseManager.getCurrentPhase()?.constructor.name).toBe(SelectModifierPhase.name);
expect(game).toBeAtPhase("SelectModifierPhase");
await game.phaseInterceptor.to("SelectModifierPhase");
expect(scene.ui.getMode()).to.equal(UiMode.MODIFIER_SELECT);

View File

@ -147,7 +147,7 @@ describe("Lost at Sea - Mystery Encounter", () => {
await runSelectMysteryEncounterOption(game, 1);
expect(scene.phaseManager.getCurrentPhase()?.constructor.name).toBe(MysteryEncounterPhase.name);
expect(game).toBeAtPhase("MysteryEncounterPhase");
expect(scene.ui.playError).not.toHaveBeenCalled(); // No error sfx, option is disabled
expect(mysteryEncounterPhase.handleOptionSelect).not.toHaveBeenCalled();
expect(mysteryEncounterPhase.continueEncounter).not.toHaveBeenCalled();
@ -212,7 +212,7 @@ describe("Lost at Sea - Mystery Encounter", () => {
await runSelectMysteryEncounterOption(game, 2);
expect(scene.phaseManager.getCurrentPhase()?.constructor.name).toBe(MysteryEncounterPhase.name);
expect(game).toBeAtPhase("MysteryEncounterPhase");
expect(scene.ui.playError).not.toHaveBeenCalled(); // No error sfx, option is disabled
expect(mysteryEncounterPhase.handleOptionSelect).not.toHaveBeenCalled();
expect(mysteryEncounterPhase.continueEncounter).not.toHaveBeenCalled();

View File

@ -12,8 +12,6 @@ import { MysteriousChallengersEncounter } from "#mystery-encounters/mysterious-c
import { MysteryEncounter } from "#mystery-encounters/mystery-encounter";
import * as MysteryEncounters from "#mystery-encounters/mystery-encounters";
import { HUMAN_TRANSITABLE_BIOMES } from "#mystery-encounters/mystery-encounters";
import { CommandPhase } from "#phases/command-phase";
import { SelectModifierPhase } from "#phases/select-modifier-phase";
import {
runMysteryEncounterToEnd,
skipBattleRunMysteryEncounterRewardsPhase,
@ -152,7 +150,7 @@ describe("Mysterious Challengers - Mystery Encounter", () => {
await game.runToMysteryEncounter(MysteryEncounterType.MYSTERIOUS_CHALLENGERS, defaultParty);
await runMysteryEncounterToEnd(game, 1, undefined, true);
expect(scene.phaseManager.getCurrentPhase()?.constructor.name).toBe(CommandPhase.name);
expect(game).toBeAtPhase("CommandPhase");
expect(scene.currentBattle.trainer).toBeDefined();
expect(scene.currentBattle.mysteryEncounter?.encounterMode).toBe(MysteryEncounterMode.TRAINER_BATTLE);
});
@ -162,7 +160,7 @@ describe("Mysterious Challengers - Mystery Encounter", () => {
await runMysteryEncounterToEnd(game, 1, undefined, true);
await skipBattleRunMysteryEncounterRewardsPhase(game);
await game.phaseInterceptor.to("SelectModifierPhase", false);
expect(scene.phaseManager.getCurrentPhase()?.constructor.name).toBe(SelectModifierPhase.name);
expect(game).toBeAtPhase("SelectModifierPhase");
await game.phaseInterceptor.to("SelectModifierPhase");
expect(scene.ui.getMode()).to.equal(UiMode.MODIFIER_SELECT);
@ -196,7 +194,7 @@ describe("Mysterious Challengers - Mystery Encounter", () => {
await game.runToMysteryEncounter(MysteryEncounterType.MYSTERIOUS_CHALLENGERS, defaultParty);
await runMysteryEncounterToEnd(game, 2, undefined, true);
expect(scene.phaseManager.getCurrentPhase()?.constructor.name).toBe(CommandPhase.name);
expect(game).toBeAtPhase("CommandPhase");
expect(scene.currentBattle.trainer).toBeDefined();
expect(scene.currentBattle.mysteryEncounter?.encounterMode).toBe(MysteryEncounterMode.TRAINER_BATTLE);
});
@ -206,7 +204,7 @@ describe("Mysterious Challengers - Mystery Encounter", () => {
await runMysteryEncounterToEnd(game, 2, undefined, true);
await skipBattleRunMysteryEncounterRewardsPhase(game);
await game.phaseInterceptor.to("SelectModifierPhase", false);
expect(scene.phaseManager.getCurrentPhase()?.constructor.name).toBe(SelectModifierPhase.name);
expect(game).toBeAtPhase("SelectModifierPhase");
await game.phaseInterceptor.to("SelectModifierPhase");
expect(scene.ui.getMode()).to.equal(UiMode.MODIFIER_SELECT);
@ -253,7 +251,7 @@ describe("Mysterious Challengers - Mystery Encounter", () => {
await game.runToMysteryEncounter(MysteryEncounterType.MYSTERIOUS_CHALLENGERS, defaultParty);
await runMysteryEncounterToEnd(game, 3, undefined, true);
expect(scene.phaseManager.getCurrentPhase()?.constructor.name).toBe(CommandPhase.name);
expect(game).toBeAtPhase("CommandPhase");
expect(scene.currentBattle.trainer).toBeDefined();
expect(scene.currentBattle.mysteryEncounter?.encounterMode).toBe(MysteryEncounterMode.TRAINER_BATTLE);
});
@ -262,8 +260,7 @@ describe("Mysterious Challengers - Mystery Encounter", () => {
await game.runToMysteryEncounter(MysteryEncounterType.MYSTERIOUS_CHALLENGERS, defaultParty);
await runMysteryEncounterToEnd(game, 3, undefined, true);
await skipBattleRunMysteryEncounterRewardsPhase(game);
await game.phaseInterceptor.to("SelectModifierPhase", false);
expect(scene.phaseManager.getCurrentPhase()?.constructor.name).toBe(SelectModifierPhase.name);
expect(game).toBeAtPhase("SelectModifierPhase");
await game.phaseInterceptor.to("SelectModifierPhase");
expect(scene.ui.getMode()).to.equal(UiMode.MODIFIER_SELECT);

View File

@ -246,7 +246,7 @@ describe("Part-Timer - Mystery Encounter", () => {
await runSelectMysteryEncounterOption(game, 3);
expect(scene.phaseManager.getCurrentPhase()?.constructor.name).toBe(MysteryEncounterPhase.name);
expect(game).toBeAtPhase("MysteryEncounterPhase");
expect(scene.ui.playError).not.toHaveBeenCalled(); // No error sfx, option is disabled
expect(mysteryEncounterPhase.handleOptionSelect).not.toHaveBeenCalled();
expect(mysteryEncounterPhase.continueEncounter).not.toHaveBeenCalled();

View File

@ -119,7 +119,7 @@ describe("Safari Zone - Mystery Encounter", () => {
await runSelectMysteryEncounterOption(game, 1);
expect(scene.phaseManager.getCurrentPhase()?.constructor.name).toBe(MysteryEncounterPhase.name);
expect(game).toBeAtPhase("MysteryEncounterPhase");
expect(scene.ui.playError).not.toHaveBeenCalled(); // No error sfx, option is disabled
expect(mysteryEncounterPhase.handleOptionSelect).not.toHaveBeenCalled();
expect(mysteryEncounterPhase.continueEncounter).not.toHaveBeenCalled();

View File

@ -8,9 +8,7 @@ import { SpeciesId } from "#enums/species-id";
import { UiMode } from "#enums/ui-mode";
import * as MysteryEncounters from "#mystery-encounters/mystery-encounters";
import { TeleportingHijinksEncounter } from "#mystery-encounters/teleporting-hijinks-encounter";
import { CommandPhase } from "#phases/command-phase";
import { MysteryEncounterPhase } from "#phases/mystery-encounter-phases";
import { SelectModifierPhase } from "#phases/select-modifier-phase";
import {
runMysteryEncounterToEnd,
runSelectMysteryEncounterOption,
@ -157,7 +155,7 @@ describe("Teleporting Hijinks - Mystery Encounter", () => {
await runSelectMysteryEncounterOption(game, 1);
expect(scene.phaseManager.getCurrentPhase()?.constructor.name).toBe(MysteryEncounterPhase.name);
expect(game).toBeAtPhase("MysteryEncounterPhase");
expect(scene.ui.playError).not.toHaveBeenCalled(); // No error sfx, option is disabled
expect(mysteryEncounterPhase.handleOptionSelect).not.toHaveBeenCalled();
expect(mysteryEncounterPhase.continueEncounter).not.toHaveBeenCalled();
@ -167,7 +165,7 @@ describe("Teleporting Hijinks - Mystery Encounter", () => {
await game.runToMysteryEncounter(MysteryEncounterType.TELEPORTING_HIJINKS, defaultParty);
await runMysteryEncounterToEnd(game, 1, undefined, true);
expect(scene.phaseManager.getCurrentPhase()?.constructor.name).toBe(CommandPhase.name);
expect(game).toBeAtPhase("CommandPhase");
});
it("should transport to a new area", async () => {
@ -229,7 +227,7 @@ describe("Teleporting Hijinks - Mystery Encounter", () => {
await runSelectMysteryEncounterOption(game, 2);
expect(scene.phaseManager.getCurrentPhase()?.constructor.name).toBe(MysteryEncounterPhase.name);
expect(game).toBeAtPhase("MysteryEncounterPhase");
expect(scene.ui.playError).not.toHaveBeenCalled(); // No error sfx, option is disabled
expect(mysteryEncounterPhase.handleOptionSelect).not.toHaveBeenCalled();
expect(mysteryEncounterPhase.continueEncounter).not.toHaveBeenCalled();
@ -239,7 +237,7 @@ describe("Teleporting Hijinks - Mystery Encounter", () => {
await game.runToMysteryEncounter(MysteryEncounterType.TELEPORTING_HIJINKS, [SpeciesId.METAGROSS]);
await runMysteryEncounterToEnd(game, 2, undefined, true);
expect(scene.phaseManager.getCurrentPhase()?.constructor.name).toBe(CommandPhase.name);
expect(game).toBeAtPhase("CommandPhase");
});
it("should transport to a new area", async () => {
@ -300,7 +298,7 @@ describe("Teleporting Hijinks - Mystery Encounter", () => {
await runMysteryEncounterToEnd(game, 3, undefined, true);
await skipBattleRunMysteryEncounterRewardsPhase(game);
await game.phaseInterceptor.to("SelectModifierPhase", false);
expect(scene.phaseManager.getCurrentPhase()?.constructor.name).toBe(SelectModifierPhase.name);
expect(game).toBeAtPhase("SelectModifierPhase");
await game.phaseInterceptor.to("SelectModifierPhase");
expect(scene.ui.getMode()).to.equal(UiMode.MODIFIER_SELECT);

View File

@ -12,8 +12,6 @@ import { MysteryEncounter } from "#mystery-encounters/mystery-encounter";
import * as MysteryEncounters from "#mystery-encounters/mystery-encounters";
import { HUMAN_TRANSITABLE_BIOMES } from "#mystery-encounters/mystery-encounters";
import { TheExpertPokemonBreederEncounter } from "#mystery-encounters/the-expert-pokemon-breeder-encounter";
import { CommandPhase } from "#phases/command-phase";
import { SelectModifierPhase } from "#phases/select-modifier-phase";
import {
runMysteryEncounterToEnd,
skipBattleRunMysteryEncounterRewardsPhase,
@ -157,7 +155,7 @@ describe("The Expert Pokémon Breeder - Mystery Encounter", () => {
expect(successfullyLoaded).toBe(true);
// Check usual battle stuff
expect(scene.phaseManager.getCurrentPhase()?.constructor.name).toBe(CommandPhase.name);
expect(game).toBeAtPhase("CommandPhase");
expect(scene.currentBattle.trainer).toBeDefined();
expect(scene.currentBattle.mysteryEncounter?.encounterMode).toBe(MysteryEncounterMode.TRAINER_BATTLE);
expect(scene.getPlayerParty().length).toBe(1);
@ -175,8 +173,8 @@ describe("The Expert Pokémon Breeder - Mystery Encounter", () => {
await runMysteryEncounterToEnd(game, 1, undefined, true);
await skipBattleRunMysteryEncounterRewardsPhase(game);
await game.phaseInterceptor.to("SelectModifierPhase", false);
expect(scene.phaseManager.getCurrentPhase()?.constructor.name).toBe(SelectModifierPhase.name);
expect(game).toBeAtPhase("SelectModifierPhase");
await game.phaseInterceptor.to("SelectModifierPhase");
const eggsAfter = scene.gameData.eggs;
const commonEggs = scene.currentBattle.mysteryEncounter!.misc.pokemon1CommonEggs;
@ -242,7 +240,7 @@ describe("The Expert Pokémon Breeder - Mystery Encounter", () => {
expect(successfullyLoaded).toBe(true);
// Check usual battle stuff
expect(scene.phaseManager.getCurrentPhase()?.constructor.name).toBe(CommandPhase.name);
expect(game).toBeAtPhase("CommandPhase");
expect(scene.currentBattle.trainer).toBeDefined();
expect(scene.currentBattle.mysteryEncounter?.encounterMode).toBe(MysteryEncounterMode.TRAINER_BATTLE);
expect(scene.getPlayerParty().length).toBe(1);
@ -260,8 +258,8 @@ describe("The Expert Pokémon Breeder - Mystery Encounter", () => {
await runMysteryEncounterToEnd(game, 2, undefined, true);
await skipBattleRunMysteryEncounterRewardsPhase(game);
await game.phaseInterceptor.to("SelectModifierPhase", false);
expect(scene.phaseManager.getCurrentPhase()?.constructor.name).toBe(SelectModifierPhase.name);
expect(game).toBeAtPhase("SelectModifierPhase");
await game.phaseInterceptor.to("SelectModifierPhase");
const eggsAfter = scene.gameData.eggs;
const commonEggs = scene.currentBattle.mysteryEncounter!.misc.pokemon2CommonEggs;
@ -324,7 +322,7 @@ describe("The Expert Pokémon Breeder - Mystery Encounter", () => {
expect(successfullyLoaded).toBe(true);
// Check usual battle stuff
expect(scene.phaseManager.getCurrentPhase()?.constructor.name).toBe(CommandPhase.name);
expect(game).toBeAtPhase("CommandPhase");
expect(scene.currentBattle.trainer).toBeDefined();
expect(scene.currentBattle.mysteryEncounter?.encounterMode).toBe(MysteryEncounterMode.TRAINER_BATTLE);
expect(scene.getPlayerParty().length).toBe(1);
@ -342,8 +340,8 @@ describe("The Expert Pokémon Breeder - Mystery Encounter", () => {
await runMysteryEncounterToEnd(game, 3, undefined, true);
await skipBattleRunMysteryEncounterRewardsPhase(game);
await game.phaseInterceptor.to("SelectModifierPhase", false);
expect(scene.phaseManager.getCurrentPhase()?.constructor.name).toBe(SelectModifierPhase.name);
expect(game).toBeAtPhase("SelectModifierPhase");
await game.phaseInterceptor.to("SelectModifierPhase");
const eggsAfter = scene.gameData.eggs;
const commonEggs = scene.currentBattle.mysteryEncounter!.misc.pokemon3CommonEggs;

View File

@ -182,7 +182,7 @@ describe("The Pokemon Salesman - Mystery Encounter", () => {
await runSelectMysteryEncounterOption(game, 1);
expect(scene.phaseManager.getCurrentPhase()?.constructor.name).toBe(MysteryEncounterPhase.name);
expect(game).toBeAtPhase("MysteryEncounterPhase");
expect(scene.ui.playError).not.toHaveBeenCalled(); // No error sfx, option is disabled
expect(mysteryEncounterPhase.handleOptionSelect).not.toHaveBeenCalled();
expect(mysteryEncounterPhase.continueEncounter).not.toHaveBeenCalled();

View File

@ -17,9 +17,7 @@ import { PokemonMove } from "#moves/pokemon-move";
import * as EncounterPhaseUtils from "#mystery-encounters/encounter-phase-utils";
import * as MysteryEncounters from "#mystery-encounters/mystery-encounters";
import { TheStrongStuffEncounter } from "#mystery-encounters/the-strong-stuff-encounter";
import { CommandPhase } from "#phases/command-phase";
import { MovePhase } from "#phases/move-phase";
import { SelectModifierPhase } from "#phases/select-modifier-phase";
import {
runMysteryEncounterToEnd,
skipBattleRunMysteryEncounterRewardsPhase,
@ -192,7 +190,7 @@ describe("The Strong Stuff - Mystery Encounter", () => {
await runMysteryEncounterToEnd(game, 2, undefined, true);
const enemyField = scene.getEnemyField();
expect(scene.phaseManager.getCurrentPhase()?.constructor.name).toBe(CommandPhase.name);
expect(game).toBeAtPhase("CommandPhase");
expect(enemyField.length).toBe(1);
expect(enemyField[0].species.speciesId).toBe(SpeciesId.SHUCKLE);
expect(enemyField[0].summonData.statStages).toEqual([0, 1, 0, 1, 0, 0, 0]);
@ -230,7 +228,7 @@ describe("The Strong Stuff - Mystery Encounter", () => {
await runMysteryEncounterToEnd(game, 2, undefined, true);
await skipBattleRunMysteryEncounterRewardsPhase(game);
await game.phaseInterceptor.to("SelectModifierPhase", false);
expect(scene.phaseManager.getCurrentPhase()?.constructor.name).toBe(SelectModifierPhase.name);
expect(game).toBeAtPhase("SelectModifierPhase");
await game.phaseInterceptor.to("SelectModifierPhase");
expect(scene.ui.getMode()).to.equal(UiMode.MODIFIER_SELECT);

View File

@ -15,9 +15,7 @@ import { MysteryEncounter } from "#mystery-encounters/mystery-encounter";
import * as MysteryEncounters from "#mystery-encounters/mystery-encounters";
import { HUMAN_TRANSITABLE_BIOMES } from "#mystery-encounters/mystery-encounters";
import { TheWinstrateChallengeEncounter } from "#mystery-encounters/the-winstrate-challenge-encounter";
import { CommandPhase } from "#phases/command-phase";
import { PartyHealPhase } from "#phases/party-heal-phase";
import { SelectModifierPhase } from "#phases/select-modifier-phase";
import { VictoryPhase } from "#phases/victory-phase";
import { runMysteryEncounterToEnd } from "#test/mystery-encounter/encounter-test-utils";
import { GameManager } from "#test/test-utils/game-manager";
@ -262,7 +260,7 @@ describe("The Winstrate Challenge - Mystery Encounter", () => {
await game.runToMysteryEncounter(MysteryEncounterType.THE_WINSTRATE_CHALLENGE, defaultParty);
await runMysteryEncounterToEnd(game, 1, undefined, true);
expect(scene.phaseManager.getCurrentPhase()?.constructor.name).toBe(CommandPhase.name);
expect(game).toBeAtPhase("CommandPhase");
expect(scene.currentBattle.trainer).toBeDefined();
expect(scene.currentBattle.trainer!.config.trainerType).toBe(TrainerType.VICTOR);
expect(scene.currentBattle.mysteryEncounter?.enemyPartyConfigs.length).toBe(4);
@ -295,7 +293,7 @@ describe("The Winstrate Challenge - Mystery Encounter", () => {
// Should have Macho Brace in the rewards
await skipBattleToNextBattle(game, true);
await game.phaseInterceptor.to("SelectModifierPhase", false);
expect(scene.phaseManager.getCurrentPhase()?.constructor.name).toBe(SelectModifierPhase.name);
expect(game).toBeAtPhase("SelectModifierPhase");
await game.phaseInterceptor.to("SelectModifierPhase");
expect(scene.ui.getMode()).to.equal(UiMode.MODIFIER_SELECT);
@ -337,7 +335,7 @@ describe("The Winstrate Challenge - Mystery Encounter", () => {
it("should have a Rarer Candy in the rewards", async () => {
await game.runToMysteryEncounter(MysteryEncounterType.THE_WINSTRATE_CHALLENGE, defaultParty);
await runMysteryEncounterToEnd(game, 2);
expect(scene.phaseManager.getCurrentPhase()?.constructor.name).toBe(SelectModifierPhase.name);
expect(game).toBeAtPhase("SelectModifierPhase");
await game.phaseInterceptor.to("SelectModifierPhase");
expect(scene.ui.getMode()).to.equal(UiMode.MODIFIER_SELECT);

View File

@ -20,9 +20,7 @@ import {
} from "#mystery-encounters/encounter-phase-utils";
import * as MysteryEncounters from "#mystery-encounters/mystery-encounters";
import { TrashToTreasureEncounter } from "#mystery-encounters/trash-to-treasure-encounter";
import { CommandPhase } from "#phases/command-phase";
import { MovePhase } from "#phases/move-phase";
import { SelectModifierPhase } from "#phases/select-modifier-phase";
import {
runMysteryEncounterToEnd,
skipBattleRunMysteryEncounterRewardsPhase,
@ -172,8 +170,8 @@ describe("Trash to Treasure - Mystery Encounter", () => {
it("should give 1 Leftovers, 1 Shell Bell, and Black Sludge", async () => {
await game.runToMysteryEncounter(MysteryEncounterType.TRASH_TO_TREASURE, defaultParty);
await runMysteryEncounterToEnd(game, 1);
await game.phaseInterceptor.to("SelectModifierPhase", false);
expect(scene.phaseManager.getCurrentPhase()?.constructor.name).toBe(SelectModifierPhase.name);
expect(game).toBeAtPhase("SelectModifierPhase");
await game.phaseInterceptor.to("SelectModifierPhase");
const leftovers = scene.findModifier(m => m instanceof TurnHealModifier) as TurnHealModifier;
expect(leftovers).toBeDefined();
@ -221,7 +219,7 @@ describe("Trash to Treasure - Mystery Encounter", () => {
await runMysteryEncounterToEnd(game, 2, undefined, true);
const enemyField = scene.getEnemyField();
expect(scene.phaseManager.getCurrentPhase()?.constructor.name).toBe(CommandPhase.name);
expect(game).toBeAtPhase("CommandPhase");
expect(enemyField.length).toBe(1);
expect(enemyField[0].species.speciesId).toBe(SpeciesId.GARBODOR);
expect(enemyField[0].moveset).toEqual([
@ -243,7 +241,7 @@ describe("Trash to Treasure - Mystery Encounter", () => {
await runMysteryEncounterToEnd(game, 2, undefined, true);
await skipBattleRunMysteryEncounterRewardsPhase(game);
await game.phaseInterceptor.to("SelectModifierPhase", false);
expect(scene.phaseManager.getCurrentPhase()?.constructor.name).toBe(SelectModifierPhase.name);
expect(game).toBeAtPhase("SelectModifierPhase");
await game.phaseInterceptor.to("SelectModifierPhase");
expect(scene.ui.getMode()).to.equal(UiMode.MODIFIER_SELECT);

View File

@ -15,7 +15,6 @@ import * as EncounterPhaseUtils from "#mystery-encounters/encounter-phase-utils"
import { generateModifierType } from "#mystery-encounters/encounter-phase-utils";
import * as MysteryEncounters from "#mystery-encounters/mystery-encounters";
import { UncommonBreedEncounter } from "#mystery-encounters/uncommon-breed-encounter";
import { CommandPhase } from "#phases/command-phase";
import { MovePhase } from "#phases/move-phase";
import { MysteryEncounterPhase } from "#phases/mystery-encounter-phases";
import { StatStageChangePhase } from "#phases/stat-stage-change-phase";
@ -120,7 +119,7 @@ describe("Uncommon Breed - Mystery Encounter", () => {
await runMysteryEncounterToEnd(game, 1, undefined, true);
const enemyField = scene.getEnemyField();
expect(scene.phaseManager.getCurrentPhase()?.constructor.name).toBe(CommandPhase.name);
expect(game).toBeAtPhase("CommandPhase");
expect(enemyField.length).toBe(1);
expect(enemyField[0].species.speciesId).toBe(speciesToSpawn);
@ -147,7 +146,7 @@ describe("Uncommon Breed - Mystery Encounter", () => {
await runMysteryEncounterToEnd(game, 1, undefined, true);
const enemyField = scene.getEnemyField();
expect(scene.phaseManager.getCurrentPhase()?.constructor.name).toBe(CommandPhase.name);
expect(game).toBeAtPhase("CommandPhase");
expect(enemyField.length).toBe(1);
expect(enemyField[0].species.speciesId).toBe(speciesToSpawn);
@ -199,7 +198,7 @@ describe("Uncommon Breed - Mystery Encounter", () => {
await runSelectMysteryEncounterOption(game, 2);
expect(scene.phaseManager.getCurrentPhase()?.constructor.name).toBe(MysteryEncounterPhase.name);
expect(game).toBeAtPhase("MysteryEncounterPhase");
expect(scene.ui.playError).not.toHaveBeenCalled(); // No error sfx, option is disabled
expect(mysteryEncounterPhase.handleOptionSelect).not.toHaveBeenCalled();
expect(mysteryEncounterPhase.continueEncounter).not.toHaveBeenCalled();
@ -259,7 +258,7 @@ describe("Uncommon Breed - Mystery Encounter", () => {
await runSelectMysteryEncounterOption(game, 3);
expect(scene.phaseManager.getCurrentPhase()?.constructor.name).toBe(MysteryEncounterPhase.name);
expect(game).toBeAtPhase("MysteryEncounterPhase");
expect(scene.ui.playError).not.toHaveBeenCalled(); // No error sfx, option is disabled
expect(mysteryEncounterPhase.handleOptionSelect).not.toHaveBeenCalled();
expect(mysteryEncounterPhase.continueEncounter).not.toHaveBeenCalled();

View File

@ -10,8 +10,6 @@ import * as EncounterPhaseUtils from "#mystery-encounters/encounter-phase-utils"
import * as EncounterTransformationSequence from "#mystery-encounters/encounter-transformation-sequence";
import * as MysteryEncounters from "#mystery-encounters/mystery-encounters";
import { WeirdDreamEncounter } from "#mystery-encounters/weird-dream-encounter";
import { CommandPhase } from "#phases/command-phase";
import { SelectModifierPhase } from "#phases/select-modifier-phase";
import {
runMysteryEncounterToEnd,
skipBattleRunMysteryEncounterRewardsPhase,
@ -116,8 +114,8 @@ describe("Weird Dream - Mystery Encounter", () => {
const bstsPrior = pokemonPrior.map(species => species.getSpeciesForm().getBaseStatTotal());
await runMysteryEncounterToEnd(game, 1);
await game.phaseInterceptor.to("SelectModifierPhase", false);
expect(scene.phaseManager.getCurrentPhase()?.constructor.name).toBe(SelectModifierPhase.name);
expect(game).toBeAtPhase("SelectModifierPhase");
await game.phaseInterceptor.to("SelectModifierPhase");
const pokemonAfter = scene.getPlayerParty();
const bstsAfter = pokemonAfter.map(pokemon => pokemon.getSpeciesForm().getBaseStatTotal());
@ -140,7 +138,7 @@ describe("Weird Dream - Mystery Encounter", () => {
await game.runToMysteryEncounter(MysteryEncounterType.WEIRD_DREAM, defaultParty);
await runMysteryEncounterToEnd(game, 1);
await game.phaseInterceptor.to("SelectModifierPhase", false);
expect(scene.phaseManager.getCurrentPhase()?.constructor.name).toBe(SelectModifierPhase.name);
expect(game).toBeAtPhase("SelectModifierPhase");
await game.phaseInterceptor.to("SelectModifierPhase");
expect(scene.ui.getMode()).to.equal(UiMode.MODIFIER_SELECT);
@ -187,7 +185,7 @@ describe("Weird Dream - Mystery Encounter", () => {
await runMysteryEncounterToEnd(game, 2, undefined, true);
const enemyField = scene.getEnemyField();
expect(scene.phaseManager.getCurrentPhase()?.constructor.name).toBe(CommandPhase.name);
expect(game).toBeAtPhase("CommandPhase");
expect(enemyField.length).toBe(1);
expect(scene.getEnemyParty().length).toBe(scene.getPlayerParty().length);
});
@ -197,7 +195,7 @@ describe("Weird Dream - Mystery Encounter", () => {
await runMysteryEncounterToEnd(game, 2, undefined, true);
await skipBattleRunMysteryEncounterRewardsPhase(game);
await game.phaseInterceptor.to("SelectModifierPhase", false);
expect(scene.phaseManager.getCurrentPhase()?.constructor.name).toBe(SelectModifierPhase.name);
expect(game).toBeAtPhase("SelectModifierPhase");
await game.phaseInterceptor.to("SelectModifierPhase");
expect(scene.ui.getMode()).to.equal(UiMode.MODIFIER_SELECT);

View File

@ -34,7 +34,7 @@ describe("Mystery Encounters", () => {
]);
await game.phaseInterceptor.to(MysteryEncounterPhase, false);
expect(game.scene.phaseManager.getCurrentPhase()!.constructor.name).toBe(MysteryEncounterPhase.name);
expect(game).toBeAtPhase("MysteryEncounterPhase");
});
it("Encounters should not run on X1 waves", async () => {

View File

@ -3,7 +3,7 @@ import { MysteryEncounterTier } from "#enums/mystery-encounter-tier";
import { MysteryEncounterType } from "#enums/mystery-encounter-type";
import { SpeciesId } from "#enums/species-id";
import { UiMode } from "#enums/ui-mode";
import { MysteryEncounterOptionSelectedPhase, MysteryEncounterPhase } from "#phases/mystery-encounter-phases";
import { MysteryEncounterOptionSelectedPhase } from "#phases/mystery-encounter-phases";
import { GameManager } from "#test/test-utils/game-manager";
import type { MessageUiHandler } from "#ui/message-ui-handler";
import type { MysteryEncounterUiHandler } from "#ui/mystery-encounter-ui-handler";
@ -38,7 +38,7 @@ describe("Mystery Encounter Phases", () => {
]);
await game.phaseInterceptor.to("MysteryEncounterPhase", false);
expect(game.scene.phaseManager.getCurrentPhase()?.constructor.name).toBe(MysteryEncounterPhase.name);
expect(game).toBeAtPhase("MysteryEncounterPhase");
});
it("Runs MysteryEncounterPhase", async () => {

View File

@ -44,6 +44,7 @@ import type { InputsHandler } from "#test/test-utils/inputs-handler";
import { MockFetch } from "#test/test-utils/mocks/mock-fetch";
import { PhaseInterceptor } from "#test/test-utils/phase-interceptor";
import { TextInterceptor } from "#test/test-utils/text-interceptor";
import type { PhaseClass, PhaseString } from "#types/phase-types";
import type { BallUiHandler } from "#ui/ball-ui-handler";
import type { BattleMessageUiHandler } from "#ui/battle-message-ui-handler";
import type { CommandUiHandler } from "#ui/command-ui-handler";
@ -160,7 +161,7 @@ export class GameManager {
* End the currently running phase immediately.
*/
endPhase() {
this.scene.phaseManager.getCurrentPhase()?.end();
this.scene.phaseManager.getCurrentPhase().end();
}
/**
@ -412,10 +413,11 @@ export class GameManager {
* Checks if the current phase matches the target phase.
* @param phaseTarget - The target phase.
* @returns Whether the current phase matches the target phase
* @todo Remove `phaseClass` from signature
*/
isCurrentPhase(phaseTarget) {
isCurrentPhase(phaseTarget: PhaseClass | PhaseString) {
const targetName = typeof phaseTarget === "string" ? phaseTarget : phaseTarget.name;
return this.scene.phaseManager.getCurrentPhase()?.constructor.name === targetName;
return this.scene.phaseManager.getCurrentPhase().phaseName === targetName;
}
/**

View File

@ -0,0 +1,45 @@
/** biome-ignore-start lint/correctness/noUnusedImports: TSDoc imports */
import type { Phase } from "#app/phase";
import type { GameManager } from "#test/test-utils/game-manager";
// biome-ignore-end lint/correctness/noUnusedImports: TSDoc
import { isGameManagerInstance, receivedStr } from "#test/test-utils/test-utils";
import type { PhaseString } from "#types/phase-types";
import type { MatcherState, SyncExpectationResult } from "@vitest/expect";
/**
* Matcher that checks if the current {@linkcode Phase} is of the given type.
* @param received - The object to check. Should be the current {@linkcode GameManager}
* @param expectedPhase - The expected {@linkcode PhaseString}
* @returns The result of the matching
*/
export function toBeAtPhase(this: MatcherState, received: unknown, expectedPhase: PhaseString): SyncExpectationResult {
if (!isGameManagerInstance(received)) {
return {
pass: this.isNot,
message: () => `Expected to receive a GameManager, but got ${receivedStr(received)}!`,
};
}
if (!received.scene?.phaseManager) {
return {
pass: this.isNot,
message: () => `Expected GameManager.${received.scene ? "scene.phaseManager" : "scene"} to be defined!`,
};
}
const currPhase = received.scene.phaseManager.getCurrentPhase();
const pass = currPhase.is(expectedPhase);
const actual = currPhase.phaseName;
return {
pass,
message: () =>
pass
? `Expected the current phase to NOT be ${expectedPhase}, but it was!`
: `Expected the current phase to be ${expectedPhase}, but got ${actual} instead!`,
expected: expectedPhase,
actual,
};
}

View File

@ -384,7 +384,7 @@ export class PhaseInterceptor {
const actionForNextPrompt = this.prompts[0];
const expireFn = actionForNextPrompt.expireFn?.();
const currentMode = this.scene.ui.getMode();
const currentPhase = this.scene.phaseManager.getCurrentPhase()?.constructor.name;
const currentPhase = this.scene.phaseManager.getCurrentPhase().phaseName;
const currentHandler = this.scene.ui.getHandler();
if (expireFn) {
this.prompts.shift();