2024-08-22 06:49:33 -07:00
|
|
|
import { BattlerIndex } from "#app/battle";
|
2024-11-08 14:44:34 -08:00
|
|
|
import { Status } from "#app/data/status-effect";
|
2025-01-12 15:33:05 -08:00
|
|
|
import type { EnemyPokemon, PlayerPokemon } from "#app/field/pokemon";
|
2024-08-22 06:49:33 -07:00
|
|
|
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";
|
2024-11-08 14:44:34 -08:00
|
|
|
import { StatusEffect } from "#enums/status-effect";
|
2025-02-22 22:52:07 -06:00
|
|
|
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);
|
2025-03-09 16:13:25 -05:00
|
|
|
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);
|
2025-03-09 16:13:25 -05:00
|
|
|
game.override.enemyMoveset([Moves.SPLASH, Moves.NONE, Moves.NONE, Moves.NONE]);
|
2024-06-28 18:59:06 -06:00
|
|
|
});
|
|
|
|
|
2025-03-09 16:13:25 -05:00
|
|
|
test("Purify heals opponent status effect and restores user hp", async () => {
|
|
|
|
await game.startBattle();
|
2024-06-28 18:59:06 -06:00
|
|
|
|
2025-03-09 16:13:25 -05:00
|
|
|
const enemyPokemon: EnemyPokemon = game.scene.getEnemyPokemon()!;
|
|
|
|
const playerPokemon: PlayerPokemon = game.scene.getPlayerPokemon()!;
|
2024-06-28 18:59:06 -06:00
|
|
|
|
2025-03-09 16:13:25 -05:00
|
|
|
playerPokemon.hp = playerPokemon.getMaxHp() - 1;
|
|
|
|
enemyPokemon.status = new Status(StatusEffect.BURN);
|
2024-06-28 18:59:06 -06:00
|
|
|
|
2025-03-09 16:13:25 -05: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
|
|
|
|
2025-03-09 16:13:25 -05:00
|
|
|
expect(enemyPokemon.status).toBeNull();
|
|
|
|
expect(playerPokemon.isFullHp()).toBe(true);
|
|
|
|
});
|
2024-06-28 18:59:06 -06:00
|
|
|
|
2025-03-09 16:13:25 -05: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
|
|
|
|
2025-03-09 16:13:25 -05:00
|
|
|
const playerPokemon: PlayerPokemon = game.scene.getPlayerPokemon()!;
|
2024-06-28 18:59:06 -06:00
|
|
|
|
2025-03-09 16:13:25 -05:00
|
|
|
playerPokemon.hp = playerPokemon.getMaxHp() - 1;
|
|
|
|
const playerInitialHp = playerPokemon.hp;
|
2024-06-28 18:59:06 -06:00
|
|
|
|
2025-03-09 16:13:25 -05: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
|
|
|
|
2025-03-09 16:13:25 -05:00
|
|
|
expect(playerPokemon.hp).toBe(playerInitialHp);
|
|
|
|
});
|
2024-06-28 18:59:06 -06:00
|
|
|
});
|