pokerogue/test/abilities/desolate-land.test.ts
Sirz Benjie 48e911e03c
[Refactor] Remove circular deps 3 (#5959)
* Move game-mode to its own file

Reduces circular imports to 325

* Move battler-index to own file

Reduces circular deps to 314

* Move trainer-variant to own file

Reduces circ deps to 313

* Move enums in pokemon to their own file

* Move arena-tag-type to its own file

* Move pokemon-moves to its own file

* Move command to own file

* Move learnMoveType to own file

* Move form change item to own file

* Move battlerTagLapseType to own file

* Move anim enums to own shared file

* Move enums out of challenges

* Move species form change triggers to own file

Reduces circ imports to 291

* Update test importing pokemon move

* Replace move attribute imports with string names

* Untangle circular deps from game data

* Fix missing string call in switch summon phase

* Apply kev's suggestions from code review

Co-authored-by: NightKev <34855794+DayKev@users.noreply.github.com>

* Ensure ChargeMove's is method calls super

* Use InstanceType for proper narrowing

* Apply kev's suggestions from code review

Co-authored-by: NightKev <34855794+DayKev@users.noreply.github.com>

---------

Co-authored-by: NightKev <34855794+DayKev@users.noreply.github.com>
2025-06-09 16:24:13 -07:00

156 lines
5.2 KiB
TypeScript

import { PokeballType } from "#app/enums/pokeball";
import { WeatherType } from "#app/enums/weather-type";
import type { CommandPhase } from "#app/phases/command-phase";
import { Command } from "#enums/command";
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, it, expect, vi } from "vitest";
describe("Abilities - Desolate Land", () => {
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
.moveset(MoveId.SPLASH)
.hasPassiveAbility(true)
.enemySpecies(SpeciesId.RALTS)
.enemyAbility(AbilityId.BALL_FETCH)
.enemyMoveset(MoveId.SPLASH);
});
/**
* This checks that the weather has changed after the Enemy Pokemon with {@linkcode AbilityId.DESOLATE_LAND}
* is forcefully moved out of the field from moves such as Roar {@linkcode MoveId.ROAR}
*/
it("should lift only when all pokemon with this ability leave the field", async () => {
game.override.battleStyle("double").enemyMoveset([MoveId.SPLASH, MoveId.ROAR]);
await game.classicMode.startBattle([
SpeciesId.MAGCARGO,
SpeciesId.MAGCARGO,
SpeciesId.MAGIKARP,
SpeciesId.MAGIKARP,
]);
expect(game.scene.arena.weather?.weatherType).toBe(WeatherType.HARSH_SUN);
vi.spyOn(game.scene, "randBattleSeedInt").mockImplementation((_range, min = 0) => {
return min;
});
game.move.select(MoveId.SPLASH, 0, 2);
game.move.select(MoveId.SPLASH, 1, 2);
await game.move.selectEnemyMove(MoveId.ROAR, 0);
await game.move.selectEnemyMove(MoveId.SPLASH, 1);
await game.phaseInterceptor.to("TurnEndPhase");
expect(game.scene.arena.weather?.weatherType).toBe(WeatherType.HARSH_SUN);
await game.toNextTurn();
vi.spyOn(game.scene, "randBattleSeedInt").mockImplementation((_range, min = 0) => {
return min + 1;
});
game.move.select(MoveId.SPLASH, 0, 2);
game.move.select(MoveId.SPLASH, 1, 2);
await game.move.selectEnemyMove(MoveId.ROAR, 1);
await game.move.selectEnemyMove(MoveId.SPLASH, 0);
await game.phaseInterceptor.to("TurnEndPhase");
expect(game.scene.arena.weather?.weatherType).not.toBe(WeatherType.HARSH_SUN);
});
it("should lift when enemy faints", async () => {
game.override
.battleStyle("single")
.moveset([MoveId.SHEER_COLD])
.ability(AbilityId.NO_GUARD)
.startingLevel(100)
.enemyLevel(1)
.enemyMoveset([MoveId.SPLASH])
.enemySpecies(SpeciesId.MAGCARGO)
.enemyHasPassiveAbility(true);
await game.classicMode.startBattle([SpeciesId.MAGIKARP]);
expect(game.scene.arena.weather?.weatherType).toBe(WeatherType.HARSH_SUN);
game.move.select(MoveId.SHEER_COLD);
await game.phaseInterceptor.to("TurnEndPhase");
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.battleStyle("even-doubles").enemyMoveset([MoveId.SPLASH, MoveId.MEMENTO]).startingWave(12);
await game.classicMode.startBattle([SpeciesId.MAGIKARP, SpeciesId.MAGCARGO]);
expect(game.scene.arena.weather?.weatherType).toBe(WeatherType.HARSH_SUN);
game.move.select(MoveId.SPLASH, 0, 2);
game.move.select(MoveId.SPLASH, 1, 2);
await game.move.selectEnemyMove(MoveId.MEMENTO, 0);
await game.move.selectEnemyMove(MoveId.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
.battleStyle("single")
.enemyMoveset([MoveId.SPLASH])
.enemySpecies(SpeciesId.MAGCARGO)
.enemyHasPassiveAbility(true);
await game.classicMode.startBattle([SpeciesId.MAGIKARP]);
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");
expect(game.scene.arena.weather?.weatherType).not.toBe(WeatherType.HARSH_SUN);
});
it("should lift after fleeing from a wild pokemon", async () => {
game.override.enemyAbility(AbilityId.DESOLATE_LAND).ability(AbilityId.BALL_FETCH);
await game.classicMode.startBattle([SpeciesId.MAGIKARP]);
expect(game.scene.arena.weather?.weatherType).toBe(WeatherType.HARSH_SUN);
vi.spyOn(game.scene.getPlayerPokemon()!, "randBattleSeedInt").mockReturnValue(0);
const commandPhase = game.scene.phaseManager.getCurrentPhase() as CommandPhase;
commandPhase.handleCommand(Command.RUN, 0);
await game.phaseInterceptor.to("BerryPhase");
expect(game.scene.arena.weather?.weatherType).not.toBe(WeatherType.HARSH_SUN);
});
});