namespace PkmnLib.Plugin.Gen7.Scripts.Abilities;

/// <summary>
/// Delta Stream is an ability that creates strong winds when the Pokémon enters battle.
/// These winds weaken the power of super-effective Flying-type moves and prevent other weather conditions.
/// This ability is exclusive to Mega Rayquaza.
///
/// <see href="https://bulbapedia.bulbagarden.net/wiki/Delta_Stream_(Ability)">Bulbapedia - Delta Stream</see>
/// </summary>
[Script(ScriptCategory.Ability, "delta_stream")]
public class DeltaStreamAbility : Script, IScriptOnSwitchIn
{
    /// <inheritdoc />
    public void OnSwitchIn(IPokemon pokemon, byte position)
    {
        var battle = pokemon.BattleData?.Battle;
        if (battle == null)
            return;

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