namespace PkmnLib.Plugin.Gen7.Scripts.Abilities;

/// <summary>
/// Electric Surge is an ability that creates Electric Terrain when the Pokémon enters battle.
/// This terrain prevents grounded Pokémon from falling asleep and boosts Electric-type moves.
/// This ability is exclusive to Tapu Koko.
///
/// <see href="https://bulbapedia.bulbagarden.net/wiki/Electric_Surge_(Ability)">Bulbapedia - Electric Surge</see>
/// </summary>
[Script(ScriptCategory.Ability, "electric_surge")]
public class ElectricSurge : Script, IScriptOnSwitchIn
{
    /// <inheritdoc />
    public void OnSwitchIn(IPokemon pokemon, byte position)
    {
        var battleData = pokemon.BattleData;
        if (battleData == null)
            return;

        EventBatchId batchId = new();
        battleData.Battle.EventHook.Invoke(new AbilityTriggerEvent(pokemon)
        {
            BatchId = batchId,
        });
        battleData.Battle.SetTerrain(ScriptUtils.ResolveName<Terrain.ElectricTerrain>(), batchId);
    }
}