From 1902da079d7dab0e74884381bf159af3a3214e5f Mon Sep 17 00:00:00 2001 From: Dread134 Date: Mon, 13 May 2024 16:50:50 -0400 Subject: [PATCH] Update Item Check Updated item check for when applying item to a Pokemon Used similar code to when generating map for After Battle items list. Gets all item triggers for the Pokemon, then maps it and flattens it down to just a list of items the pokemon can use to change form. Then finally it checks if the current item exists in the list. --- src/modifier/modifier-type.ts | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/src/modifier/modifier-type.ts b/src/modifier/modifier-type.ts index 2457a705b..3ccf33dbe 100644 --- a/src/modifier/modifier-type.ts +++ b/src/modifier/modifier-type.ts @@ -577,8 +577,11 @@ export class FormChangeItemModifierType extends PokemonModifierType implements G constructor(formChangeItem: FormChangeItem) { super(Utils.toReadableString(FormChangeItem[formChangeItem]), `Causes certain Pokémon to change form`, (_type, args) => new Modifiers.PokemonFormChangeItemModifier(this, (args[0] as PlayerPokemon).id, formChangeItem, true), (pokemon: PlayerPokemon) => { - if (pokemonFormChanges.hasOwnProperty(pokemon.species.speciesId) && !!pokemonFormChanges[pokemon.species.speciesId].find(fc => fc.trigger.hasTriggerType(SpeciesFormChangeItemTrigger) - && (fc.trigger as SpeciesFormChangeItemTrigger).item === this.formChangeItem)) + if (pokemonFormChanges.hasOwnProperty(pokemon.species.speciesId) + && !!pokemonFormChanges[pokemon.species.speciesId].find(fc => fc.trigger.hasTriggerType(SpeciesFormChangeItemTrigger)) + && pokemonFormChanges[pokemon.species.speciesId].filter(fc => fc.trigger.hasTriggerType(SpeciesFormChangeItemTrigger)) + .map(fc => fc.findTrigger(SpeciesFormChangeItemTrigger) as SpeciesFormChangeItemTrigger) + .flat().flatMap(fc => fc.item).includes(this.formChangeItem)) return null; return PartyUiHandler.NoEffectMessage;