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

@@ -20,12 +20,12 @@ public class ElectrifyTests
/// <see cref="BattleChoiceQueue"/>. When <paramref name="targetStillHasChoice"/> is false, the queue
/// only contains another Pokémon's choice, simulating a target that already moved this turn.
/// </summary>
private static (Electrify script, IExecutingMove move, IPokemon target, IScriptSet choiceVolatile, IHitData hitData)
CreateTestSetup(bool targetStillHasChoice = true, bool hasQueue = true)
private static (Electrify script, IExecutingMove move, IBattlePokemon target, IScriptSet choiceVolatile, IHitData
hitData) CreateTestSetup(bool targetStillHasChoice = true, bool hasQueue = true)
{
var script = new Electrify();
var move = Substitute.For<IExecutingMove>();
var target = Substitute.For<IPokemon>();
var target = Substitute.For<IBattlePokemon>();
var hitData = Substitute.For<IHitData>();
move.GetHitData(target, 0).Returns(hitData);
@@ -40,9 +40,7 @@ public class ElectrifyTests
var battle = Substitute.For<IBattle>();
battle.ChoiceQueue.Returns(hasQueue ? queue : null);
var battleData = Substitute.For<IPokemonBattleData>();
battleData.Battle.Returns(battle);
target.BattleData.Returns(battleData);
target.Battle.Returns(battle);
return (script, move, target, choiceVolatile, hitData);
}
@@ -111,10 +109,8 @@ public class ElectrifyTests
var library = LibraryHelpers.LoadLibrary();
var battle = Substitute.For<IBattle>();
battle.Library.Returns(library);
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);
await Assert.That(library.StaticLibrary.Types.TryGetTypeIdentifier("normal", out var normal)).IsTrue();
await Assert.That(library.StaticLibrary.Types.TryGetTypeIdentifier("electric", out var electric)).IsTrue();
@@ -127,24 +123,4 @@ public class ElectrifyTests
await Assert.That(moveType).IsNotNull();
await Assert.That(moveType!.Value).IsEqualTo(electric);
}
/// <summary>
/// Technical test: without battle data on the target the move type cannot be resolved and remains
/// unchanged.
/// </summary>
[Test]
public async Task ChangeMoveType_TargetHasNoBattleData_TypeUnchanged()
{
// Arrange
var effect = new ElectrifyEffect();
var target = Substitute.For<IPokemon>();
target.BattleData.Returns((IPokemonBattleData?)null);
TypeIdentifier? moveType = null;
// Act
effect.ChangeMoveType(Substitute.For<IExecutingMove>(), target, 0, ref moveType);
// Assert
await Assert.That(moveType).IsNull();
}
}