Fixed types in shuckle juice and old gateau

This commit is contained in:
Wlowscha 2025-06-09 18:37:12 +02:00
parent 2678535bef
commit d22f7b1d4a
No known key found for this signature in database
GPG Key ID: 3C8F1AD330565D04
2 changed files with 6 additions and 6 deletions

View File

@ -13,6 +13,7 @@ export interface BASE_STAT_FLAT_PARAMS {
export interface BASE_STAT_FLAT_DATA { export interface BASE_STAT_FLAT_DATA {
statModifier: number; statModifier: number;
stats: Stat[];
} }
/** /**
@ -20,12 +21,10 @@ export interface BASE_STAT_FLAT_DATA {
*/ */
export class BaseStatFlatHeldItem extends HeldItem { export class BaseStatFlatHeldItem extends HeldItem {
public effects: ITEM_EFFECT[] = [ITEM_EFFECT.BASE_STAT_FLAT]; public effects: ITEM_EFFECT[] = [ITEM_EFFECT.BASE_STAT_FLAT];
private stats: Stat[];
public isTransferable = false; public isTransferable = false;
constructor(type: HeldItemId, maxStackCount = 1, stats: Stat[]) { constructor(type: HeldItemId, maxStackCount = 1) {
super(type, maxStackCount); super(type, maxStackCount);
this.stats = stats;
} }
get description(): string { get description(): string {
@ -53,15 +52,16 @@ export class BaseStatFlatHeldItem extends HeldItem {
*/ */
apply(params: BASE_STAT_FLAT_PARAMS): boolean { apply(params: BASE_STAT_FLAT_PARAMS): boolean {
const pokemon = params.pokemon; const pokemon = params.pokemon;
const itemData = pokemon.heldItemManager.heldItems[this.type].data; const itemData = pokemon.heldItemManager.heldItems[this.type]?.data as BASE_STAT_FLAT_DATA;
if (!itemData) { if (!itemData) {
return false; return false;
} }
const statModifier = itemData.statModifier; const statModifier = itemData.statModifier;
const stats = itemData.stats;
const baseStats = params.baseStats; const baseStats = params.baseStats;
// Modifies the passed in baseStats[] array by a flat value, only if the stat is specified in this.stats // Modifies the passed in baseStats[] array by a flat value, only if the stat is specified in this.stats
baseStats.forEach((v, i) => { baseStats.forEach((v, i) => {
if (this.stats.includes(i)) { if (stats.includes(i)) {
const newVal = Math.floor(v + statModifier); const newVal = Math.floor(v + statModifier);
baseStats[i] = Math.min(Math.max(newVal, 1), 999999); baseStats[i] = Math.min(Math.max(newVal, 1), 999999);
} }

View File

@ -63,7 +63,7 @@ export class BaseStatTotalHeldItem extends HeldItem {
*/ */
apply(params: BASE_STAT_TOTAL_PARAMS): boolean { apply(params: BASE_STAT_TOTAL_PARAMS): boolean {
const pokemon = params.pokemon; const pokemon = params.pokemon;
const itemData = pokemon.heldItemManager.heldItems[this.type].data; const itemData = pokemon.heldItemManager.heldItems[this.type]?.data as BASE_STAT_TOTAL_DATA;
if (!itemData) { if (!itemData) {
return false; return false;
} }