Files
PkmnLib.NET/Plugins/PkmnLib.Plugin.Gen7.Tests/Scripts/Moves/GrassKnotTests.cs

58 lines
2.3 KiB
C#
Raw Permalink Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

using PkmnLib.Dynamic.Models;
using PkmnLib.Plugin.Gen7.Scripts.Moves;
namespace PkmnLib.Plugin.Gen7.Tests.Scripts.Moves;
/// <summary>
/// Tests for the <see cref="GrassKnot"/> move script.
/// Gen VII Bulbapedia behavior: "Grass Knot deals damage scaled by the target's weight rather than using a
/// fixed base power", with cutoffs at 10, 25, 50, 100 and 200 kilograms.
/// </summary>
public class GrassKnotTests
{
/// <summary>
/// Bulbapedia weight/power table: 0.19.9 kg → 20, 10.024.9 kg → 40, 25.049.9 kg → 60,
/// 50.099.9 kg → 80, 100.0199.9 kg → 100, 200.0 kg or more → 120. Each cutoff is tested on both
/// sides of the boundary.
/// </summary>
[Test, Arguments(0.1f, (ushort)20), Arguments(9.9f, (ushort)20), Arguments(10.0f, (ushort)40),
Arguments(24.9f, (ushort)40), Arguments(25.0f, (ushort)60), Arguments(49.9f, (ushort)60),
Arguments(50.0f, (ushort)80), Arguments(99.9f, (ushort)80), Arguments(100.0f, (ushort)100),
Arguments(199.9f, (ushort)100), Arguments(200.0f, (ushort)120), Arguments(999.9f, (ushort)120)]
public async Task ChangeBasePower_TargetWeight_SetsBasePowerFromWeightTable(float weightInKg, ushort expectedPower)
{
// Arrange
var script = new GrassKnot();
var move = Substitute.For<IExecutingMove>();
var target = Substitute.For<IBattlePokemon>();
target.WeightInKg.Returns(weightInKg);
ushort basePower = 1;
// Act
script.ChangeBasePower(move, target, 0, ref basePower);
// Assert
await Assert.That(basePower).IsEqualTo(expectedPower);
}
/// <summary>
/// Bulbapedia: the base power depends only on the target's weight — the incoming base power value is
/// fully replaced rather than modified.
/// </summary>
[Test]
public async Task ChangeBasePower_HighIncomingBasePower_IsReplacedByWeightTableValue()
{
// Arrange
var script = new GrassKnot();
var move = Substitute.For<IExecutingMove>();
var target = Substitute.For<IBattlePokemon>();
target.WeightInKg.Returns(5f);
ushort basePower = 250;
// Act
script.ChangeBasePower(move, target, 0, ref basePower);
// Assert
await Assert.That(basePower).IsEqualTo((ushort)20);
}
}