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

@@ -18,7 +18,7 @@ public class MoonlightTests
/// Creates a fully mocked test setup for Moonlight tests. Moonlight targets the user itself, so the
/// returned Pokémon is used as both the move's user and the target of the secondary effect.
/// </summary>
private static (Moonlight moonlight, IExecutingMove move, IPokemon user) CreateTestSetup(uint maxHp,
private static (Moonlight moonlight, IExecutingMove move, IBattlePokemon user) CreateTestSetup(uint maxHp,
string? weatherName)
{
var moonlight = new Moonlight();
@@ -26,12 +26,10 @@ public class MoonlightTests
var battle = Substitute.For<IBattle>();
battle.WeatherName.Returns(weatherName == null ? (StringKey?)null : new StringKey(weatherName));
var battleData = Substitute.For<IPokemonBattleData>();
battleData.Battle.Returns(battle);
var user = Substitute.For<IPokemon>();
user.BattleData.Returns(battleData);
var user = Substitute.For<IBattlePokemon>();
user.BoostedStats.Returns(new StatisticSet<uint>(maxHp, 0, 0, 0, 0, 0));
user.Battle.Returns(battle);
move.User.Returns(user);
return (moonlight, move, user);
@@ -40,7 +38,7 @@ public class MoonlightTests
/// <summary>
/// Helper to extract the heal amount from the user's received Heal calls.
/// </summary>
private static uint? GetHealAmount(IPokemon user)
private static uint? GetHealAmount(IBattlePokemon user)
{
var call = user.ReceivedCalls().FirstOrDefault(c => c.GetMethodInfo().Name == "Heal");
return call != null ? (uint)call.GetArguments()[0]! : null;
@@ -128,25 +126,4 @@ public class MoonlightTests
// Assert
await Assert.That(user.ReceivedCalls().Any(c => c.GetMethodInfo().Name == "Heal")).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 async Task OnSecondaryEffect_UserHasNoBattleData_DoesNotHeal()
{
// Arrange
var moonlight = new Moonlight();
var move = Substitute.For<IExecutingMove>();
var user = Substitute.For<IPokemon>();
user.BattleData.Returns((IPokemonBattleData?)null);
move.User.Returns(user);
// Act
moonlight.OnSecondaryEffect(move, user, 0);
// Assert
await Assert.That(user.ReceivedCalls().Any(c => c.GetMethodInfo().Name == "Heal")).IsFalse();
}
}