namespace PkmnLib.Plugin.Gen7.Scripts.Abilities;

/// <summary>
/// Insomnia is an ability that prevents the Pokémon from falling asleep.
///
/// <see href="https://bulbapedia.bulbagarden.net/wiki/Insomnia_(Ability)">Bulbapedia - Insomnia</see>
/// </summary>
[Script(ScriptCategory.Ability, "insomnia")]
public class Insomnia : Script, IScriptPreventStatusChange
{
    /// <inheritdoc />
    public void PreventStatusChange(IPokemon pokemon, StringKey status, bool selfInflicted, ref bool preventStatus)
    {
        if (status != ScriptUtils.ResolveName<Status.Sleep>())
            return;
        pokemon.BattleData?.Battle.EventHook.Invoke(new AbilityTriggerEvent(pokemon));
        preventStatus = true;
    }
}