Files
PkmnLib.NET/Plugins/PkmnLib.Plugin.Gen7/Scripts/Pokemon/WishEffect.cs

35 lines
887 B
C#

namespace PkmnLib.Plugin.Gen7.Scripts.Pokemon;
[Script(ScriptCategory.Pokemon, "wish")]
public class WishEffect : Script, IScriptOnEndTurn
{
private IBattlePokemon? _pokemon;
private bool _hasDoneFirstTurn;
/// <inheritdoc />
public override void OnAddedToParent(IScriptSource source)
{
if (source is not IBattlePokemon pokemon)
{
throw new InvalidOperationException("Wish script can only be added to a Pokemon.");
}
_pokemon = pokemon;
}
/// <inheritdoc />
public void OnEndTurn(IScriptSource owner, IBattle battle)
{
if (_pokemon == null)
return;
if (!_hasDoneFirstTurn)
{
_hasDoneFirstTurn = true;
return;
}
if (_pokemon.IsOnBattlefield == true)
{
_pokemon.Heal(_pokemon.MaxHealth / 2);
}
}
}