mirror of
https://github.com/pagefaultgames/pokerogue.git
synced 2025-03-05 01:18:15 +00:00
106 lines
3.8 KiB
TypeScript
106 lines
3.8 KiB
TypeScript
import { afterEach, beforeAll, beforeEach, describe, expect, it, vi } from "vitest";
|
|
import Phaser from "phaser";
|
|
import GameManager from "#app/test/utils/gameManager";
|
|
import Overrides from "#app/overrides";
|
|
import { Species } from "#enums/species";
|
|
import {
|
|
CommandPhase,
|
|
MoveEndPhase,
|
|
StatChangePhase,
|
|
} from "#app/phases";
|
|
import { Moves } from "#enums/moves";
|
|
import { getMovePosition } from "#app/test/utils/gameManagerUtils";
|
|
import { Abilities } from "#enums/abilities";
|
|
import { BattleStat } from "#app/data/battle-stat.js";
|
|
|
|
const TIMEOUT = 20 * 1000;
|
|
|
|
describe("Moves - Make It Rain", () => {
|
|
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("double");
|
|
vi.spyOn(Overrides, "MOVESET_OVERRIDE", "get").mockReturnValue([Moves.MAKE_IT_RAIN, Moves.SPLASH]);
|
|
vi.spyOn(Overrides, "OPP_SPECIES_OVERRIDE", "get").mockReturnValue(Species.SNORLAX);
|
|
vi.spyOn(Overrides, "OPP_ABILITY_OVERRIDE", "get").mockReturnValue(Abilities.INSOMNIA);
|
|
vi.spyOn(Overrides, "OPP_MOVESET_OVERRIDE", "get").mockReturnValue([Moves.SPLASH, Moves.SPLASH, Moves.SPLASH, Moves.SPLASH]);
|
|
vi.spyOn(Overrides, "STARTING_LEVEL_OVERRIDE", "get").mockReturnValue(100);
|
|
vi.spyOn(Overrides, "OPP_LEVEL_OVERRIDE", "get").mockReturnValue(100);
|
|
});
|
|
|
|
it("should only reduce Sp. Atk. once in a double battle", async () => {
|
|
await game.startBattle([Species.CHARIZARD, Species.BLASTOISE]);
|
|
|
|
const playerPokemon = game.scene.getPlayerField();
|
|
expect(playerPokemon.length).toBe(2);
|
|
playerPokemon.forEach(p => expect(p).toBeDefined());
|
|
|
|
const enemyPokemon = game.scene.getEnemyField();
|
|
expect(enemyPokemon.length).toBe(2);
|
|
enemyPokemon.forEach(p => expect(p).toBeDefined());
|
|
|
|
game.doAttack(getMovePosition(game.scene, 0, Moves.MAKE_IT_RAIN));
|
|
|
|
await game.phaseInterceptor.to(CommandPhase);
|
|
game.doAttack(getMovePosition(game.scene, 1, Moves.SPLASH));
|
|
|
|
await game.phaseInterceptor.to(MoveEndPhase);
|
|
|
|
expect(playerPokemon[0].summonData.battleStats[BattleStat.SPATK]).toBe(-1);
|
|
}, TIMEOUT);
|
|
|
|
it("should apply effects even if the target faints", async () => {
|
|
vi.spyOn(Overrides, "OPP_LEVEL_OVERRIDE", "get").mockReturnValue(1); // ensures the enemy will faint
|
|
game.override.battleType("single");
|
|
|
|
await game.startBattle([Species.CHARIZARD]);
|
|
|
|
const playerPokemon = game.scene.getPlayerPokemon();
|
|
expect(playerPokemon).toBeDefined();
|
|
|
|
const enemyPokemon = game.scene.getEnemyPokemon();
|
|
expect(enemyPokemon).toBeDefined();
|
|
|
|
game.doAttack(getMovePosition(game.scene, 0, Moves.MAKE_IT_RAIN));
|
|
|
|
await game.phaseInterceptor.to(StatChangePhase);
|
|
|
|
expect(enemyPokemon.isFainted()).toBe(true);
|
|
expect(playerPokemon.summonData.battleStats[BattleStat.SPATK]).toBe(-1);
|
|
}, TIMEOUT);
|
|
|
|
it("should reduce Sp. Atk. once after KOing two enemies", async () => {
|
|
vi.spyOn(Overrides, "OPP_LEVEL_OVERRIDE", "get").mockReturnValue(1); // ensures the enemy will faint
|
|
|
|
await game.startBattle([Species.CHARIZARD, Species.BLASTOISE]);
|
|
|
|
const playerPokemon = game.scene.getPlayerField();
|
|
playerPokemon.forEach(p => expect(p).toBeDefined());
|
|
|
|
const enemyPokemon = game.scene.getEnemyField();
|
|
enemyPokemon.forEach(p => expect(p).toBeDefined());
|
|
|
|
game.doAttack(getMovePosition(game.scene, 0, Moves.MAKE_IT_RAIN));
|
|
|
|
await game.phaseInterceptor.to(CommandPhase);
|
|
game.doAttack(getMovePosition(game.scene, 1, Moves.SPLASH));
|
|
|
|
await game.phaseInterceptor.to(StatChangePhase);
|
|
|
|
enemyPokemon.forEach(p => expect(p.isFainted()).toBe(true));
|
|
expect(playerPokemon[0].summonData.battleStats[BattleStat.SPATK]).toBe(-1);
|
|
}, TIMEOUT);
|
|
});
|