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

@@ -5,28 +5,28 @@ namespace PkmnLib.Plugin.Gen7.Scripts.Pokemon;
[Script(ScriptCategory.Pokemon, "bide")]
public class BideEffect : Script, IScriptForceTurnSelection, IScriptOnIncomingHit, IScriptOnDamage
{
private readonly IPokemon? _owner;
private readonly IBattlePokemon? _owner;
public byte Turns;
public uint DamageTaken;
public readonly List<IPokemon> HitBy = [];
public readonly List<IBattlePokemon> HitBy = [];
private BideEffect()
{
}
public BideEffect(IPokemon owner)
public BideEffect(IBattlePokemon owner)
{
_owner = owner;
}
/// <inheritdoc />
public void OnIncomingHit(IExecutingMove move, IPokemon target, byte hit)
public void OnIncomingHit(IExecutingMove move, IBattlePokemon target, byte hit)
{
HitBy.Add(move.User);
}
/// <inheritdoc />
public void OnDamage(IPokemon pokemon, DamageSource source, uint oldHealth, uint newHealth)
public void OnDamage(IBattlePokemon pokemon, DamageSource source, uint oldHealth, uint newHealth)
{
DamageTaken += oldHealth - newHealth;
}
@@ -38,16 +38,15 @@ public class BideEffect : Script, IScriptForceTurnSelection, IScriptOnIncomingHi
{
if (_owner == null)
return;
var ownerBattleData = _owner.BattleData;
if (ownerBattleData == null)
if (_owner == null)
return;
if (ownerBattleData.SideIndex != sideIndex || ownerBattleData.Position != position)
if (_owner.SideIndex != sideIndex || _owner.Position != position)
return;
if (_choice != null)
{
choice = _choice;
return;
}
choice = _choice = TurnChoiceHelper.CreateMoveChoice(_owner, "bide", ownerBattleData.SideIndex, position);
choice = _choice = TurnChoiceHelper.CreateMoveChoice(_owner, "bide", _owner.SideIndex, position);
}
}