2024-09-15 13:06:22 -04:00
|
|
|
import { allMoves } from "#app/data/move";
|
|
|
|
import { Abilities } from "#enums/abilities";
|
|
|
|
import { Moves } from "#enums/moves";
|
|
|
|
import { Species } from "#enums/species";
|
|
|
|
import GameManager from "#test/utils/gameManager";
|
|
|
|
import Phaser from "phaser";
|
|
|
|
import { afterEach, beforeAll, beforeEach, describe, expect, it, vi } from "vitest";
|
|
|
|
|
|
|
|
describe("Arena - Grassy Terrain", () => {
|
|
|
|
let phaserGame: Phaser.Game;
|
|
|
|
let game: GameManager;
|
|
|
|
const TIMEOUT = 20 * 1000;
|
|
|
|
|
|
|
|
beforeAll(() => {
|
|
|
|
phaserGame = new Phaser.Game({
|
|
|
|
type: Phaser.HEADLESS,
|
|
|
|
});
|
|
|
|
});
|
|
|
|
|
|
|
|
afterEach(() => {
|
|
|
|
game.phaseInterceptor.restoreOg();
|
|
|
|
});
|
|
|
|
|
|
|
|
beforeEach(() => {
|
|
|
|
game = new GameManager(phaserGame);
|
|
|
|
game.override
|
|
|
|
.battleType("single")
|
|
|
|
.disableCrits()
|
2024-09-16 10:58:28 -04:00
|
|
|
.enemyLevel(1)
|
|
|
|
.enemySpecies(Species.SHUCKLE)
|
|
|
|
.enemyAbility(Abilities.STURDY)
|
|
|
|
.enemyMoveset(Moves.FLY)
|
2024-09-15 13:06:22 -04:00
|
|
|
.moveset([Moves.GRASSY_TERRAIN, Moves.EARTHQUAKE])
|
2024-09-16 10:58:28 -04:00
|
|
|
.ability(Abilities.NO_GUARD);
|
2024-09-15 13:06:22 -04:00
|
|
|
});
|
|
|
|
|
|
|
|
it("halves the damage of Earthquake", async () => {
|
2024-09-16 10:58:28 -04:00
|
|
|
await game.classicMode.startBattle([Species.TAUROS]);
|
2024-09-15 13:06:22 -04:00
|
|
|
|
|
|
|
const eq = allMoves[Moves.EARTHQUAKE];
|
|
|
|
vi.spyOn(eq, "calculateBattlePower");
|
|
|
|
|
|
|
|
game.move.select(Moves.EARTHQUAKE);
|
|
|
|
await game.toNextTurn();
|
|
|
|
|
|
|
|
expect(eq.calculateBattlePower).toHaveReturnedWith(100);
|
|
|
|
|
|
|
|
game.move.select(Moves.GRASSY_TERRAIN);
|
|
|
|
await game.toNextTurn();
|
|
|
|
|
|
|
|
game.move.select(Moves.EARTHQUAKE);
|
|
|
|
await game.phaseInterceptor.to("BerryPhase");
|
|
|
|
|
|
|
|
expect(eq.calculateBattlePower).toHaveReturnedWith(50);
|
|
|
|
}, TIMEOUT);
|
2024-09-16 10:58:28 -04:00
|
|
|
|
|
|
|
it("Does not halve the damage of Earthquake if opponent is not grounded", async () => {
|
|
|
|
await game.classicMode.startBattle([Species.NINJASK]);
|
|
|
|
|
|
|
|
const eq = allMoves[Moves.EARTHQUAKE];
|
|
|
|
vi.spyOn(eq, "calculateBattlePower");
|
|
|
|
|
|
|
|
game.move.select(Moves.GRASSY_TERRAIN);
|
|
|
|
await game.toNextTurn();
|
|
|
|
|
|
|
|
game.move.select(Moves.EARTHQUAKE);
|
|
|
|
await game.phaseInterceptor.to("BerryPhase");
|
|
|
|
|
|
|
|
expect(eq.calculateBattlePower).toHaveReturnedWith(100);
|
|
|
|
}, TIMEOUT);
|
2024-09-15 13:06:22 -04:00
|
|
|
});
|