mirror of
https://github.com/pagefaultgames/pokerogue.git
synced 2025-12-15 14:25:32 +01:00
* Add failure conditions and move failures part 1 * Add second and third failure sequences * Refactor mostly complete, need to recheck tests * Adjust status checks to respect ignoreStatus useModes * Adjust restriction for stuff cheeks * Address bertie's review comments * Add counterRedirectAttr to other counter-like moves * Adjust some documentation for new methods * Make substitute use the move tag * Adjust counter attr to use array.find * Adjust move condition check that occurs in the third failure check sequence * Insert move failure check sequence part 4 into move phase * Revert type adjustment to getBattlerIndex * Make charging moves deduct pp on use instead of on release * Fix first move condition not using 1 based starting wave * Tweak charge move handling and protean timing * Adjust fly tests to expect pp reduction properly * Add missing attribute to counter * Adjust revival blessing hardcore test to respect new return value of isUsable * Adjust copycat test to account for how it actually works * Play sleep animation and message * Remove BYPASS_SLEEP battler tag in favor of boolean holder * Finish unfinished docs * Ensure move restrictions are only checked for players * Adjust pollen puff condition, fix docs on `isOpponent` * Fix failAgainstFinalBossCondition * Fix dig test * Adjust dive's test * Fix missing break in applyConditions * Fix getBattlerIndex for enemyPokemon * Adjust type hint test to not rely on teleport * Minor adjustments from code review Co-authored-by: Bertie690 <136088738+Bertie690@users.noreply.github.com> * Add tests for teleport * Minor adjustments from code review Co-authored-by: Bertie690 <136088738+Bertie690@users.noreply.github.com> * PR review changes Fix type hints test name Update Dig/Dive test name Separate TSDoc imports in `pokemon-utils.ts` Add missing `@returns` in `move-phase.ts` Fix comment typos Separate TSDoc imports in `move-phase.ts` Add return hints to `trySelectMove` Minor formatting Remove duplicate `.affectedByGravity()` on Telekinesis Fix docs for `checkRestrictions` Manually format method definition Fix comment spacing Fix variable naming * Address kev's review comments Co-authored-by: NightKev <34855794+DayKev@users.noreply.github.com> * Minor adjustments from code review Co-authored-by: Bertie690 <136088738+Bertie690@users.noreply.github.com> * Remove optional chaining * fix: type for InferKeys * chore: apply biome * chore: fix merge conflicts from Biome update * Remove latent isNullOrUndefined * Drop readonly on timingModifier * docs: Add class comment * Address comments from code review * Drop readonly from timingModifier * Cleanup proc chance computation * Move `cureStatus` into the Pokemon class * Final touchups --------- Co-authored-by: Bertie690 <136088738+Bertie690@users.noreply.github.com> Co-authored-by: NightKev <34855794+DayKev@users.noreply.github.com>
113 lines
3.9 KiB
TypeScript
113 lines
3.9 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();
|
|
expect(game.field.getPlayerPokemon().getStatStage(Stat.ATK));
|
|
});
|
|
|
|
it("should apply secondary effects of a move", async () => {
|
|
game.override.moveset([MoveId.SLEEP_TALK, MoveId.DIG, MoveId.FLY, MoveId.WOOD_HAMMER]); // Dig and Fly are invalid moves, Wood Hammer should always be called
|
|
await game.classicMode.startBattle([SpeciesId.FEEBAS]);
|
|
|
|
game.move.select(MoveId.SLEEP_TALK);
|
|
await game.toNextTurn();
|
|
|
|
expect(game.field.getPlayerPokemon().isFullHp()).toBeFalsy(); // Wood Hammer recoil effect should be applied
|
|
});
|
|
});
|