Move all battle state from IPokemon to an ephemeral IBattlePokemon wrapper
This commit is contained in:
@@ -32,9 +32,9 @@ public class ImprisonTests
|
||||
/// Creates the Pokémon that used Imprison, knowing the given moves (with an empty move slot, as real
|
||||
/// movesets can have them), and the <see cref="ImprisonEffect"/> bound to it.
|
||||
/// </summary>
|
||||
private static (ImprisonEffect effect, IPokemon user) CreateImprisonUser(params string[] knownMoves)
|
||||
private static (ImprisonEffect effect, IBattlePokemon user) CreateImprisonUser(params string[] knownMoves)
|
||||
{
|
||||
var user = Substitute.For<IPokemon>();
|
||||
var user = Substitute.For<IBattlePokemon>();
|
||||
var moves = knownMoves.Select(ILearnedMove? (m) => CreateLearnedMove(m)).Append(null).ToArray();
|
||||
user.Moves.Returns(moves);
|
||||
return (new ImprisonEffect(user), user);
|
||||
@@ -43,7 +43,7 @@ public class ImprisonTests
|
||||
/// <summary>
|
||||
/// Creates a move choice by the given Pokémon for a move with the given name.
|
||||
/// </summary>
|
||||
private static IMoveChoice CreateMoveChoice(IPokemon chooser, string moveName)
|
||||
private static IMoveChoice CreateMoveChoice(IBattlePokemon chooser, string moveName)
|
||||
{
|
||||
var choice = Substitute.For<IMoveChoice>();
|
||||
choice.User.Returns(chooser);
|
||||
@@ -63,18 +63,16 @@ public class ImprisonTests
|
||||
// Arrange
|
||||
var script = new Imprison();
|
||||
var move = Substitute.For<IExecutingMove>();
|
||||
var user = Substitute.For<IPokemon>();
|
||||
var user = Substitute.For<IBattlePokemon>();
|
||||
move.User.Returns(user);
|
||||
var target = Substitute.For<IPokemon>();
|
||||
var target = Substitute.For<IBattlePokemon>();
|
||||
|
||||
var battle = Substitute.For<IBattle>();
|
||||
battle.GetScripts().Returns(_ => new ScriptIterator(Array.Empty<IEnumerable<ScriptContainer>>()));
|
||||
var battleVolatile = new ScriptSet(battle);
|
||||
battle.Volatile.Returns(battleVolatile);
|
||||
|
||||
var battleData = Substitute.For<IPokemonBattleData>();
|
||||
battleData.Battle.Returns(battle);
|
||||
target.BattleData.Returns(battleData);
|
||||
target.Battle.Returns(battle);
|
||||
|
||||
// Act
|
||||
script.OnSecondaryEffect(move, target, 0);
|
||||
@@ -83,23 +81,6 @@ public class ImprisonTests
|
||||
await Assert.That(battleVolatile.Get<ImprisonEffect>()).IsNotNull();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Technical test: without battle data on the target (outside of battle) the secondary effect does
|
||||
/// nothing and does not throw.
|
||||
/// </summary>
|
||||
[Test]
|
||||
public void OnSecondaryEffect_TargetHasNoBattleData_DoesNotThrow()
|
||||
{
|
||||
// Arrange
|
||||
var script = new Imprison();
|
||||
var move = Substitute.For<IExecutingMove>();
|
||||
var target = Substitute.For<IPokemon>();
|
||||
target.BattleData.Returns((IPokemonBattleData?)null);
|
||||
|
||||
// Act & Assert
|
||||
script.OnSecondaryEffect(move, target, 0);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Bulbapedia: "opponents cannot use any move which is also known by the user." An opponent choosing a
|
||||
/// move the Imprison user knows has its selection prevented.
|
||||
@@ -109,7 +90,7 @@ public class ImprisonTests
|
||||
{
|
||||
// Arrange
|
||||
var (effect, _) = CreateImprisonUser("tackle", "imprison");
|
||||
var opponent = Substitute.For<IPokemon>();
|
||||
var opponent = Substitute.For<IBattlePokemon>();
|
||||
var choice = CreateMoveChoice(opponent, "tackle");
|
||||
var prevent = false;
|
||||
|
||||
@@ -129,7 +110,7 @@ public class ImprisonTests
|
||||
{
|
||||
// Arrange
|
||||
var (effect, _) = CreateImprisonUser("tackle", "imprison");
|
||||
var opponent = Substitute.For<IPokemon>();
|
||||
var opponent = Substitute.For<IBattlePokemon>();
|
||||
var choice = CreateMoveChoice(opponent, "ember");
|
||||
var prevent = false;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user