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,11 +5,11 @@ namespace PkmnLib.Plugin.Gen7.Scripts.Pokemon;
[Script(ScriptCategory.Pokemon, "encore")]
public class EncoreEffect : Script, IScriptForceTurnSelection, IScriptOnEndTurn
{
private readonly IPokemon _owner;
private readonly IBattlePokemon _owner;
private readonly StringKey _move;
private int _turns;
public EncoreEffect(IPokemon owner, StringKey move, int turns)
public EncoreEffect(IBattlePokemon owner, StringKey move, int turns)
{
_owner = owner;
_move = move;
@@ -19,12 +19,11 @@ public class EncoreEffect : Script, IScriptForceTurnSelection, IScriptOnEndTurn
/// <inheritdoc />
public void ForceTurnSelection(IBattle battle, byte sideIndex, byte position, ref ITurnChoice? choice)
{
var opposingSideIndex = (byte)(_owner.BattleData?.SideIndex == 0 ? 1 : 0);
var opposingSideIndex = (byte)(_owner.SideIndex == 0 ? 1 : 0);
choice = TurnChoiceHelper.CreateMoveChoice(_owner, _move, opposingSideIndex, position);
if (choice is IMoveChoice { ChosenMove.CurrentPp: <= 0 } moveChoice)
{
choice = moveChoice.User.BattleData?.Battle.Library.MiscLibrary.ReplacementChoice(_owner, opposingSideIndex,
position);
choice = moveChoice.User.Battle.Library.MiscLibrary.ReplacementChoice(_owner, opposingSideIndex, position);
}
}