namespace PkmnLib.Plugin.Gen7.Scripts.Abilities;

/// <summary>
/// Justified is an ability that raises the Pokémon's Attack stat when hit by a Dark-type move.
///
/// <see href="https://bulbapedia.bulbagarden.net/wiki/Justified_(Ability)">Bulbapedia - Justified</see>
/// </summary>
[Script(ScriptCategory.Ability, "justified")]
public class Justified : Script, IScriptOnIncomingHit
{
    /// <inheritdoc />
    public void OnIncomingHit(IExecutingMove move, IPokemon target, byte hit)
    {
        if (move.GetHitData(target, hit).Type?.Name != "dark")
            return;

        EventBatchId batchId = new();

        move.Battle.EventHook.Invoke(new AbilityTriggerEvent(target)
        {
            BatchId = batchId,
        });
        target.ChangeStatBoost(Statistic.Attack, 1, true, false, batchId);
    }
}