RynthSuite/Tools/RynthCore.RynthAiTests/Tests/PetCaptureRulesTests.cs
BlankenshipG dc8cc9bc81 feat: SK pet auto-capture with the selected siphon lens
ILT Mini Remote Pets can auto-use Flawed/Pristine/Perfect/Resonance/Asheron's
lenses when a target is within 5 m and at ACECustom's health gate. RynthILT
0.2.10; RynthAi HandWrittenVersion stays 0.5.0-legacy-ui on sk.

Co-authored-by: Cursor <cursoragent@cursor.com>
2026-10-18 15:59:53 -04:00

70 lines
3.3 KiB
C#

// ACECustom MonsterCapture health / range / lens table — matches Source/ACE.Server/Entity/MonsterCapture.cs.
using RynthCore.Plugin.RynthAi.MiniRemote;
using RynthCore.RynthAiTests.Harness;
namespace RynthCore.RynthAiTests.Tests;
internal static class PetCaptureRulesTests
{
public static void Register(Runner r)
{
r.Add("pet capture: health gate matches ACECustom (≤20% or under 20 HP)", HealthGate);
r.Add("pet capture: Asheron's Lens bypasses the health gate", AsheronsBypass);
r.Add("pet capture: range is 5 m; dead creatures are never capturable", RangeAndDead);
r.Add("pet capture: lens WCIDs match PetGuideController", LensWcids);
}
private static void HealthGate()
{
// Full health — refuse.
Check.False(PetCaptureRules.IsWeakEnough(100, 100), "100/100 too strong");
Check.False(PetCaptureRules.IsWeakEnough(21, 100), "21% and ≥20 HP too strong");
// Fraction gate.
Check.True(PetCaptureRules.IsWeakEnough(20, 100), "20% exactly is allowed");
Check.True(PetCaptureRules.IsWeakEnough(1, 100), "1% allowed");
// Absolute HP gate (high % but under 20 HP).
Check.True(PetCaptureRules.IsWeakEnough(15, 50), "15/50 = 30% but under 20 HP");
Check.True(PetCaptureRules.IsWeakEnough(19, 19), "19/19 under 20 HP");
// Ratio-only path (no absolute HP): only the fraction half.
Check.True(PetCaptureRules.IsWeakEnoughRatio(0.20f), "ratio 0.20");
Check.False(PetCaptureRules.IsWeakEnoughRatio(0.21f), "ratio 0.21");
Check.False(PetCaptureRules.IsWeakEnoughRatio(0f), "ratio 0 = dead");
Check.False(PetCaptureRules.IsWeakEnough(0, 100), "0 current = dead");
}
private static void AsheronsBypass()
{
var asheron = PetCaptureRules.LensAt(4);
Check.Eq(asheron.Wcid, 78780012u, "Asheron's WCID");
Check.True(asheron.BypassesHealthGate, "bypasses health");
Check.True(PetCaptureRules.CanAttempt(asheron, 100, 100), "full health ok for Asheron's");
Check.False(PetCaptureRules.CanAttempt(asheron, 0, 100), "still not when dead");
var flawed = PetCaptureRules.LensAt(0);
Check.False(PetCaptureRules.CanAttempt(flawed, 100, 100), "Flawed refuses full health");
Check.True(PetCaptureRules.CanAttempt(flawed, 10, 100), "Flawed at 10%");
}
private static void RangeAndDead()
{
Check.Eq(PetCaptureRules.CaptureRangeM, 5.0f, "5 m range");
Check.True(PetCaptureRules.InRange(0), "at feet");
Check.True(PetCaptureRules.InRange(5.0), "at 5 m");
Check.False(PetCaptureRules.InRange(5.01), "past 5 m");
Check.False(PetCaptureRules.InRange(-1), "unknown distance");
}
private static void LensWcids()
{
Check.Eq(PetCaptureRules.Lenses.Length, 5, "five selectable lenses");
Check.Eq(PetCaptureRules.LensAt(0).Wcid, 78780001u, "Flawed");
Check.Eq(PetCaptureRules.LensAt(1).Wcid, 78780002u, "Pristine");
Check.Eq(PetCaptureRules.LensAt(2).Wcid, 78780003u, "Perfect");
Check.Eq(PetCaptureRules.LensAt(3).Wcid, 78780010u, "Resonance");
Check.Eq(PetCaptureRules.LensAt(4).Wcid, 78780012u, "Asheron's");
Check.Eq(PetCaptureRules.LensNames.Length, PetCaptureRules.Lenses.Length, "combo labels match");
}
}