Fix crash on giving a Pokemon a held item

pull/16/head
Flashfyre 2024-03-06 21:12:31 -05:00
parent 113ac10c1b
commit a4528f5349
1 changed files with 1 additions and 1 deletions

View File

@ -140,7 +140,7 @@ 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;
const maxStackCount = matchingModifier.getMaxStackCount(pokemon.scene);
const maxStackCount = dummyModifier.getMaxStackCount(pokemon.scene);
if (!maxStackCount)
return `${pokemon.name} can\'t take\nthis item!`;
if (matchingModifier && matchingModifier.stackCount === maxStackCount)