pokerogue/test/moves/heal_bell.test.ts

101 lines
3.6 KiB
TypeScript

import { StatusEffect } from "#app/enums/status-effect";
import { AbilityId } from "#enums/ability-id";
import { MoveId } from "#enums/move-id";
import { SpeciesId } from "#enums/species-id";
import GameManager from "#test/testUtils/gameManager";
import Phaser from "phaser";
import { afterEach, beforeAll, beforeEach, describe, it, expect, vi } from "vitest";
describe("Moves - Heal Bell", () => {
let phaserGame: Phaser.Game;
let game: GameManager;
beforeAll(() => {
phaserGame = new Phaser.Game({
type: Phaser.HEADLESS,
});
});
afterEach(() => {
game.phaseInterceptor.restoreOg();
});
beforeEach(() => {
game = new GameManager(phaserGame);
game.override
.moveset([MoveId.HEAL_BELL, MoveId.SPLASH])
.statusEffect(StatusEffect.BURN)
.battleStyle("double")
.enemyAbility(AbilityId.BALL_FETCH)
.enemyMoveset(MoveId.SPLASH);
});
it("should cure status effect of the user, its ally, and all party pokemon", async () => {
await game.classicMode.startBattle([SpeciesId.RATTATA, SpeciesId.RATTATA, SpeciesId.RATTATA]);
const [leftPlayer, rightPlayer, partyPokemon] = game.scene.getPlayerParty();
vi.spyOn(leftPlayer, "resetStatus");
vi.spyOn(rightPlayer, "resetStatus");
vi.spyOn(partyPokemon, "resetStatus");
game.move.select(MoveId.HEAL_BELL, 0);
await game.phaseInterceptor.to("CommandPhase");
game.move.select(MoveId.SPLASH, 1);
await game.toNextTurn();
expect(leftPlayer.resetStatus).toHaveBeenCalledOnce();
expect(rightPlayer.resetStatus).toHaveBeenCalledOnce();
expect(partyPokemon.resetStatus).toHaveBeenCalledOnce();
expect(leftPlayer.status?.effect).toBeUndefined();
expect(rightPlayer.status?.effect).toBeUndefined();
expect(partyPokemon.status?.effect).toBeUndefined();
});
it("should not cure status effect of the target/target's allies", async () => {
game.override.enemyStatusEffect(StatusEffect.BURN);
await game.classicMode.startBattle([SpeciesId.RATTATA, SpeciesId.RATTATA]);
const [leftOpp, rightOpp] = game.scene.getEnemyField();
vi.spyOn(leftOpp, "resetStatus");
vi.spyOn(rightOpp, "resetStatus");
game.move.select(MoveId.HEAL_BELL, 0);
await game.phaseInterceptor.to("CommandPhase");
game.move.select(MoveId.SPLASH, 1);
await game.toNextTurn();
expect(leftOpp.resetStatus).toHaveBeenCalledTimes(0);
expect(rightOpp.resetStatus).toHaveBeenCalledTimes(0);
expect(leftOpp.status?.effect).toBeTruthy();
expect(rightOpp.status?.effect).toBeTruthy();
expect(leftOpp.status?.effect).toBe(StatusEffect.BURN);
expect(rightOpp.status?.effect).toBe(StatusEffect.BURN);
});
it("should not cure status effect of allies ON FIELD with Soundproof, should still cure allies in party", async () => {
game.override.ability(AbilityId.SOUNDPROOF);
await game.classicMode.startBattle([SpeciesId.RATTATA, SpeciesId.RATTATA, SpeciesId.RATTATA]);
const [leftPlayer, rightPlayer, partyPokemon] = game.scene.getPlayerParty();
vi.spyOn(leftPlayer, "resetStatus");
vi.spyOn(rightPlayer, "resetStatus");
vi.spyOn(partyPokemon, "resetStatus");
game.move.select(MoveId.HEAL_BELL, 0);
await game.phaseInterceptor.to("CommandPhase");
game.move.select(MoveId.SPLASH, 1);
await game.toNextTurn();
expect(leftPlayer.resetStatus).toHaveBeenCalledOnce();
expect(rightPlayer.resetStatus).toHaveBeenCalledTimes(0);
expect(partyPokemon.resetStatus).toHaveBeenCalledOnce();
expect(leftPlayer.status?.effect).toBeUndefined();
expect(rightPlayer.status?.effect).toBe(StatusEffect.BURN);
expect(partyPokemon.status?.effect).toBeUndefined();
});
});