Expunged RewardFunc

This commit is contained in:
Bertie690 2025-08-07 13:50:54 -04:00
parent b3f3aa56bd
commit 88e0a3d6ec
12 changed files with 31 additions and 36 deletions

View File

@ -3,9 +3,7 @@ import type { RewardId } from "#enums/reward-id";
import type { TrainerItemId } from "#enums/trainer-item-id"; import type { TrainerItemId } from "#enums/trainer-item-id";
import type { Pokemon } from "#field/pokemon"; import type { Pokemon } from "#field/pokemon";
import type { allRewardsType } from "#items/all-rewards"; import type { allRewardsType } from "#items/all-rewards";
import type { Reward, RewardGenerator } from "#items/reward"; import type { RewardGenerator } from "#items/reward";
export type RewardFunc = Reward | RewardGenerator;
// TODO: Remove party from arguments can be accessed from `globalScene` // TODO: Remove party from arguments can be accessed from `globalScene`
export type WeightedRewardWeightFunc = (party: Pokemon[], rerollCount?: number) => number; export type WeightedRewardWeightFunc = (party: Pokemon[], rerollCount?: number) => number;

View File

@ -3,13 +3,12 @@ import { globalScene } from "#app/global-scene";
import { pokemonEvolutions, pokemonPrevolutions } from "#balance/pokemon-evolutions"; import { pokemonEvolutions, pokemonPrevolutions } from "#balance/pokemon-evolutions";
import { signatureSpecies } from "#balance/signature-species"; import { signatureSpecies } from "#balance/signature-species";
import { tmSpecies } from "#balance/tms"; import { tmSpecies } from "#balance/tms";
import { allRewards } from "#data/data-lists";
import { doubleBattleDialogue } from "#data/double-battle-dialogue"; import { doubleBattleDialogue } from "#data/double-battle-dialogue";
import { Gender } from "#data/gender"; import { Gender } from "#data/gender";
import type { PokemonSpecies, PokemonSpeciesFilter } from "#data/pokemon-species"; import type { PokemonSpecies, PokemonSpeciesFilter } from "#data/pokemon-species";
import { AbilityId } from "#enums/ability-id"; import { AbilityId } from "#enums/ability-id";
import { MoveId } from "#enums/move-id"; import { MoveId } from "#enums/move-id";
import { PartyMemberStrength } from "#enums/party-member-strength"; import type { PartyMemberStrength } from "#enums/party-member-strength";
import { PokeballType } from "#enums/pokeball"; import { PokeballType } from "#enums/pokeball";
import { PokemonType } from "#enums/pokemon-type"; import { PokemonType } from "#enums/pokemon-type";
import { SpeciesId } from "#enums/species-id"; import { SpeciesId } from "#enums/species-id";
@ -19,6 +18,8 @@ import { TrainerSlot } from "#enums/trainer-slot";
import { TrainerType } from "#enums/trainer-type"; import { TrainerType } from "#enums/trainer-type";
import { TrainerVariant } from "#enums/trainer-variant"; import { TrainerVariant } from "#enums/trainer-variant";
import type { EnemyPokemon } from "#field/pokemon"; import type { EnemyPokemon } from "#field/pokemon";
import { allRewards } from "#items/all-rewards";
import type { Reward, RewardGenerator } from "#items/reward";
import { PokemonMove } from "#moves/pokemon-move"; import { PokemonMove } from "#moves/pokemon-move";
import { getIsInitialized, initI18n } from "#plugins/i18n"; import { getIsInitialized, initI18n } from "#plugins/i18n";
import type { EvilTeam } from "#trainers/evil-admin-trainer-pools"; import type { EvilTeam } from "#trainers/evil-admin-trainer-pools";
@ -28,10 +29,9 @@ import {
getGymLeaderPartyTemplate, getGymLeaderPartyTemplate,
getWavePartyTemplate, getWavePartyTemplate,
TrainerPartyCompoundTemplate, TrainerPartyCompoundTemplate,
TrainerPartyTemplate, type TrainerPartyTemplate,
trainerPartyTemplates, trainerPartyTemplates,
} from "#trainers/trainer-party-template"; } from "#trainers/trainer-party-template";
import type { RewardFunc } from "#types/rewards";
import type { import type {
GenAIFunc, GenAIFunc,
GenTrainerItemsFunc, GenTrainerItemsFunc,
@ -109,7 +109,7 @@ export class TrainerConfig {
public victoryBgm: string; public victoryBgm: string;
public genTrainerItemsFunc: GenTrainerItemsFunc; public genTrainerItemsFunc: GenTrainerItemsFunc;
public genAIFuncs: GenAIFunc[] = []; public genAIFuncs: GenAIFunc[] = [];
public rewardFuncs: RewardFunc[] = []; public rewardFuncs: (Reward | RewardGenerator)[] = [];
public partyTemplates: TrainerPartyTemplate[]; public partyTemplates: TrainerPartyTemplate[];
public partyTemplateFunc: PartyTemplateFunc; public partyTemplateFunc: PartyTemplateFunc;
public partyMemberFuncs: PartyMemberFuncs = {}; public partyMemberFuncs: PartyMemberFuncs = {};
@ -501,7 +501,7 @@ export class TrainerConfig {
return this; return this;
} }
setRewardFuncs(...rewardFuncs: (() => RewardFunc)[]): TrainerConfig { setRewardFuncs(...rewardFuncs: (Reward | RewardGenerator)[]): TrainerConfig {
this.rewardFuncs = rewardFuncs.map(func => () => { this.rewardFuncs = rewardFuncs.map(func => () => {
const rewardFunc = func(); const rewardFunc = func();
const reward = rewardFunc(); const reward = rewardFunc();

View File

@ -52,19 +52,17 @@ export const RewardId = {
MEMORY_MUSHROOM: 0x2B03, MEMORY_MUSHROOM: 0x2B03,
DNA_SPLICERS: 0x2B04, DNA_SPLICERS: 0x2B04,
HELD_ITEM: 0x2C01, // TODO: Remove? SPECIES_STAT_BOOSTER: 0x2C01,
SPECIES_STAT_BOOSTER: 0x2C02, RARE_SPECIES_STAT_BOOSTER: 0x2C02,
RARE_SPECIES_STAT_BOOSTER: 0x2C03, BASE_STAT_BOOSTER: 0x2C03,
BASE_STAT_BOOSTER: 0x2C04, ATTACK_TYPE_BOOSTER: 0x2C04,
ATTACK_TYPE_BOOSTER: 0x2C05, BERRY: 0x2C05,
BERRY: 0x2C06,
TRAINER_ITEM: 0x2D01, TEMP_STAT_STAGE_BOOSTER: 0x2D01,
TEMP_STAT_STAGE_BOOSTER: 0x2D02, DIRE_HIT: 0x2D02,
DIRE_HIT: 0x2D03, LURE: 0x2D03,
LURE: 0x2D04, SUPER_LURE: 0x2D04,
SUPER_LURE: 0x2D05, MAX_LURE: 0x2D05,
MAX_LURE: 0x2D06,
FORM_CHANGE_ITEM: 0x2E01, FORM_CHANGE_ITEM: 0x2E01,
RARE_FORM_CHANGE_ITEM: 0x2E02, RARE_FORM_CHANGE_ITEM: 0x2E02,

View File

@ -3,7 +3,6 @@ import { RewardId } from "#enums/reward-id";
import { RarityTier } from "#enums/reward-tier"; import { RarityTier } from "#enums/reward-tier";
import { TrainerItemId } from "#enums/trainer-item-id"; import { TrainerItemId } from "#enums/trainer-item-id";
import { VoucherType } from "#system/voucher"; import { VoucherType } from "#system/voucher";
import type { RewardFunc } from "#types/rewards";
import { import {
AddMoneyReward, AddMoneyReward,
AddPokeballReward, AddPokeballReward,
@ -27,6 +26,8 @@ import {
PokemonReviveReward, PokemonReviveReward,
PokemonStatusHealReward, PokemonStatusHealReward,
RememberMoveReward, RememberMoveReward,
type Reward,
type RewardGenerator,
SpeciesStatBoosterRewardGenerator, SpeciesStatBoosterRewardGenerator,
TempStatStageBoosterRewardGenerator, TempStatStageBoosterRewardGenerator,
TeraTypeRewardGenerator, TeraTypeRewardGenerator,
@ -184,7 +185,7 @@ export const allRewards = {
[RewardId.DIRE_HIT]: new LapsingTrainerItemReward(TrainerItemId.DIRE_HIT, RewardId.TEMP_STAT_STAGE_BOOSTER), [RewardId.DIRE_HIT]: new LapsingTrainerItemReward(TrainerItemId.DIRE_HIT, RewardId.TEMP_STAT_STAGE_BOOSTER),
} as const satisfies { } as const satisfies {
[k in RewardId]: RewardFunc; [k in RewardId]: Reward | RewardGenerator;
}; };
export type allRewardsType = typeof allRewards; export type allRewardsType = typeof allRewards;

View File

@ -3,7 +3,7 @@ import { getRewardCategory, RewardCategoryId, RewardId } from "#enums/reward-id"
import type { RarityTier } from "#enums/reward-tier"; import type { RarityTier } from "#enums/reward-tier";
import type { TrainerItemId } from "#enums/trainer-item-id"; import type { TrainerItemId } from "#enums/trainer-item-id";
import { allRewards } from "#items/all-rewards"; import { allRewards } from "#items/all-rewards";
import type { RewardFunc, RewardPoolId, RewardSpecs } from "#types/rewards"; import type { RewardPoolId, RewardSpecs } from "#types/rewards";
import { heldItemRarities } from "./held-item-default-tiers"; import { heldItemRarities } from "./held-item-default-tiers";
import { import {
HeldItemReward, HeldItemReward,
@ -62,7 +62,7 @@ export function generateRewardOptionFromId<T extends RewardPoolId>(
return new RewardOption(reward, upgradeCount, tier, cost); return new RewardOption(reward, upgradeCount, tier, cost);
} }
const rewardFunc = allRewards[id] as RewardFunc; const rewardFunc = allRewards[id] as Reward | RewardGenerator;
const reward = rewardFunc instanceof RewardGenerator ? rewardFunc.generateReward(pregenArgs) : rewardFunc; const reward = rewardFunc instanceof RewardGenerator ? rewardFunc.generateReward(pregenArgs) : rewardFunc;
if (reward) { if (reward) {
const tier = tierOverride ?? rewardRarities[id]; const tier = tierOverride ?? rewardRarities[id];

View File

@ -1,7 +1,6 @@
import { globalScene } from "#app/global-scene"; import { globalScene } from "#app/global-scene";
import type { Reward } from "#items/reward"; import type { Reward, RewardGenerator } from "#items/reward";
import { BattlePhase } from "#phases/battle-phase"; import { BattlePhase } from "#phases/battle-phase";
import type { RewardFunc } from "#types/rewards";
import i18next from "i18next"; import i18next from "i18next";
export class RewardPhase extends BattlePhase { export class RewardPhase extends BattlePhase {
@ -10,7 +9,7 @@ export class RewardPhase extends BattlePhase {
public readonly phaseName: "RewardPhase" | "RibbonRewardPhase" | "GameOverRewardPhase" = "RewardPhase"; public readonly phaseName: "RewardPhase" | "RibbonRewardPhase" | "GameOverRewardPhase" = "RewardPhase";
protected reward: Reward; protected reward: Reward;
constructor(rewardFunc: RewardFunc) { constructor(rewardFunc: Reward | RewardGenerator) {
super(); super();
this.reward = rewardFunc(); this.reward = rewardFunc();

View File

@ -1,15 +1,15 @@
import { globalScene } from "#app/global-scene"; import { globalScene } from "#app/global-scene";
import type { PokemonSpecies } from "#data/pokemon-species"; import type { PokemonSpecies } from "#data/pokemon-species";
import { UiMode } from "#enums/ui-mode"; import { UiMode } from "#enums/ui-mode";
import type { Reward, RewardGenerator } from "#items/reward";
import { RewardPhase } from "#phases/reward-phase"; import { RewardPhase } from "#phases/reward-phase";
import type { RewardFunc } from "#types/rewards";
import i18next from "i18next"; import i18next from "i18next";
export class RibbonRewardPhase extends RewardPhase { export class RibbonRewardPhase extends RewardPhase {
public readonly phaseName = "RibbonRewardPhase"; public readonly phaseName = "RibbonRewardPhase";
private species: PokemonSpecies; private species: PokemonSpecies;
constructor(rewardFunc: RewardFunc, species: PokemonSpecies) { constructor(rewardFunc: Reward | RewardGenerator, species: PokemonSpecies) {
super(rewardFunc); super(rewardFunc);
this.species = species; this.species = species;

View File

@ -1,7 +1,6 @@
import { globalScene } from "#app/global-scene"; import { globalScene } from "#app/global-scene";
import { type Reward, RewardGenerator } from "#items/reward"; import { type Reward, RewardGenerator } from "#items/reward";
import { BattlePhase } from "#phases/battle-phase"; import { BattlePhase } from "#phases/battle-phase";
import type { RewardFunc } from "#types/rewards";
import i18next from "i18next"; import i18next from "i18next";
export class RewardPhase extends BattlePhase { export class RewardPhase extends BattlePhase {
@ -10,7 +9,7 @@ export class RewardPhase extends BattlePhase {
public readonly phaseName: "RewardPhase" | "RibbonRewardPhase" | "GameOverRewardPhase" = "RewardPhase"; public readonly phaseName: "RewardPhase" | "RibbonRewardPhase" | "GameOverRewardPhase" = "RewardPhase";
protected reward: Reward; protected reward: Reward;
constructor(rewardFunc: RewardFunc) { constructor(rewardFunc: Reward | RewardGenerator) {
super(); super();
const reward = rewardFunc(); const reward = rewardFunc();

View File

@ -5,8 +5,8 @@ import { Challenges } from "#enums/challenges";
import { MysteryEncounterTier } from "#enums/mystery-encounter-tier"; import { MysteryEncounterTier } from "#enums/mystery-encounter-tier";
import { MysteryEncounterType } from "#enums/mystery-encounter-type"; import { MysteryEncounterType } from "#enums/mystery-encounter-type";
import { SpeciesId } from "#enums/species-id"; import { SpeciesId } from "#enums/species-id";
import { TrainerItemId } from "#enums/trainer-item-id";
import { TextStyle } from "#enums/text-style"; import { TextStyle } from "#enums/text-style";
import { TrainerItemId } from "#enums/trainer-item-id";
import { WeatherType } from "#enums/weather-type"; import { WeatherType } from "#enums/weather-type";
import { addTextObject } from "#ui/text"; import { addTextObject } from "#ui/text";
import type { nil } from "#utils/common"; import type { nil } from "#utils/common";

View File

@ -5,8 +5,8 @@ import { Button } from "#enums/buttons";
import { Command } from "#enums/command"; import { Command } from "#enums/command";
import { PokemonType } from "#enums/pokemon-type"; import { PokemonType } from "#enums/pokemon-type";
import { SpeciesId } from "#enums/species-id"; import { SpeciesId } from "#enums/species-id";
import { TrainerItemId } from "#enums/trainer-item-id";
import { TextStyle } from "#enums/text-style"; import { TextStyle } from "#enums/text-style";
import { TrainerItemId } from "#enums/trainer-item-id";
import { UiMode } from "#enums/ui-mode"; import { UiMode } from "#enums/ui-mode";
import type { CommandPhase } from "#phases/command-phase"; import type { CommandPhase } from "#phases/command-phase";
import { PartyUiHandler, PartyUiMode } from "#ui/party-ui-handler"; import { PartyUiHandler, PartyUiMode } from "#ui/party-ui-handler";

View File

@ -56,4 +56,4 @@ export class ModifierHelper extends GameManagerHelper {
private log(...params: any[]) { private log(...params: any[]) {
console.log("Modifiers:", ...params); console.log("Modifiers:", ...params);
} }
} }

View File

@ -56,4 +56,4 @@ export class ModifierHelper extends GameManagerHelper {
private log(...params: any[]) { private log(...params: any[]) {
console.log("Modifiers:", ...params); console.log("Modifiers:", ...params);
} }
} }