diff --git a/test/moves/instruct.test.ts b/test/moves/instruct.test.ts index dd25db4ec90..f336d7428d3 100644 --- a/test/moves/instruct.test.ts +++ b/test/moves/instruct.test.ts @@ -336,7 +336,7 @@ describe("Moves - Instruct", () => { game.move.select(Moves.ELECTRO_DRIFT); await game.setTurnOrder([BattlerIndex.PLAYER, BattlerIndex.ENEMY]); await game.phaseInterceptor.to("FaintPhase"); - await game.move.learnMove(Moves.ELECTROWEB); + await game.move.changeMoveset[Moves.ELECTROWEB]; await game.toNextWave(); game.move.select(Moves.SPLASH); diff --git a/test/phases/learn-move-phase.test.ts b/test/phases/learn-move-phase.test.ts index 019b833d386..5e5ea159e54 100644 --- a/test/phases/learn-move-phase.test.ts +++ b/test/phases/learn-move-phase.test.ts @@ -102,64 +102,4 @@ describe("Learn Move Phase", () => { expect(bulbasaur.level).toBeGreaterThanOrEqual(levelReq); expect(bulbasaur.getMoveset().map(m => m?.moveId)).toEqual(prevMoveset); }); - - it("macro should add moves in free slots normally", async () => { - await game.classicMode.startBattle([Species.BULBASAUR]); - const bulbasaur = game.scene.getPlayerPokemon()!; - - game.move.changeMoveset(bulbasaur, [Moves.SPLASH, Moves.ABSORB, Moves.ACID]); - game.move.select(Moves.SPLASH); - await game.move.learnMove(Moves.SACRED_FIRE, 0, 1); - expect(bulbasaur.getMoveset().map(m => m?.moveId)).toEqual([ - Moves.SPLASH, - Moves.ABSORB, - Moves.ACID, - Moves.SACRED_FIRE, - ]); - }); - - it("macro should replace moves", async () => { - await game.classicMode.startBattle([Species.BULBASAUR]); - const bulbasaur = game.scene.getPlayerPokemon()!; - - game.move.changeMoveset(bulbasaur, [Moves.SPLASH, Moves.ABSORB, Moves.ACID, Moves.VINE_WHIP]); - game.move.select(Moves.SPLASH); - await game.move.learnMove(Moves.SACRED_FIRE, 0, 1); - expect(bulbasaur.getMoveset().map(m => m?.moveId)).toEqual([ - Moves.SPLASH, - Moves.SACRED_FIRE, - Moves.ACID, - Moves.VINE_WHIP, - ]); - }); - - it("macro should allow for cancelling move learning", async () => { - await game.classicMode.startBattle([Species.BULBASAUR]); - const bulbasaur = game.scene.getPlayerPokemon()!; - - game.move.changeMoveset(bulbasaur, [Moves.SPLASH, Moves.ABSORB, Moves.ACID, Moves.VINE_WHIP]); - game.move.select(Moves.SPLASH); - await game.move.learnMove(Moves.SACRED_FIRE, 0, 4); - expect(bulbasaur.getMoveset().map(m => m?.moveId)).toEqual([ - Moves.SPLASH, - Moves.ABSORB, - Moves.ACID, - Moves.VINE_WHIP, - ]); - }); - - it("macro works on off-field party members", async () => { - await game.classicMode.startBattle([Species.BULBASAUR, Species.SQUIRTLE]); - const squirtle = game.scene.getPlayerParty()[1]!; - - game.move.changeMoveset(squirtle, [Moves.SPLASH, Moves.WATER_GUN, Moves.FREEZE_DRY, Moves.GROWL]); - game.move.select(Moves.TACKLE); - await game.move.learnMove(Moves.SHELL_SMASH, 1, 0); - expect(squirtle.getMoveset().map(m => m?.moveId)).toEqual([ - Moves.SHELL_SMASH, - Moves.WATER_GUN, - Moves.FREEZE_DRY, - Moves.GROWL, - ]); - }); }); diff --git a/test/testUtils/helpers/moveHelper.ts b/test/testUtils/helpers/moveHelper.ts index 269cf65ea56..9dc197be0e8 100644 --- a/test/testUtils/helpers/moveHelper.ts +++ b/test/testUtils/helpers/moveHelper.ts @@ -1,10 +1,8 @@ import type { BattlerIndex } from "#app/battle"; -import { Button } from "#app/enums/buttons"; import type Pokemon from "#app/field/pokemon"; import { PokemonMove } from "#app/field/pokemon"; import Overrides from "#app/overrides"; import type { CommandPhase } from "#app/phases/command-phase"; -import { LearnMovePhase } from "#app/phases/learn-move-phase"; import { MoveEffectPhase } from "#app/phases/move-effect-phase"; import { Command } from "#app/ui/command-ui-handler"; import { UiMode } from "#enums/ui-mode"; @@ -14,7 +12,7 @@ import { GameManagerHelper } from "#test/testUtils/helpers/gameManagerHelper"; import { vi } from "vitest"; /** - * Helper to handle a Pokemon's move + * Helper to help with move-related operations. */ export class MoveHelper extends GameManagerHelper { /** @@ -45,7 +43,8 @@ export class MoveHelper extends GameManagerHelper { } /** - * Select the move to be used by the given Pokemon(-index). Triggers during the next {@linkcode CommandPhase} + * Select the move to be used by the given Pokemon(-index) to use during the next {@linkcode CommandPhase}. + * The moveslot selected will be the first one containing the given move and not out of PP. * @param move - the move to use * @param pkmIndex - the pokemon index. Relevant for double-battles only (defaults to 0) * @param targetIndex - The {@linkcode BattlerIndex} of the Pokemon to target for single-target moves, or `null` if a manual call to `selectTarget()` is required @@ -131,39 +130,4 @@ export class MoveHelper extends GameManagerHelper { const movesetStr = moveset.map(moveId => Moves[moveId]).join(", "); console.log(`Pokemon ${pokemon.species.name}'s moveset manually set to ${movesetStr} (=[${moveset.join(", ")}])!`); } - - /** - * Simulates learning a move for a player pokemon. - * @param move The {@linkcode Moves} being learnt - * @param partyIndex The party position of the {@linkcode PlayerPokemon} learning the move (defaults to 0) - * @param moveSlotIndex The INDEX (0-4) of the move slot to replace if existent move slots are full; - * defaults to 0 (first slot) and 4 aborts the procedure - * @returns a promise that resolves once the move has been successfully learnt - */ - public async learnMove(move: Moves | number, partyIndex = 0, moveSlotIndex = 0) { - return new Promise(async (resolve, reject) => { - this.game.scene.pushPhase(new LearnMovePhase(partyIndex, move)); - - // if slots are full, queue up inputs to replace existing moves - if (this.game.scene.getPlayerParty()[partyIndex].moveset.filter(m => m).length === 4) { - this.game.onNextPrompt("LearnMovePhase", UiMode.CONFIRM, () => { - this.game.scene.ui.processInput(Button.ACTION); // "Should a move be forgotten and replaced with XXX?" - }); - this.game.onNextPrompt("LearnMovePhase", UiMode.SUMMARY, () => { - for (let x = 0; x < (moveSlotIndex ?? 0); x++) { - this.game.scene.ui.processInput(Button.DOWN); // Scrolling in summary pane to move position - } - this.game.scene.ui.processInput(Button.ACTION); - if (moveSlotIndex === 4) { - this.game.onNextPrompt("LearnMovePhase", UiMode.CONFIRM, () => { - this.game.scene.ui.processInput(Button.ACTION); // "Give up on learning XXX?" - }); - } - }); - } - - await this.game.phaseInterceptor.to(LearnMovePhase).catch(e => reject(e)); - resolve(); - }); - } }