using PkmnLib.Static.Moves;

namespace PkmnLib.Plugin.Gen7.Scripts.Abilities;

/// <summary>
/// Hustle is an ability that increases the Pokémon's Attack by 50% but lowers the accuracy of its physical moves.
///
/// <see href="https://bulbapedia.bulbagarden.net/wiki/Hustle_(Ability)">Bulbapedia - Hustle</see>
/// </summary>
[Script(ScriptCategory.Ability, "hustle")]
public class Hustle : Script, IScriptChangeOffensiveStatValue, IScriptChangeAccuracy
{
    /// <inheritdoc />
    public void ChangeOffensiveStatValue(IExecutingMove move, IPokemon target, byte hit, uint defensiveStat,
        ImmutableStatisticSet<uint> targetStats, Statistic stat, ref uint value)
    {
        if (stat != Statistic.Attack)
            return;
        value = value.MultiplyOrMax(1.5f);
    }

    /// <inheritdoc />
    public void ChangeAccuracy(IExecutingMove executingMove, IPokemon target, byte hitIndex, ref int modifiedAccuracy)
    {
        if (executingMove.UseMove.Category == MoveCategory.Physical)
        {
            modifiedAccuracy = (int)(modifiedAccuracy * 0.8f);
        }
    }
}