pokerogue/test/challenges/limited-support.test.ts
Amani H. 94650670fd
[Challenge] Add Nuzlocke-related Challenges (#6186)
* [Challenge] Add Nuzlocke-related Challenges

Co-authored-by: Matilde Simões <matilde.simoes@tecnico.ulisboa.pt>
Co-authored-by: Fuad Ali <fuad.ali@tecnico.ulisboa.pt>
Co-authored-by: NightKev <34855794+DayKev@users.noreply.github.com>
Co-authored-by: Sirzento <sirzento@gmx.de>

* Add Sacred Ash to `revive` Group

* Separate Challenge Utility Functions

* Misc. Changes

* Transition to `BooleanHolder`

* Add "Nuzlocke" Achievement

* Change Challenge Order

* Adjust Nuzlocke Achievement to Include Fresh Start

* Fix Infinite Reward Reroll Bug

* Fix Party Heal

* Minor Change

* Adjust TODOs

* Add Unit Tests

* Tweak Faint Cry in Permanent Faint

* Resolve rebase issue

* Apply Matthew's Suggestions

Co-authored-by: Bertie690 <136088738+Bertie690@users.noreply.github.com>

* Apply Matthew's Suggestions Pt. 2

Co-authored-by: Bertie690 <136088738+Bertie690@users.noreply.github.com>

* Fix and Lint Suggestions

* Revert Accidental Overrides

* Fix and Lint Suggestions Pt. 2

* Rename Challenges

* Prevent `RandomMoveAttr` from Using Banned Moves

* Update Locales

---------

Co-authored-by: Matilde Simões <matilde.simoes@tecnico.ulisboa.pt>
Co-authored-by: Fuad Ali <fuad.ali@tecnico.ulisboa.pt>
Co-authored-by: NightKev <34855794+DayKev@users.noreply.github.com>
Co-authored-by: Sirzento <sirzento@gmx.de>
Co-authored-by: Bertie690 <136088738+Bertie690@users.noreply.github.com>
2025-08-07 18:47:28 -06:00

91 lines
2.9 KiB
TypeScript

import { AbilityId } from "#enums/ability-id";
import { Challenges } from "#enums/challenges";
import { MoveId } from "#enums/move-id";
import { SpeciesId } from "#enums/species-id";
import { UiMode } from "#enums/ui-mode";
import { GameManager } from "#test/test-utils/game-manager";
import { ModifierSelectUiHandler } from "#ui/modifier-select-ui-handler";
import Phaser from "phaser";
import { afterEach, beforeAll, beforeEach, describe, expect, it } from "vitest";
describe("Challenges - Limited Support", () => {
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
.battleStyle("single")
.enemySpecies(SpeciesId.VOLTORB)
.enemyAbility(AbilityId.BALL_FETCH)
.enemyMoveset(MoveId.SPLASH);
});
it('should disable the shop in "No Shop"', async () => {
game.override.startingWave(181);
game.challengeMode.addChallenge(Challenges.LIMITED_SUPPORT, 2, 1);
await game.challengeMode.startBattle([SpeciesId.NUZLEAF]);
game.move.use(MoveId.SPLASH);
await game.doKillOpponents();
await game.phaseInterceptor.to("SelectModifierPhase");
expect(game.scene.ui.getMode()).toBe(UiMode.MODIFIER_SELECT);
const modifierSelectHandler = game.scene.ui.handlers.find(
h => h instanceof ModifierSelectUiHandler,
) as ModifierSelectUiHandler;
expect(modifierSelectHandler.shopOptionsRows).toHaveLength(0);
});
it('should disable the automatic party heal in "No Heal"', async () => {
game.override.startingWave(10);
game.challengeMode.addChallenge(Challenges.LIMITED_SUPPORT, 1, 1);
await game.challengeMode.startBattle([SpeciesId.NUZLEAF]);
const playerPokemon = game.field.getPlayerPokemon();
playerPokemon.hp /= 2;
game.move.use(MoveId.SPLASH);
await game.doKillOpponents();
await game.toNextWave();
expect(playerPokemon).not.toHaveFullHp();
});
it('should disable both automatic party healing and shop in "Both"', async () => {
game.override.startingWave(10);
game.challengeMode.addChallenge(Challenges.LIMITED_SUPPORT, 3, 1);
await game.challengeMode.startBattle([SpeciesId.NUZLEAF]);
const playerPokemon = game.field.getPlayerPokemon();
playerPokemon.hp /= 2;
game.move.use(MoveId.SPLASH);
await game.doKillOpponents();
await game.toNextWave();
expect(playerPokemon).not.toHaveFullHp();
game.move.use(MoveId.SPLASH);
await game.doKillOpponents();
await game.phaseInterceptor.to("SelectModifierPhase");
expect(game.scene.ui.getMode()).toBe(UiMode.MODIFIER_SELECT);
const modifierSelectHandler = game.scene.ui.handlers.find(
h => h instanceof ModifierSelectUiHandler,
) as ModifierSelectUiHandler;
expect(modifierSelectHandler.shopOptionsRows).toHaveLength(0);
});
});