namespace PkmnLib.Plugin.Gen7.Scripts.Abilities;

/// <summary>
/// Snow Warning is an ability that creates hail when the Pokémon enters battle.
///
/// <see href="https://bulbapedia.bulbagarden.net/wiki/Snow_Warning_(Ability)">Bulbapedia - Snow Warning</see>
/// </summary>
[Script(ScriptCategory.Ability, "snow_warning")]
public class SnowWarning : Script, IScriptOnSwitchIn
{
    /// <inheritdoc />
    public void OnSwitchIn(IPokemon pokemon, byte position)
    {
        var battleData = pokemon.BattleData;
        if (battleData == null)
            return;

        if (battleData.Battle.WeatherName == ScriptUtils.ResolveName<Weather.Hail>())
            return;

        EventBatchId batchId = new();
        battleData.Battle.EventHook.Invoke(new AbilityTriggerEvent(pokemon));
        battleData.Battle.SetWeather(ScriptUtils.ResolveName<Weather.Hail>(), 5, batchId);
    }
}