mirror of
https://github.com/pagefaultgames/pokerogue.git
synced 2025-08-09 17:09:26 +02:00
* 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>
103 lines
3.5 KiB
TypeScript
103 lines
3.5 KiB
TypeScript
import { Button } from "#enums/buttons";
|
|
import { HeldItemId } from "#enums/held-item-id";
|
|
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 { PartyUiHandler, PartyUiMode } from "#ui/party-ui-handler";
|
|
import { RewardSelectUiHandler } from "#ui/reward-select-ui-handler";
|
|
import Phaser from "phaser";
|
|
import type BBCodeText from "phaser3-rex-plugins/plugins/bbcodetext";
|
|
import { afterEach, beforeAll, beforeEach, describe, expect, it } from "vitest";
|
|
|
|
describe("UI - Transfer Items", () => {
|
|
let phaserGame: Phaser.Game;
|
|
let game: GameManager;
|
|
|
|
beforeAll(() => {
|
|
phaserGame = new Phaser.Game({
|
|
type: Phaser.HEADLESS,
|
|
});
|
|
});
|
|
|
|
afterEach(() => {
|
|
game.phaseInterceptor.restoreOg();
|
|
});
|
|
|
|
beforeEach(async () => {
|
|
game = new GameManager(phaserGame);
|
|
game.override
|
|
.battleStyle("single")
|
|
.startingLevel(100)
|
|
.startingWave(1)
|
|
.startingHeldItems([
|
|
{ entry: HeldItemId.SITRUS_BERRY, count: 1 },
|
|
{ entry: HeldItemId.APICOT_BERRY, count: 2 },
|
|
{ entry: HeldItemId.LUM_BERRY, count: 2 },
|
|
])
|
|
.moveset([MoveId.DRAGON_CLAW])
|
|
.enemySpecies(SpeciesId.MAGIKARP)
|
|
.enemyMoveset([MoveId.SPLASH]);
|
|
|
|
await game.classicMode.startBattle([SpeciesId.RAYQUAZA, SpeciesId.RAYQUAZA, SpeciesId.RAYQUAZA]);
|
|
|
|
game.move.select(MoveId.DRAGON_CLAW);
|
|
|
|
game.onNextPrompt("SelectRewardPhase", UiMode.REWARD_SELECT, () => {
|
|
expect(game.scene.ui.getHandler()).toBeInstanceOf(RewardSelectUiHandler);
|
|
|
|
const handler = game.scene.ui.getHandler() as RewardSelectUiHandler;
|
|
handler.setCursor(1);
|
|
handler.processInput(Button.ACTION);
|
|
|
|
void game.scene.ui.setModeWithoutClear(UiMode.PARTY, PartyUiMode.ITEM_TRANSFER);
|
|
});
|
|
|
|
await game.phaseInterceptor.to("BattleEndPhase");
|
|
});
|
|
|
|
it("check red tint for held item limit in transfer menu", async () => {
|
|
game.onNextPrompt("SelectRewardPhase", UiMode.PARTY, () => {
|
|
expect(game.scene.ui.getHandler()).toBeInstanceOf(PartyUiHandler);
|
|
|
|
const handler = game.scene.ui.getHandler() as PartyUiHandler;
|
|
handler.processInput(Button.ACTION);
|
|
|
|
expect(handler.optionsContainer.list.some(option => (option as BBCodeText).text?.includes("Sitrus Berry"))).toBe(
|
|
true,
|
|
);
|
|
expect(
|
|
handler.optionsContainer.list.some(option => (option as BBCodeText).text?.includes("Apicot Berry (2)")),
|
|
).toBe(true);
|
|
expect(
|
|
handler.optionsContainer.list.some(option => RegExp(/Lum Berry\[color.*(2)/).exec((option as BBCodeText).text)),
|
|
).toBe(true);
|
|
|
|
game.phaseInterceptor.unlock();
|
|
});
|
|
|
|
await game.phaseInterceptor.to("SelectRewardPhase");
|
|
});
|
|
|
|
it("check transfer option for pokemon to transfer to", async () => {
|
|
game.onNextPrompt("SelectRewardPhase", UiMode.PARTY, () => {
|
|
expect(game.scene.ui.getHandler()).toBeInstanceOf(PartyUiHandler);
|
|
|
|
const handler = game.scene.ui.getHandler() as PartyUiHandler;
|
|
handler.processInput(Button.ACTION); // select Pokemon
|
|
handler.processInput(Button.ACTION); // select held item (Sitrus Berry)
|
|
|
|
handler.setCursor(1); // move to other Pokemon
|
|
handler.processInput(Button.ACTION); // select Pokemon
|
|
|
|
expect(handler.optionsContainer.list.some(option => (option as BBCodeText).text?.includes("Transfer"))).toBe(
|
|
true,
|
|
);
|
|
|
|
game.phaseInterceptor.unlock();
|
|
});
|
|
|
|
await game.phaseInterceptor.to("SelectRewardPhase");
|
|
});
|
|
});
|