From 62634e7d6bdc37f0c70a059c1acf175eb6532a56 Mon Sep 17 00:00:00 2001 From: Wlowscha <54003515+Wlowscha@users.noreply.github.com> Date: Fri, 31 Jan 2025 00:48:46 +0100 Subject: [PATCH] Implemented tests for Desolate Land --- src/test/abilities/desolate-land.test.ts | 29 +++++++++++++++++++++++- src/test/utils/gameManager.ts | 14 ++++++------ 2 files changed, 35 insertions(+), 8 deletions(-) diff --git a/src/test/abilities/desolate-land.test.ts b/src/test/abilities/desolate-land.test.ts index df268d332ba..dec156c3764 100644 --- a/src/test/abilities/desolate-land.test.ts +++ b/src/test/abilities/desolate-land.test.ts @@ -1,3 +1,4 @@ +import { PokeballType } from "#app/enums/pokeball"; import { WeatherType } from "#app/enums/weather-type"; import { Abilities } from "#enums/abilities"; import { Moves } from "#enums/moves"; @@ -34,7 +35,7 @@ describe("Abilities - Desolate Land", () => { * This checks that the weather has changed after the Enemy Pokemon with {@linkcode Abilities.DESOLATE_LAND} * is forcefully moved out of the field from moves such as Roar {@linkcode Moves.ROAR} */ - it("should lift when all pokemon with this ability leave the field", async () => { + it("should lift only when all pokemon with this ability leave the field", async () => { game.override .battleType("double") .enemyMoveset([ Moves.SPLASH, Moves.ROAR ]); @@ -92,6 +93,29 @@ describe("Abilities - Desolate Land", () => { expect(game.scene.arena.weather?.weatherType).not.toBe(WeatherType.HARSH_SUN); }); + it("should lift when pokemon returns upon switching from double to single battle", async () => { + game.override + .battleType("even-doubles") + .enemyMoveset([ Moves.SPLASH, Moves.MEMENTO ]) + .startingWave(12); + await game.classicMode.startBattle([ Species.MAGIKARP, Species.MAGCARGO ]); + + expect(game.scene.arena.weather?.weatherType).toBe(WeatherType.HARSH_SUN); + + game.move.select(Moves.SPLASH, 0, 2); + game.move.select(Moves.SPLASH, 1, 2); + await game.forceEnemyMove(Moves.MEMENTO, 0); + await game.forceEnemyMove(Moves.MEMENTO, 1); + + await game.phaseInterceptor.to("TurnEndPhase"); + + expect(game.scene.arena.weather?.weatherType).toBe(WeatherType.HARSH_SUN); + + await game.toNextWave(); + + expect(game.scene.arena.weather?.weatherType).not.toBe(WeatherType.HARSH_SUN); + }); + it("should lift when enemy is captured", async () => { game.override .battleType("single") @@ -102,6 +126,9 @@ describe("Abilities - Desolate Land", () => { expect(game.scene.arena.weather?.weatherType).toBe(WeatherType.HARSH_SUN); + game.scene.pokeballCounts[PokeballType.MASTER_BALL] = 1; + + game.doThrowPokeball(PokeballType.MASTER_BALL); await game.phaseInterceptor.to("TurnEndPhase"); diff --git a/src/test/utils/gameManager.ts b/src/test/utils/gameManager.ts index f43dddf0f05..fba5b8fb063 100644 --- a/src/test/utils/gameManager.ts +++ b/src/test/utils/gameManager.ts @@ -24,6 +24,7 @@ import { TurnInitPhase } from "#app/phases/turn-init-phase"; import { TurnStartPhase } from "#app/phases/turn-start-phase"; import ErrorInterceptor from "#app/test/utils/errorInterceptor"; import type InputsHandler from "#app/test/utils/inputsHandler"; +import type BallUiHandler from "#app/ui/ball-ui-handler"; import type BattleMessageUiHandler from "#app/ui/battle-message-ui-handler"; import type CommandUiHandler from "#app/ui/command-ui-handler"; import type ModifierSelectUiHandler from "#app/ui/modifier-select-ui-handler"; @@ -458,16 +459,15 @@ export default class GameManager { (this.scene.ui.getHandler() as CommandUiHandler).processInput(Button.ACTION); }); - this.doSelectPokeball(ballIndex, "CommandPhase"); + this.doSelectPokeball(ballIndex); } // ??? - doSelectPokeball(slot: number, inPhase = "SwitchPhase") { - this.onNextPrompt(inPhase, Mode.PARTY, () => { - const partyHandler = this.scene.ui.getHandler() as PartyUiHandler; + doSelectPokeball(ballIndex: number) { + this.onNextPrompt("CommandPhase", Mode.BALL, () => { + const ballHandler = this.scene.ui.getHandler() as BallUiHandler; - partyHandler.setCursor(slot); - partyHandler.processInput(Button.ACTION); // select party slot - partyHandler.processInput(Button.ACTION); // send out (or whatever option is at the top) + ballHandler.setCursor(ballIndex); + ballHandler.processInput(Button.ACTION); // select ball and throw }); }