using PkmnLib.Static.Moves;

namespace PkmnLib.Plugin.Gen7.Scripts.Abilities;

/// <summary>
/// Weak Armor is an ability that lowers Defense and raises Speed when hit by a physical move.
///
/// <see href="https://bulbapedia.bulbagarden.net/wiki/Weak_Armor_(Ability)">Bulbapedia - Weak Armor</see>
/// </summary>
[Script(ScriptCategory.Ability, "weak_armor")]
public class WeakArmor : Script, IScriptOnIncomingHit
{
    /// <inheritdoc />
    public void OnIncomingHit(IExecutingMove move, IPokemon target, byte hit)
    {
        if (move.UseMove.Category != MoveCategory.Physical)
            return;

        target.BattleData?.Battle.EventHook.Invoke(new AbilityTriggerEvent(target));
        target.ChangeStatBoost(Statistic.Defense, -1, true, false);
        target.ChangeStatBoost(Statistic.Speed, 1, true, false);
    }
}