2024-06-15 19:14:49 -07:00
|
|
|
import { Abilities } from "#enums/abilities";
|
|
|
|
import { Moves } from "#enums/moves";
|
2024-07-25 16:36:39 -07:00
|
|
|
import { Species } from "#enums/species";
|
|
|
|
import Phaser from "phaser";
|
|
|
|
import { afterEach, beforeAll, beforeEach, describe, expect, test } from "vitest";
|
2024-08-06 07:06:25 -07:00
|
|
|
import GameManager from "#test/utils/gameManager";
|
|
|
|
import { getMovePosition } from "#test/utils/gameManagerUtils";
|
2024-08-19 03:23:52 +01:00
|
|
|
import { TurnEndPhase } from "#app/phases/turn-end-phase.js";
|
2024-06-15 19:14:49 -07:00
|
|
|
|
|
|
|
const TIMEOUT = 20 * 1000;
|
|
|
|
|
|
|
|
describe("Abilities - Unseen Fist", () => {
|
|
|
|
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 15:24:07 -07:00
|
|
|
game.override.starterSpecies(Species.URSHIFU);
|
2024-07-25 14:57:47 -07:00
|
|
|
game.override.enemySpecies(Species.SNORLAX);
|
2024-07-25 15:18:14 -07:00
|
|
|
game.override.enemyMoveset([Moves.PROTECT, Moves.PROTECT, Moves.PROTECT, Moves.PROTECT]);
|
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-06-15 19:14:49 -07:00
|
|
|
});
|
|
|
|
|
|
|
|
test(
|
|
|
|
"ability causes a contact move to ignore Protect",
|
|
|
|
() => testUnseenFistHitResult(game, Moves.QUICK_ATTACK, Moves.PROTECT, true),
|
|
|
|
TIMEOUT
|
|
|
|
);
|
|
|
|
|
|
|
|
test(
|
|
|
|
"ability does not cause a non-contact move to ignore Protect",
|
|
|
|
() => testUnseenFistHitResult(game, Moves.ABSORB, Moves.PROTECT, false),
|
|
|
|
TIMEOUT
|
|
|
|
);
|
|
|
|
|
|
|
|
test(
|
|
|
|
"ability does not apply if the source has Long Reach",
|
|
|
|
() => {
|
2024-07-25 16:36:39 -07:00
|
|
|
game.override.passiveAbility(Abilities.LONG_REACH);
|
2024-06-15 19:14:49 -07:00
|
|
|
testUnseenFistHitResult(game, Moves.QUICK_ATTACK, Moves.PROTECT, false);
|
|
|
|
}, TIMEOUT
|
|
|
|
);
|
|
|
|
|
|
|
|
test(
|
|
|
|
"ability causes a contact move to ignore Wide Guard",
|
|
|
|
() => testUnseenFistHitResult(game, Moves.BREAKING_SWIPE, Moves.WIDE_GUARD, true),
|
|
|
|
TIMEOUT
|
|
|
|
);
|
|
|
|
|
|
|
|
test(
|
|
|
|
"ability does not cause a non-contact move to ignore Wide Guard",
|
|
|
|
() => testUnseenFistHitResult(game, Moves.BULLDOZE, Moves.WIDE_GUARD, false),
|
|
|
|
TIMEOUT
|
|
|
|
);
|
|
|
|
});
|
|
|
|
|
|
|
|
async function testUnseenFistHitResult(game: GameManager, attackMove: Moves, protectMove: Moves, shouldSucceed: boolean = true): Promise<void> {
|
2024-07-25 15:51:05 -07:00
|
|
|
game.override.moveset([attackMove]);
|
2024-07-25 15:18:14 -07:00
|
|
|
game.override.enemyMoveset([protectMove, protectMove, protectMove, protectMove]);
|
2024-06-15 19:14:49 -07:00
|
|
|
|
|
|
|
await game.startBattle();
|
|
|
|
|
2024-08-07 09:23:12 -07:00
|
|
|
const leadPokemon = game.scene.getPlayerPokemon()!;
|
2024-06-15 19:14:49 -07:00
|
|
|
expect(leadPokemon).not.toBe(undefined);
|
|
|
|
|
2024-08-07 09:23:12 -07:00
|
|
|
const enemyPokemon = game.scene.getEnemyPokemon()!;
|
2024-06-15 19:14:49 -07:00
|
|
|
expect(enemyPokemon).not.toBe(undefined);
|
|
|
|
|
|
|
|
const enemyStartingHp = enemyPokemon.hp;
|
|
|
|
|
|
|
|
game.doAttack(getMovePosition(game.scene, 0, attackMove));
|
2024-06-20 02:11:29 -07:00
|
|
|
await game.phaseInterceptor.to(TurnEndPhase, false);
|
2024-06-15 19:14:49 -07:00
|
|
|
|
|
|
|
if (shouldSucceed) {
|
|
|
|
expect(enemyPokemon.hp).toBeLessThan(enemyStartingHp);
|
|
|
|
} else {
|
|
|
|
expect(enemyPokemon.hp).toBe(enemyStartingHp);
|
|
|
|
}
|
|
|
|
}
|