using PkmnLib.Static.Moves;

namespace PkmnLib.Plugin.Gen7.Scripts.Abilities;

/// <summary>
/// Wonder Skin is an ability that makes status moves more likely to miss.
///
/// <see href="https://bulbapedia.bulbagarden.net/wiki/Wonder_Skin_(Ability)">Bulbapedia - Wonder Skin</see>
/// </summary>
[Script(ScriptCategory.Ability, "wonder_skin")]
public class WonderSkin : Script, IScriptChangeIncomingAccuracy
{
    /// <inheritdoc />
    public void ChangeIncomingAccuracy(IExecutingMove executingMove, IPokemon target, byte hitIndex,
        ref int modifiedAccuracy)
    {
        if (executingMove.UseMove.Category == MoveCategory.Status && executingMove.UseMove.Accuracy != 255)
        {
            executingMove.Battle.EventHook.Invoke(new AbilityTriggerEvent(target));
            modifiedAccuracy /= 2;
        }
    }
}