Move all battle state from IPokemon to an ephemeral IBattlePokemon wrapper
This commit is contained in:
@@ -14,16 +14,14 @@ namespace PkmnLib.Plugin.Gen7.Tests.Scripts.Moves;
|
||||
/// </summary>
|
||||
public class CoreEnforcerTests
|
||||
{
|
||||
private static (CoreEnforcer script, IExecutingMove move, IMoveChoice currentChoice, IPokemon target, IHitData
|
||||
private static (CoreEnforcer script, IExecutingMove move, IMoveChoice currentChoice, IBattlePokemon target, IHitData
|
||||
hitData, IBattle battle) CreateTestSetup()
|
||||
{
|
||||
var script = new CoreEnforcer();
|
||||
var battle = Substitute.For<IBattle>();
|
||||
var battleData = Substitute.For<IPokemonBattleData>();
|
||||
battleData.Battle.Returns(battle);
|
||||
var target = Substitute.For<IPokemon>();
|
||||
target.BattleData.Returns(battleData);
|
||||
var target = Substitute.For<IBattlePokemon>();
|
||||
|
||||
target.Battle.Returns(battle);
|
||||
var currentChoice = Substitute.For<IMoveChoice>();
|
||||
var move = Substitute.For<IExecutingMove>();
|
||||
move.MoveChoice.Returns(currentChoice);
|
||||
@@ -120,24 +118,6 @@ public class CoreEnforcerTests
|
||||
hitData.Received(1).Fail();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Technical test: a target without battle data (not in battle) is left untouched.
|
||||
/// </summary>
|
||||
[Test]
|
||||
public void OnSecondaryEffect_TargetHasNoBattleData_DoesNothing()
|
||||
{
|
||||
// Arrange
|
||||
var (script, move, _, target, hitData, _) = CreateTestSetup();
|
||||
target.BattleData.Returns((IPokemonBattleData?)null);
|
||||
|
||||
// Act
|
||||
script.OnSecondaryEffect(move, target, 0);
|
||||
|
||||
// Assert
|
||||
target.DidNotReceive().SuppressAbility();
|
||||
hitData.DidNotReceive().Fail();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Bulbapedia: the condition is that "the target has already used a move" — an action by a different
|
||||
/// Pokémon (e.g. the user's ally in a Double Battle) does not count as the target having acted.
|
||||
@@ -148,7 +128,7 @@ public class CoreEnforcerTests
|
||||
// Arrange
|
||||
var (script, move, currentChoice, target, hitData, battle) = CreateTestSetup();
|
||||
var allyChoice = Substitute.For<IMoveChoice>();
|
||||
allyChoice.User.Returns(Substitute.For<IPokemon>());
|
||||
allyChoice.User.Returns(Substitute.For<IBattlePokemon>());
|
||||
SetTurnChoices(battle, allyChoice, currentChoice);
|
||||
|
||||
// Act
|
||||
@@ -162,7 +142,7 @@ public class CoreEnforcerTests
|
||||
/// <summary>
|
||||
/// Bulbapedia: "The move cannot suppress certain signature abilities including Multitype, Stance
|
||||
/// Change, Schooling, Comatose, Shields Down, Disguise, RKS System, Battle Bond, Power Construct".
|
||||
/// The script requests the suppression unconditionally; <see cref="IPokemon.SuppressAbility"/> refuses
|
||||
/// The script requests the suppression unconditionally; <see cref="IBattlePokemon.SuppressAbility"/> refuses
|
||||
/// it when <see cref="IAbility.CanBeChanged"/> is false, so these abilities must carry that flag in the
|
||||
/// Gen7 data.
|
||||
/// </summary>
|
||||
|
||||
Reference in New Issue
Block a user