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

@@ -17,23 +17,21 @@ public class FreezeShockTests
/// <summary>
/// Creates a fully mocked test setup for Freeze Shock secondary effect tests.
/// </summary>
private static (FreezeShock script, IExecutingMove move, IPokemon target, IPokemon user, IBattleRandom random)
CreateTestSetup()
private static (FreezeShock script, IExecutingMove move, IBattlePokemon target, IBattlePokemon user, IBattleRandom
random) CreateTestSetup()
{
var script = new FreezeShock();
var move = Substitute.For<IExecutingMove>();
var user = Substitute.For<IPokemon>();
var user = Substitute.For<IBattlePokemon>();
move.User.Returns(user);
var battle = Substitute.For<IBattle>();
var random = Substitute.For<IBattleRandom>();
battle.Random.Returns(random);
var battleData = Substitute.For<IPokemonBattleData>();
battleData.Battle.Returns(battle);
var target = Substitute.For<IPokemon>();
target.BattleData.Returns(battleData);
var target = Substitute.For<IBattlePokemon>();
target.Battle.Returns(battle);
return (script, move, target, user, random);
}
@@ -92,24 +90,6 @@ public class FreezeShockTests
await Assert.That(random.ReceivedCalls().Any(c => c.GetMethodInfo().Name == "EffectChance")).IsTrue();
}
/// <summary>
/// Technical test: outside of battle (no battle data on the target) the secondary effect does nothing
/// and does not throw.
/// </summary>
[Test]
public async Task OnSecondaryEffect_TargetHasNoBattleData_DoesNotParalyzeTarget()
{
// Arrange
var (script, move, target, _, _) = CreateTestSetup();
target.BattleData.Returns((IPokemonBattleData?)null);
// Act
script.OnSecondaryEffect(move, target, 0);
// Assert
await Assert.That(target.ReceivedCalls().Any(c => c.GetMethodInfo().Name == "SetStatus")).IsFalse();
}
/// <summary>
/// Bulbapedia: the user is "cloaked in a freezing light" on the charge turn and attacks on the following
/// turn. The concrete script provides the <see cref="RequireChargeEffect"/> volatile that forces the user
@@ -120,7 +100,7 @@ public class FreezeShockTests
{
// Arrange
var script = new FreezeShock();
var user = Substitute.For<IPokemon>();
var user = Substitute.For<IBattlePokemon>();
// Act
var chargeEffect = script.CreateVolatile(user);