pokerogue/test/abilities/healer.test.ts
Bertie690 6c03181621
[Bug] Refactored status code, fixed Rest/Sleep Talk status checks (#5872)
* Reworked status code, fixed bugs and added Rest tests

* Fixed rest bug

* Fixed bugs, split up status code, re-added required Rest parameter

* Cleaned up comments and such

* Added edge case to rest about locales

* Maybe did stuff

* Split up `trySetStatus` fully; fixed rest turn order display to match mainline

* Reverted healing changes to move to other PR

* Fixed message code a bit

* Condensed all status immunity tests under 1 roof

* Fixed the tests

* Added pollen puff tests back again

* Fixed swallow test

* Reverted swallow test

fixing in other prs

* Fixed pollen puff

* Fixed cirrc dep isuse

* fixed stockpile to no longer fail on stack full

* Fixed rest thing...?

* readded swallow conds

* Fixed tests

* wip

* Fixed tests

* Added pokemon heal phase to the turn queue

* ddddd

* Fixed the tests

* Fixed corrosion test

* Ran linting

* Fixed infiltrator bug

* Fix pokemon.ts

* Update move.ts

* Update corrosion.test.ts

* Update pokemon.ts documentation

* Remove missed line in TSDocs

* Update pokemon.ts

Co-authored-by: Sirz Benjie <142067137+SirzBenjie@users.noreply.github.com>

* Update modifier.ts

Co-authored-by: Sirz Benjie <142067137+SirzBenjie@users.noreply.github.com>

* Update modifier.ts

Co-authored-by: Sirz Benjie <142067137+SirzBenjie@users.noreply.github.com>

* Update obtain-status-effect-phase.ts

* Fix merge issues and apply Biome

* Revert pokemon-heal-phase.ts

* ddddd

* Fixed test file syntax err

* Update toxic spikes status set text to be quiet

* ran biome

* ran boime

* Prevent rest failure message from displaying outside of move phase

---------

Co-authored-by: Sirz Benjie <142067137+SirzBenjie@users.noreply.github.com>
Co-authored-by: NightKev <34855794+DayKev@users.noreply.github.com>
2025-08-20 08:45:09 -05:00

95 lines
3.5 KiB
TypeScript

import { PostTurnResetStatusAbAttr } from "#abilities/ability";
import { allAbilities } from "#data/data-lists";
import { AbilityId } from "#enums/ability-id";
import { MoveId } from "#enums/move-id";
import { SpeciesId } from "#enums/species-id";
import { StatusEffect } from "#enums/status-effect";
import type { Pokemon } from "#field/pokemon";
import { GameManager } from "#test/test-utils/game-manager";
import { isNullOrUndefined } from "#utils/common";
import Phaser from "phaser";
import { afterEach, beforeAll, beforeEach, describe, expect, it, vi } from "vitest";
describe("Abilities - Healer", () => {
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.SPLASH])
.ability(AbilityId.BALL_FETCH)
.battleStyle("double")
.criticalHits(false)
.enemySpecies(SpeciesId.MAGIKARP)
.enemyAbility(AbilityId.BALL_FETCH)
.enemyMoveset(MoveId.SPLASH);
// Mock healer to have a 100% chance of healing its ally
vi.spyOn(allAbilities[AbilityId.HEALER].getAttrs("PostTurnResetStatusAbAttr")[0], "getCondition").mockReturnValue(
(pokemon: Pokemon) => !isNullOrUndefined(pokemon.getAlly()),
);
});
it("should not queue a message phase for healing if the ally has fainted", async () => {
const abSpy = vi.spyOn(PostTurnResetStatusAbAttr.prototype, "canApply");
game.override.moveset([MoveId.SPLASH, MoveId.LUNAR_DANCE]);
await game.classicMode.startBattle([SpeciesId.MAGIKARP, SpeciesId.MAGIKARP]);
const user = game.field.getPlayerPokemon();
// Only want one magikarp to have the ability
vi.spyOn(user, "getAbility").mockReturnValue(allAbilities[AbilityId.HEALER]);
game.move.select(MoveId.SPLASH);
// faint the ally
game.move.select(MoveId.LUNAR_DANCE, 1);
await game.phaseInterceptor.to("TurnEndPhase");
// It's not enough to just test that the ally still has its status.
// We need to ensure that the ability failed to meet its condition
expect(abSpy).toHaveReturnedWith(false);
});
it("should heal the status of an ally if the ally has a status", async () => {
await game.classicMode.startBattle([SpeciesId.MAGIKARP, SpeciesId.MAGIKARP]);
const [user, ally] = game.scene.getPlayerField();
// Only want one magikarp to have the ability.
vi.spyOn(user, "getAbility").mockReturnValue(allAbilities[AbilityId.HEALER]);
ally.doSetStatus(StatusEffect.BURN);
game.move.select(MoveId.SPLASH);
game.move.select(MoveId.SPLASH, 1);
await game.phaseInterceptor.to("TurnEndPhase");
await game.toNextTurn();
expect(ally.status?.effect, "status effect was not healed").toBeFalsy();
});
// TODO: Healer is currently checked before the
it.todo("should heal a burn before its end of turn damage", async () => {
await game.classicMode.startBattle([SpeciesId.MAGIKARP, SpeciesId.MAGIKARP]);
const [user, ally] = game.scene.getPlayerField();
// Only want one magikarp to have the ability.
vi.spyOn(user, "getAbility").mockReturnValue(allAbilities[AbilityId.HEALER]);
ally.doSetStatus(StatusEffect.BURN);
game.move.select(MoveId.SPLASH);
game.move.select(MoveId.SPLASH, 1);
await game.phaseInterceptor.to("TurnEndPhase");
await game.toNextTurn();
expect(ally.status?.effect, "status effect was not healed").toBeFalsy();
expect(ally.hp).toBe(ally.getMaxHp());
});
});