namespace PkmnLib.Plugin.Gen7.Scripts.Abilities;

/// <summary>
/// Sap Sipper is an ability that grants immunity to Grass-type moves and raises Attack when hit by one.
///
/// <see href="https://bulbapedia.bulbagarden.net/wiki/Sap_Sipper_(Ability)">Bulbapedia - Sap Sipper</see>
/// </summary>
[Script(ScriptCategory.Ability, "sap_sipper")]
public class SapSipper : Script, IScriptIsInvulnerableToMove
{
    /// <inheritdoc />
    public void IsInvulnerableToMove(IExecutingMove move, IPokemon target, ref bool invulnerable)
    {
        if (move.GetHitData(target, 0).Type?.Name == "grass")
        {
            invulnerable = true;
            move.Battle.EventHook.Invoke(new AbilityTriggerEvent(target));
            target.ChangeStatBoost(Statistic.Attack, 1, true, false);
        }
    }
}