Implements freeze, poisoned, badly poisoned
This commit is contained in:
@@ -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 },
|
||||
}));
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user