namespace PkmnLib.Plugin.Gen7.Scripts.Abilities;

/// <summary>
/// Anger Point is an ability that maximizes the user's Attack stat when it is hit by a critical hit.
/// The user's Attack stat is raised to +6 stages immediately after taking a critical hit.
///
/// <see href="https://bulbapedia.bulbagarden.net/wiki/Anger_Point_(Ability)">Bulbapedia - Anger Point</see>
/// </summary>
[Script(ScriptCategory.Ability, "anger_point")]
public class AngerPoint : Script, IScriptOnIncomingHit
{
    /// <inheritdoc />
    public void OnIncomingHit(IExecutingMove move, IPokemon target, byte hit)
    {
        if (move.GetHitData(target, hit).IsCritical)
        {
            EventBatchId batchId = new();
            move.Battle.EventHook.Invoke(new AbilityTriggerEvent(target)
            {
                BatchId = batchId,
            });
            target.ChangeStatBoost(Statistic.Attack, 12, true, false, batchId);
        }
    }
}