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

@@ -35,11 +35,12 @@ public class EchoedVoiceTests
/// Creates a fully mocked test setup where the user's side has a real <see cref="ScriptSet"/> as its
/// volatile scripts.
/// </summary>
private static (EchoedVoice script, IExecutingMove move, IPokemon target, IScriptSet sideScripts) CreateTestSetup()
private static (EchoedVoice script, IExecutingMove move, IBattlePokemon target, IScriptSet sideScripts)
CreateTestSetup()
{
var script = new EchoedVoice();
var move = Substitute.For<IExecutingMove>();
var target = Substitute.For<IPokemon>();
var target = Substitute.For<IBattlePokemon>();
var side = Substitute.For<IBattleSide>();
side.GetScripts().Returns(_ => new ScriptIterator(Array.Empty<IEnumerable<ScriptContainer>>()));
@@ -49,13 +50,10 @@ public class EchoedVoiceTests
var battle = Substitute.For<IBattle>();
battle.Sides.Returns(new[] { side });
var battleData = Substitute.For<IPokemonBattleData>();
battleData.Battle.Returns(battle);
battleData.SideIndex.Returns((byte)0);
var user = Substitute.For<IPokemon>();
user.BattleData.Returns(battleData);
var user = Substitute.For<IBattlePokemon>();
move.User.Returns(user);
user.SideIndex.Returns((byte)0);
user.Battle.Returns(battle);
return (script, move, target, sideScripts);
}
@@ -155,25 +153,6 @@ public class EchoedVoiceTests
await Assert.That(sideScripts.Get<EchoedVoiceData>()!.Stacks).IsEqualTo(2);
}
/// <summary>
/// Technical test: without battle data on the user (outside of battle) the base power hook does
/// nothing and does not throw.
/// </summary>
[Test]
public async Task ChangeBasePower_UserHasNoBattleData_BasePowerUnchanged()
{
// Arrange
var (script, move, target, _) = CreateTestSetup();
move.User.BattleData.Returns((IPokemonBattleData?)null);
ushort basePower = 40;
// Act
script.ChangeBasePower(move, target, 0, ref basePower);
// Assert
await Assert.That(basePower).IsEqualTo((ushort)40);
}
/// <summary>
/// Bulbapedia: the boost only applies on "consecutive" turns — when a Pokémon on the side chooses a
/// move other than Echoed Voice, the <see cref="EchoedVoiceData"/> marker removes itself, resetting