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

@@ -19,8 +19,8 @@ public class Conversion2Tests
{
private static readonly IDynamicLibrary Library = LibraryHelpers.LoadLibrary();
private static (Conversion2 script, IExecutingMove move, IPokemon user, IPokemon target, IHitData hitData)
CreateTestSetup(TypeIdentifier? lastMoveType)
private static (Conversion2 script, IExecutingMove move, IBattlePokemon user, IBattlePokemon target, IHitData
hitData) CreateTestSetup(TypeIdentifier? lastMoveType)
{
var script = new Conversion2();
@@ -30,15 +30,13 @@ public class Conversion2Tests
battle.Library.Returns(Library);
battle.Random.Returns(random);
var userBattleData = Substitute.For<IPokemonBattleData>();
userBattleData.Battle.Returns(battle);
var user = Substitute.For<IPokemon>();
user.BattleData.Returns(userBattleData);
var user = Substitute.For<IBattlePokemon>();
user.Battle.Returns(battle);
var targetBattleData = Substitute.For<IPokemonBattleData>();
var target = Substitute.For<IBattlePokemon>();
if (lastMoveType == null)
{
targetBattleData.LastMoveChoice.Returns((IMoveChoice?)null);
target.LastMoveChoice.Returns((IMoveChoice?)null);
}
else
{
@@ -48,12 +46,9 @@ public class Conversion2Tests
learnedMove.MoveData.Returns(moveData);
var lastChoice = Substitute.For<IMoveChoice>();
lastChoice.ChosenMove.Returns(learnedMove);
targetBattleData.LastMoveChoice.Returns(lastChoice);
target.LastMoveChoice.Returns(lastChoice);
}
var target = Substitute.For<IPokemon>();
target.BattleData.Returns(targetBattleData);
var move = Substitute.For<IExecutingMove>();
move.User.Returns(user);
var hitData = Substitute.For<IHitData>();
@@ -70,9 +65,9 @@ public class Conversion2Tests
/// <summary>
/// Helper that returns the single type the user was changed to, or null when
/// <see cref="IPokemon.SetTypes"/> was never called.
/// <see cref="IBattlePokemon.SetTypes"/> was never called.
/// </summary>
private static TypeIdentifier? GetSetType(IPokemon user)
private static TypeIdentifier? GetSetType(IBattlePokemon user)
{
var call = user.ReceivedCalls().FirstOrDefault(c => c.GetMethodInfo().Name == "SetTypes");
return call != null ? ((IReadOnlyList<TypeIdentifier>)call.GetArguments()[0]!).Single() : null;