pokerogue/test/moves/sleep-talk.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

106 lines
3.5 KiB
TypeScript

import { AbilityId } from "#enums/ability-id";
import { MoveId } from "#enums/move-id";
import { MoveResult } from "#enums/move-result";
import { MoveUseMode } from "#enums/move-use-mode";
import { SpeciesId } from "#enums/species-id";
import { Stat } from "#enums/stat";
import { StatusEffect } from "#enums/status-effect";
import { GameManager } from "#test/test-utils/game-manager";
import Phaser from "phaser";
import { afterEach, beforeAll, beforeEach, describe, expect, it } from "vitest";
describe("Moves - Sleep Talk", () => {
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, MoveId.SLEEP_TALK])
.statusEffect(StatusEffect.SLEEP)
.ability(AbilityId.BALL_FETCH)
.battleStyle("single")
.criticalHits(false)
.enemySpecies(SpeciesId.MAGIKARP)
.enemyAbility(AbilityId.NO_GUARD)
.enemyMoveset(MoveId.SPLASH)
.enemyLevel(100);
});
it("should call a random valid move if the user is asleep", async () => {
game.override.moveset([MoveId.SLEEP_TALK, MoveId.DIG, MoveId.FLY, MoveId.SWORDS_DANCE]); // Dig and Fly are invalid moves, Swords Dance should always be called
await game.classicMode.startBattle([SpeciesId.FEEBAS]);
game.move.select(MoveId.SLEEP_TALK);
await game.toNextTurn();
const feebas = game.field.getPlayerPokemon();
expect(feebas.getStatStage(Stat.ATK)).toBe(2);
expect(feebas.getLastXMoves(2)).toEqual([
expect.objectContaining({
move: MoveId.SWORDS_DANCE,
result: MoveResult.SUCCESS,
useMode: MoveUseMode.FOLLOW_UP,
}),
expect.objectContaining({
move: MoveId.SLEEP_TALK,
result: MoveResult.SUCCESS,
useMode: MoveUseMode.NORMAL,
}),
]);
});
it("should fail if the user is not asleep", async () => {
game.override.statusEffect(StatusEffect.POISON);
await game.classicMode.startBattle([SpeciesId.FEEBAS]);
game.move.select(MoveId.SLEEP_TALK);
await game.toNextTurn();
expect(game.field.getPlayerPokemon().getLastXMoves()[0].result).toBe(MoveResult.FAIL);
});
it("should fail the turn the user wakes up from Sleep", async () => {
await game.classicMode.startBattle([SpeciesId.FEEBAS]);
const feebas = game.field.getPlayerPokemon();
expect(feebas.status?.effect).toBe(StatusEffect.SLEEP);
feebas.status!.sleepTurnsRemaining = 1;
game.move.select(MoveId.SLEEP_TALK);
await game.toNextTurn();
expect(feebas).toHaveUsedMove({ result: MoveResult.FAIL });
});
it("should fail if the user has no valid moves", async () => {
game.override.moveset([MoveId.SLEEP_TALK, MoveId.DIG, MoveId.METRONOME, MoveId.SOLAR_BEAM]);
await game.classicMode.startBattle([SpeciesId.FEEBAS]);
game.move.select(MoveId.SLEEP_TALK);
await game.toNextTurn();
expect(game.field.getPlayerPokemon().getLastXMoves()[0].result).toBe(MoveResult.FAIL);
});
it("should apply secondary effects of the called move", async () => {
game.override.moveset([MoveId.SLEEP_TALK, MoveId.SCALE_SHOT]);
await game.classicMode.startBattle([SpeciesId.FEEBAS]);
game.move.select(MoveId.SLEEP_TALK);
await game.toNextTurn();
const feebas = game.field.getPlayerPokemon();
expect(feebas.getStatStage(Stat.SPD)).toBe(1);
expect(feebas.getStatStage(Stat.DEF)).toBe(-1);
});
});