mirror of
https://github.com/pagefaultgames/pokerogue.git
synced 2025-03-05 17:38:35 +00:00
74 lines
2.6 KiB
TypeScript
74 lines
2.6 KiB
TypeScript
|
import Phaser from "phaser";
|
||
|
import { afterEach, beforeAll, beforeEach, describe, expect, test, vi } from "vitest";
|
||
|
import GameManager from "../utils/gameManager";
|
||
|
import Overrides from "#app/overrides";
|
||
|
import { Species } from "#enums/species";
|
||
|
import { Abilities } from "#enums/abilities";
|
||
|
import { Moves } from "#enums/moves";
|
||
|
import { getMovePosition } from "../utils/gameManagerUtils";
|
||
|
import { BerryPhase, CommandPhase, MoveEndPhase, TurnEndPhase } from "#app/phases.js";
|
||
|
import { BattlerTagType } from "#app/enums/battler-tag-type.js";
|
||
|
import { allMoves } from "#app/data/move.js";
|
||
|
|
||
|
const TIMEOUT = 20 * 1000;
|
||
|
|
||
|
describe("Moves - Astonish", () => {
|
||
|
let phaserGame: Phaser.Game;
|
||
|
let game: GameManager;
|
||
|
|
||
|
beforeAll(() => {
|
||
|
phaserGame = new Phaser.Game({
|
||
|
type: Phaser.HEADLESS,
|
||
|
});
|
||
|
});
|
||
|
|
||
|
afterEach(() => {
|
||
|
game.phaseInterceptor.restoreOg();
|
||
|
});
|
||
|
|
||
|
beforeEach(() => {
|
||
|
game = new GameManager(phaserGame);
|
||
|
vi.spyOn(Overrides, "BATTLE_TYPE_OVERRIDE", "get").mockReturnValue("single");
|
||
|
vi.spyOn(Overrides, "MOVESET_OVERRIDE", "get").mockReturnValue([Moves.ASTONISH, Moves.SPLASH]);
|
||
|
vi.spyOn(Overrides, "OPP_SPECIES_OVERRIDE", "get").mockReturnValue(Species.BLASTOISE);
|
||
|
vi.spyOn(Overrides, "OPP_ABILITY_OVERRIDE", "get").mockReturnValue(Abilities.INSOMNIA);
|
||
|
vi.spyOn(Overrides, "OPP_MOVESET_OVERRIDE", "get").mockReturnValue([Moves.TACKLE, Moves.TACKLE, Moves.TACKLE, Moves.TACKLE]);
|
||
|
vi.spyOn(Overrides, "STARTING_LEVEL_OVERRIDE", "get").mockReturnValue(100);
|
||
|
vi.spyOn(Overrides, "OPP_LEVEL_OVERRIDE", "get").mockReturnValue(100);
|
||
|
|
||
|
vi.spyOn(allMoves[Moves.ASTONISH], "chance", "get").mockReturnValue(100);
|
||
|
});
|
||
|
|
||
|
test(
|
||
|
"move effect should cancel the target's move on the turn it applies",
|
||
|
async () => {
|
||
|
await game.startBattle([Species.MEOWSCARADA]);
|
||
|
|
||
|
const leadPokemon = game.scene.getPlayerPokemon();
|
||
|
expect(leadPokemon).toBeDefined();
|
||
|
|
||
|
const enemyPokemon = game.scene.getEnemyPokemon();
|
||
|
expect(enemyPokemon).toBeDefined();
|
||
|
|
||
|
game.doAttack(getMovePosition(game.scene, 0, Moves.ASTONISH));
|
||
|
|
||
|
await game.phaseInterceptor.to(MoveEndPhase, false);
|
||
|
|
||
|
expect(enemyPokemon.getTag(BattlerTagType.FLINCHED)).toBeDefined();
|
||
|
|
||
|
await game.phaseInterceptor.to(TurnEndPhase);
|
||
|
|
||
|
expect(leadPokemon.hp).toBe(leadPokemon.getMaxHp());
|
||
|
expect(enemyPokemon.getTag(BattlerTagType.FLINCHED)).toBeUndefined();
|
||
|
|
||
|
await game.phaseInterceptor.to(CommandPhase, false);
|
||
|
|
||
|
game.doAttack(getMovePosition(game.scene, 0, Moves.SPLASH));
|
||
|
|
||
|
await game.phaseInterceptor.to(BerryPhase, false);
|
||
|
|
||
|
expect(leadPokemon.hp).toBeLessThan(leadPokemon.getMaxHp());
|
||
|
}, TIMEOUT
|
||
|
);
|
||
|
});
|