namespace PkmnLib.Plugin.Gen7.Scripts.Abilities;

/// <summary>
/// Motor Drive is an ability that grants immunity to Electric-type moves and raises Speed when hit by one.
///
/// <see href="https://bulbapedia.bulbagarden.net/wiki/Motor_Drive_(Ability)">Bulbapedia - Motor Drive</see>
/// </summary>
[Script(ScriptCategory.Ability, "motor_drive")]
public class MotorDrive : Script, IScriptIsInvulnerableToMove
{
    /// <inheritdoc />
    public void IsInvulnerableToMove(IExecutingMove move, IPokemon target, ref bool invulnerable)
    {
        if (move.UseMove.MoveType.Name != "electric")
            return;
        invulnerable = true;
        move.Battle.EventHook.Invoke(new AbilityTriggerEvent(target));
        target.ChangeStatBoost(Statistic.Speed, 1, true, false);
    }
}