pokerogue/test/moves/purify.test.ts

71 lines
2.3 KiB
TypeScript
Raw Normal View History

import { BattlerIndex } from "#app/battle";
import { Status } from "#app/data/status-effect";
import type { EnemyPokemon, PlayerPokemon } from "#app/field/pokemon";
import { MoveEndPhase } from "#app/phases/move-end-phase";
2024-06-28 18:59:06 -06:00
import { Moves } from "#enums/moves";
import { Species } from "#enums/species";
import { StatusEffect } from "#enums/status-effect";
import GameManager from "#test/testUtils/gameManager";
2024-07-25 16:10:38 -07:00
import Phaser from "phaser";
import { afterEach, beforeAll, beforeEach, describe, expect, test } from "vitest";
2024-06-28 18:59:06 -06:00
describe("Moves - Purify", () => {
let phaserGame: Phaser.Game;
let game: GameManager;
beforeAll(() => {
phaserGame = new Phaser.Game({
type: Phaser.HEADLESS,
});
});
afterEach(() => {
game.phaseInterceptor.restoreOg();
});
beforeEach(() => {
game = new GameManager(phaserGame);
2024-07-25 14:48:48 -07:00
game.override.battleType("single");
2024-06-28 18:59:06 -06:00
2024-07-25 15:24:07 -07:00
game.override.starterSpecies(Species.PYUKUMUKU);
2024-07-25 15:29:19 -07:00
game.override.startingLevel(10);
game.override.moveset([Moves.PURIFY, Moves.SIZZLY_SLIDE]);
2024-06-28 18:59:06 -06:00
2024-07-25 14:57:47 -07:00
game.override.enemySpecies(Species.MAGIKARP);
2024-07-25 16:10:38 -07:00
game.override.enemyLevel(10);
game.override.enemyMoveset([Moves.SPLASH, Moves.NONE, Moves.NONE, Moves.NONE]);
2024-06-28 18:59:06 -06:00
});
test("Purify heals opponent status effect and restores user hp", async () => {
await game.startBattle();
2024-06-28 18:59:06 -06:00
const enemyPokemon: EnemyPokemon = game.scene.getEnemyPokemon()!;
const playerPokemon: PlayerPokemon = game.scene.getPlayerPokemon()!;
2024-06-28 18:59:06 -06:00
playerPokemon.hp = playerPokemon.getMaxHp() - 1;
enemyPokemon.status = new Status(StatusEffect.BURN);
2024-06-28 18:59:06 -06:00
game.move.select(Moves.PURIFY);
await game.setTurnOrder([BattlerIndex.PLAYER, BattlerIndex.ENEMY]);
await game.phaseInterceptor.to(MoveEndPhase);
2024-06-28 18:59:06 -06:00
expect(enemyPokemon.status).toBeNull();
expect(playerPokemon.isFullHp()).toBe(true);
});
2024-06-28 18:59:06 -06:00
test("Purify does not heal if opponent doesnt have any status effect", async () => {
await game.startBattle();
2024-06-28 18:59:06 -06:00
const playerPokemon: PlayerPokemon = game.scene.getPlayerPokemon()!;
2024-06-28 18:59:06 -06:00
playerPokemon.hp = playerPokemon.getMaxHp() - 1;
const playerInitialHp = playerPokemon.hp;
2024-06-28 18:59:06 -06:00
game.move.select(Moves.PURIFY);
await game.setTurnOrder([BattlerIndex.PLAYER, BattlerIndex.ENEMY]);
await game.phaseInterceptor.to(MoveEndPhase);
2024-06-28 18:59:06 -06:00
expect(playerPokemon.hp).toBe(playerInitialHp);
});
2024-06-28 18:59:06 -06:00
});