namespace PkmnLib.Plugin.Gen7.Scripts.Abilities;

/// <summary>
/// Filter is an ability that reduces the damage taken from super-effective moves by 25%.
/// This ability is similar to Solid Rock, but is exclusive to certain Pokémon like Mr. Mime.
///
/// <see href="https://bulbapedia.bulbagarden.net/wiki/Filter_(Ability)">Bulbapedia - Filter</see>
/// </summary>
[Script(ScriptCategory.Ability, "filter")]
public class Filter : Script, IScriptChangeIncomingMoveDamageModifier
{
    /// <inheritdoc />
    public void ChangeIncomingMoveDamageModifier(IExecutingMove move, IPokemon target, byte hit, ref float modifier)
    {
        if (move.GetHitData(target, hit).Effectiveness >= 2.0f)
        {
            modifier *= 0.75f;
            move.Battle.EventHook.Invoke(new AbilityTriggerEvent(move.User));
        }
    }
}