pokerogue/test/abilities/moody.test.ts
Sirz Benjie 8afedc33d7
[Refactor] [Ability] Ab attr apply type safety (#6002)
* [WIP] Refactor ability attribute apply args

* [WIP] update ability signatures

* Update callsites in pokemon.ts

* Update callsites in moves.ts

* Update abattr callsites in move-phase

* Update abattr callsites in battler-tags

Also removed stat drop ability application from cancelling ME stat boost effects

* format with biome and remove cancelled from weather lapse

* Update abattr callsites in MEP

* Update callsites in turn-start-phase

* Update abAttr callsites in misc phases

* Remove latent test functionality

* update ability attribute callsite in shield dust test

* update abattr callsite in winstrate challenge encounter

* Fix some tests to mock proper methods

* Remove improper condition in mimicry's ability application

* Fix improper simulated check in moody's apply method

* Pass source to postApplyDamage in pokemon.ts

* [wip] fix cud chew tests

* Make cud chew consumption not subclass postTurnAbAttr

* Fix regression in flower veil

* Update trySetStatus test in pokemon to respect new return value for undefined

* Remove empty, unused file

* Fix blockCrit method broken in merge

* Fix unnecessary attr type cast in move phase

* Address typing issue in safeguard test

* Improve documentation and get rid of ts-expect-error directive

* Minor comment/TSDoc updates and fixes

* Apply suggestions from code review

Co-authored-by: NightKev <34855794+DayKev@users.noreply.github.com>

* Apply suggestions from code review

---------

Co-authored-by: NightKev <34855794+DayKev@users.noreply.github.com>
2025-06-22 18:23:08 -07:00

88 lines
2.9 KiB
TypeScript

import { BATTLE_STATS, EFFECTIVE_STATS } from "#enums/stat";
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, expect, it, vi } from "vitest";
describe("Abilities - Moody", () => {
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")
.enemySpecies(SpeciesId.RATTATA)
.enemyAbility(AbilityId.BALL_FETCH)
.ability(AbilityId.MOODY)
.enemyMoveset(MoveId.SPLASH)
.moveset(MoveId.SPLASH);
});
it("should increase one stat stage by 2 and decrease a different stat stage by 1", async () => {
await game.classicMode.startBattle();
const playerPokemon = game.scene.getPlayerPokemon()!;
game.move.select(MoveId.SPLASH);
await game.toNextTurn();
// Find the increased and decreased stats, make sure they are different.
const changedStats = EFFECTIVE_STATS.filter(
s => playerPokemon.getStatStage(s) === 2 || playerPokemon.getStatStage(s) === -1,
);
expect(changedStats).toBeTruthy();
expect(changedStats.length).toBe(2);
expect(changedStats[0] !== changedStats[1]).toBeTruthy();
});
it("should only increase one stat stage by 2 if all stat stages are at -6", async () => {
await game.classicMode.startBattle();
const playerPokemon = game.scene.getPlayerPokemon()!;
// Set all stat stages to -6
vi.spyOn(playerPokemon.summonData, "statStages", "get").mockReturnValue(new Array(BATTLE_STATS.length).fill(-6));
game.move.select(MoveId.SPLASH);
await game.toNextTurn();
// Should increase one stat stage by 2 (from -6, meaning it will be -4)
const increasedStat = EFFECTIVE_STATS.filter(s => playerPokemon.getStatStage(s) === -4);
expect(increasedStat).toBeTruthy();
expect(increasedStat.length).toBe(1);
});
it("should only decrease one stat stage by 1 stage if all stat stages are at 6", async () => {
await game.classicMode.startBattle([SpeciesId.MAGIKARP]);
const playerPokemon = game.scene.getPlayerPokemon()!;
// Set all stat stages to 6
vi.spyOn(playerPokemon.summonData, "statStages", "get").mockReturnValue(new Array(BATTLE_STATS.length).fill(6));
game.move.select(MoveId.SPLASH);
await game.toNextTurn();
// Should decrease one stat stage by 1 (from 6, meaning it will be 5)
const decreasedStat = EFFECTIVE_STATS.filter(s => playerPokemon.getStatStage(s) === 5);
expect(decreasedStat).toBeTruthy();
expect(decreasedStat.length).toBe(1);
});
});