pokerogue/test/moves/ceaseless_edge.test.ts

108 lines
4.4 KiB
TypeScript
Raw Normal View History

2024-07-25 16:43:48 -07:00
import { ArenaTagSide, ArenaTrapTag } from "#app/data/arena-tag";
import { allMoves } from "#app/data/moves/move";
2024-07-25 16:43:48 -07:00
import { Abilities } from "#app/enums/abilities";
import { ArenaTagType } from "#app/enums/arena-tag-type";
import { MoveEffectPhase } from "#app/phases/move-effect-phase";
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:43:48 -07:00
import Phaser from "phaser";
import { afterEach, beforeAll, beforeEach, describe, expect, test, vi } from "vitest";
describe("Moves - Ceaseless Edge", () => {
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("single");
2024-07-25 14:57:47 -07:00
game.override.enemySpecies(Species.RATTATA);
2024-07-25 15:05:32 -07:00
game.override.enemyAbility(Abilities.RUN_AWAY);
game.override.enemyPassiveAbility(Abilities.RUN_AWAY);
2024-07-25 15:29:19 -07:00
game.override.startingLevel(100);
2024-07-25 16:10:38 -07:00
game.override.enemyLevel(100);
game.override.moveset([Moves.CEASELESS_EDGE, Moves.SPLASH, Moves.ROAR]);
game.override.enemyMoveset(Moves.SPLASH);
vi.spyOn(allMoves[Moves.CEASELESS_EDGE], "accuracy", "get").mockReturnValue(100);
});
test("move should hit and apply spikes", async () => {
await game.classicMode.startBattle([Species.ILLUMISE]);
const enemyPokemon = game.scene.getEnemyPokemon()!;
const enemyStartingHp = enemyPokemon.hp;
game.move.select(Moves.CEASELESS_EDGE);
await game.phaseInterceptor.to(MoveEffectPhase, false);
// Spikes should not have any layers before move effect is applied
const tagBefore = game.scene.arena.getTagOnSide(ArenaTagType.SPIKES, ArenaTagSide.ENEMY) as ArenaTrapTag;
expect(tagBefore instanceof ArenaTrapTag).toBeFalsy();
await game.phaseInterceptor.to(TurnEndPhase);
const tagAfter = game.scene.arena.getTagOnSide(ArenaTagType.SPIKES, ArenaTagSide.ENEMY) as ArenaTrapTag;
expect(tagAfter instanceof ArenaTrapTag).toBeTruthy();
expect(tagAfter.layers).toBe(1);
expect(enemyPokemon.hp).toBeLessThan(enemyStartingHp);
});
test("move should hit twice with multi lens and apply two layers of spikes", async () => {
game.override.startingHeldItems([{ name: "MULTI_LENS" }]);
await game.classicMode.startBattle([Species.ILLUMISE]);
const enemyPokemon = game.scene.getEnemyPokemon()!;
const enemyStartingHp = enemyPokemon.hp;
game.move.select(Moves.CEASELESS_EDGE);
await game.phaseInterceptor.to(MoveEffectPhase, false);
// Spikes should not have any layers before move effect is applied
const tagBefore = game.scene.arena.getTagOnSide(ArenaTagType.SPIKES, ArenaTagSide.ENEMY) as ArenaTrapTag;
expect(tagBefore instanceof ArenaTrapTag).toBeFalsy();
await game.phaseInterceptor.to(TurnEndPhase);
const tagAfter = game.scene.arena.getTagOnSide(ArenaTagType.SPIKES, ArenaTagSide.ENEMY) as ArenaTrapTag;
expect(tagAfter instanceof ArenaTrapTag).toBeTruthy();
expect(tagAfter.layers).toBe(2);
expect(enemyPokemon.hp).toBeLessThan(enemyStartingHp);
});
test("trainer - move should hit twice, apply two layers of spikes, force switch opponent - opponent takes damage", async () => {
game.override.startingHeldItems([{ name: "MULTI_LENS" }]);
game.override.startingWave(25);
await game.classicMode.startBattle([Species.ILLUMISE]);
game.move.select(Moves.CEASELESS_EDGE);
await game.phaseInterceptor.to(MoveEffectPhase, false);
// Spikes should not have any layers before move effect is applied
const tagBefore = game.scene.arena.getTagOnSide(ArenaTagType.SPIKES, ArenaTagSide.ENEMY) as ArenaTrapTag;
expect(tagBefore instanceof ArenaTrapTag).toBeFalsy();
await game.toNextTurn();
const tagAfter = game.scene.arena.getTagOnSide(ArenaTagType.SPIKES, ArenaTagSide.ENEMY) as ArenaTrapTag;
expect(tagAfter instanceof ArenaTrapTag).toBeTruthy();
expect(tagAfter.layers).toBe(2);
const hpBeforeSpikes = game.scene.currentBattle.enemyParty[1].hp;
// Check HP of pokemon that WILL BE switched in (index 1)
game.forceEnemyToSwitch();
game.move.select(Moves.SPLASH);
await game.phaseInterceptor.to(TurnEndPhase, false);
expect(game.scene.currentBattle.enemyParty[0].hp).toBeLessThan(hpBeforeSpikes);
});
});