Fix cherry pick migration

This commit is contained in:
Sirz Benjie 2025-02-18 22:58:13 -06:00
parent 610b82c4c0
commit 9b9962ba73
No known key found for this signature in database
GPG Key ID: 4A524B4D196C759E
5 changed files with 46 additions and 5 deletions

View File

@ -9,7 +9,7 @@ import { PokemonAnimType } from "#app/enums/pokemon-anim-type";
import * as messages from "#app/messages";
import { allMoves } from "#app/data/move";
import type { MoveEffectPhase } from "#app/phases/move-effect-phase";
import { GameManager } from "#test/testUtils/gameManager";
import GameManager from "#test/utils/gameManager";
describe("BattlerTag - SubstituteTag", () => {
let phaserGame: Phaser.Game;

View File

@ -4,7 +4,7 @@ import { getApiBaseUrl } from "#test/utils/testUtils";
import { ScoreboardCategory, type RankingEntry } from "#app/ui/daily-run-scoreboard";
import { http, HttpResponse } from "msw";
import { afterEach, beforeAll, beforeEach, describe, expect, it, vi } from "vitest";
import { initServerForApiTests } from "#test/testUtils/testFileInitialization";
import { initServerForApiTests } from "#test/utils/testFileInitialization";
const apiBase = getApiBaseUrl();
const dailyApi = new PokerogueDailyApi(apiBase);

View File

@ -11,7 +11,7 @@ import type { SessionSaveData } from "#app/system/game-data";
import { getApiBaseUrl } from "#test/utils/testUtils";
import { http, HttpResponse } from "msw";
import { afterEach, beforeAll, beforeEach, describe, expect, it, vi } from "vitest";
import { initServerForApiTests } from "#test/testUtils/testFileInitialization";
import { initServerForApiTests } from "#test/utils/testFileInitialization";
const apiBase = getApiBaseUrl();
const sessionSavedataApi = new PokerogueSessionSavedataApi(apiBase);

View File

@ -41,13 +41,14 @@ import type { MysteryEncounterType } from "#enums/mystery-encounter-type";
import { PlayerGender } from "#enums/player-gender";
import type { Species } from "#enums/species";
import { generateStarter, waitUntil } from "#test/utils/gameManagerUtils";
import GameWrapper from "#test/utils/gameWrapper";
import { GameWrapper } from "#test/utils/gameWrapper";
import { ChallengeModeHelper } from "#test/utils/helpers/challengeModeHelper";
import { ClassicModeHelper } from "#test/utils/helpers/classicModeHelper";
import { DailyModeHelper } from "#test/utils/helpers/dailyModeHelper";
import { ModifierHelper } from "#test/utils/helpers/modifiersHelper";
import { MoveHelper } from "#test/utils/helpers/moveHelper";
import { OverridesHelper } from "#test/utils/helpers/overridesHelper";
import { FieldHelper } from "#test/utils/helpers/fieldHelper";
import { ReloadHelper } from "#test/utils/helpers/reloadHelper";
import { SettingsHelper } from "#test/utils/helpers/settingsHelper";
import PhaseInterceptor from "#test/utils/phaseInterceptor";
@ -57,7 +58,7 @@ import fs from "fs";
import { expect, vi } from "vitest";
import { globalScene } from "#app/global-scene";
import type StarterSelectUiHandler from "#app/ui/starter-select-ui-handler";
import { MockFetch } from "#test/testUtils/mocks/mockFetch";
import { MockFetch } from "#test/utils/mocks/mockFetch";
/**
* Class to manage the game state and transitions between phases.
@ -76,6 +77,7 @@ export default class GameManager {
public readonly settings: SettingsHelper;
public readonly reload: ReloadHelper;
public readonly modifiers: ModifierHelper;
public readonly field: FieldHelper;
/**
* Creates an instance of GameManager.

View File

@ -0,0 +1,39 @@
import type { EnemyPokemon, PlayerPokemon } from "#app/field/pokemon";
import { GameManagerHelper } from "#test/utils/helpers/gameManagerHelper";
import { expect } from "vitest";
// tsdoc imports
// eslint-disable-next-line @typescript-eslint/no-unused-vars
import { type globalScene } from "#app/global-scene";
/** Helper to manage pokemon */
export class FieldHelper extends GameManagerHelper {
/**
* Passthrough for {@linkcode globalScene.getPlayerPokemon} that adds an `undefined` check for
* the Pokemon so that the return type for the function doesn't have `undefined`.
* This removes the need to add a `!` like when calling `game.scene.getPlayerPokemon()!`.
* @param includeSwitching Whether a pokemon that is currently switching out is valid, default `true`
* @returns The first {@linkcode PlayerPokemon} that is {@linkcode globalScene.getPlayerField on the field}
* and {@linkcode PlayerPokemon.isActive is active}
* (aka {@linkcode PlayerPokemon.isAllowedInBattle is allowed in battle}).
*/
public getPlayerPokemon(includeSwitching: boolean = true): PlayerPokemon {
const pokemon = this.game.scene.getPlayerPokemon(includeSwitching);
expect(pokemon).toBeDefined();
return pokemon!;
}
/**
* Passthrough for {@linkcode globalScene.getEnemyPokemon} that adds an `undefined` check for
* the Pokemon so that the return type for the function doesn't have `undefined`.
* This removes the need to add a `!` like when calling `game.scene.getEnemyPokemon()!`.
* @param includeSwitching Whether a pokemon that is currently switching out is valid, default `true`
* @returns The first {@linkcode EnemyPokemon} that is {@linkcode globalScene.getEnemyField on the field}
* and {@linkcode EnemyPokemon.isActive is active}
* (aka {@linkcode EnemyPokemon.isAllowedInBattle is allowed in battle}).
*/
public getEnemyPokemon(includeSwitching: boolean = true): EnemyPokemon {
const pokemon = this.game.scene.getEnemyPokemon(includeSwitching);
expect(pokemon).toBeDefined();
return pokemon!;
}
}