Move all battle state from IPokemon to an ephemeral IBattlePokemon wrapper
This commit is contained in:
@@ -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));
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user