2024-09-02 22:12:34 -04:00
|
|
|
import { BATTLE_STATS, EFFECTIVE_STATS } from "#enums/stat";
|
2024-08-22 16:57:38 -04:00
|
|
|
import { Abilities } from "#enums/abilities";
|
|
|
|
import { Moves } from "#enums/moves";
|
|
|
|
import { Species } from "#enums/species";
|
2025-02-22 22:52:07 -06:00
|
|
|
import GameManager from "#test/testUtils/gameManager";
|
2024-08-22 16:57:38 -04:00
|
|
|
import Phaser from "phaser";
|
2024-09-02 22:12:34 -04:00
|
|
|
import { afterEach, beforeAll, beforeEach, describe, expect, it, vi } from "vitest";
|
2024-08-22 16:57:38 -04:00
|
|
|
|
|
|
|
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
|
|
|
|
.battleType("single")
|
|
|
|
.enemySpecies(Species.RATTATA)
|
|
|
|
.enemyAbility(Abilities.BALL_FETCH)
|
|
|
|
.ability(Abilities.MOODY)
|
2024-09-09 09:55:11 -07:00
|
|
|
.enemyMoveset(Moves.SPLASH)
|
|
|
|
.moveset(Moves.SPLASH);
|
2024-08-22 16:57:38 -04:00
|
|
|
});
|
|
|
|
|
2024-09-02 22:12:34 -04:00
|
|
|
it("should increase one stat stage by 2 and decrease a different stat stage by 1",
|
2024-08-22 16:57:38 -04:00
|
|
|
async () => {
|
2024-09-02 22:12:34 -04:00
|
|
|
await game.classicMode.startBattle();
|
2024-08-22 16:57:38 -04:00
|
|
|
|
|
|
|
const playerPokemon = game.scene.getPlayerPokemon()!;
|
|
|
|
game.move.select(Moves.SPLASH);
|
|
|
|
await game.toNextTurn();
|
|
|
|
|
|
|
|
// Find the increased and decreased stats, make sure they are different.
|
2024-09-02 22:12:34 -04:00
|
|
|
const changedStats = EFFECTIVE_STATS.filter(s => playerPokemon.getStatStage(s) === 2 || playerPokemon.getStatStage(s) === -1);
|
2024-08-22 16:57:38 -04:00
|
|
|
|
|
|
|
expect(changedStats).toBeTruthy();
|
|
|
|
expect(changedStats.length).toBe(2);
|
|
|
|
expect(changedStats[0] !== changedStats[1]).toBeTruthy();
|
|
|
|
});
|
|
|
|
|
2024-09-02 22:12:34 -04:00
|
|
|
it("should only increase one stat stage by 2 if all stat stages are at -6",
|
2024-08-22 16:57:38 -04:00
|
|
|
async () => {
|
2024-09-02 22:12:34 -04:00
|
|
|
await game.classicMode.startBattle();
|
2024-08-22 16:57:38 -04:00
|
|
|
|
|
|
|
const playerPokemon = game.scene.getPlayerPokemon()!;
|
2024-09-02 22:12:34 -04:00
|
|
|
|
|
|
|
// Set all stat stages to -6
|
|
|
|
vi.spyOn(playerPokemon.summonData, "statStages", "get").mockReturnValue(new Array(BATTLE_STATS.length).fill(-6));
|
2024-08-22 16:57:38 -04:00
|
|
|
|
|
|
|
game.move.select(Moves.SPLASH);
|
|
|
|
await game.toNextTurn();
|
|
|
|
|
2024-09-02 22:12:34 -04:00
|
|
|
// Should increase one stat stage by 2 (from -6, meaning it will be -4)
|
|
|
|
const increasedStat = EFFECTIVE_STATS.filter(s => playerPokemon.getStatStage(s) === -4);
|
2024-08-22 16:57:38 -04:00
|
|
|
|
|
|
|
expect(increasedStat).toBeTruthy();
|
|
|
|
expect(increasedStat.length).toBe(1);
|
|
|
|
});
|
|
|
|
|
2024-09-02 22:12:34 -04:00
|
|
|
it("should only decrease one stat stage by 1 stage if all stat stages are at 6",
|
2024-08-22 16:57:38 -04:00
|
|
|
async () => {
|
2024-09-02 22:12:34 -04:00
|
|
|
await game.classicMode.startBattle();
|
2024-08-22 16:57:38 -04:00
|
|
|
|
|
|
|
const playerPokemon = game.scene.getPlayerPokemon()!;
|
2024-09-02 22:12:34 -04:00
|
|
|
|
|
|
|
// Set all stat stages to 6
|
|
|
|
vi.spyOn(playerPokemon.summonData, "statStages", "get").mockReturnValue(new Array(BATTLE_STATS.length).fill(6));
|
2024-08-22 16:57:38 -04:00
|
|
|
|
|
|
|
game.move.select(Moves.SPLASH);
|
|
|
|
await game.toNextTurn();
|
|
|
|
|
2024-09-02 22:12:34 -04:00
|
|
|
// Should decrease one stat stage by 1 (from 6, meaning it will be 5)
|
|
|
|
const decreasedStat = EFFECTIVE_STATS.filter(s => playerPokemon.getStatStage(s) === 5);
|
|
|
|
|
2024-08-22 16:57:38 -04:00
|
|
|
expect(decreasedStat).toBeTruthy();
|
|
|
|
expect(decreasedStat.length).toBe(1);
|
|
|
|
});
|
|
|
|
});
|