Implements freeze, poisoned, badly poisoned

This commit is contained in:
2025-05-19 15:56:27 +02:00
parent 9d2c2de17a
commit 405a21e887
5 changed files with 107 additions and 10 deletions

View File

@@ -5,6 +5,7 @@ namespace PkmnLib.Plugin.Gen7.Scripts.Status;
[Script(ScriptCategory.Status, "sleep")]
public class Sleep : Script
{
private IPokemon? _pokemon;
public int Turns { get; set; }
/// <inheritdoc />
@@ -15,6 +16,7 @@ public class Sleep : Script
return;
if (source is not IPokemon pokemon)
throw new InvalidOperationException("Sleep script can only be added to a Pokemon.");
_pokemon = pokemon;
var battleData = pokemon.BattleData;
if (battleData != null)
{
@@ -29,12 +31,7 @@ public class Sleep : Script
Turns--;
if (Turns <= 0)
{
RemoveSelf();
move.User.BattleData?.Battle.EventHook.Invoke(new DialogEvent("pokemon_woke_up",
new Dictionary<string, object>
{
{ "pokemon", move.User },
}));
move.User.ClearStatus();
return;
}
@@ -52,4 +49,13 @@ public class Sleep : Script
return;
prevent = true;
}
/// <inheritdoc />
public override void OnRemove()
{
_pokemon?.BattleData?.Battle.EventHook.Invoke(new DialogEvent("pokemon_woke_up", new Dictionary<string, object>
{
{ "pokemon", _pokemon },
}));
}
}