From cb0919ceeba7fa03377793018881b9661f011f42 Mon Sep 17 00:00:00 2001 From: geeil-han Date: Wed, 30 Oct 2024 20:04:25 +0100 Subject: [PATCH] added automated test case to arena trap test --- src/test/abilities/arena_trap.test.ts | 39 ++++++++++++++++++++++++++- 1 file changed, 38 insertions(+), 1 deletion(-) diff --git a/src/test/abilities/arena_trap.test.ts b/src/test/abilities/arena_trap.test.ts index 5068fed6b77..48cf67a2bfe 100644 --- a/src/test/abilities/arena_trap.test.ts +++ b/src/test/abilities/arena_trap.test.ts @@ -1,9 +1,10 @@ +import { allAbilities } from "#app/data/ability"; import { Abilities } from "#enums/abilities"; import { Moves } from "#enums/moves"; import { Species } from "#enums/species"; import GameManager from "#test/utils/gameManager"; import Phaser from "phaser"; -import { afterEach, beforeAll, beforeEach, describe, it, expect } from "vitest"; +import { afterEach, beforeAll, beforeEach, describe, it, expect, vi } from "vitest"; describe("Abilities - Arena Trap", () => { let phaserGame: Phaser.Game; @@ -55,4 +56,40 @@ describe("Abilities - Arena Trap", () => { 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 {@link Abilities.ARENA_TRAP} + * is forcefully moved out of the field from moves such as Roar {@link Moves.ROAR} + * + * Note: It should be able to switch out/run away + */ + it("should lift if pokemon with this ability leaves the field", async () => { + game.override.battleType("double"); + game.override.enemyMoveset(Moves.SPLASH); + game.override.moveset([ Moves.ROAR, Moves.SPLASH ]); + await game.classicMode.startBattle([ Species.MAGIKARP, Species.SUDOWOODO, Species.LUNATONE ]); + + const enemy1 = game.scene.getEnemyField()[0]; + const enemy2 = game.scene.getEnemyField()[1]; + const player1 = game.scene.getPlayerField()[0]; + const player2 = game.scene.getPlayerField()[1]; + + vi.spyOn(enemy1, "getAbility").mockReturnValue(allAbilities[Abilities.ARENA_TRAP]); + vi.spyOn(enemy2, "getAbility").mockReturnValue(allAbilities[Abilities.BALL_FETCH]); + vi.spyOn(player1, "getAbility").mockReturnValue(allAbilities[Abilities.BALL_FETCH]); + vi.spyOn(player2, "getAbility").mockReturnValue(allAbilities[Abilities.BALL_FETCH]); + + game.move.select(Moves.ROAR); + game.move.select(Moves.SPLASH); + + // This runs the fist command phase where the moves are selected + await game.toNextTurn(); + // During the next command phase the player pokemons should not be trapped anymore + await game.toNextTurn(); + + expect(game.scene.getPlayerField()[0].isTrapped()).toBe(false); + expect(game.scene.getPlayerField()[1].isTrapped()).toBe(false); + expect(game.scene.getEnemyField()[0].isOnField()).toBe(false); + expect(game.scene.getEnemyField()[1].isOnField()).toBe(true); + }); });