27 lines
1.1 KiB
C#

namespace PkmnLib.Plugin.Gen7.Scripts.Abilities;
/// <summary>
/// Desolate Land is an ability that creates extremely harsh sunlight when the Pokémon enters battle.
/// This sunlight is so intense that it prevents other weather conditions and makes Water-type moves fail.
/// This ability is exclusive to Primal Groudon.
///
/// <see href="https://bulbapedia.bulbagarden.net/wiki/Desolate_Land_(Ability)">Bulbapedia - Desolate Land</see>
/// </summary>
[Script(ScriptCategory.Ability, "desolate_land")]
public class DesolateLandAbility : Script, IScriptOnSwitchIn
{
/// <inheritdoc />
public void OnSwitchIn(IPokemon pokemon, byte position)
{
var battle = pokemon.BattleData?.Battle;
if (battle == null)
return;
battle.SetWeather(ScriptUtils.ResolveName<Weather.DesolateLands>(), -1);
if (battle.WeatherName == ScriptUtils.ResolveName<Weather.DesolateLands>())
{
((Weather.DesolateLands)battle.WeatherScript.Script!).MarkAsPlaced(pokemon);
battle.EventHook.Invoke(new AbilityTriggerEvent(pokemon));
}
}
}