2025-01-12 15:33:05 -08:00
|
|
|
import type { EnemyPokemon } from "#app/field/pokemon";
|
2024-11-25 14:15:39 -08:00
|
|
|
import { DamageAnimPhase } from "#app/phases/damage-anim-phase";
|
2024-08-22 06:49:33 -07:00
|
|
|
import { MoveEndPhase } from "#app/phases/move-end-phase";
|
2024-06-17 21:39:59 -06:00
|
|
|
import { Abilities } from "#enums/abilities";
|
|
|
|
import { Moves } from "#enums/moves";
|
|
|
|
import { Species } from "#enums/species";
|
2025-02-22 22:52:07 -06:00
|
|
|
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";
|
2024-06-17 21:39:59 -06:00
|
|
|
|
|
|
|
describe("Abilities - Sturdy", () => {
|
|
|
|
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-06-17 21:39:59 -06:00
|
|
|
|
2024-07-25 15:24:07 -07:00
|
|
|
game.override.starterSpecies(Species.LUCARIO);
|
2024-07-25 15:29:19 -07:00
|
|
|
game.override.startingLevel(100);
|
2025-03-09 16:13:25 -05:00
|
|
|
game.override.moveset([Moves.CLOSE_COMBAT, Moves.FISSURE]);
|
2024-06-17 21:39:59 -06:00
|
|
|
|
2024-07-25 14:57:47 -07:00
|
|
|
game.override.enemySpecies(Species.ARON);
|
2024-07-25 16:10:38 -07:00
|
|
|
game.override.enemyLevel(5);
|
2024-07-25 15:05:32 -07:00
|
|
|
game.override.enemyAbility(Abilities.STURDY);
|
2024-06-17 21:39:59 -06:00
|
|
|
});
|
|
|
|
|
2025-03-09 16:13:25 -05:00
|
|
|
test("Sturdy activates when user is at full HP", async () => {
|
|
|
|
await game.startBattle();
|
|
|
|
game.move.select(Moves.CLOSE_COMBAT);
|
|
|
|
await game.phaseInterceptor.to(MoveEndPhase);
|
|
|
|
expect(game.scene.getEnemyParty()[0].hp).toBe(1);
|
|
|
|
});
|
|
|
|
|
|
|
|
test("Sturdy doesn't activate when user is not at full HP", async () => {
|
|
|
|
await game.startBattle();
|
|
|
|
|
|
|
|
const enemyPokemon: EnemyPokemon = game.scene.getEnemyParty()[0];
|
|
|
|
enemyPokemon.hp = enemyPokemon.getMaxHp() - 1;
|
|
|
|
|
|
|
|
game.move.select(Moves.CLOSE_COMBAT);
|
|
|
|
await game.phaseInterceptor.to(DamageAnimPhase);
|
|
|
|
|
|
|
|
expect(enemyPokemon.hp).toBe(0);
|
|
|
|
expect(enemyPokemon.isFainted()).toBe(true);
|
|
|
|
});
|
2024-06-17 21:39:59 -06:00
|
|
|
|
2025-03-09 16:13:25 -05:00
|
|
|
test("Sturdy pokemon should be immune to OHKO moves", async () => {
|
|
|
|
await game.startBattle();
|
|
|
|
game.move.select(Moves.FISSURE);
|
|
|
|
await game.phaseInterceptor.to(MoveEndPhase);
|
|
|
|
|
|
|
|
const enemyPokemon: EnemyPokemon = game.scene.getEnemyParty()[0];
|
|
|
|
expect(enemyPokemon.isFullHp()).toBe(true);
|
|
|
|
});
|
|
|
|
|
|
|
|
test("Sturdy is ignored by pokemon with `Abilities.MOLD_BREAKER`", async () => {
|
|
|
|
game.override.ability(Abilities.MOLD_BREAKER);
|
|
|
|
|
|
|
|
await game.startBattle();
|
|
|
|
game.move.select(Moves.CLOSE_COMBAT);
|
|
|
|
await game.phaseInterceptor.to(DamageAnimPhase);
|
|
|
|
|
|
|
|
const enemyPokemon: EnemyPokemon = game.scene.getEnemyParty()[0];
|
|
|
|
expect(enemyPokemon.hp).toBe(0);
|
|
|
|
expect(enemyPokemon.isFainted()).toBe(true);
|
|
|
|
});
|
2024-06-17 21:39:59 -06:00
|
|
|
});
|