Move all battle state from IPokemon to an ephemeral IBattlePokemon wrapper
This commit is contained in:
@@ -31,12 +31,12 @@ public class MimicTests
|
||||
/// Creates a fully mocked executing Mimic move. The user knows one other move in slot 0 and Mimic in
|
||||
/// slot 1. If <paramref name="targetLastUsedMove"/> is null, the target has not used a move yet.
|
||||
/// </summary>
|
||||
private static (IExecutingMove move, IPokemon user, IPokemon target, IHitData hitData) CreateTestSetup(
|
||||
private static (IExecutingMove move, IBattlePokemon user, IBattlePokemon target, IHitData hitData) CreateTestSetup(
|
||||
string? targetLastUsedMove, string userOtherMove = "swords_dance")
|
||||
{
|
||||
var move = Substitute.For<IExecutingMove>();
|
||||
var user = Substitute.For<IPokemon>();
|
||||
var target = Substitute.For<IPokemon>();
|
||||
var user = Substitute.For<IBattlePokemon>();
|
||||
var target = Substitute.For<IBattlePokemon>();
|
||||
move.User.Returns(user);
|
||||
var hitData = Substitute.For<IHitData>();
|
||||
move.GetHitData(target, 0).Returns(hitData);
|
||||
@@ -49,20 +49,18 @@ public class MimicTests
|
||||
var userMoves = new[] { CreateLearnedMove(userOtherMove), mimicMove };
|
||||
user.Moves.Returns(userMoves);
|
||||
|
||||
var battleData = Substitute.For<IPokemonBattleData>();
|
||||
if (targetLastUsedMove != null)
|
||||
{
|
||||
var lastChoice = Substitute.For<IMoveChoice>();
|
||||
var lastUsedMove = CreateLearnedMove(targetLastUsedMove);
|
||||
lastChoice.ChosenMove.Returns(lastUsedMove);
|
||||
battleData.LastMoveChoice.Returns(lastChoice);
|
||||
target.LastMoveChoice.Returns(lastChoice);
|
||||
}
|
||||
else
|
||||
{
|
||||
battleData.LastMoveChoice.Returns((IMoveChoice?)null);
|
||||
target.LastMoveChoice.Returns((IMoveChoice?)null);
|
||||
}
|
||||
|
||||
target.BattleData.Returns(battleData);
|
||||
return (move, user, target, hitData);
|
||||
}
|
||||
|
||||
@@ -84,9 +82,9 @@ public class MimicTests
|
||||
hitData.ReceivedCalls().Any(c => c.GetMethodInfo().Name == "Fail");
|
||||
|
||||
/// <summary>
|
||||
/// Helper to extract the arguments of the user's received <see cref="IPokemon.LearnTemporaryMove"/> call.
|
||||
/// Helper to extract the arguments of the user's received <see cref="IBattlePokemon.LearnTemporaryMove"/> call.
|
||||
/// </summary>
|
||||
private static (StringKey moveName, byte index)? GetLearnedMove(IPokemon user)
|
||||
private static (StringKey moveName, byte index)? GetLearnedMove(IBattlePokemon user)
|
||||
{
|
||||
var call = user.ReceivedCalls().FirstOrDefault(c => c.GetMethodInfo().Name == "LearnTemporaryMove");
|
||||
if (call == null)
|
||||
|
||||
Reference in New Issue
Block a user