namespace PkmnLib.Plugin.Gen7.Scripts.Abilities;

/// <summary>
/// Tangled Feet is an ability that raises evasion if the Pokémon is confused.
///
/// <see href="https://bulbapedia.bulbagarden.net/wiki/Tangled_Feet_(Ability)">Bulbapedia - Tangled Feet</see>
/// </summary>
[Script(ScriptCategory.Ability, "tangled_feet")]
public class TangledFeet : Script, IScriptChangeIncomingAccuracy
{
    /// <inheritdoc />
    public void ChangeIncomingAccuracy(IExecutingMove executingMove, IPokemon target, byte hitIndex,
        ref int modifiedAccuracy)
    {
        if (modifiedAccuracy != 255 && target.Volatile.Contains<Pokemon.Confusion>())
        {
            modifiedAccuracy /= 2;
        }
    }
}