Move all battle state from IPokemon to an ephemeral IBattlePokemon wrapper
This commit is contained in:
@@ -26,12 +26,10 @@ public class MistyTerrainTests
|
||||
var move = Substitute.For<IExecutingMove>();
|
||||
|
||||
var battle = Substitute.For<IBattle>();
|
||||
var battleData = Substitute.For<IPokemonBattleData>();
|
||||
battleData.Battle.Returns(battle);
|
||||
|
||||
var user = Substitute.For<IPokemon>();
|
||||
user.BattleData.Returns(battleData);
|
||||
var user = Substitute.For<IBattlePokemon>();
|
||||
move.User.Returns(user);
|
||||
user.Battle.Returns(battle);
|
||||
|
||||
return (script, move, battle);
|
||||
}
|
||||
@@ -40,12 +38,12 @@ public class MistyTerrainTests
|
||||
/// Creates a mocked setup for the terrain script's base power hook, with a target that is either
|
||||
/// grounded or floating and a hit of the given type (null for a typeless hit).
|
||||
/// </summary>
|
||||
private static (MistyTerrainScript terrain, IExecutingMove move, IPokemon target) CreateTerrainSetup(
|
||||
private static (MistyTerrainScript terrain, IExecutingMove move, IBattlePokemon target) CreateTerrainSetup(
|
||||
bool targetFloating, string? moveType)
|
||||
{
|
||||
var terrain = new MistyTerrainScript();
|
||||
var move = Substitute.For<IExecutingMove>();
|
||||
var target = Substitute.For<IPokemon>();
|
||||
var target = Substitute.For<IBattlePokemon>();
|
||||
target.IsFloating.Returns(targetFloating);
|
||||
|
||||
var hitData = Substitute.For<IHitData>();
|
||||
@@ -67,30 +65,12 @@ public class MistyTerrainTests
|
||||
var (script, move, battle) = CreateMoveTestSetup();
|
||||
|
||||
// Act
|
||||
script.OnSecondaryEffect(move, Substitute.For<IPokemon>(), 0);
|
||||
script.OnSecondaryEffect(move, Substitute.For<IBattlePokemon>(), 0);
|
||||
|
||||
// Assert
|
||||
battle.Received(1).SetTerrain(ScriptUtils.ResolveName<MistyTerrainScript>());
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Technical test: without battle data on the user (outside of battle) the effect does nothing and
|
||||
/// does not throw.
|
||||
/// </summary>
|
||||
[Test]
|
||||
public void OnSecondaryEffect_UserHasNoBattleData_DoesNotSetTerrain()
|
||||
{
|
||||
// Arrange
|
||||
var (script, move, battle) = CreateMoveTestSetup();
|
||||
move.User.BattleData.Returns((IPokemonBattleData?)null);
|
||||
|
||||
// Act
|
||||
script.OnSecondaryEffect(move, Substitute.For<IPokemon>(), 0);
|
||||
|
||||
// Assert
|
||||
battle.DidNotReceiveWithAnyArgs().SetTerrain(default);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Bulbapedia: "It halves the power of Dragon-type moves used against affected Pokémon (regardless of
|
||||
/// whether the user of the move is affected by Misty Terrain)." Halving uses integer division.
|
||||
@@ -172,7 +152,7 @@ public class MistyTerrainTests
|
||||
{
|
||||
// Arrange
|
||||
var terrain = new MistyTerrainScript();
|
||||
var pokemon = Substitute.For<IPokemon>();
|
||||
var pokemon = Substitute.For<IBattlePokemon>();
|
||||
pokemon.IsFloating.Returns(false);
|
||||
var preventStatus = false;
|
||||
|
||||
@@ -192,7 +172,7 @@ public class MistyTerrainTests
|
||||
{
|
||||
// Arrange
|
||||
var terrain = new MistyTerrainScript();
|
||||
var pokemon = Substitute.For<IPokemon>();
|
||||
var pokemon = Substitute.For<IBattlePokemon>();
|
||||
pokemon.IsFloating.Returns(false);
|
||||
var preventStatus = false;
|
||||
|
||||
@@ -212,7 +192,7 @@ public class MistyTerrainTests
|
||||
{
|
||||
// Arrange
|
||||
var terrain = new MistyTerrainScript();
|
||||
var pokemon = Substitute.For<IPokemon>();
|
||||
var pokemon = Substitute.For<IBattlePokemon>();
|
||||
pokemon.IsFloating.Returns(true);
|
||||
var preventStatus = false;
|
||||
|
||||
@@ -233,7 +213,7 @@ public class MistyTerrainTests
|
||||
{
|
||||
// Arrange
|
||||
var terrain = new MistyTerrainScript();
|
||||
var pokemon = Substitute.For<IPokemon>();
|
||||
var pokemon = Substitute.For<IBattlePokemon>();
|
||||
pokemon.IsFloating.Returns(false);
|
||||
var preventVolatileAdd = false;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user