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

@@ -10,14 +10,13 @@ namespace PkmnLib.Plugin.Gen7.Scripts.Abilities;
public class Frisk : Script, IScriptOnSwitchIn
{
/// <inheritdoc />
public void OnSwitchIn(IPokemon pokemon, byte position)
public void OnSwitchIn(IBattlePokemon pokemon, byte position)
{
if (pokemon.BattleData?.BattleSide is null)
if (pokemon.BattleSide is null)
return;
// Check if the Pokémon has an opposing side
var opposingSide =
pokemon.BattleData.Battle.Sides.FirstOrDefault(side => side != pokemon.BattleData.BattleSide);
var opposingSide = pokemon.Battle.Sides.FirstOrDefault(side => side != pokemon.BattleSide);
if (opposingSide is null)
return;
@@ -28,7 +27,7 @@ public class Frisk : Script, IScriptOnSwitchIn
// If the opponent has a held item, reveal it
if (opponent.HeldItem != null)
{
pokemon.BattleData.Battle.EventHook.Invoke(new AbilityTriggerEvent(pokemon)
pokemon.Battle.EventHook.Invoke(new AbilityTriggerEvent(pokemon)
{
Metadata = new Dictionary<StringKey, object?>
{