pokerogue/test/abilities/status-immunity-ab-attrs.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

96 lines
3.6 KiB
TypeScript

import { allMoves } from "#data/data-lists";
import { AbilityId } from "#enums/ability-id";
import { MoveId } from "#enums/move-id";
import { MoveResult } from "#enums/move-result";
import { SpeciesId } from "#enums/species-id";
import { StatusEffect } from "#enums/status-effect";
import { StatusEffectAttr } from "#moves/move";
import { GameManager } from "#test/test-utils/game-manager";
import { toTitleCase } from "#utils/strings";
import Phaser from "phaser";
import { afterEach, beforeAll, beforeEach, describe, expect, it, vi } from "vitest";
describe.each<{ name: string; ability: AbilityId; status: StatusEffect }>([
{ name: "Vital Spirit", ability: AbilityId.VITAL_SPIRIT, status: StatusEffect.SLEEP },
{ name: "Insomnia", ability: AbilityId.INSOMNIA, status: StatusEffect.SLEEP },
{ name: "Immunity", ability: AbilityId.IMMUNITY, status: StatusEffect.POISON },
{ name: "Magma Armor", ability: AbilityId.MAGMA_ARMOR, status: StatusEffect.FREEZE },
{ name: "Limber", ability: AbilityId.LIMBER, status: StatusEffect.PARALYSIS },
{ name: "Thermal Exchange", ability: AbilityId.THERMAL_EXCHANGE, status: StatusEffect.BURN },
{ name: "Water Veil", ability: AbilityId.WATER_VEIL, status: StatusEffect.BURN },
{ name: "Water Bubble", ability: AbilityId.WATER_BUBBLE, status: StatusEffect.BURN },
])("Abilities - $name", ({ ability, status }) => {
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
.battleStyle("single")
.criticalHits(false)
.enemyLevel(100)
.enemySpecies(SpeciesId.MAGIKARP)
.enemyAbility(ability)
.enemyMoveset(MoveId.SPLASH);
// Mock Lumina Crash and Spore to be our status-inflicting moves of choice
vi.spyOn(allMoves[MoveId.LUMINA_CRASH], "attrs", "get").mockReturnValue([new StatusEffectAttr(status, false)]);
vi.spyOn(allMoves[MoveId.SPORE], "attrs", "get").mockReturnValue([new StatusEffectAttr(status, false)]);
});
const statusStr = toTitleCase(StatusEffect[status]);
it(`should prevent application of ${statusStr} without failing damaging moves`, async () => {
await game.classicMode.startBattle([SpeciesId.FEEBAS]);
const karp = game.field.getEnemyPokemon();
expect(karp.status?.effect).toBeUndefined();
expect(karp.canSetStatus(status)).toBe(false);
game.move.use(MoveId.LUMINA_CRASH);
await game.toEndOfTurn();
expect(karp.status?.effect).toBeUndefined();
expect(game.field.getPlayerPokemon().getLastXMoves()[0].result).toBe(MoveResult.SUCCESS);
});
it(`should cure ${statusStr} upon being gained`, async () => {
await game.classicMode.startBattle([SpeciesId.FEEBAS]);
const feebas = game.field.getPlayerPokemon();
feebas.doSetStatus(status);
expect(feebas.status?.effect).toBe(status);
game.move.use(MoveId.SPLASH);
await game.move.forceEnemyMove(MoveId.SKILL_SWAP);
await game.toEndOfTurn();
expect(feebas.status?.effect).toBeUndefined();
});
// TODO: This does not propagate failures currently
it.todo(
`should cause status moves inflicting ${statusStr} to count as failed if no other effects can be applied`,
async () => {
await game.classicMode.startBattle([SpeciesId.FEEBAS]);
game.move.use(MoveId.SPORE);
await game.toEndOfTurn();
const karp = game.field.getEnemyPokemon();
expect(karp.status?.effect).toBeUndefined();
expect(game.field.getPlayerPokemon().getLastXMoves()[0].result).toBe(MoveResult.FAIL);
},
);
});