pokerogue/test/daily-mode.test.ts
Wlowscha 466c4aede2
Replace remaining Modifiers with Rewards (#6091)
* Changing remaining Modifiers to Consumables, and renaming ModifierType to Reward

* Renamed modifier files and moved them into items folder

* Using rewards in most places

* Removed consumables in favor of using rewards directly

* Renamed RewardTier to RarityTier

* Reward ids, function to match rewards

* Getting reward tiers from player pool still

* Messing around with parameters of Reward.apply()

* Always requiring player pokemon in rewards

* Fixing some functions in select-reward-phase and battle-scene

* Fixed various post-merge issues

* Fixed most localization strings (accidentally broken by replacing modifierType with reward)

* Fixed tests for select reward phase

* Using Pokemon.hasSpecies()

* Zero weight for trainer items rewards which are already max stack

* Cleaning up SelectRewardPhase, held item rewards behave the same as any PokemonReward

* Cleaned up some functions

* Introduced RewardCategoryId, distributed RewardIds

* Utility `is` functions for rewards

* Minor fixes

* Moved `HeldItemEffect` to its own file

* rmade some todo comments

* Adding a big comment

* Added tsdocs and removed `RewardClass`

* undid breaking changes

* added TODO

* Moved matchingRewards function to reward-utils.ts

* Added RewardGenerator classes for mints and tera shards

* Introducing default rarity tiers for trainer items and rewards

* RewardFunc now can return RewardGenerator

* Moved pool reward functions to their own file, plus other utility files

* Fixed WeightedModifier to work with the new RewardFunc

* Fixed wrong type import

* Shifting trainer item and reward ids to avoid overlaps

* Added some types

* Updated comment in reward.ts

* Added strong typing ot item maps

* added type safety to held item name map

---------

Co-authored-by: Bertie690 <taylormw163@gmail.com>
Co-authored-by: Sirz Benjie <142067137+SirzBenjie@users.noreply.github.com>
2025-07-27 17:09:21 -07:00

94 lines
3.0 KiB
TypeScript

import { pokerogueApi } from "#api/pokerogue-api";
import { BiomeId } from "#enums/biome-id";
import { MoveId } from "#enums/move-id";
import { SpeciesId } from "#enums/species-id";
import { TrainerItemId } from "#enums/trainer-item-id";
import { UiMode } from "#enums/ui-mode";
import { GameManager } from "#test/test-utils/game-manager";
import { RewardSelectUiHandler } from "#ui/reward-select-ui-handler";
import { afterEach, beforeAll, beforeEach, describe, expect, it, vi } from "vitest";
describe("Daily Mode", () => {
let phaserGame: Phaser.Game;
let game: GameManager;
beforeAll(() => {
phaserGame = new Phaser.Game({
type: Phaser.HEADLESS,
});
});
beforeEach(() => {
game = new GameManager(phaserGame);
vi.spyOn(pokerogueApi.daily, "getSeed").mockResolvedValue("test-seed");
});
afterEach(() => {
game.phaseInterceptor.restoreOg();
});
it("should initialize properly", async () => {
await game.dailyMode.startBattle();
const party = game.scene.getPlayerParty();
expect(party).toHaveLength(3);
party.forEach(pkm => {
expect(pkm.level).toBe(20);
expect(pkm.moveset.length).toBeGreaterThan(0);
});
expect(game.scene.trainerItems.getStack(TrainerItemId.MAP)).toBe(1);
});
});
describe("Shop modifications", async () => {
let phaserGame: Phaser.Game;
let game: GameManager;
beforeAll(() => {
phaserGame = new Phaser.Game({
type: Phaser.HEADLESS,
});
});
beforeEach(() => {
game = new GameManager(phaserGame);
game.override
.startingWave(9)
.startingBiome(BiomeId.ICE_CAVE)
.battleStyle("single")
.startingLevel(100) // Avoid levelling up
.disableTrainerWaves()
.moveset([MoveId.SPLASH])
.enemyMoveset(MoveId.SPLASH);
game.modifiers.addCheck("EVIOLITE").addCheck("MINI_BLACK_HOLE");
vi.spyOn(pokerogueApi.daily, "getSeed").mockResolvedValue("test-seed");
});
afterEach(() => {
game.phaseInterceptor.restoreOg();
game.modifiers.clearChecks();
});
it("should not have Eviolite and Mini Black Hole available in Classic if not unlocked", async () => {
await game.classicMode.startBattle([SpeciesId.BULBASAUR]);
game.move.select(MoveId.SPLASH);
await game.doKillOpponents();
await game.phaseInterceptor.to("BattleEndPhase");
game.onNextPrompt("SelectRewardPhase", UiMode.REWARD_SELECT, () => {
expect(game.scene.ui.getHandler()).toBeInstanceOf(RewardSelectUiHandler);
game.modifiers.testCheck("EVIOLITE", false).testCheck("MINI_BLACK_HOLE", false);
});
});
it("should have Eviolite and Mini Black Hole available in Daily", async () => {
await game.dailyMode.startBattle();
game.move.select(MoveId.SPLASH);
await game.doKillOpponents();
await game.phaseInterceptor.to("BattleEndPhase");
game.onNextPrompt("SelectRewardPhase", UiMode.REWARD_SELECT, () => {
expect(game.scene.ui.getHandler()).toBeInstanceOf(RewardSelectUiHandler);
game.modifiers.testCheck("EVIOLITE", true).testCheck("MINI_BLACK_HOLE", true);
});
});
});