Move all battle state from IPokemon to an ephemeral IBattlePokemon wrapper

This commit is contained in:
2026-08-28 15:20:26 +02:00
parent 942be8eaeb
commit 8a2733a0a9
859 changed files with 4408 additions and 5331 deletions

View File

@@ -9,18 +9,18 @@ namespace PkmnLib.Plugin.Gen7.Scripts.Abilities;
[Script(ScriptCategory.Ability, "anticipation")]
public class Anticipation : Script, IScriptOnOpponentSwitchIn
{
private IPokemon? _owner;
private IBattlePokemon? _owner;
/// <inheritdoc />
public override void OnAddedToParent(IScriptSource source)
{
if (source is not IPokemon pokemon)
if (source is not IBattlePokemon pokemon)
throw new ArgumentException("Anticipation script can only be added to a Pokemon.", nameof(source));
_owner = pokemon;
}
/// <inheritdoc />
public void OnOpponentSwitchIn(IPokemon pokemon, byte position)
public void OnOpponentSwitchIn(IBattlePokemon pokemon, byte position)
{
if (_owner is null)
return;
@@ -37,7 +37,7 @@ public class Anticipation : Script, IScriptOnOpponentSwitchIn
if (relevantMoves)
{
pokemon.BattleData?.Battle.EventHook.Invoke(new AbilityTriggerEvent(_owner));
pokemon.Battle.EventHook.Invoke(new AbilityTriggerEvent(_owner));
}
}
}