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

@@ -21,9 +21,9 @@ public class CounterTests
/// Creates a user whose volatile scripts contain a <see cref="CounterHelperEffect"/> that has recorded
/// an incoming physical hit of the given damage by <paramref name="attacker"/>.
/// </summary>
private static IPokemon CreateUserHitBy(IPokemon? attacker, uint damage, bool physical = true)
private static IBattlePokemon CreateUserHitBy(IBattlePokemon? attacker, uint damage, bool physical = true)
{
var user = Substitute.For<IPokemon>();
var user = Substitute.For<IBattlePokemon>();
var userVolatile = new ScriptSet(user);
user.Volatile.Returns(userVolatile);
user.GetScripts().Returns(_ => new ScriptIterator(new List<IEnumerable<ScriptContainer>>()));
@@ -55,7 +55,7 @@ public class CounterTests
{
// Arrange
var script = new Counter();
var user = Substitute.For<IPokemon>();
var user = Substitute.For<IBattlePokemon>();
var userVolatile = new ScriptSet(user);
user.Volatile.Returns(userVolatile);
user.GetScripts().Returns(_ => new ScriptIterator(new List<IEnumerable<ScriptContainer>>()));
@@ -78,11 +78,11 @@ public class CounterTests
{
// Arrange
var script = new Counter();
var attacker = Substitute.For<IPokemon>();
var attacker = Substitute.For<IBattlePokemon>();
var user = CreateUserHitBy(attacker, 40);
var choice = Substitute.For<IMoveChoice>();
choice.User.Returns(user);
IReadOnlyList<IPokemon?> targets = new IPokemon?[] { Substitute.For<IPokemon>() };
IReadOnlyList<IBattlePokemon?> targets = new IBattlePokemon?[] { Substitute.For<IBattlePokemon>() };
// Act
script.ChangeTargets(choice, ref targets);
@@ -103,7 +103,7 @@ public class CounterTests
var user = CreateUserHitBy(null, 0);
var choice = Substitute.For<IMoveChoice>();
choice.User.Returns(user);
IReadOnlyList<IPokemon?> targets = new IPokemon?[] { Substitute.For<IPokemon>() };
IReadOnlyList<IBattlePokemon?> targets = new IBattlePokemon?[] { Substitute.For<IBattlePokemon>() };
// Act
script.ChangeTargets(choice, ref targets);
@@ -122,7 +122,7 @@ public class CounterTests
{
// Arrange
var script = new Counter();
var attacker = Substitute.For<IPokemon>();
var attacker = Substitute.For<IBattlePokemon>();
var user = CreateUserHitBy(attacker, damageTaken);
var move = Substitute.For<IExecutingMove>();
move.User.Returns(user);
@@ -144,9 +144,9 @@ public class CounterTests
{
// Arrange
var script = new Counter();
var attacker = Substitute.For<IPokemon>();
var attacker = Substitute.For<IBattlePokemon>();
var user = CreateUserHitBy(attacker, 40);
var someoneElse = Substitute.For<IPokemon>();
var someoneElse = Substitute.For<IBattlePokemon>();
var move = Substitute.For<IExecutingMove>();
move.User.Returns(user);
var hitData = Substitute.For<IHitData>();
@@ -167,7 +167,7 @@ public class CounterTests
public async Task CounterHelperEffect_PhysicalHit_RecordsAttackerAndDamage()
{
// Arrange
var attacker = Substitute.For<IPokemon>();
var attacker = Substitute.For<IBattlePokemon>();
var user = CreateUserHitBy(attacker, 40);
// Assert
@@ -184,7 +184,7 @@ public class CounterTests
public async Task CounterHelperEffect_SpecialHit_IsNotRecorded()
{
// Arrange
var attacker = Substitute.For<IPokemon>();
var attacker = Substitute.For<IBattlePokemon>();
var user = CreateUserHitBy(attacker, 40, false);
// Assert