Implemented tests for Desolate Land

This commit is contained in:
Wlowscha 2025-01-31 00:48:46 +01:00
parent a0e6852bd1
commit 62634e7d6b
No known key found for this signature in database
GPG Key ID: 3C8F1AD330565D04
2 changed files with 35 additions and 8 deletions

View File

@ -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");

View File

@ -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
});
}