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

@@ -57,17 +57,17 @@ public class MagmaStormTests
/// iterator is real but empty unless the test attaches scripts (such as the Grip Claw / Binding Band
/// stand-in), so the <see cref="CustomTriggers.ModifyBind"/> trigger pass runs.
/// </summary>
private static (MagmaStorm script, IExecutingMove move, IPokemon target, IScriptSet targetVolatile) CreateTestSetup(
params Script[] userScripts)
private static (MagmaStorm script, IExecutingMove move, IBattlePokemon target, IScriptSet targetVolatile)
CreateTestSetup(params Script[] userScripts)
{
var script = new MagmaStorm();
var move = Substitute.For<IExecutingMove>();
var target = Substitute.For<IPokemon>();
var target = Substitute.For<IBattlePokemon>();
target.GetScripts().Returns(_ => new ScriptIterator(new List<IEnumerable<ScriptContainer>>()));
var targetVolatile = new ScriptSet(target);
target.Volatile.Returns(targetVolatile);
var user = Substitute.For<IPokemon>();
var user = Substitute.For<IBattlePokemon>();
var containers = userScripts.Select(IEnumerable<ScriptContainer> (s) => new ScriptContainer(s)).ToArray();
user.GetScripts().Returns(_ => new ScriptIterator(containers));
move.User.Returns(user);
@@ -116,10 +116,10 @@ public class MagmaStormTests
/// Creates a trapped Pokémon substitute with the given maximum HP, together with the
/// <see cref="MagmaStormEffect"/> that traps it.
/// </summary>
private static (MagmaStormEffect effect, IPokemon owner) CreateTrappedPokemon(uint maxHealth,
private static (MagmaStormEffect effect, IBattlePokemon owner) CreateTrappedPokemon(uint maxHealth,
float percentOfMaxHealth = 1f / 8f)
{
var owner = Substitute.For<IPokemon>();
var owner = Substitute.For<IBattlePokemon>();
owner.MaxHealth.Returns(maxHealth);
owner.Types.Returns(new List<TypeIdentifier> { new(10, "fire") });
return (new MagmaStormEffect(owner, 5, percentOfMaxHealth), owner);
@@ -128,7 +128,7 @@ public class MagmaStormTests
/// <summary>
/// Helper to extract the damage amount from a Pokémon's received Damage calls.
/// </summary>
private static uint? GetDamageAmount(IPokemon pokemon)
private static uint? GetDamageAmount(IBattlePokemon pokemon)
{
var call = pokemon.ReceivedCalls().FirstOrDefault(c => c.GetMethodInfo().Name == "Damage");
return call != null ? (uint)call.GetArguments()[0]! : null;
@@ -137,7 +137,7 @@ public class MagmaStormTests
/// <summary>
/// Runs end-of-turn handling on the effect repeatedly and counts how many turns dealt damage to the target.
/// </summary>
private static int CountEndTurnDamageTicks(MagmaStormEffect effect, IPokemon target, int maxTurns = 10)
private static int CountEndTurnDamageTicks(MagmaStormEffect effect, IBattlePokemon target, int maxTurns = 10)
{
var battle = Substitute.For<IBattle>();
for (var i = 0; i < maxTurns; i++)