This commit is contained in:
34
Plugins/PkmnLib.Plugin.Gen7/Scripts/Abilities/FlowerVeil.cs
Normal file
34
Plugins/PkmnLib.Plugin.Gen7/Scripts/Abilities/FlowerVeil.cs
Normal file
@@ -0,0 +1,34 @@
|
||||
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);
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user