63 lines
2.5 KiB
C#
63 lines
2.5 KiB
C#
using PkmnLib.Dynamic.Models;
|
||
using PkmnLib.Plugin.Gen7.Scripts.Moves;
|
||
using PkmnLib.Static;
|
||
|
||
namespace PkmnLib.Plugin.Gen7.Tests.Scripts.Moves;
|
||
|
||
/// <summary>
|
||
/// Tests for the <see cref="Eruption"/> move script.
|
||
/// Gen VII Bulbapedia behavior: "Eruption deals damage. It has 150 base power at maximum HP, but its base
|
||
/// power decreases linearly with the user's remaining HP", following ⌊150 × HPcurrent / HPmax⌋ with a
|
||
/// minimum of 1.
|
||
/// </summary>
|
||
public class EruptionTests
|
||
{
|
||
private static (Eruption script, IExecutingMove move, IPokemon target) CreateTestSetup(uint currentHealth,
|
||
uint maxHealth)
|
||
{
|
||
var script = new Eruption();
|
||
var move = Substitute.For<IExecutingMove>();
|
||
var user = Substitute.For<IPokemon>();
|
||
user.CurrentHealth.Returns(currentHealth);
|
||
user.BoostedStats.Returns(new StatisticSet<uint>(maxHealth, 1, 1, 1, 1, 1));
|
||
move.User.Returns(user);
|
||
var target = Substitute.For<IPokemon>();
|
||
return (script, move, target);
|
||
}
|
||
|
||
/// <summary>
|
||
/// Bulbapedia: "It has 150 base power at maximum HP, but its base power decreases linearly with the
|
||
/// user's remaining HP" — power = ⌊150 × HPcurrent / HPmax⌋, with integer truncation.
|
||
/// </summary>
|
||
[Test, Arguments(100u, 100u, (ushort)150), Arguments(300u, 300u, (ushort)150), Arguments(50u, 100u, (ushort)75),
|
||
Arguments(75u, 100u, (ushort)112), Arguments(33u, 100u, (ushort)49), Arguments(150u, 300u, (ushort)75)]
|
||
public async Task ChangeBasePower_ScalesWithUserCurrentHp(uint currentHealth, uint maxHealth, ushort expectedPower)
|
||
{
|
||
// Arrange
|
||
var (script, move, target) = CreateTestSetup(currentHealth, maxHealth);
|
||
ushort basePower = 150;
|
||
|
||
// Act
|
||
script.ChangeBasePower(move, target, 0, ref basePower);
|
||
|
||
// Assert
|
||
await Assert.That(basePower).IsEqualTo(expectedPower);
|
||
}
|
||
|
||
/// <summary>
|
||
/// Bulbapedia: "if this calculation yields a value below 1, the move's power becomes 1 instead."
|
||
/// </summary>
|
||
[Test, Arguments(1u, 300u), Arguments(1u, 151u)]
|
||
public async Task ChangeBasePower_UserAtVeryLowHp_PowerIsAtLeastOne(uint currentHealth, uint maxHealth)
|
||
{
|
||
// Arrange
|
||
var (script, move, target) = CreateTestSetup(currentHealth, maxHealth);
|
||
ushort basePower = 150;
|
||
|
||
// Act
|
||
script.ChangeBasePower(move, target, 0, ref basePower);
|
||
|
||
// Assert
|
||
await Assert.That(basePower).IsEqualTo((ushort)1);
|
||
}
|
||
} |