namespace PkmnLib.Plugin.Gen7.Scripts.Abilities;

/// <summary>
/// Primordial Sea is an ability that creates heavy rain when the Pokémon enters battle and prevents Fire-type moves from being used.
///
/// <see href="https://bulbapedia.bulbagarden.net/wiki/Primordial_Sea_(Ability)">Bulbapedia - Primordial Sea</see>
/// </summary>
[Script(ScriptCategory.Ability, "primordial_sea")]
public class PrimordialSeaAbility : Script, IScriptOnSwitchIn
{
    /// <inheritdoc />
    public void OnSwitchIn(IPokemon pokemon, byte position)
    {
        var battle = pokemon.BattleData?.Battle;
        if (battle == null)
            return;

        battle.SetWeather(ScriptUtils.ResolveName<Weather.PrimordialSea>(), -1);
        if (battle.WeatherName == ScriptUtils.ResolveName<Weather.PrimordialSea>())
        {
            ((Weather.PrimordialSea)battle.WeatherScript.Script!).MarkAsPlaced(pokemon);
            battle.EventHook.Invoke(new AbilityTriggerEvent(pokemon));
        }
    }
}