Move all battle state from IPokemon to an ephemeral IBattlePokemon wrapper
This commit is contained in:
@@ -44,16 +44,16 @@ public class BindTests
|
||||
}
|
||||
}
|
||||
|
||||
private static (Bind script, IExecutingMove move, IPokemon user, IPokemon target, IScriptSet targetVolatile)
|
||||
CreateTestSetup(params Script[] userScripts)
|
||||
private static (Bind script, IExecutingMove move, IBattlePokemon user, IBattlePokemon target, IScriptSet
|
||||
targetVolatile) CreateTestSetup(params Script[] userScripts)
|
||||
{
|
||||
var script = new Bind();
|
||||
var move = Substitute.For<IExecutingMove>();
|
||||
var target = Substitute.For<IPokemon>();
|
||||
var target = Substitute.For<IBattlePokemon>();
|
||||
var targetVolatile = Substitute.For<IScriptSet>();
|
||||
target.Volatile.Returns(targetVolatile);
|
||||
|
||||
var user = Substitute.For<IPokemon>();
|
||||
var user = Substitute.For<IBattlePokemon>();
|
||||
// RunScriptHook iterates the user's scripts; give the mock a real iterator so the ModifyBind trigger
|
||||
// pass runs (empty unless the test attaches scripts such as the Grip Claw / Binding Band stand-in).
|
||||
var containers = userScripts.Select(IEnumerable<ScriptContainer> (s) => new ScriptContainer(s)).ToArray();
|
||||
@@ -73,7 +73,7 @@ public class BindTests
|
||||
/// <summary>
|
||||
/// Helper to extract the damage amount from the target's first received Damage call.
|
||||
/// </summary>
|
||||
private static uint? GetDamageAmount(IPokemon pokemon)
|
||||
private static uint? GetDamageAmount(IBattlePokemon pokemon)
|
||||
{
|
||||
var call = pokemon.ReceivedCalls().FirstOrDefault(c => c.GetMethodInfo().Name == "Damage");
|
||||
return call != null ? (uint)call.GetArguments()[0]! : null;
|
||||
@@ -82,7 +82,7 @@ public class BindTests
|
||||
/// <summary>
|
||||
/// Runs end-of-turn handling on the effect repeatedly and counts how many turns dealt damage to the target.
|
||||
/// </summary>
|
||||
private static int CountEndTurnDamageTicks(BindEffect effect, IPokemon target, int maxTurns = 10)
|
||||
private static int CountEndTurnDamageTicks(BindEffect effect, IBattlePokemon target, int maxTurns = 10)
|
||||
{
|
||||
var battle = Substitute.For<IBattle>();
|
||||
for (var i = 0; i < maxTurns; i++)
|
||||
@@ -204,7 +204,7 @@ public class BindTests
|
||||
public async Task BindEffect_WhileActive_PreventsSwitching()
|
||||
{
|
||||
// Arrange
|
||||
var target = Substitute.For<IPokemon>();
|
||||
var target = Substitute.For<IBattlePokemon>();
|
||||
var effect = new BindEffect(target, 5, 1f / 8f);
|
||||
var prevent = false;
|
||||
|
||||
@@ -223,7 +223,7 @@ public class BindTests
|
||||
public async Task BindEffect_WhileActive_PreventsRunningAway()
|
||||
{
|
||||
// Arrange
|
||||
var target = Substitute.For<IPokemon>();
|
||||
var target = Substitute.For<IBattlePokemon>();
|
||||
var effect = new BindEffect(target, 5, 1f / 8f);
|
||||
var prevent = false;
|
||||
|
||||
@@ -242,7 +242,7 @@ public class BindTests
|
||||
public async Task BindEffect_AfterDurationExpires_NoLongerPreventsSwitching()
|
||||
{
|
||||
// Arrange
|
||||
var target = Substitute.For<IPokemon>();
|
||||
var target = Substitute.For<IBattlePokemon>();
|
||||
target.MaxHealth.Returns(160u);
|
||||
var effect = new BindEffect(target, 1, 1f / 8f);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user