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,14 +17,12 @@ public class MirrorMoveTests
/// <summary>
/// Creates a Pokémon on the battlefield at the given side and position.
/// </summary>
private static IPokemon CreateFieldPokemon(byte side, byte position, bool onField = true)
private static IBattlePokemon CreateFieldPokemon(byte side, byte position, bool onField = true)
{
var pokemon = Substitute.For<IPokemon>();
var battleData = Substitute.For<IPokemonBattleData>();
battleData.IsOnBattlefield.Returns(onField);
battleData.SideIndex.Returns(side);
battleData.Position.Returns(position);
pokemon.BattleData.Returns(battleData);
var pokemon = Substitute.For<IBattlePokemon>();
pokemon.IsOnBattlefield.Returns(onField);
pokemon.SideIndex.Returns(side);
pokemon.Position.Returns(position);
return pokemon;
}
@@ -32,7 +30,7 @@ public class MirrorMoveTests
/// Creates a move choice that was executed earlier in the battle: the given Pokémon used the given
/// move against the given target side and position.
/// </summary>
private static IMoveChoice CreatePastMoveChoice(string moveName, IPokemon user, byte targetSide,
private static IMoveChoice CreatePastMoveChoice(string moveName, IBattlePokemon user, byte targetSide,
byte targetPosition)
{
var moveData = Substitute.For<IMoveData>();
@@ -53,7 +51,7 @@ public class MirrorMoveTests
/// position, inside a mocked battle with an (initially empty) turn history and an empty choice queue.
/// The targeted Pokémon is placed on the battlefield at that side and position and returned.
/// </summary>
private static (MirrorMove script, IMoveChoice choice, IBattle battle, IPokemon target) CreateMirrorMoveSetup(
private static (MirrorMove script, IMoveChoice choice, IBattle battle, IBattlePokemon target) CreateMirrorMoveSetup(
byte targetSide, byte targetPosition)
{
var script = new MirrorMove();
@@ -64,10 +62,8 @@ public class MirrorMoveTests
var target = CreateFieldPokemon(targetSide, targetPosition);
battle.GetPokemon(targetSide, targetPosition).Returns(target);
var user = Substitute.For<IPokemon>();
var battleData = Substitute.For<IPokemonBattleData>();
battleData.Battle.Returns(battle);
user.BattleData.Returns(battleData);
var user = Substitute.For<IBattlePokemon>();
user.Battle.Returns(battle);
var choice = Substitute.For<IMoveChoice>();
choice.User.Returns(user);
@@ -263,28 +259,6 @@ public class MirrorMoveTests
choice.DidNotReceive().Fail();
}
/// <summary>
/// Technical test: outside of battle (no battle data) the script cannot resolve a move to copy, so
/// the move name must remain unchanged.
/// </summary>
[Test]
public async Task ChangeMove_NoBattleData_MoveNameUnchanged()
{
// Arrange
var script = new MirrorMove();
var user = Substitute.For<IPokemon>();
user.BattleData.Returns((IPokemonBattleData?)null);
var choice = Substitute.For<IMoveChoice>();
choice.User.Returns(user);
StringKey moveName = "mirror_move";
// Act
script.ChangeMove(choice, ref moveName);
// Assert
await Assert.That(moveName).IsEqualTo(new StringKey("mirror_move"));
}
/// <summary>
/// Technical test: without a running choice queue (no turn is being executed) the script cannot
/// determine the current point in the turn, so the move name must remain unchanged.