namespace PkmnLib.Plugin.Gen7.Scripts.Abilities;

/// <summary>
/// Minus is an ability that boosts Special Attack if another ally has Plus or Minus.
///
/// <see href="https://bulbapedia.bulbagarden.net/wiki/Minus_(Ability)">Bulbapedia - Minus</see>
/// </summary>
[Script(ScriptCategory.Ability, "minus")]
public class Minus : Script, IScriptChangeOffensiveStatValue
{
    /// <inheritdoc />
    public void ChangeOffensiveStatValue(IExecutingMove move, IPokemon target, byte hit, uint defensiveStat,
        ImmutableStatisticSet<uint> targetStats, Statistic stat, ref uint value)
    {
        var battleData = move.User.BattleData;
        if (battleData is null)
            return;
        if (battleData.BattleSide.Pokemon.WhereNotNull().Any(x => x.IsUsable && x.ActiveAbility?.Name == "plus"))
        {
            value = value.MultiplyOrMax(1.5f);
        }
    }
}