Deukhoofd 97868ab4c6
All checks were successful
Build / Build (push) Successful in 48s
More abilities
2025-06-09 13:44:26 +02:00

34 lines
1.2 KiB
C#

namespace PkmnLib.Plugin.Gen7.Scripts.Abilities;
/// <summary>
/// Flower Veil is an ability that prevents Grass-type allies from having their stats lowered or being afflicted by status conditions.
/// This ability is exclusive to Florges and its evolutionary line.
///
/// <see href="https://bulbapedia.bulbagarden.net/wiki/Flower_Veil_(Ability)">Bulbapedia - Flower Veil</see>
/// </summary>
[Script(ScriptCategory.Ability, "flower_veil")]
public class FlowerVeil : Script
{
private IPokemon? _pokemon;
/// <inheritdoc />
public override void OnAddedToParent(IScriptSource source)
{
if (source is not IPokemon pokemon)
throw new InvalidOperationException("Flower Veil can only be added to a Pokemon script source.");
_pokemon = pokemon;
var effect = _pokemon.BattleData?.BattleSide.VolatileScripts.Add(new Side.FlowerVeilEffect());
(effect?.Script as Side.FlowerVeilEffect)?.OnAdded(_pokemon);
}
/// <inheritdoc />
public override void OnRemove()
{
if (_pokemon is null)
return;
if (_pokemon.BattleData?.BattleSide.VolatileScripts.TryGet<Side.FlowerVeilEffect>(out var script) == true)
{
script.OnRemoved(_pokemon);
}
}
}