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

@@ -11,17 +11,17 @@ namespace PkmnLib.Plugin.Gen7.Tests.Scripts.Moves;
/// </summary>
public class GuardSwapTests
{
private static (GuardSwap script, IExecutingMove move, IPokemon user, IPokemon target) CreateTestSetup(
private static (GuardSwap script, IExecutingMove move, IBattlePokemon user, IBattlePokemon target) CreateTestSetup(
sbyte userDefense, sbyte userSpecialDefense, sbyte targetDefense, sbyte targetSpecialDefense)
{
var script = new GuardSwap();
var move = Substitute.For<IExecutingMove>();
var user = Substitute.For<IPokemon>();
var user = Substitute.For<IBattlePokemon>();
user.StatBoost.Returns(new StatBoostStatisticSet(0, 0, userDefense, 0, userSpecialDefense, 0));
move.User.Returns(user);
var target = Substitute.For<IPokemon>();
var target = Substitute.For<IBattlePokemon>();
target.StatBoost.Returns(new StatBoostStatisticSet(0, 0, targetDefense, 0, targetSpecialDefense, 0));
return (script, move, user, target);
@@ -32,7 +32,7 @@ public class GuardSwapTests
/// null when that stat was not changed. Received-call inspection is used instead of NSubstitute
/// argument matchers because the trailing EventBatchId parameter cannot be bound by <c>Arg.Any</c>.
/// </summary>
private static object?[]? GetStatBoostArgs(IPokemon pokemon, Statistic stat) =>
private static object?[]? GetStatBoostArgs(IBattlePokemon pokemon, Statistic stat) =>
pokemon.ReceivedCalls().Where(c => c.GetMethodInfo().Name == "ChangeStatBoost").Select(c => c.GetArguments())
.FirstOrDefault(args => (Statistic)args[0]! == stat);