mirror of
https://github.com/pagefaultgames/pokerogue.git
synced 2025-06-21 00:52:47 +02:00
https://github.com/pagefaultgames/pokerogue/pull/5926 * Condensed all overrides into 1 line where possible I hope I got them all... * Fixed tests 0.5 * Cleaned up safeguard test to not use outdated code; fixed rest of errors * Fixed illusion test * Revert safeguart etst * Fixed battle tets * Fixed stuff * Fixed things2.0 * Fixed import issues * Revert changes outside of the tests directory * Revert changes outside of the tests directory --------- Co-authored-by: Sirz Benjie <142067137+SirzBenjie@users.noreply.github.com> Co-authored-by: NightKev <34855794+DayKev@users.noreply.github.com>
97 lines
3.1 KiB
TypeScript
97 lines
3.1 KiB
TypeScript
import { TurnEndPhase } from "#app/phases/turn-end-phase";
|
|
import { AbilityId } from "#enums/ability-id";
|
|
import { MoveId } from "#enums/move-id";
|
|
import { SpeciesId } from "#enums/species-id";
|
|
import GameManager from "#test/testUtils/gameManager";
|
|
import Phaser from "phaser";
|
|
import { afterEach, beforeAll, beforeEach, describe, expect, it } from "vitest";
|
|
import { BattlerTagType } from "#app/enums/battler-tag-type";
|
|
import { BerryPhase } from "#app/phases/berry-phase";
|
|
|
|
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);
|
|
game.override
|
|
.battleStyle("single")
|
|
.starterSpecies(SpeciesId.URSHIFU)
|
|
.enemySpecies(SpeciesId.SNORLAX)
|
|
.enemyMoveset(MoveId.PROTECT)
|
|
.startingLevel(100)
|
|
.enemyLevel(100);
|
|
});
|
|
|
|
it("should cause a contact move to ignore Protect", async () =>
|
|
await testUnseenFistHitResult(game, MoveId.QUICK_ATTACK, MoveId.PROTECT, true));
|
|
|
|
it("should not cause a non-contact move to ignore Protect", async () =>
|
|
await testUnseenFistHitResult(game, MoveId.ABSORB, MoveId.PROTECT, false));
|
|
|
|
it("should not apply if the source has Long Reach", async () => {
|
|
game.override.passiveAbility(AbilityId.LONG_REACH);
|
|
await testUnseenFistHitResult(game, MoveId.QUICK_ATTACK, MoveId.PROTECT, false);
|
|
});
|
|
|
|
it("should cause a contact move to ignore Wide Guard", async () =>
|
|
await testUnseenFistHitResult(game, MoveId.BREAKING_SWIPE, MoveId.WIDE_GUARD, true));
|
|
|
|
it("should not cause a non-contact move to ignore Wide Guard", async () =>
|
|
await testUnseenFistHitResult(game, MoveId.BULLDOZE, MoveId.WIDE_GUARD, false));
|
|
|
|
it("should cause a contact move to ignore Protect, but not Substitute", async () => {
|
|
game.override.enemyLevel(1).moveset([MoveId.TACKLE]);
|
|
|
|
await game.classicMode.startBattle();
|
|
|
|
const enemyPokemon = game.scene.getEnemyPokemon()!;
|
|
enemyPokemon.addTag(BattlerTagType.SUBSTITUTE, 0, MoveId.NONE, enemyPokemon.id);
|
|
|
|
game.move.select(MoveId.TACKLE);
|
|
|
|
await game.phaseInterceptor.to(BerryPhase, false);
|
|
|
|
expect(enemyPokemon.getTag(BattlerTagType.SUBSTITUTE)).toBeUndefined();
|
|
expect(enemyPokemon.hp).toBe(enemyPokemon.getMaxHp());
|
|
});
|
|
});
|
|
|
|
async function testUnseenFistHitResult(
|
|
game: GameManager,
|
|
attackMove: MoveId,
|
|
protectMove: MoveId,
|
|
shouldSucceed = true,
|
|
): Promise<void> {
|
|
game.override.moveset([attackMove]).enemyMoveset(protectMove);
|
|
|
|
await game.classicMode.startBattle();
|
|
|
|
const leadPokemon = game.scene.getPlayerPokemon()!;
|
|
expect(leadPokemon).not.toBe(undefined);
|
|
|
|
const enemyPokemon = game.scene.getEnemyPokemon()!;
|
|
expect(enemyPokemon).not.toBe(undefined);
|
|
|
|
const enemyStartingHp = enemyPokemon.hp;
|
|
|
|
game.move.select(attackMove);
|
|
await game.phaseInterceptor.to(TurnEndPhase, false);
|
|
|
|
if (shouldSucceed) {
|
|
expect(enemyPokemon.hp).toBeLessThan(enemyStartingHp);
|
|
} else {
|
|
expect(enemyPokemon.hp).toBe(enemyStartingHp);
|
|
}
|
|
}
|