pokerogue/test/moves/spotlight.test.ts

75 lines
2.3 KiB
TypeScript
Raw Permalink Normal View History

import { BattlerIndex } from "#app/battle";
import { TurnEndPhase } from "#app/phases/turn-end-phase";
import { Moves } from "#enums/moves";
import { Species } from "#enums/species";
import GameManager from "#test/testUtils/gameManager";
2024-07-25 16:10:38 -07:00
import Phaser from "phaser";
import { afterEach, beforeAll, beforeEach, describe, expect, test } from "vitest";
describe("Moves - Spotlight", () => {
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:24:07 -07:00
game.override.starterSpecies(Species.AMOONGUSS);
2024-07-25 14:57:47 -07:00
game.override.enemySpecies(Species.SNORLAX);
2024-07-25 15:29:19 -07:00
game.override.startingLevel(100);
2024-07-25 16:10:38 -07:00
game.override.enemyLevel(100);
2024-10-04 13:08:31 +08:00
game.override.moveset([ Moves.FOLLOW_ME, Moves.RAGE_POWDER, Moves.SPOTLIGHT, Moves.QUICK_ATTACK ]);
game.override.enemyMoveset([ Moves.FOLLOW_ME, Moves.SPLASH ]);
});
test(
"move should redirect attacks to the target",
async () => {
2024-10-04 13:08:31 +08:00
await game.classicMode.startBattle([ Species.AMOONGUSS, Species.CHARIZARD ]);
const enemyPokemon = game.scene.getEnemyField();
game.move.select(Moves.SPOTLIGHT, 0, BattlerIndex.ENEMY);
game.move.select(Moves.QUICK_ATTACK, 1, BattlerIndex.ENEMY_2);
await game.forceEnemyMove(Moves.SPLASH);
await game.forceEnemyMove(Moves.SPLASH);
await game.phaseInterceptor.to(TurnEndPhase, false);
expect(enemyPokemon[0].hp).toBeLessThan(enemyPokemon[0].getMaxHp());
expect(enemyPokemon[1].hp).toBe(enemyPokemon[1].getMaxHp());
}
);
test(
"move should cause other redirection moves to fail",
async () => {
2024-10-04 13:08:31 +08:00
await game.classicMode.startBattle([ Species.AMOONGUSS, Species.CHARIZARD ]);
const enemyPokemon = game.scene.getEnemyField();
game.move.select(Moves.SPOTLIGHT, 0, BattlerIndex.ENEMY);
game.move.select(Moves.QUICK_ATTACK, 1, BattlerIndex.ENEMY_2);
await game.forceEnemyMove(Moves.SPLASH);
await game.forceEnemyMove(Moves.FOLLOW_ME);
await game.phaseInterceptor.to("BerryPhase", false);
expect(enemyPokemon[0].hp).toBeLessThan(enemyPokemon[0].getMaxHp());
expect(enemyPokemon[1].hp).toBe(enemyPokemon[1].getMaxHp());
}
);
});