104 lines
4.2 KiB
C#
104 lines
4.2 KiB
C#
using PkmnLib.Dynamic.Models;
|
||
using PkmnLib.Plugin.Gen7.Scripts.Moves;
|
||
|
||
namespace PkmnLib.Plugin.Gen7.Tests.Scripts.Moves;
|
||
|
||
/// <summary>
|
||
/// Tests for the <see cref="HeatCrash"/> move script.
|
||
/// Gen VII Bulbapedia behavior: "Heat Crash deals damage. Its power depends on the weight of both the user
|
||
/// and the target; the greater the difference between the user's weight and the target's weight, the
|
||
/// greater the power." The power table by the target's weight relative to the user is: more than 50% → 40,
|
||
/// 33.35%–50% → 60, 25.01%–33.34% → 80, 20.01%–25% → 100, 20% or less → 120.
|
||
/// </summary>
|
||
public class HeatCrashTests
|
||
{
|
||
private static (HeatCrash script, IExecutingMove move, IPokemon target) CreateTestSetup(float userWeightInKg,
|
||
float targetWeightInKg)
|
||
{
|
||
var script = new HeatCrash();
|
||
var move = Substitute.For<IExecutingMove>();
|
||
var user = Substitute.For<IPokemon>();
|
||
user.WeightInKg.Returns(userWeightInKg);
|
||
move.User.Returns(user);
|
||
var target = Substitute.For<IPokemon>();
|
||
target.WeightInKg.Returns(targetWeightInKg);
|
||
return (script, move, target);
|
||
}
|
||
|
||
/// <summary>
|
||
/// Bulbapedia weight/power table: target more than 50% of the user's weight → 40,
|
||
/// 33.35%–50% → 60, 25.01%–33.34% → 80, 20.01%–25% → 100, 20% or less → 120.
|
||
/// Each bracket is tested with values inside the bracket on both sides.
|
||
/// </summary>
|
||
[Test, Arguments(50f, 100f, (ushort)40), Arguments(100f, 100f, (ushort)40), Arguments(190f, 100f, (ushort)40),
|
||
Arguments(210f, 100f, (ushort)60), Arguments(290f, 100f, (ushort)60), Arguments(310f, 100f, (ushort)80),
|
||
Arguments(390f, 100f, (ushort)80), Arguments(410f, 100f, (ushort)100), Arguments(490f, 100f, (ushort)100),
|
||
Arguments(510f, 100f, (ushort)120), Arguments(1000f, 100f, (ushort)120)]
|
||
// target heavier than the user
|
||
// equal weight (100%)
|
||
// target at ~52.6%
|
||
// target at ~47.6%
|
||
// target at ~34.5%
|
||
// target at ~32.3%
|
||
// target at ~25.6%
|
||
// target at ~24.4%
|
||
// target at ~20.4%
|
||
// target at ~19.6%
|
||
// target at 10%
|
||
public async Task ChangeBasePower_WeightRatio_SetsBasePowerFromWeightTable(float userWeightInKg,
|
||
float targetWeightInKg, ushort expectedPower)
|
||
{
|
||
// Arrange
|
||
var (script, move, target) = CreateTestSetup(userWeightInKg, targetWeightInKg);
|
||
ushort basePower = 1;
|
||
|
||
// Act
|
||
script.ChangeBasePower(move, target, 0, ref basePower);
|
||
|
||
// Assert
|
||
await Assert.That(basePower).IsEqualTo(expectedPower);
|
||
}
|
||
|
||
/// <summary>
|
||
/// Bulbapedia weight/power table boundaries: the brackets are "33.35% - 50%" → 60,
|
||
/// "25.01% - 33.34%" → 80, "20.01% - 25%" → 100 and "20% or less" → 120, so a target weighing
|
||
/// exactly 50%, one third, 25% or 20% of the user belongs to the higher-power bracket.
|
||
/// </summary>
|
||
[Test, Arguments(200f, 100f, (ushort)60), Arguments(300f, 100f, (ushort)80), Arguments(400f, 100f, (ushort)100),
|
||
Arguments(500f, 100f, (ushort)120)]
|
||
// target at exactly 50%
|
||
// target at exactly one third (33.33% ≤ 33.34%)
|
||
// target at exactly 25%
|
||
// target at exactly 20%
|
||
public async Task ChangeBasePower_ExactBracketBoundary_UsesHigherPowerBracket(float userWeightInKg,
|
||
float targetWeightInKg, ushort expectedPower)
|
||
{
|
||
// Arrange
|
||
var (script, move, target) = CreateTestSetup(userWeightInKg, targetWeightInKg);
|
||
ushort basePower = 1;
|
||
|
||
// Act
|
||
script.ChangeBasePower(move, target, 0, ref basePower);
|
||
|
||
// Assert
|
||
await Assert.That(basePower).IsEqualTo(expectedPower);
|
||
}
|
||
|
||
/// <summary>
|
||
/// Bulbapedia: "Its power depends on the weight of both the user and the target" — the base power is
|
||
/// derived from the weight ratio alone, fully replacing the incoming base power value.
|
||
/// </summary>
|
||
[Test]
|
||
public async Task ChangeBasePower_HighIncomingBasePower_IsReplacedByWeightTableValue()
|
||
{
|
||
// Arrange
|
||
var (script, move, target) = CreateTestSetup(100f, 100f);
|
||
ushort basePower = 250;
|
||
|
||
// Act
|
||
script.ChangeBasePower(move, target, 0, ref basePower);
|
||
|
||
// Assert
|
||
await Assert.That(basePower).IsEqualTo((ushort)40);
|
||
}
|
||
} |