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

@@ -18,20 +18,18 @@ public class MetronomeTests
/// Creates a fully mocked test setup for Metronome tests. The user's move library and battle random are
/// mocked so that tests control which move <see cref="Metronome.ChangeMove"/> "randomly" rolls.
/// </summary>
private static (Metronome metronome, IMoveChoice choice, IPokemon user, IReadOnlyMoveLibrary moveLibrary,
private static (Metronome metronome, IMoveChoice choice, IBattlePokemon user, IReadOnlyMoveLibrary moveLibrary,
IBattleRandom random) CreateTestSetup()
{
var metronome = new Metronome();
var user = Substitute.For<IPokemon>();
var user = Substitute.For<IBattlePokemon>();
var choice = Substitute.For<IMoveChoice>();
choice.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);
user.BattleData.Returns(battleData);
user.Battle.Returns(battle);
var moveLibrary = Substitute.For<IReadOnlyMoveLibrary>();
var staticLibrary = Substitute.For<IStaticLibrary>();
@@ -73,27 +71,6 @@ public class MetronomeTests
await Assert.That(moveName).IsEqualTo(new StringKey("tackle"));
}
/// <summary>
/// Technical test: if the user has no <see cref="IPokemon.BattleData"/>, the script cannot roll a random
/// move and must leave the move name unchanged.
/// </summary>
[Test]
public async Task ChangeMove_UserHasNoBattleData_MoveNameUnchanged()
{
// Arrange
var (metronome, choice, user, moveLibrary, random) = CreateTestSetup();
user.BattleData.Returns((IPokemonBattleData?)null);
var tackle = CreateMoveData("tackle");
moveLibrary.GetRandom(random).Returns(tackle);
var moveName = new StringKey("metronome");
// Act
metronome.ChangeMove(choice, ref moveName);
// Assert
await Assert.That(moveName).IsEqualTo(new StringKey("metronome"));
}
/// <summary>
/// Bulbapedia: "Metronome cannot select a Max Move, a Z-Move, or any of the moves" in its list of
/// unselectable moves. When an unselectable move is rolled, the script rerolls until it finds a