Implements freeze, poisoned, badly poisoned
This commit is contained in:
@@ -3,5 +3,48 @@ namespace PkmnLib.Plugin.Gen7.Scripts.Status;
|
||||
[Script(ScriptCategory.Status, "frozen")]
|
||||
public class Frozen : Script
|
||||
{
|
||||
// TODO: Implement the Frozen status effect.
|
||||
private IPokemon? _pokemon;
|
||||
|
||||
/// <inheritdoc />
|
||||
public override void OnAddedToParent(IScriptSource source)
|
||||
{
|
||||
_pokemon = source as IPokemon;
|
||||
if (_pokemon == null)
|
||||
{
|
||||
throw new InvalidOperationException("Frozen script can only be added to a Pokemon.");
|
||||
}
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
public override void PreventMove(IExecutingMove move, ref bool prevent)
|
||||
{
|
||||
if (move.UseMove.MoveType.Name == "fire" || move.UseMove.HasFlag("defrost"))
|
||||
{
|
||||
_pokemon?.ClearStatus();
|
||||
return;
|
||||
}
|
||||
|
||||
prevent = true;
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
public override void OnEndTurn(IBattle battle)
|
||||
{
|
||||
if (_pokemon == null)
|
||||
return;
|
||||
if (battle.Random.GetInt(0, 100) >= 20)
|
||||
return;
|
||||
|
||||
_pokemon.ClearStatus();
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
public override void OnRemove()
|
||||
{
|
||||
_pokemon?.BattleData?.Battle.EventHook.Invoke(new DialogEvent("pokemon_thawed_out",
|
||||
new Dictionary<string, object>
|
||||
{
|
||||
{ "pokemon", _pokemon },
|
||||
}));
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user