From bc236cd0488d12447dfda5935a4b3c9d1353c014 Mon Sep 17 00:00:00 2001 From: Flashfyre Date: Wed, 6 Mar 2024 20:07:43 -0500 Subject: [PATCH] Add check for max stack count of 0 --- src/modifier/modifier-type.ts | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/modifier/modifier-type.ts b/src/modifier/modifier-type.ts index 95e4c8f358c..baf88fd7ac3 100644 --- a/src/modifier/modifier-type.ts +++ b/src/modifier/modifier-type.ts @@ -140,7 +140,10 @@ export class PokemonHeldItemModifierType extends PokemonModifierType { super(name, description, newModifierFunc, (pokemon: PlayerPokemon) => { const dummyModifier = this.newModifier(pokemon); const matchingModifier = pokemon.scene.findModifier(m => m instanceof Modifiers.PokemonHeldItemModifier && m.pokemonId === pokemon.id && m.matchType(dummyModifier)) as Modifiers.PokemonHeldItemModifier; - if (matchingModifier && matchingModifier.stackCount === matchingModifier.getMaxStackCount(pokemon.scene)) + const maxStackCount = matchingModifier.getMaxStackCount(pokemon.scene); + if (!maxStackCount) + return `${pokemon.name} can\'t take\nthis item!`; + if (matchingModifier && matchingModifier.stackCount === maxStackCount) return `${pokemon.name} has too many\nof this item!`; return null; }, iconImage, group, soundName);