Last couple abilities

This commit is contained in:
2025-06-15 13:32:58 +02:00
parent cd6095455a
commit b11203cb3a
12 changed files with 229 additions and 20 deletions

View File

@@ -8,21 +8,11 @@ namespace PkmnLib.Plugin.Gen7.Scripts.Abilities;
[Script(ScriptCategory.Ability, "shields_down")]
public class ShieldsDown : Script
{
private IPokemon? _owningPokemon;
/// <inheritdoc />
public override void OnAddedToParent(IScriptSource source)
{
if (source is not IPokemon pokemon)
throw new ArgumentException("ShieldsDown script must be added to a Pokemon.", nameof(source));
_owningPokemon = pokemon;
}
/// <inheritdoc />
public override void OnSwitchIn(IPokemon pokemon, byte position) => ChangeFormIfNeeded(pokemon);
/// <inheritdoc />
public override void OnEndTurn(IScriptSource owner, IBattle battle) => ChangeFormIfNeeded(_owningPokemon);
public override void OnEndTurn(IScriptSource owner, IBattle battle) => ChangeFormIfNeeded(owner as IPokemon);
private static void ChangeFormIfNeeded(IPokemon? pokemon)
{