namespace PkmnLib.Plugin.Gen7.Scripts.Abilities;

/// <summary>
/// Dark Aura is an ability that increases the power of Dark-type moves by 33% for all Pokémon on the field.
/// The effect can be modified by other abilities (such as Aura Break) via a custom script hook.
/// 
/// <see href="https://bulbapedia.bulbagarden.net/wiki/Dark_Aura_(Ability)">Bulbapedia - Dark Aura</see>
/// </summary>
[Script(ScriptCategory.Ability, "dark_aura")]
public class DarkAura : Script, IScriptChangeDamageModifier
{
    /// <inheritdoc />
    public void ChangeDamageModifier(IExecutingMove move, IPokemon target, byte hit, ref float modifier)
    {
        if (move.GetHitData(target, hit).Type?.Name == "dark")
        {
            var auraModifier = 5448f / 4096f;
            var args = new CustomTriggers.ModifyAuraEffectArgs(move, target, hit, auraModifier);
            move.Battle.Sides.SelectMany(side => side.Pokemon).WhereNotNull()
                .RunScriptHook<IScriptCustomTrigger>(x => x.CustomTrigger(CustomTriggers.ModifyAuraEffect, args));
            auraModifier = args.AuraEffect;
            modifier *= auraModifier;
            move.Battle.EventHook.Invoke(new AbilityTriggerEvent(move.User));
        }
    }
}