Move all battle state from IPokemon to an ephemeral IBattlePokemon wrapper

This commit is contained in:
2026-08-28 15:20:26 +02:00
parent 942be8eaeb
commit 8a2733a0a9
859 changed files with 4408 additions and 5331 deletions

View File

@@ -25,7 +25,7 @@ public class FusionBoltTests
moveData.SecondaryEffect.Returns((ISecondaryEffect?)null);
var learnedMove = Substitute.For<ILearnedMove>();
learnedMove.MoveData.Returns(moveData);
var user = Substitute.For<IPokemon>();
var user = Substitute.For<IBattlePokemon>();
var choice = new MoveChoice(user, learnedMove, 0, 0);
if (failed)
choice.Fail();
@@ -36,7 +36,7 @@ public class FusionBoltTests
/// Creates a fully mocked test setup where the current turn consists of the given choices, executed in
/// order, and the script is evaluating the given executing choice.
/// </summary>
private static (FusionBolt script, IExecutingMove move, IPokemon target) CreateTestSetup(
private static (FusionBolt script, IExecutingMove move, IBattlePokemon target) CreateTestSetup(
IMoveChoice executingChoice, params ITurnChoice[] currentTurnChoices)
{
var script = new FusionBolt();
@@ -46,11 +46,9 @@ public class FusionBoltTests
var battle = Substitute.For<IBattle>();
battle.PreviousTurnChoices.Returns(new List<IReadOnlyList<ITurnChoice>> { currentTurnChoices });
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);
return (script, move, target);
}
@@ -135,10 +133,8 @@ public class FusionBoltTests
new ITurnChoice[] { boltChoice },
});
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 modifier = 1f;
// Act
@@ -229,25 +225,4 @@ public class FusionBoltTests
// Assert
await Assert.That(modifier).IsEqualTo(1f);
}
/// <summary>
/// Technical test: outside of battle (no battle data on the target) the modifier is left unchanged and
/// the hook does not throw.
/// </summary>
[Test]
public async Task ChangeDamageModifier_TargetHasNoBattleData_ModifierUnchanged()
{
// Arrange
var script = new FusionBolt();
var move = Substitute.For<IExecutingMove>();
var target = Substitute.For<IPokemon>();
target.BattleData.Returns((IPokemonBattleData?)null);
var modifier = 1f;
// Act
script.ChangeDamageModifier(move, target, 0, ref modifier);
// Assert
await Assert.That(modifier).IsEqualTo(1f);
}
}