import {afterEach, beforeAll, beforeEach, describe, expect, it, vi} from "vitest"; import Phaser from "phaser"; import GameManager from "#app/test/utils/gameManager"; import Overrides from "#app/overrides"; import { CommandPhase, EnemyCommandPhase, VictoryPhase } from "#app/phases"; import {Mode} from "#app/ui/ui"; import {Stat} from "#app/data/pokemon-stat"; import {getMovePosition} from "#app/test/utils/gameManagerUtils"; import {Command} from "#app/ui/command-ui-handler"; import {BattleStat} from "#app/data/battle-stat"; import { Abilities } from "#enums/abilities"; import { Moves } from "#enums/moves"; import { Species } from "#enums/species"; describe("Abilities - Moxie", () => { let phaserGame: Phaser.Game; let game: GameManager; beforeAll(() => { phaserGame = new Phaser.Game({ type: Phaser.HEADLESS, }); }); afterEach(() => { game.phaseInterceptor.restoreOg(); }); beforeEach(() => { game = new GameManager(phaserGame); const moveToUse = Moves.AERIAL_ACE; game.override.battleType("single"); game.override.enemySpecies(Species.RATTATA); vi.spyOn(Overrides, "OPP_ABILITY_OVERRIDE", "get").mockReturnValue(Abilities.MOXIE); vi.spyOn(Overrides, "ABILITY_OVERRIDE", "get").mockReturnValue(Abilities.MOXIE); vi.spyOn(Overrides, "STARTING_LEVEL_OVERRIDE", "get").mockReturnValue(2000); vi.spyOn(Overrides, "MOVESET_OVERRIDE", "get").mockReturnValue([moveToUse]); vi.spyOn(Overrides, "OPP_MOVESET_OVERRIDE", "get").mockReturnValue([Moves.TACKLE,Moves.TACKLE,Moves.TACKLE,Moves.TACKLE]); }); it("MOXIE", async() => { const moveToUse = Moves.AERIAL_ACE; await game.startBattle([ Species.MIGHTYENA, Species.MIGHTYENA, ]); let battleStatsPokemon = game.scene.getParty()[0].summonData.battleStats; expect(battleStatsPokemon[Stat.ATK]).toBe(0); game.onNextPrompt("CommandPhase", Mode.COMMAND, () => { game.scene.ui.setMode(Mode.FIGHT, (game.scene.getCurrentPhase() as CommandPhase).getFieldIndex()); }); game.onNextPrompt("CommandPhase", Mode.FIGHT, () => { const movePosition = getMovePosition(game.scene, 0, moveToUse); (game.scene.getCurrentPhase() as CommandPhase).handleCommand(Command.FIGHT, movePosition, false); }); await game.phaseInterceptor.runFrom(EnemyCommandPhase).to(VictoryPhase); battleStatsPokemon = game.scene.getParty()[0].summonData.battleStats; expect(battleStatsPokemon[BattleStat.ATK]).toBe(1); }, 20000); });