96 lines
3.4 KiB
C#
96 lines
3.4 KiB
C#
using PkmnLib.Dynamic.Models;
|
|
using PkmnLib.Dynamic.ScriptHandling;
|
|
using PkmnLib.Dynamic.ScriptHandling.Registry;
|
|
using PkmnLib.Plugin.Gen7.Scripts.Moves;
|
|
using PkmnLib.Plugin.Gen7.Scripts.Pokemon;
|
|
|
|
namespace PkmnLib.Plugin.Gen7.Tests.Scripts.Moves;
|
|
|
|
/// <summary>
|
|
/// Tests for the <see cref="FakeOut"/> move script.
|
|
/// Gen VII Bulbapedia behavior: "Fake Out inflicts damage and always makes the target flinch, unless it has
|
|
/// the Ability Inner Focus or Shield Dust." and "Fake Out will fail if not used on the first turn the user
|
|
/// is out."
|
|
/// </summary>
|
|
public class FakeOutTests
|
|
{
|
|
/// <summary>
|
|
/// Creates a fully mocked test setup where the user switched in on the given turn and the battle is
|
|
/// currently on the given turn.
|
|
/// </summary>
|
|
private static (FakeOut script, IExecutingMove move) CreateStopSetup(uint switchInTurn, uint currentTurn)
|
|
{
|
|
var script = new FakeOut();
|
|
var move = Substitute.For<IExecutingMove>();
|
|
|
|
var battle = Substitute.For<IBattle>();
|
|
battle.CurrentTurnNumber.Returns(currentTurn);
|
|
|
|
var user = Substitute.For<IBattlePokemon>();
|
|
move.User.Returns(user);
|
|
user.SwitchInTurn.Returns(switchInTurn);
|
|
user.Battle.Returns(battle);
|
|
|
|
return (script, move);
|
|
}
|
|
|
|
/// <summary>
|
|
/// Bulbapedia: "Fake Out will fail if not used on the first turn the user is out." — on the first turn
|
|
/// the user is on the field (its switch-in turn), the move is not stopped. This includes Pokémon sent
|
|
/// out later in the battle, as the check is against the turn the user came out, not the battle's first
|
|
/// turn.
|
|
/// </summary>
|
|
[Test, Arguments(1u, 1u), Arguments(5u, 5u)]
|
|
public async Task StopBeforeMove_FirstTurnOnField_MoveNotStopped(uint switchInTurn, uint currentTurn)
|
|
{
|
|
// Arrange
|
|
var (script, move) = CreateStopSetup(switchInTurn, currentTurn);
|
|
var stop = false;
|
|
|
|
// Act
|
|
script.StopBeforeMove(move, ref stop);
|
|
|
|
// Assert
|
|
await Assert.That(stop).IsFalse();
|
|
}
|
|
|
|
/// <summary>
|
|
/// Bulbapedia: "Fake Out will fail if not used on the first turn the user is out." — on any later turn
|
|
/// the move is stopped.
|
|
/// </summary>
|
|
[Test, Arguments(1u, 2u), Arguments(1u, 10u), Arguments(4u, 5u)]
|
|
public async Task StopBeforeMove_LaterTurnOnField_MoveStopped(uint switchInTurn, uint currentTurn)
|
|
{
|
|
// Arrange
|
|
var (script, move) = CreateStopSetup(switchInTurn, currentTurn);
|
|
var stop = false;
|
|
|
|
// Act
|
|
script.StopBeforeMove(move, ref stop);
|
|
|
|
// Assert
|
|
await Assert.That(stop).IsTrue();
|
|
}
|
|
|
|
/// <summary>
|
|
/// Bulbapedia: "Fake Out inflicts damage and always makes the target flinch" — the secondary effect puts
|
|
/// a <see cref="FlinchEffect"/> on the target.
|
|
/// </summary>
|
|
[Test]
|
|
public async Task OnSecondaryEffect_AddsFlinchEffectToTarget()
|
|
{
|
|
// Arrange
|
|
var script = new FakeOut();
|
|
var move = Substitute.For<IExecutingMove>();
|
|
var target = Substitute.For<IBattlePokemon>();
|
|
target.GetScripts().Returns(_ => new ScriptIterator(Array.Empty<IEnumerable<ScriptContainer>>()));
|
|
IScriptSet volatileSet = new ScriptSet(target);
|
|
target.Volatile.Returns(volatileSet);
|
|
|
|
// Act
|
|
script.OnSecondaryEffect(move, target, 0);
|
|
|
|
// Assert
|
|
await Assert.That(volatileSet.Contains(ScriptUtils.ResolveName<FlinchEffect>())).IsTrue();
|
|
}
|
|
} |