namespace PkmnLib.Plugin.Gen7.Scripts.Abilities; /// /// Psychic Surge is an ability that creates Psychic Terrain when the Pokémon enters battle. /// /// Bulbapedia - Psychic Surge /// [Script(ScriptCategory.Ability, "psychic_surge")] public class PsychicSurge : Script, IScriptOnSwitchIn { /// public void OnSwitchIn(IPokemon pokemon, byte position) { if (pokemon.BattleData?.Battle is null) return; var terrainName = ScriptUtils.ResolveName(); if (pokemon.BattleData.Battle.TerrainName == terrainName) return; EventBatchId batchId = new(); pokemon.BattleData.Battle.EventHook.Invoke(new AbilityTriggerEvent(pokemon) { BatchId = batchId, }); pokemon.BattleData.Battle.SetTerrain(terrainName, batchId); } }