More abilities, refactor IPokemon.SetStatus to pass pokemon that caused the status change
All checks were successful
Build / Build (push) Successful in 50s
All checks were successful
Build / Build (push) Successful in 50s
This commit is contained in:
@@ -3,34 +3,18 @@ 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(IScriptSource owner, IBattle battle)
|
||||
{
|
||||
if (_pokemon == null)
|
||||
{
|
||||
if (owner is not IPokemon pokemon)
|
||||
return;
|
||||
}
|
||||
if (!_hasDoneFirstTurn)
|
||||
{
|
||||
_hasDoneFirstTurn = true;
|
||||
return;
|
||||
}
|
||||
_pokemon.SetStatus(ScriptUtils.ResolveName<Status.Sleep>(), true);
|
||||
pokemon.SetStatus(ScriptUtils.ResolveName<Status.Sleep>(), pokemon);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user