Move all battle state from IPokemon to an ephemeral IBattlePokemon wrapper
This commit is contained in:
@@ -19,12 +19,12 @@ public class BanefulBunkerTests
|
||||
/// <see cref="ProtectionScript.OnSecondaryEffect"/>. The <c>target</c> of the secondary effect is the
|
||||
/// Pokémon using Baneful Bunker itself, as the move is self-targeted.
|
||||
/// </summary>
|
||||
private static (BanefulBunker script, IExecutingMove move, IPokemon target, IHitData hitData, IScriptSet volatileSet
|
||||
) CreateProtectSetup(bool userMovesLast, float randomRoll)
|
||||
private static (BanefulBunker script, IExecutingMove move, IBattlePokemon target, IHitData hitData, IScriptSet
|
||||
volatileSet ) CreateProtectSetup(bool userMovesLast, float randomRoll)
|
||||
{
|
||||
var script = new BanefulBunker();
|
||||
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);
|
||||
|
||||
@@ -38,9 +38,7 @@ public class BanefulBunkerTests
|
||||
battle.ChoiceQueue.Returns(queue);
|
||||
battle.Random.Returns(random);
|
||||
|
||||
var battleData = Substitute.For<IPokemonBattleData>();
|
||||
battleData.Battle.Returns(battle);
|
||||
target.BattleData.Returns(battleData);
|
||||
target.Battle.Returns(battle);
|
||||
|
||||
// Give the mock a real script iterator (used by the volatile add hook) and a real volatile script set.
|
||||
target.GetScripts().Returns(_ => new ScriptIterator(Array.Empty<IEnumerable<ScriptContainer>>()));
|
||||
@@ -54,12 +52,12 @@ public class BanefulBunkerTests
|
||||
/// Creates a fully mocked setup for driving <see cref="BanefulBunkerEffect.BlockIncomingHit"/>, the
|
||||
/// volatile script that <see cref="BanefulBunker"/> attaches to its user.
|
||||
/// </summary>
|
||||
private static (BanefulBunkerEffect effect, IExecutingMove move, IPokemon target, IPokemon attacker)
|
||||
private static (BanefulBunkerEffect effect, IExecutingMove move, IBattlePokemon target, IBattlePokemon attacker)
|
||||
CreateBlockSetup(bool isContact, bool hasProtectFlag, MoveCategory category = MoveCategory.Physical)
|
||||
{
|
||||
var effect = new BanefulBunkerEffect();
|
||||
var move = Substitute.For<IExecutingMove>();
|
||||
var target = Substitute.For<IPokemon>();
|
||||
var target = Substitute.For<IBattlePokemon>();
|
||||
var hitData = Substitute.For<IHitData>();
|
||||
hitData.IsContact.Returns(isContact);
|
||||
move.GetHitData(target, 0).Returns(hitData);
|
||||
@@ -69,19 +67,17 @@ public class BanefulBunkerTests
|
||||
useMove.Category.Returns(category);
|
||||
move.UseMove.Returns(useMove);
|
||||
|
||||
var attacker = Substitute.For<IPokemon>();
|
||||
var attacker = Substitute.For<IBattlePokemon>();
|
||||
attacker.GetScripts().Returns(_ => new ScriptIterator(Array.Empty<IEnumerable<ScriptContainer>>()));
|
||||
move.User.Returns(attacker);
|
||||
|
||||
target.BattleData.Returns(Substitute.For<IPokemonBattleData>());
|
||||
|
||||
return (effect, move, target, attacker);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Helper to extract the status name from a Pokémon's received <see cref="IPokemon.SetStatus"/> calls.
|
||||
/// Helper to extract the status name from a Pokémon's received <see cref="IBattlePokemon.SetStatus"/> calls.
|
||||
/// </summary>
|
||||
private static string? GetStatusSet(IPokemon pokemon)
|
||||
private static string? GetStatusSet(IBattlePokemon pokemon)
|
||||
{
|
||||
var call = pokemon.ReceivedCalls().FirstOrDefault(c => c.GetMethodInfo().Name == "SetStatus");
|
||||
return call != null ? ((StringKey)call.GetArguments()[0]!).ToString() : null;
|
||||
|
||||
Reference in New Issue
Block a user