From 37de57e73ce663b0bec58726607ea93643550f42 Mon Sep 17 00:00:00 2001 From: frutescens Date: Thu, 22 Aug 2024 22:54:13 -0700 Subject: [PATCH] Some updates --- src/phases/learn-move-phase.ts | 1 - src/test/phases/learn-move-phase.test.ts | 49 ++++++++++++++++++++++ src/test/phases/learn_move_phase.test.ts | 52 ------------------------ src/test/utils/phaseInterceptor.ts | 2 + 4 files changed, 51 insertions(+), 53 deletions(-) create mode 100644 src/test/phases/learn-move-phase.test.ts delete mode 100644 src/test/phases/learn_move_phase.test.ts diff --git a/src/phases/learn-move-phase.ts b/src/phases/learn-move-phase.ts index fc3da097ffe..b196f861ed0 100644 --- a/src/phases/learn-move-phase.ts +++ b/src/phases/learn-move-phase.ts @@ -16,7 +16,6 @@ export class LearnMovePhase extends PlayerPartyMemberPokemonPhase { constructor(scene: BattleScene, partyMemberIndex: integer, moveId: Moves) { super(scene, partyMemberIndex); - this.moveId = moveId; } diff --git a/src/test/phases/learn-move-phase.test.ts b/src/test/phases/learn-move-phase.test.ts new file mode 100644 index 00000000000..fe1df9acd4e --- /dev/null +++ b/src/test/phases/learn-move-phase.test.ts @@ -0,0 +1,49 @@ +import { afterEach, beforeAll, beforeEach, describe, expect, it, vi } from "vitest"; +import Phaser from "phaser"; +import GameManager from "#test/utils/gameManager"; +import { Species } from "#enums/species"; +import * as Utils from "#app/utils"; +import { Moves } from "#enums/moves"; +import BattleScene from "#app/battle-scene"; +import { LearnMovePhase } from "#app/phases/learn-move-phase"; +import Overrides from "#app/overrides"; +//import { allMoves } from "#app/data/move"; + +describe("Learn Move Phase", () => { + let phaserGame: Phaser.Game; + let game: GameManager; + let scene: BattleScene; + + beforeAll(() => { + phaserGame = new Phaser.Game({ + type: Phaser.HEADLESS, + }); + }); + + afterEach(() => { + game.phaseInterceptor.restoreOg(); + }); + + beforeEach(() => { + game = new GameManager(phaserGame); + scene = game.scene; + Overrides.XP_MULTIPLIER_OVERRIDE = 50; + game.override.startingLevel(5); + }); + + it("If Pokemon has less than 4 moves, its newest move will be added to the lowest empty index", async () => { + game.override.moveset([Moves.SPLASH]); + await game.startBattle([Species.BULBASAUR]); + const pokemon = game.scene.getPlayerPokemon()!; + const newMovePos = pokemon?.getMoveset().length; + game.move.select(Moves.SPLASH); + await game.doKillOpponents(); + await game.phaseInterceptor.to(LearnMovePhase); + const newMove = pokemon.getMoveset()[newMovePos]; + const levelMove = pokemon.getLevelMoves(5)[0]; + const levelReq = levelMove[0]; + const levelMoveId = levelMove[1]; + expect(pokemon.level).toBeGreaterThanOrEqual(levelReq); + expect(newMove?.moveId).toBe(levelMoveId); + }); +}); diff --git a/src/test/phases/learn_move_phase.test.ts b/src/test/phases/learn_move_phase.test.ts deleted file mode 100644 index 596dd71fd59..00000000000 --- a/src/test/phases/learn_move_phase.test.ts +++ /dev/null @@ -1,52 +0,0 @@ -import { afterEach, beforeAll, beforeEach, describe, expect, it, vi } from "vitest"; -import Phaser from "phaser"; -import GameManager from "#test/utils/gameManager"; -import { Species } from "#enums/species"; -import * as Utils from "#app/utils"; -import { Moves } from "#enums/moves"; -import { allMoves } from "#app/data/move"; -import { SPLASH_ONLY } from "#test/utils/testUtils"; -import { LearnMovePhase } from "#app/phases/learn-move-phase"; -import { TurnEndPhase } from "#app/phases/turn-end-phase"; - -describe("Learn Move Phase", () => { - let phaserGame: Phaser.Game; - let game: GameManager; - let scene: BattleScene; - - beforeAll(() => { - phaserGame = new Phaser.Game({ - type: Phaser.HEADLESS, - }); - }); - - afterEach(() => { - game.phaseInterceptor.restoreOg(); - }); - - beforeEach(() => { - game = new GameManager(phaserGame); - scene = game.scene; - }); - - describe("If Pokemon has less than 4 moves, its newest move will be added to the lowest empty index", () => { - it("new move should be found at index 1", async () => { - game.override.moveset([Moves.SPLASH, Moves.NONE, Moves.NONE, Moves.NONE]); - await game.startBattle([Species.BULBASAUR]); - const pokemon = game.scene.getPlayerPokemon()!; - const prevLength = pokemon?.getMoveset().length; - game.move.select(Moves.SPLASH); - await game.doKillOpponents(); - await game.phaseInterceptor.to(ExpPhase, false); - const expPhase = game.scene.getCurrentPhase() as ExpPhase; - expPhase.expValue = 1500; - console.log(pokemon?.level); - await game.phaseInterceptor.to(LearnMovePhase, false); - const phase = game.scene.getCurrentPhase() as MoveLearnPhase; - const newMove = phase.moveId; - const messageMode = phase.messageMode; - - console.log(allMoves[newMove]); - }); - }); -}); \ No newline at end of file diff --git a/src/test/utils/phaseInterceptor.ts b/src/test/utils/phaseInterceptor.ts index ca3d55137fa..08b11722572 100644 --- a/src/test/utils/phaseInterceptor.ts +++ b/src/test/utils/phaseInterceptor.ts @@ -8,6 +8,7 @@ import { EggLapsePhase } from "#app/phases/egg-lapse-phase"; import { EncounterPhase } from "#app/phases/encounter-phase"; import { EnemyCommandPhase } from "#app/phases/enemy-command-phase"; import { FaintPhase } from "#app/phases/faint-phase"; +import { LearnMovePhase } from "#app/phases/learn-move-phase"; import { LoginPhase } from "#app/phases/login-phase"; import { MessagePhase } from "#app/phases/message-phase"; import { MoveEffectPhase } from "#app/phases/move-effect-phase"; @@ -83,6 +84,7 @@ export default class PhaseInterceptor { [NextEncounterPhase, this.startPhase], [NewBattlePhase, this.startPhase], [VictoryPhase, this.startPhase], + [LearnMovePhase, this.startPhase], [MoveEndPhase, this.startPhase], [StatChangePhase, this.startPhase], [ShinySparklePhase, this.startPhase],