Deukhoofd 1b9d137bb0
All checks were successful
Build / Build (push) Successful in 50s
Surprisingly, more abilities
2025-06-14 13:37:58 +02:00

37 lines
1.2 KiB
C#

namespace PkmnLib.Plugin.Gen7.Scripts.Abilities;
/// <summary>
/// Shed Skin is an ability that gives the Pokémon a chance to heal from a status condition at the end of each turn.
///
/// <see href="https://bulbapedia.bulbagarden.net/wiki/Shed_Skin_(Ability)">Bulbapedia - Shed Skin</see>
/// </summary>
[Script(ScriptCategory.Ability, "shed_skin")]
public class ShedSkin : Script
{
private IPokemon? _owningPokemon;
/// <inheritdoc />
public override void OnAddedToParent(IScriptSource source)
{
if (source is not IPokemon pokemon)
throw new ArgumentException("ShedSkin script must be added to a Pokemon.", nameof(source));
_owningPokemon = pokemon;
}
/// <inheritdoc />
public override void OnEndTurn(IScriptSource owner, IBattle battle)
{
if (_owningPokemon is null || _owningPokemon.StatusScript.IsEmpty)
return;
if (battle.Random.GetInt(3) == 0)
{
EventBatchId batchId = new();
battle.EventHook.Invoke(new AbilityTriggerEvent(_owningPokemon)
{
BatchId = batchId,
});
_owningPokemon.ClearStatus(batchId);
}
}
}