mirror of
https://github.com/pagefaultgames/pokerogue.git
synced 2025-09-23 15:03:24 +02:00
Fixed callers directly passing true
to to
This commit is contained in:
parent
9b02a82e12
commit
831922c247
@ -102,7 +102,7 @@ describe("Abilities - Good As Gold", () => {
|
||||
|
||||
game.move.select(MoveId.HELPING_HAND, 0);
|
||||
game.move.select(MoveId.TACKLE, 1);
|
||||
await game.phaseInterceptor.to("MoveEndPhase", true);
|
||||
await game.phaseInterceptor.to("MoveEndPhase");
|
||||
|
||||
expect(game.scene.getPlayerField()[1].getTag(BattlerTagType.HELPING_HAND)).toBeUndefined();
|
||||
});
|
||||
|
@ -3,7 +3,6 @@ import { MoveId } from "#enums/move-id";
|
||||
import { SpeciesId } from "#enums/species-id";
|
||||
import { Stat } from "#enums/stat";
|
||||
import type { EnemyPokemon, PlayerPokemon } from "#field/pokemon";
|
||||
import { DamageAnimPhase } from "#phases/damage-anim-phase";
|
||||
import { TurnEndPhase } from "#phases/turn-end-phase";
|
||||
import { GameManager } from "#test/test-utils/game-manager";
|
||||
import Phaser from "phaser";
|
||||
@ -50,7 +49,7 @@ describe("Moves - Fissure", () => {
|
||||
game.override.ability(AbilityId.NO_GUARD).enemyAbility(AbilityId.FUR_COAT);
|
||||
|
||||
game.move.select(MoveId.FISSURE);
|
||||
await game.phaseInterceptor.to(DamageAnimPhase, true);
|
||||
await game.phaseInterceptor.to("DamageAnimPhase");
|
||||
|
||||
expect(enemyPokemon.isFainted()).toBe(true);
|
||||
});
|
||||
|
@ -123,9 +123,8 @@ describe("Moves - Focus Punch", () => {
|
||||
await game.classicMode.startBattle([SpeciesId.CHARIZARD]);
|
||||
|
||||
game.move.select(MoveId.FOCUS_PUNCH);
|
||||
await game.phaseInterceptor.to("MoveEndPhase", true);
|
||||
await game.phaseInterceptor.to("MessagePhase", false);
|
||||
await game.phaseInterceptor.to("MoveEndPhase", true);
|
||||
await game.phaseInterceptor.to("MoveEndPhase");
|
||||
await game.phaseInterceptor.to("MoveEndPhase");
|
||||
expect(game.textInterceptor.logs).toContain(i18next.t("moveTriggers:lostFocus", { pokemonName: "Charizard" }));
|
||||
expect(game.textInterceptor.logs).not.toContain(i18next.t("battle:attackFailed"));
|
||||
});
|
||||
|
@ -5,11 +5,9 @@ import { StatusEffect } from "#enums/status-effect";
|
||||
import { UiMode } from "#enums/ui-mode";
|
||||
// biome-ignore lint/performance/noNamespaceImport: Necessary for mocks
|
||||
import * as EncounterPhaseUtils from "#mystery-encounters/encounter-phase-utils";
|
||||
import { MessagePhase } from "#phases/message-phase";
|
||||
import { MysteryEncounterBattlePhase, MysteryEncounterRewardsPhase } from "#phases/mystery-encounter-phases";
|
||||
import { VictoryPhase } from "#phases/victory-phase";
|
||||
import type { GameManager } from "#test/test-utils/game-manager";
|
||||
import { MockConsole } from "#test/test-utils/mocks/mock-console/mock-console";
|
||||
import type { MessageUiHandler } from "#ui/message-ui-handler";
|
||||
import type { MysteryEncounterUiHandler } from "#ui/mystery-encounter-ui-handler";
|
||||
import type { OptionSelectUiHandler } from "#ui/option-select-ui-handler";
|
||||
@ -47,7 +45,7 @@ export async function runMysteryEncounterToEnd(
|
||||
return await game.phaseInterceptor.to("MysteryEncounterRewardsPhase");
|
||||
}
|
||||
if (game.scene.battleStyle === BattleStyle.SWITCH) {
|
||||
MockConsole.queuePostTestWarning("BattleStyle.SWITCH was used during a test case, swapping to set mode...");
|
||||
console.warn("BattleStyle.SWITCH was used during ME battle, swapping to set mode...");
|
||||
game.settings.battleStyle(BattleStyle.SET);
|
||||
}
|
||||
await game.toNextTurn();
|
||||
@ -69,7 +67,7 @@ export async function runSelectMysteryEncounterOption(
|
||||
() => game.isCurrentPhase("MysteryEncounterOptionSelectedPhase", "CommandPhase", "TurnInitPhase"),
|
||||
);
|
||||
|
||||
if (game.isCurrentPhase(MessagePhase)) {
|
||||
if (game.isCurrentPhase("MessagePhase")) {
|
||||
await game.phaseInterceptor.to("MessagePhase");
|
||||
}
|
||||
|
||||
@ -84,7 +82,7 @@ export async function runSelectMysteryEncounterOption(
|
||||
() => game.isCurrentPhase("MysteryEncounterOptionSelectedPhase", "CommandPhase", "TurnInitPhase"),
|
||||
);
|
||||
|
||||
await game.phaseInterceptor.to("MysteryEncounterPhase", true);
|
||||
await game.phaseInterceptor.to("MysteryEncounterPhase");
|
||||
|
||||
// select the desired option
|
||||
const uiHandler = game.scene.ui.getHandler<MysteryEncounterUiHandler>();
|
||||
@ -154,7 +152,10 @@ async function handleSecondaryOptionSelect(game: GameManager, pokemonNo: number,
|
||||
* @param game
|
||||
* @param runRewardsPhase
|
||||
*/
|
||||
export async function skipBattleRunMysteryEncounterRewardsPhase(game: GameManager, runRewardsPhase = true) {
|
||||
export async function skipBattleRunMysteryEncounterRewardsPhase(
|
||||
game: GameManager,
|
||||
runRewardsPhase?: false | undefined,
|
||||
) {
|
||||
game.scene.phaseManager.clearPhaseQueue();
|
||||
game.scene.phaseManager.clearPhaseQueueSplice();
|
||||
game.scene.getEnemyParty().forEach(p => {
|
||||
|
@ -6,7 +6,7 @@ import { Phase } from "#app/phase";
|
||||
*/
|
||||
export abstract class mockPhase extends Phase {
|
||||
public phaseName: any;
|
||||
start() {
|
||||
public override start() {
|
||||
this.end();
|
||||
}
|
||||
}
|
||||
|
@ -87,7 +87,6 @@ export class PhaseInterceptor {
|
||||
* @param target - The name of the {@linkcode Phase} to transition to
|
||||
* @param runTarget - Whether or not to run the target phase before resolving; default `true`
|
||||
* @returns A Promise that resolves once `target` has been reached.
|
||||
* @todo remove `Constructor` from type signature in favor of phase strings
|
||||
* @remarks
|
||||
* This will not resolve for _any_ reason until the target phase has been reached.
|
||||
* @example
|
||||
@ -95,6 +94,11 @@ export class PhaseInterceptor {
|
||||
* await game.phaseInterceptor.to("MoveEffectPhase", false);
|
||||
* ```
|
||||
*/
|
||||
public async to(target: PhaseString, runTarget?: boolean): Promise<void>;
|
||||
/**
|
||||
* @deprecated Use `PhaseString` instead for `target`
|
||||
*/
|
||||
public async to(target: Constructor<Phase>, runTarget?: boolean): Promise<void>;
|
||||
public async to(target: PhaseString | Constructor<Phase>, runTarget = true): Promise<void> {
|
||||
this.target = typeof target === "string" ? target : (target.name as PhaseString);
|
||||
|
||||
|
@ -60,9 +60,9 @@ describe("Utils - Phase Interceptor - Unit", () => {
|
||||
* @param phases - An array of constructors to {@linkcode Phase}s to set.
|
||||
* Constructors must have no arguments.
|
||||
*/
|
||||
function setPhases(phase: Constructor<mockPhase>, ...phases: Constructor<mockPhase>[]) {
|
||||
function setPhases(...phases: [Constructor<mockPhase>, ...Constructor<mockPhase>[]]) {
|
||||
game.scene.phaseManager.clearAllPhases();
|
||||
game.scene.phaseManager.phaseQueue = [phase, ...phases].map(m => new m()) as Phase[];
|
||||
game.scene.phaseManager.phaseQueue = phases.map(m => new m()) as Phase[];
|
||||
game.scene.phaseManager.shiftPhase(); // start the thing going
|
||||
}
|
||||
|
||||
@ -77,7 +77,7 @@ describe("Utils - Phase Interceptor - Unit", () => {
|
||||
}
|
||||
|
||||
/** Wrapper function to make TS not complain about incompatible argument typing on `PhaseString`. */
|
||||
function to(phaseName: string, runTarget = true) {
|
||||
function to(phaseName: string, runTarget?: false): Promise<void> {
|
||||
return game.phaseInterceptor.to(phaseName as unknown as PhaseString, runTarget);
|
||||
}
|
||||
|
||||
|
@ -48,7 +48,7 @@ describe.todo("UI - Battle Info", () => {
|
||||
|
||||
game.move.select(MoveId.SPLASH);
|
||||
await game.doKillOpponents();
|
||||
await game.phaseInterceptor.to("ExpPhase", true);
|
||||
await game.phaseInterceptor.to("ExpPhase");
|
||||
|
||||
expect(Math.pow).not.toHaveBeenCalledWith(2, expGainsSpeed);
|
||||
},
|
||||
|
Loading…
Reference in New Issue
Block a user