This commit is contained in:
36
Plugins/PkmnLib.Plugin.Gen7/Scripts/Pokemon/YawnEffect.cs
Normal file
36
Plugins/PkmnLib.Plugin.Gen7/Scripts/Pokemon/YawnEffect.cs
Normal file
@@ -0,0 +1,36 @@
|
||||
namespace PkmnLib.Plugin.Gen7.Scripts.Pokemon;
|
||||
|
||||
[Script(ScriptCategory.Pokemon, "yawn")]
|
||||
public class YawnEffect : Script
|
||||
{
|
||||
private IPokemon? _pokemon;
|
||||
private bool _hasDoneFirstTurn;
|
||||
|
||||
/// <inheritdoc />
|
||||
public override void OnAddedToParent(IScriptSource source)
|
||||
{
|
||||
if (source is IPokemon pokemon)
|
||||
{
|
||||
_pokemon = pokemon;
|
||||
}
|
||||
else
|
||||
{
|
||||
throw new InvalidOperationException("YawnEffect can only be added to a Pokemon.");
|
||||
}
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
public override void OnEndTurn(IBattle battle)
|
||||
{
|
||||
if (_pokemon == null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
if (!_hasDoneFirstTurn)
|
||||
{
|
||||
_hasDoneFirstTurn = true;
|
||||
return;
|
||||
}
|
||||
_pokemon.SetStatus(ScriptUtils.ResolveName<Status.Sleep>());
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user