[Test] MoveHelper#changeMoveset disables moveset overrides

Also fix Assist tests and add `expect` for max moveset length
This commit is contained in:
NightKev 2025-05-31 18:45:27 -07:00
parent 1ff2701964
commit a9198b7860
2 changed files with 18 additions and 7 deletions

View File

@ -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();

View File

@ -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));