namespace PkmnLib.Plugin.Gen7.Scripts.Abilities;

/// <summary>
/// Aroma Veil is an ability that prevents allies from being affected by moves that prevent the use of moves, such as Taunt, Torment, and Disable.
/// This effect applies to all Pokémon on the same side of the field.
///
/// <see href="https://bulbapedia.bulbagarden.net/wiki/Aroma_Veil_(Ability)">Bulbapedia - Aroma Veil</see>
/// </summary>
[Script(ScriptCategory.Ability, "aroma_veil")]
public class AromaVeil : Script, IScriptOnSwitchIn, IScriptOnSwitchOut
{
    /// <inheritdoc />
    public void OnSwitchIn(IPokemon pokemon, byte position)
    {
        var side = pokemon.BattleData?.BattleSide;
        var effect = side?.VolatileScripts.Add(new Side.AromaVeilEffect())?.Script as Side.AromaVeilEffect;
        effect?.PlacerActivated(pokemon);
    }

    /// <inheritdoc />
    public void OnSwitchOut(IPokemon oldPokemon, byte position)
    {
        var side = oldPokemon.BattleData?.BattleSide;
        var effect = side?.VolatileScripts.Get<Side.AromaVeilEffect>();
        effect?.PlacerDeactivated(oldPokemon);
    }
}