This commit is contained in:
@@ -0,0 +1,94 @@
|
||||
using PkmnLib.Dynamic.Models;
|
||||
using PkmnLib.Plugin.Gen7.Scripts.Moves;
|
||||
using PkmnLib.Static;
|
||||
using PkmnLib.Static.Moves;
|
||||
|
||||
namespace PkmnLib.Plugin.Gen7.Tests.Scripts.Moves;
|
||||
|
||||
/// <summary>
|
||||
/// Tests for the <see cref="FoulPlay"/> move script.
|
||||
/// Behavior is verified against the Bulbapedia page for Foul Play (Generation VII behavior).
|
||||
/// </summary>
|
||||
public class FoulPlayTests
|
||||
{
|
||||
/// <summary>
|
||||
/// Creates a fully mocked test setup for Foul Play tests, with a target whose (boosted) offensive
|
||||
/// stats are set to the given values.
|
||||
/// </summary>
|
||||
private static (FoulPlay script, IExecutingMove move, IPokemon target) CreateTestSetup(MoveCategory category,
|
||||
uint targetAttack, uint targetSpecialAttack)
|
||||
{
|
||||
var script = new FoulPlay();
|
||||
var move = Substitute.For<IExecutingMove>();
|
||||
var useMove = Substitute.For<IMoveData>();
|
||||
useMove.Category.Returns(category);
|
||||
move.UseMove.Returns(useMove);
|
||||
|
||||
var target = Substitute.For<IPokemon>();
|
||||
target.BoostedStats.Returns(new StatisticSet<uint>(100, targetAttack, 80, targetSpecialAttack, 80, 80));
|
||||
|
||||
var user = Substitute.For<IPokemon>();
|
||||
move.User.Returns(user);
|
||||
|
||||
return (script, move, target);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Bulbapedia: "Foul Play inflicts damage. It uses the target's Attack stat to calculate damage instead
|
||||
/// of the user's."
|
||||
/// The offensive stat value (initially the user's Attack) must be replaced by the target's Attack.
|
||||
/// </summary>
|
||||
[Test, Arguments(50u), Arguments(150u), Arguments(400u)]
|
||||
public async Task ChangeOffensiveStatValue_PhysicalMove_UsesTargetsAttackInsteadOfUsers(uint targetAttack)
|
||||
{
|
||||
// Arrange
|
||||
var (script, move, target) = CreateTestSetup(MoveCategory.Physical, targetAttack, 80);
|
||||
uint value = 100; // The user's own Attack stat, which must be discarded.
|
||||
|
||||
// Act
|
||||
script.ChangeOffensiveStatValue(move, target, 0, 200, new StatisticSet<uint>(), Statistic.Attack, ref value);
|
||||
|
||||
// Assert
|
||||
await Assert.That(value).IsEqualTo(targetAttack);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Bulbapedia: "The target's Attack stat stage-modifiers are applied (rather than the user's)".
|
||||
/// The stat used must be the target's boosted Attack (<see cref="IPokemon.BoostedStats"/>, which includes
|
||||
/// stat stages), not its flat Attack (<see cref="IPokemon.FlatStats"/>).
|
||||
/// </summary>
|
||||
[Test]
|
||||
public async Task ChangeOffensiveStatValue_PhysicalMove_TargetStatStagesApplied()
|
||||
{
|
||||
// Arrange - the target's flat Attack is 100, but its stat stages boost it to 400.
|
||||
var (script, move, target) = CreateTestSetup(MoveCategory.Physical, 400, 80);
|
||||
target.FlatStats.Returns(new StatisticSet<uint>(100, 100, 80, 80, 80, 80));
|
||||
uint value = 100;
|
||||
|
||||
// Act
|
||||
script.ChangeOffensiveStatValue(move, target, 0, 200, new StatisticSet<uint>(), Statistic.Attack, ref value);
|
||||
|
||||
// Assert
|
||||
await Assert.That(value).IsEqualTo(400u);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Technical test: the script generically supports special moves by using the target's Special Attack
|
||||
/// instead. (Foul Play itself is a physical move; Bulbapedia: "It uses the target's Attack stat to
|
||||
/// calculate damage instead of the user's.")
|
||||
/// </summary>
|
||||
[Test]
|
||||
public async Task ChangeOffensiveStatValue_SpecialMove_UsesTargetsSpecialAttack()
|
||||
{
|
||||
// Arrange
|
||||
var (script, move, target) = CreateTestSetup(MoveCategory.Special, 150, 240);
|
||||
uint value = 100;
|
||||
|
||||
// Act
|
||||
script.ChangeOffensiveStatValue(move, target, 0, 200, new StatisticSet<uint>(), Statistic.SpecialAttack,
|
||||
ref value);
|
||||
|
||||
// Assert
|
||||
await Assert.That(value).IsEqualTo(240u);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user