Move all battle state from IPokemon to an ephemeral IBattlePokemon wrapper
This commit is contained in:
@@ -20,23 +20,21 @@ public class MudSportTests
|
||||
/// Creates a fully mocked test setup where the battle has a real <see cref="ScriptSet"/> as its volatile
|
||||
/// script set.
|
||||
/// </summary>
|
||||
private static (MudSport script, IExecutingMove move, IPokemon target, IBattle battle, IScriptSet battleVolatile)
|
||||
CreateTestSetup()
|
||||
private static (MudSport script, IExecutingMove move, IBattlePokemon target, IBattle battle, IScriptSet
|
||||
battleVolatile) CreateTestSetup()
|
||||
{
|
||||
var script = new MudSport();
|
||||
var move = Substitute.For<IExecutingMove>();
|
||||
var target = Substitute.For<IPokemon>();
|
||||
var target = Substitute.For<IBattlePokemon>();
|
||||
|
||||
var battle = Substitute.For<IBattle>();
|
||||
battle.GetScripts().Returns(_ => new ScriptIterator(Array.Empty<IEnumerable<ScriptContainer>>()));
|
||||
IScriptSet battleVolatile = new ScriptSet(battle);
|
||||
battle.Volatile.Returns(battleVolatile);
|
||||
|
||||
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, target, battle, battleVolatile);
|
||||
}
|
||||
@@ -71,25 +69,6 @@ public class MudSportTests
|
||||
await Assert.That(battleVolatile.Contains(ScriptUtils.ResolveName<MudSportEffect>())).IsTrue();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Technical test: without battle data on the user (outside of battle) the secondary effect does nothing
|
||||
/// and does not throw.
|
||||
/// </summary>
|
||||
[Test]
|
||||
public void OnSecondaryEffect_UserHasNoBattleData_DoesNotThrow()
|
||||
{
|
||||
// Arrange
|
||||
var script = new MudSport();
|
||||
var move = Substitute.For<IExecutingMove>();
|
||||
var target = Substitute.For<IPokemon>();
|
||||
var user = Substitute.For<IPokemon>();
|
||||
user.BattleData.Returns((IPokemonBattleData?)null);
|
||||
move.User.Returns(user);
|
||||
|
||||
// Act & Assert - should not throw
|
||||
script.OnSecondaryEffect(move, target, 0);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Bulbapedia: "Mud Sport now reduces the base power of Electric-type moves by 67% (approximated as a
|
||||
/// factor of 1352/4096) on both sides in battle."
|
||||
@@ -101,7 +80,7 @@ public class MudSportTests
|
||||
// Arrange
|
||||
var effect = new MudSportEffect();
|
||||
var electricMove = CreateExecutingMoveOfType("electric");
|
||||
var target = Substitute.For<IPokemon>();
|
||||
var target = Substitute.For<IBattlePokemon>();
|
||||
|
||||
// Act
|
||||
effect.ChangeBasePower(electricMove, target, 0, ref basePower);
|
||||
@@ -120,7 +99,7 @@ public class MudSportTests
|
||||
// Arrange
|
||||
var effect = new MudSportEffect();
|
||||
var fireMove = CreateExecutingMoveOfType("fire");
|
||||
var target = Substitute.For<IPokemon>();
|
||||
var target = Substitute.For<IBattlePokemon>();
|
||||
ushort basePower = 100;
|
||||
|
||||
// Act
|
||||
|
||||
Reference in New Issue
Block a user