This commit is contained in:
35
Plugins/PkmnLib.Plugin.Gen7/Scripts/Pokemon/WishEffect.cs
Normal file
35
Plugins/PkmnLib.Plugin.Gen7/Scripts/Pokemon/WishEffect.cs
Normal file
@@ -0,0 +1,35 @@
|
||||
namespace PkmnLib.Plugin.Gen7.Scripts.Pokemon;
|
||||
|
||||
[Script(ScriptCategory.Pokemon, "wish")]
|
||||
public class WishEffect : Script
|
||||
{
|
||||
private IPokemon? _pokemon;
|
||||
private bool _hasDoneFirstTurn;
|
||||
|
||||
/// <inheritdoc />
|
||||
public override void OnAddedToParent(IScriptSource source)
|
||||
{
|
||||
if (source is not IPokemon pokemon)
|
||||
{
|
||||
throw new InvalidOperationException("Wish script can only be added to a Pokemon.");
|
||||
}
|
||||
_pokemon = pokemon;
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
public override void OnEndTurn(IBattle battle)
|
||||
{
|
||||
if (_pokemon == null)
|
||||
return;
|
||||
if (!_hasDoneFirstTurn)
|
||||
{
|
||||
_hasDoneFirstTurn = true;
|
||||
return;
|
||||
}
|
||||
|
||||
if (_pokemon.BattleData?.IsOnBattlefield == true)
|
||||
{
|
||||
_pokemon.Heal(_pokemon.MaxHealth / 2);
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user