From a9198b7860f9f518cbbbb1850ec3f67353fd0c42 Mon Sep 17 00:00:00 2001 From: NightKev <34855794+DayKev@users.noreply.github.com> Date: Sat, 31 May 2025 18:45:27 -0700 Subject: [PATCH] [Test] `MoveHelper#changeMoveset` disables moveset overrides Also fix Assist tests and add `expect` for max moveset length --- test/moves/assist.test.ts | 8 ++------ test/testUtils/helpers/moveHelper.ts | 17 ++++++++++++++++- 2 files changed, 18 insertions(+), 7 deletions(-) diff --git a/test/moves/assist.test.ts b/test/moves/assist.test.ts index 27aa5528f17..5d47fef33b4 100644 --- a/test/moves/assist.test.ts +++ b/test/moves/assist.test.ts @@ -1,7 +1,6 @@ import { BattlerIndex } from "#enums/battler-index"; import { Stat } from "#app/enums/stat"; import { MoveResult } from "#enums/move-result"; -import { CommandPhase } from "#app/phases/command-phase"; import { AbilityId } from "#enums/ability-id"; import { MoveId } from "#enums/move-id"; import { SpeciesId } from "#enums/species-id"; @@ -80,7 +79,6 @@ describe("Moves - Assist", () => { // Player uses Sketch to copy Swords Dance, Player_2 stalls a turn. Player will attempt Assist and should have no usable moves await game.toNextTurn(); game.move.select(MoveId.ASSIST, 0); - await game.phaseInterceptor.to(CommandPhase); game.move.select(MoveId.PROTECT, 1); await game.toNextTurn(); @@ -88,15 +86,13 @@ describe("Moves - Assist", () => { }); it("should apply secondary effects of a move", async () => { - game.override.moveset([MoveId.ASSIST, MoveId.WOOD_HAMMER, MoveId.WOOD_HAMMER, MoveId.WOOD_HAMMER]); await game.classicMode.startBattle([SpeciesId.FEEBAS, SpeciesId.SHUCKLE]); const [feebas, shuckle] = game.scene.getPlayerField(); - game.move.changeMoveset(feebas, [MoveId.ASSIST, MoveId.SKETCH, MoveId.PROTECT, MoveId.DRAGON_TAIL]); - game.move.changeMoveset(shuckle, [MoveId.ASSIST, MoveId.SKETCH, MoveId.PROTECT, MoveId.DRAGON_TAIL]); + game.move.changeMoveset(feebas, [MoveId.ASSIST, MoveId.WOOD_HAMMER]); + game.move.changeMoveset(shuckle, [MoveId.ASSIST, MoveId.WOOD_HAMMER]); game.move.select(MoveId.ASSIST, 0); - await game.phaseInterceptor.to(CommandPhase); game.move.select(MoveId.ASSIST, 1); await game.toNextTurn(); diff --git a/test/testUtils/helpers/moveHelper.ts b/test/testUtils/helpers/moveHelper.ts index ed1441a6a2f..7cf1190b7ee 100644 --- a/test/testUtils/helpers/moveHelper.ts +++ b/test/testUtils/helpers/moveHelper.ts @@ -11,7 +11,7 @@ import { MoveId } from "#enums/move-id"; import { UiMode } from "#enums/ui-mode"; import { getMovePosition } from "#test/testUtils/gameManagerUtils"; import { GameManagerHelper } from "#test/testUtils/helpers/gameManagerHelper"; -import { vi } from "vitest"; +import { expect, vi } from "vitest"; import { coerceArray } from "#app/utils/common"; import { MoveUseMode } from "#enums/move-use-mode"; @@ -160,12 +160,27 @@ export class MoveHelper extends GameManagerHelper { /** * Changes a pokemon's moveset to the given move(s). + * * Used when the normal moveset override can't be used (such as when it's necessary to check or update properties of the moveset). + * + * **Note**: Will disable the moveset override matching the pokemon's party. * @param pokemon - The {@linkcode Pokemon} being modified * @param moveset - The {@linkcode MoveId} (single or array) to change the Pokemon's moveset to. */ public changeMoveset(pokemon: Pokemon, moveset: MoveId | MoveId[]): void { + if (pokemon.isPlayer()) { + if (coerceArray(Overrides.MOVESET_OVERRIDE).length > 0) { + vi.spyOn(Overrides, "MOVESET_OVERRIDE", "get").mockReturnValue([]); + console.warn("Player moveset override disabled due to use of `game.move.changeMoveset`!"); + } + } else { + if (coerceArray(Overrides.OPP_MOVESET_OVERRIDE).length > 0) { + vi.spyOn(Overrides, "OPP_MOVESET_OVERRIDE", "get").mockReturnValue([]); + console.warn("Enemy moveset override disabled due to use of `game.move.changeMoveset`!"); + } + } moveset = coerceArray(moveset); + expect(moveset.length, "Cannot assign more than 4 moves to a moveset!").toBeLessThanOrEqual(4); pokemon.moveset = []; moveset.forEach(move => { pokemon.moveset.push(new PokemonMove(move));