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,12 +18,12 @@ namespace PkmnLib.Plugin.Gen7.Tests.Scripts.Moves;
/// </summary>
public class DiveTests
{
private static (Dive script, IExecutingMove move, IPokemon user, ScriptSet userVolatile, IMoveChoice moveChoice)
CreateTestSetup()
private static (Dive script, IExecutingMove move, IBattlePokemon user, ScriptSet userVolatile, IMoveChoice
moveChoice) CreateTestSetup()
{
var script = new Dive();
var move = Substitute.For<IExecutingMove>();
var user = Substitute.For<IPokemon>();
var user = Substitute.For<IBattlePokemon>();
// Use a real script set so the charge volatile added by Dive can be inspected afterwards.
var userVolatile = new ScriptSet(user);
user.Volatile.Returns(userVolatile);
@@ -35,9 +35,7 @@ public class DiveTests
var battle = Substitute.For<IBattle>();
battle.EventHook.Returns(new EventHook());
var battleData = Substitute.For<IPokemonBattleData>();
battleData.Battle.Returns(battle);
user.BattleData.Returns(battleData);
user.Battle.Returns(battle);
return (script, move, user, userVolatile, moveChoice);
}
@@ -126,7 +124,7 @@ public class DiveTests
// Arrange
var (script, move, user, userVolatile, _) = CreateTestSetup();
userVolatile.Add(new DiveEffect(user));
var target = Substitute.For<IPokemon>();
var target = Substitute.For<IBattlePokemon>();
// Act
script.OnSecondaryEffect(move, target, 0);
@@ -248,7 +246,7 @@ public class DiveTests
public async Task OnAfterMoveChoice_ChoiceIsNotDiveCharge_RemovesDiveEffect()
{
// Arrange
var user = Substitute.For<IPokemon>();
var user = Substitute.For<IBattlePokemon>();
var userVolatile = new ScriptSet(user);
user.GetScripts().Returns(_ => new ScriptIterator(new List<IEnumerable<ScriptContainer>>()));
var effect = new DiveEffect(user);
@@ -271,7 +269,7 @@ public class DiveTests
public async Task OnAfterMoveChoice_ChoiceIsDiveCharge_KeepsDiveEffect()
{
// Arrange
var user = Substitute.For<IPokemon>();
var user = Substitute.For<IBattlePokemon>();
var userVolatile = new ScriptSet(user);
user.GetScripts().Returns(_ => new ScriptIterator(new List<IEnumerable<ScriptContainer>>()));
var effect = new DiveEffect(user);