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.
pull/826/head
Dread134 2024-05-13 16:50:50 -04:00
parent ed87293867
commit 1902da079d
1 changed files with 5 additions and 2 deletions

View File

@ -577,8 +577,11 @@ export class FormChangeItemModifierType extends PokemonModifierType implements G
constructor(formChangeItem: FormChangeItem) { 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), 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) => { (pokemon: PlayerPokemon) => {
if (pokemonFormChanges.hasOwnProperty(pokemon.species.speciesId) && !!pokemonFormChanges[pokemon.species.speciesId].find(fc => fc.trigger.hasTriggerType(SpeciesFormChangeItemTrigger) if (pokemonFormChanges.hasOwnProperty(pokemon.species.speciesId)
&& (fc.trigger as SpeciesFormChangeItemTrigger).item === this.formChangeItem)) && !!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 null;
return PartyUiHandler.NoEffectMessage; return PartyUiHandler.NoEffectMessage;