reverted another test file

This commit is contained in:
Bertie690 2025-08-03 19:47:28 -04:00
parent a22a6b89b9
commit eed5f0c011

View File

@ -4,7 +4,7 @@ import { MoveId } from "#enums/move-id";
import { SpeciesId } from "#enums/species-id"; import { SpeciesId } from "#enums/species-id";
import { GameManager } from "#test/test-utils/game-manager"; import { GameManager } from "#test/test-utils/game-manager";
import Phaser from "phaser"; import Phaser from "phaser";
import { afterEach, beforeAll, beforeEach, describe, expect, it } from "vitest"; import { afterEach, beforeAll, beforeEach, describe, expect, it, vi } from "vitest";
describe("Abilities - Arena Trap", () => { describe("Abilities - Arena Trap", () => {
let phaserGame: Phaser.Game; let phaserGame: Phaser.Game;
@ -23,86 +23,68 @@ describe("Abilities - Arena Trap", () => {
beforeEach(() => { beforeEach(() => {
game = new GameManager(phaserGame); game = new GameManager(phaserGame);
game.override game.override
.moveset(MoveId.SPLASH)
.ability(AbilityId.ARENA_TRAP) .ability(AbilityId.ARENA_TRAP)
.enemySpecies(SpeciesId.RALTS) .enemySpecies(SpeciesId.RALTS)
.enemyAbility(AbilityId.BALL_FETCH) .enemyAbility(AbilityId.BALL_FETCH)
.enemyMoveset(MoveId.SPLASH); .enemyMoveset(MoveId.TELEPORT);
}); });
// NB: Since switching moves bypass trapping, the only way fleeing can occur is from the player // TODO: Enable test when Issue #935 is addressed
// TODO: Implement once forced flee helper exists it.todo("should not allow grounded Pokémon to flee", async () => {
it.todo("should interrupt player flee attempt and display message, unless user has Run Away", async () => {
game.override.battleStyle("single"); game.override.battleStyle("single");
await game.classicMode.startBattle([SpeciesId.DUGTRIO, SpeciesId.GOTHITELLE]);
const enemy = game.field.getEnemyPokemon(); await game.classicMode.startBattle();
// flee stuff goes here const enemy = game.scene.getEnemyPokemon();
game.onNextPrompt("CommandPhase", UiMode.COMMAND, () => { game.move.select(MoveId.SPLASH);
// no switch out command should be queued due to arena trap
expect(game.scene.currentBattle.turnCommands[0]).toBeNull();
// back out and cancel the flee to avoid timeout
(game.scene.ui.getHandler() as CommandUiHandler).processInput(Button.CANCEL);
game.move.use(MoveId.SPLASH);
});
await game.toNextTurn(); await game.toNextTurn();
expect(game.textInterceptor.logs).toContain(
i18next.t("abilityTriggers:arenaTrap", {
pokemonNameWithAffix: getPokemonNameWithAffix(enemy),
abilityName: allAbilities[AbilityId.ARENA_TRAP].name,
}),
);
});
it("should interrupt player switch attempt and display message", async () => { expect(enemy).toBe(game.scene.getEnemyPokemon());
game.override.battleStyle("single").enemyAbility(AbilityId.ARENA_TRAP);
await game.classicMode.startBattle([SpeciesId.DUGTRIO, SpeciesId.GOTHITELLE]);
const enemy = game.field.getEnemyPokemon();
game.doSwitchPokemon(1);
game.onNextPrompt("CommandPhase", UiMode.PARTY, () => {
// no switch out command should be queued due to arena trap
expect(game.scene.currentBattle.turnCommands[0]).toBeNull();
// back out and cancel the switch to avoid timeout
(game.scene.ui.getHandler() as CommandUiHandler).processInput(Button.CANCEL);
game.move.use(MoveId.SPLASH);
});
await game.toNextTurn();
expect(game.textInterceptor.logs).toContain(
i18next.t("abilityTriggers:arenaTrap", {
pokemonNameWithAffix: getPokemonNameWithAffix(enemy),
abilityName: allAbilities[AbilityId.ARENA_TRAP].name,
}),
);
}); });
it("should guarantee double battle with any one LURE", async () => { it("should guarantee double battle with any one LURE", async () => {
game.override.startingModifier([{ name: "LURE" }]).startingWave(2); game.override.startingModifier([{ name: "LURE" }]).startingWave(2);
await game.classicMode.startBattle([SpeciesId.DUGTRIO]);
expect(game.scene.getEnemyField()).toHaveLength(2); await game.classicMode.startBattle();
expect(game.scene.getEnemyField().length).toBe(2);
}); });
/**
* This checks if the Player Pokemon is able to switch out/run away after the Enemy Pokemon with {@linkcode AbilityId.ARENA_TRAP}
* is forcefully moved out of the field from moves such as Roar {@linkcode MoveId.ROAR}
*
* Note: It should be able to switch out/run away
*/
it("should lift if pokemon with this ability leaves the field", async () => { it("should lift if pokemon with this ability leaves the field", async () => {
game.override.battleStyle("single"); game.override
await game.classicMode.startBattle([SpeciesId.MAGIKARP]); .battleStyle("double")
.enemyMoveset(MoveId.SPLASH)
.moveset([MoveId.ROAR, MoveId.SPLASH])
.ability(AbilityId.BALL_FETCH);
await game.classicMode.startBattle([SpeciesId.MAGIKARP, SpeciesId.SUDOWOODO, SpeciesId.LUNATONE]);
const player = game.field.getPlayerPokemon(); const [enemy1, enemy2] = game.scene.getEnemyField();
const enemy = game.field.getEnemyPokemon(); const [player1, player2] = game.scene.getPlayerField();
expect(player.isTrapped()).toBe(true); vi.spyOn(enemy1, "getAbility").mockReturnValue(allAbilities[AbilityId.ARENA_TRAP]);
expect(enemy.isOnField()).toBe(true);
game.move.use(MoveId.ROAR); game.move.select(MoveId.ROAR);
await game.toEndOfTurn(); game.move.select(MoveId.SPLASH, 1);
expect(player.isTrapped()).toBe(false); // This runs the fist command phase where the moves are selected
expect(enemy.isOnField()).toBe(false); await game.toNextTurn();
// During the next command phase the player pokemons should not be trapped anymore
game.move.select(MoveId.SPLASH);
game.move.select(MoveId.SPLASH, 1);
await game.toNextTurn();
expect(player1.isTrapped()).toBe(false);
expect(player2.isTrapped()).toBe(false);
expect(enemy1.isOnField()).toBe(false);
expect(enemy2.isOnField()).toBe(true);
}); });
}); });