Even more abilities
All checks were successful
Build / Build (push) Successful in 51s

This commit is contained in:
2025-06-14 13:21:23 +02:00
parent 4b07f36176
commit 5961bb746e
31 changed files with 787 additions and 157 deletions

View File

@@ -0,0 +1,37 @@
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(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);
}
}
}