namespace PkmnLib.Plugin.Gen7.Scripts.Abilities; /// /// Frisk is an ability that reveals the held items of opposing Pokémon when the Pokémon enters battle. /// This ability is commonly associated with Banette and Gothitelle. /// /// Bulbapedia - Frisk /// [Script(ScriptCategory.Ability, "frisk")] public class Frisk : Script, IScriptOnSwitchIn { /// public void OnSwitchIn(IPokemon pokemon, byte position) { if (pokemon.BattleData?.BattleSide is null) return; // Check if the Pokémon has an opposing side var opposingSide = pokemon.BattleData.Battle.Sides.FirstOrDefault(side => side != pokemon.BattleData.BattleSide); if (opposingSide is null) return; EventBatchId batchId = new(); // Iterate through the opposing Pokémon foreach (var opponent in opposingSide.Pokemon.WhereNotNull()) { // If the opponent has a held item, reveal it if (opponent.HeldItem != null) { pokemon.BattleData.Battle.EventHook.Invoke(new AbilityTriggerEvent(pokemon) { Metadata = new Dictionary { { "opponent", opponent }, { "held_item", opponent.HeldItem }, }, BatchId = batchId, }); } } } }