mirror of
https://github.com/pagefaultgames/pokerogue.git
synced 2025-08-13 02:49:26 +02:00
NoneReward
constructed without any parameters; util function to generate reward options never returns null
This commit is contained in:
parent
6f0fb543ac
commit
07dad0981d
@ -36,7 +36,7 @@ import {
|
|||||||
|
|
||||||
// TODO: Move to `reward-utils.ts` and un-exportt
|
// TODO: Move to `reward-utils.ts` and un-exportt
|
||||||
export const allRewards = {
|
export const allRewards = {
|
||||||
[RewardId.NONE]: new NoneReward("", ""),
|
[RewardId.NONE]: new NoneReward(),
|
||||||
|
|
||||||
// Pokeball rewards
|
// Pokeball rewards
|
||||||
[RewardId.POKEBALL]: new AddPokeballReward("pb", PokeballType.POKEBALL, 5, RewardId.POKEBALL),
|
[RewardId.POKEBALL]: new AddPokeballReward("pb", PokeballType.POKEBALL, 5, RewardId.POKEBALL),
|
||||||
|
@ -7,6 +7,7 @@ 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,
|
||||||
|
NoneReward,
|
||||||
type PokemonMoveReward,
|
type PokemonMoveReward,
|
||||||
type RememberMoveReward,
|
type RememberMoveReward,
|
||||||
type Reward,
|
type Reward,
|
||||||
@ -45,7 +46,7 @@ export function generateRewardOptionFromId<T extends RewardPoolId>(
|
|||||||
cost = 0,
|
cost = 0,
|
||||||
tierOverride?: RarityTier,
|
tierOverride?: RarityTier,
|
||||||
upgradeCount = 0,
|
upgradeCount = 0,
|
||||||
): RewardOption | null {
|
): RewardOption {
|
||||||
// Destructure specs into individual parameters
|
// Destructure specs into individual parameters
|
||||||
const pregenArgs = typeof specs === "object" ? specs.args : undefined;
|
const pregenArgs = typeof specs === "object" ? specs.args : undefined;
|
||||||
const id: RewardPoolId = typeof specs === "object" ? specs.id : specs;
|
const id: RewardPoolId = typeof specs === "object" ? specs.id : specs;
|
||||||
@ -62,13 +63,13 @@ 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 Reward | RewardGenerator;
|
const tempReward = allRewards[id] as Reward | RewardGenerator;
|
||||||
const reward = rewardFunc instanceof RewardGenerator ? rewardFunc.generateReward(pregenArgs) : rewardFunc;
|
let reward = tempReward instanceof RewardGenerator ? tempReward.generateReward(pregenArgs) : tempReward;
|
||||||
if (reward) {
|
if (!reward) {
|
||||||
const tier = tierOverride ?? rewardRarities[id];
|
reward = new NoneReward();
|
||||||
return new RewardOption(reward, upgradeCount, tier, cost);
|
|
||||||
}
|
}
|
||||||
return null;
|
const tier = tierOverride ?? rewardRarities[id];
|
||||||
|
return new RewardOption(reward, upgradeCount, tier, cost);
|
||||||
}
|
}
|
||||||
|
|
||||||
export function getPlayerShopRewardOptionsForWave(waveIndex: number, baseCost: number): RewardOption[] {
|
export function getPlayerShopRewardOptionsForWave(waveIndex: number, baseCost: number): RewardOption[] {
|
||||||
|
@ -1519,5 +1519,9 @@ export class RewardOption {
|
|||||||
}
|
}
|
||||||
|
|
||||||
export class NoneReward extends Reward {
|
export class NoneReward extends Reward {
|
||||||
|
constructor() {
|
||||||
|
super("", "");
|
||||||
|
}
|
||||||
|
|
||||||
override apply(): void {}
|
override apply(): void {}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user