Move all battle state from IPokemon to an ephemeral IBattlePokemon wrapper
This commit is contained in:
@@ -19,11 +19,11 @@ public class BeatUpTests
|
||||
{
|
||||
/// <summary>
|
||||
/// Creates a mocked party member with the given base Attack stat, usability, and optional non-volatile
|
||||
/// status script in its <see cref="IPokemon.StatusScript"/>.
|
||||
/// status script in its <see cref="IBattlePokemon.StatusScript"/>.
|
||||
/// </summary>
|
||||
private static IPokemon CreatePartyMember(ushort baseAttack = 100, bool usable = true, Script? status = null)
|
||||
private static IBattlePokemon CreatePartyMember(ushort baseAttack = 100, bool usable = true, Script? status = null)
|
||||
{
|
||||
var pokemon = Substitute.For<IPokemon>();
|
||||
var pokemon = Substitute.For<IBattlePokemon>();
|
||||
pokemon.IsUsable.Returns(usable);
|
||||
pokemon.StatusScript.Returns(status == null ? new ScriptContainer() : new ScriptContainer(status));
|
||||
var form = Substitute.For<IForm>();
|
||||
@@ -35,24 +35,20 @@ public class BeatUpTests
|
||||
/// <summary>
|
||||
/// Creates a fully mocked test setup where the user and the given other Pokémon form a party in a battle.
|
||||
/// </summary>
|
||||
private static (BeatUp script, IMoveChoice choice, IExecutingMove move) CreateTestSetup(IPokemon user,
|
||||
params IPokemon?[] otherPartyMembers)
|
||||
private static (BeatUp script, IMoveChoice choice, IExecutingMove move) CreateTestSetup(IBattlePokemon user,
|
||||
params IBattlePokemon?[] otherPartyMembers)
|
||||
{
|
||||
var script = new BeatUp();
|
||||
|
||||
var members = new List<IPokemon?> { user };
|
||||
var members = new List<IBattlePokemon?> { user };
|
||||
members.AddRange(otherPartyMembers);
|
||||
|
||||
var party = Substitute.For<IPokemonParty>();
|
||||
party.GetEnumerator().Returns(_ => members.GetEnumerator());
|
||||
var battleParty = Substitute.For<IBattleParty>();
|
||||
battleParty.Party.Returns(party);
|
||||
battleParty.BattlePokemon.Returns(members);
|
||||
|
||||
var battle = Substitute.For<IBattle>();
|
||||
battle.Parties.Returns(new[] { battleParty });
|
||||
var battleData = Substitute.For<IPokemonBattleData>();
|
||||
battleData.Battle.Returns(battle);
|
||||
user.BattleData.Returns(battleData);
|
||||
user.Battle.Returns(battle);
|
||||
|
||||
var choice = Substitute.For<IMoveChoice>();
|
||||
choice.User.Returns(user);
|
||||
@@ -121,28 +117,6 @@ public class BeatUpTests
|
||||
await Assert.That(numberOfHits).IsEqualTo((byte)1);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Technical test: outside of battle (no <see cref="IPokemon.BattleData"/>) there are no relevant party
|
||||
/// members, and the number of hits falls back to a single strike.
|
||||
/// </summary>
|
||||
[Test]
|
||||
public async Task ChangeNumberOfHits_NoBattleData_SingleHit()
|
||||
{
|
||||
// Arrange
|
||||
var script = new BeatUp();
|
||||
var user = Substitute.For<IPokemon>();
|
||||
user.BattleData.Returns((IPokemonBattleData?)null);
|
||||
var choice = Substitute.For<IMoveChoice>();
|
||||
choice.User.Returns(user);
|
||||
byte numberOfHits = 3;
|
||||
|
||||
// Act
|
||||
script.ChangeNumberOfHits(choice, ref numberOfHits);
|
||||
|
||||
// Assert
|
||||
await Assert.That(numberOfHits).IsEqualTo((byte)1);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Bulbapedia: "the base power per strike is no longer 10, but instead individually based on the Attack
|
||||
/// base stats of the party Pokémon: BasePower = BaseAttack(PartyMember)/10 + 5".
|
||||
@@ -155,7 +129,7 @@ public class BeatUpTests
|
||||
// Arrange
|
||||
var user = CreatePartyMember(baseAttack);
|
||||
var (script, _, move) = CreateTestSetup(user);
|
||||
var target = Substitute.For<IPokemon>();
|
||||
var target = Substitute.For<IBattlePokemon>();
|
||||
ushort basePower = 10;
|
||||
|
||||
// Act
|
||||
@@ -175,7 +149,7 @@ public class BeatUpTests
|
||||
// Arrange
|
||||
var user = CreatePartyMember(100);
|
||||
var (script, _, move) = CreateTestSetup(user, CreatePartyMember(250));
|
||||
var target = Substitute.For<IPokemon>();
|
||||
var target = Substitute.For<IBattlePokemon>();
|
||||
ushort basePower = 10;
|
||||
|
||||
// Act
|
||||
@@ -197,7 +171,7 @@ public class BeatUpTests
|
||||
var user = CreatePartyMember(100);
|
||||
var (script, _, move) = CreateTestSetup(user, CreatePartyMember(250, status: new Burned()),
|
||||
CreatePartyMember(60));
|
||||
var target = Substitute.For<IPokemon>();
|
||||
var target = Substitute.For<IBattlePokemon>();
|
||||
ushort basePower = 10;
|
||||
|
||||
// Act
|
||||
@@ -217,7 +191,7 @@ public class BeatUpTests
|
||||
// Arrange
|
||||
var user = CreatePartyMember(100);
|
||||
var (script, _, move) = CreateTestSetup(user);
|
||||
var target = Substitute.For<IPokemon>();
|
||||
var target = Substitute.For<IBattlePokemon>();
|
||||
ushort basePower = 10;
|
||||
|
||||
// Act
|
||||
|
||||
Reference in New Issue
Block a user