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

@@ -11,7 +11,8 @@ public static class TargetResolver
/// <summary>
/// Get the targets of a move based on the target type, and the selected side and position to target.
/// </summary>
public static IReadOnlyList<IPokemon?> ResolveTargets(IBattle battle, byte side, byte position, MoveTarget target)
public static IReadOnlyList<IBattlePokemon?> ResolveTargets(IBattle battle, byte side, byte position,
MoveTarget target)
{
return target switch
{
@@ -29,13 +30,10 @@ public static class TargetResolver
/// <summary>
/// Validates whether a given target is valid for a move choice. Returns true if the target is valid.
/// </summary>
public static bool IsValidTarget(byte side, byte position, MoveTarget target, IPokemon user)
public static bool IsValidTarget(byte side, byte position, MoveTarget target, IBattlePokemon user)
{
var userBattleData = user.BattleData;
if (userBattleData == null)
throw new ArgumentNullException(nameof(user.BattleData));
var userSide = userBattleData.SideIndex;
var userPosition = userBattleData.Position;
var userSide = user.SideIndex;
var userPosition = user.Position;
switch (target)
{
@@ -80,7 +78,7 @@ public static class TargetResolver
throw new ArgumentOutOfRangeException(nameof(target), target, null);
}
private static IReadOnlyList<IPokemon?> GetAllTargets(IBattle battle) =>
private static IReadOnlyList<IBattlePokemon?> GetAllTargets(IBattle battle) =>
battle.Sides.SelectMany(x => x.Pokemon).ToList();
private static byte GetOppositeSide(byte side) => side == 0 ? (byte)1 : (byte)0;
@@ -89,7 +87,7 @@ public static class TargetResolver
/// Gets all Pokémon that are adjacent to of directly opposite of a Pokémon. This means the target,
/// the Pokémon left of it, the Pokémon right of it, and the Pokémon opposite of it.
/// </summary>
private static IReadOnlyList<IPokemon?> GetAllAdjacentAndOpponent(IBattle battle, byte side, byte position)
private static IReadOnlyList<IBattlePokemon?> GetAllAdjacentAndOpponent(IBattle battle, byte side, byte position)
{
var left = position - 1;
var right = position + 1;
@@ -123,7 +121,7 @@ public static class TargetResolver
];
}
private static IReadOnlyList<IPokemon?> GetAllAdjacent(IBattle battle, byte side, byte position)
private static IReadOnlyList<IBattlePokemon?> GetAllAdjacent(IBattle battle, byte side, byte position)
{
var left = position - 1;
var right = position + 1;