namespace PkmnLib.Plugin.Gen7.Scripts.Abilities;

/// <summary>
/// IncreasedStab is a generic ability that increases the STAB (Same Type Attack Bonus) modifier from 1.5x to 2.0x.
/// This ability is used by abilities like Adaptability.
///
/// <see href="https://bulbapedia.bulbagarden.net/wiki/Adaptability_(Ability)">Bulbapedia - Adaptability</see>
/// </summary>
[Script(ScriptCategory.Ability, "increased_stab")]
public class IncreasedStab : Script, IScriptChangeStabModifier
{
    /// <inheritdoc />
    public void ChangeStabModifier(IExecutingMove executingMove, IPokemon target, byte hitNumber, bool isStab,
        ref float modifier)
    {
        if (!isStab || !modifier.IsApproximatelyEqualTo(1.5f))
            return;
        executingMove.Battle.EventHook.Invoke(new AbilityTriggerEvent(executingMove.User));
        modifier = 2.0f;
    }
}