pokerogue/src/test/moves/make_it_rain.test.ts

106 lines
3.5 KiB
TypeScript
Raw Normal View History

2024-07-25 16:10:38 -07:00
import { BattleStat } from "#app/data/battle-stat.js";
import {
CommandPhase,
MoveEndPhase,
StatChangePhase,
} from "#app/phases";
2024-07-25 16:10:38 -07:00
import GameManager from "#app/test/utils/gameManager";
import { getMovePosition } from "#app/test/utils/gameManagerUtils";
import { Abilities } from "#enums/abilities";
2024-07-25 16:10:38 -07:00
import { Moves } from "#enums/moves";
import { Species } from "#enums/species";
import Phaser from "phaser";
import { afterEach, beforeAll, beforeEach, describe, expect, it } from "vitest";
2024-07-25 15:18:14 -07:00
import { SPLASH_ONLY } from "../utils/testUtils";
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);
2024-07-25 14:48:48 -07:00
game.override.battleType("double");
2024-07-25 15:51:05 -07:00
game.override.moveset([Moves.MAKE_IT_RAIN, Moves.SPLASH]);
2024-07-25 14:57:47 -07:00
game.override.enemySpecies(Species.SNORLAX);
2024-07-25 15:05:32 -07:00
game.override.enemyAbility(Abilities.INSOMNIA);
2024-07-25 15:18:14 -07:00
game.override.enemyMoveset(SPLASH_ONLY);
2024-07-25 15:29:19 -07:00
game.override.startingLevel(100);
2024-07-25 16:10:38 -07:00
game.override.enemyLevel(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 () => {
2024-07-25 16:10:38 -07:00
game.override.enemyLevel(1); // ensures the enemy will faint
2024-07-25 14:48:48 -07:00
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 () => {
2024-07-25 16:10:38 -07:00
game.override.enemyLevel(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);
});