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

@@ -129,7 +129,7 @@ public interface IExecutingMove : IScriptSource
/// <summary>
/// The user of the move.
/// </summary>
IPokemon User { get; }
IBattlePokemon User { get; }
/// <summary>
/// The move the user has actually chosen to do.
@@ -151,17 +151,17 @@ public interface IExecutingMove : IScriptSource
/// <summary>
/// Gets a hit data for a target, with a specific index.
/// </summary>
IHitData GetHitData(IPokemon target, byte hit);
IHitData GetHitData(IBattlePokemon target, byte hit);
/// <summary>
/// Checks whether a Pokémon is a target for this move.
/// </summary>
bool IsPokemonTarget(IPokemon target);
bool IsPokemonTarget(IBattlePokemon target);
/// <summary>
/// Gets the index of the hits in this move where the hits for a specific target start.
/// </summary>
int GetTargetIndex(IPokemon target);
int GetTargetIndex(IBattlePokemon target);
/// <summary>
/// Gets a hit based on its raw index.
@@ -171,7 +171,7 @@ public interface IExecutingMove : IScriptSource
/// <summary>
/// Gets the targets of this move.
/// </summary>
IReadOnlyList<IPokemon?> Targets { get; }
IReadOnlyList<IBattlePokemon?> Targets { get; }
/// <summary>
/// The underlying move choice.
@@ -192,12 +192,12 @@ public interface IExecutingMove : IScriptSource
/// <inheritdoc cref="IExecutingMove"/>
public class ExecutingMoveImpl : ScriptSource, IExecutingMove
{
private readonly IReadOnlyList<IPokemon?> _targets;
private readonly IReadOnlyList<IBattlePokemon?> _targets;
private readonly IHitData[] _hits;
private readonly IBattle _battle;
/// <inheritdoc cref="ExecutingMoveImpl"/>
public ExecutingMoveImpl(IReadOnlyList<IPokemon?> targets, byte numberOfHits, ILearnedMove chosenMove,
public ExecutingMoveImpl(IReadOnlyList<IBattlePokemon?> targets, byte numberOfHits, ILearnedMove chosenMove,
IMoveData useMove, IMoveChoice moveChoice, IBattle battle)
{
_targets = targets;
@@ -222,7 +222,7 @@ public class ExecutingMoveImpl : ScriptSource, IExecutingMove
public byte NumberOfHits { get; }
/// <inheritdoc />
public IPokemon User => MoveChoice.User;
public IBattlePokemon User => MoveChoice.User;
/// <inheritdoc />
public ILearnedMove ChosenMove { get; }
@@ -239,7 +239,7 @@ public class ExecutingMoveImpl : ScriptSource, IExecutingMove
public IScriptSet Volatile => MoveChoice.Volatile;
/// <inheritdoc />
public IHitData GetHitData(IPokemon target, byte hit)
public IHitData GetHitData(IBattlePokemon target, byte hit)
{
var targetIndex = _targets.IndexOf(target);
if (targetIndex == -1)
@@ -252,10 +252,10 @@ public class ExecutingMoveImpl : ScriptSource, IExecutingMove
}
/// <inheritdoc />
public bool IsPokemonTarget(IPokemon target) => _targets.Contains(target);
public bool IsPokemonTarget(IBattlePokemon target) => _targets.Contains(target);
/// <inheritdoc />
public int GetTargetIndex(IPokemon target)
public int GetTargetIndex(IBattlePokemon target)
{
var targetIndex = _targets.IndexOf(target);
if (targetIndex == -1)
@@ -273,7 +273,7 @@ public class ExecutingMoveImpl : ScriptSource, IExecutingMove
}
/// <inheritdoc />
public IReadOnlyList<IPokemon?> Targets => _targets.ToList();
public IReadOnlyList<IBattlePokemon?> Targets => _targets.ToList();
/// <inheritdoc />
public IMoveChoice MoveChoice { get; }