pokerogue/src/test/abilities/costar.test.ts

91 lines
3.1 KiB
TypeScript
Raw Normal View History

import { BattleStat } from "#app/data/battle-stat.js";
import { Abilities } from "#app/enums/abilities.js";
import { Moves } from "#app/enums/moves.js";
import { Species } from "#app/enums/species.js";
2024-07-25 15:51:05 -07:00
import Phaser from "phaser";
import { afterEach, beforeAll, beforeEach, describe, expect, test } from "vitest";
import GameManager from "#test/utils/gameManager";
import { getMovePosition } from "#test/utils/gameManagerUtils";
import { SPLASH_ONLY } from "#test/utils/testUtils";
2024-08-19 03:23:52 +01:00
import { CommandPhase } from "#app/phases/command-phase.js";
import { MessagePhase } from "#app/phases/message-phase.js";
const TIMEOUT = 20 * 1000;
describe("Abilities - COSTAR", () => {
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:35:20 -07:00
game.override.ability(Abilities.COSTAR);
2024-07-25 15:51:05 -07:00
game.override.moveset([Moves.SPLASH, Moves.NASTY_PLOT]);
2024-07-25 15:18:14 -07:00
game.override.enemyMoveset(SPLASH_ONLY);
});
test(
"ability copies positive stat changes",
async () => {
2024-07-25 15:05:32 -07:00
game.override.enemyAbility(Abilities.BALL_FETCH);
await game.startBattle([Species.MAGIKARP, Species.MAGIKARP, Species.FLAMIGO]);
let [leftPokemon, rightPokemon] = game.scene.getPlayerField();
game.doAttack(getMovePosition(game.scene, 0, Moves.NASTY_PLOT));
await game.phaseInterceptor.to(CommandPhase);
game.doAttack(getMovePosition(game.scene, 1, Moves.SPLASH));
await game.toNextTurn();
expect(leftPokemon.summonData.battleStats[BattleStat.SPATK]).toBe(+2);
expect(rightPokemon.summonData.battleStats[BattleStat.SPATK]).toBe(0);
game.doAttack(getMovePosition(game.scene, 0, Moves.SPLASH));
await game.phaseInterceptor.to(CommandPhase);
game.doSwitchPokemon(2);
await game.phaseInterceptor.to(MessagePhase);
[leftPokemon, rightPokemon] = game.scene.getPlayerField();
expect(leftPokemon.summonData.battleStats[BattleStat.SPATK]).toBe(+2);
expect(rightPokemon.summonData.battleStats[BattleStat.SPATK]).toBe(+2);
},
TIMEOUT,
);
test(
"ability copies negative stat changes",
async () => {
2024-07-25 15:05:32 -07:00
game.override.enemyAbility(Abilities.INTIMIDATE);
await game.startBattle([Species.MAGIKARP, Species.MAGIKARP, Species.FLAMIGO]);
let [leftPokemon, rightPokemon] = game.scene.getPlayerField();
expect(leftPokemon.summonData.battleStats[BattleStat.ATK]).toBe(-2);
expect(leftPokemon.summonData.battleStats[BattleStat.ATK]).toBe(-2);
game.doAttack(getMovePosition(game.scene, 0, Moves.SPLASH));
await game.phaseInterceptor.to(CommandPhase);
game.doSwitchPokemon(2);
await game.phaseInterceptor.to(MessagePhase);
[leftPokemon, rightPokemon] = game.scene.getPlayerField();
expect(leftPokemon.summonData.battleStats[BattleStat.ATK]).toBe(-2);
expect(rightPokemon.summonData.battleStats[BattleStat.ATK]).toBe(-2);
},
TIMEOUT,
);
});