using PkmnLib.Dynamic.Models;
using PkmnLib.Plugin.Gen7.Scripts.Moves;
using PkmnLib.Static;
namespace PkmnLib.Plugin.Gen7.Tests.Scripts.Moves;
///
/// Tests for the 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.
///
public class EruptionTests
{
private static (Eruption script, IExecutingMove move, IPokemon target) CreateTestSetup(uint currentHealth,
uint maxHealth)
{
var script = new Eruption();
var move = Substitute.For();
var user = Substitute.For();
user.CurrentHealth.Returns(currentHealth);
user.BoostedStats.Returns(new StatisticSet(maxHealth, 1, 1, 1, 1, 1));
move.User.Returns(user);
var target = Substitute.For();
return (script, move, target);
}
///
/// 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.
///
[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);
}
///
/// Bulbapedia: "if this calculation yields a value below 1, the move's power becomes 1 instead."
///
[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);
}
}