RynthSuite/Tools/RynthCore.RynthAiHostTests/Tests/T11LootTests.cs
Tom Bohar dafd6084a7 Snapshot for release 2026.10.6.2 (internal e3a94cf)
Faster weapon switches; T11 loot support (by SilentKelpie, rynth/RynthSuite PR #3).
2026-10-06 11:21:16 -04:00

127 lines
5.8 KiB
C#

using RynthCore.Loot;
using RynthCore.Loot.T11;
using RynthCore.Loot.VTank;
using RynthCore.Plugin.RynthAi;
using RynthCore.Plugin.RynthAi.Loot;
using RynthCore.RynthAiHostTests.Fakes;
using RynthCore.RynthAiTests.Harness;
using N = RynthCore.Loot.VTank.VTankNodeTypes;
namespace RynthCore.RynthAiHostTests.Tests;
// T11 (ACECustom tier 11+) items through the real evaluator: the virtual T11 keys answered by
// WorldObject.Values, the wield requirement and ratings the server strips put back from the
// item text, and "Can Wield" fed by the "/aug" reply.
internal static class T11LootTests
{
private const string WeaponLongDesc =
"Property Details:\n" +
"- Weapon Grade: A- (91% of max damage)\n" +
"- Wield requires: 2,500 Item Augmentations\n" +
"\n" +
"Modifiers:\n" +
"- Damage Rating +30 [14-69]\n" +
"- Crit Chance +4 [1-8]\n";
private const string ArmorUse =
"Modifiers:\n" +
"- Damage Resist +6 [2-12]\n" +
"- Max Health +100 [40-200]\n";
public static void Register(Runner r)
{
r.Add("loot t11: virtual keys read the item text", VirtualKeys);
r.Add("loot t11: stripped wield requirement 158/159/160 restored", StrippedWield);
r.Add("loot t11: modifier ratings feed Gear* keys and TotalRatings", ModifierRatings);
r.Add("loot t11: a live rating wins over the modifier text", LiveRatingWins);
r.Add("loot t11: retail items are untouched", RetailUntouched);
r.Add("loot t11: Can Wield from the /aug reply and the override", CanWield);
}
private static VTankLootCondition C(int node, params string[] data) => new(node, "0", data);
private static bool M(WorldObject item, params VTankLootCondition[] conds)
{
var rule = new VTankLootRule { Name = "r", Action = VTankLootAction.Keep };
rule.Conditions.AddRange(conds);
return VTankLootEvaluator.Match(rule, item);
}
private static string K(int key) => key.ToString(System.Globalization.CultureInfo.InvariantCulture);
private static Item Weapon() => new Item("T11 - Tachi", AcObjectClass.MeleeWeapon).Str(16, WeaponLongDesc);
private static void VirtualKeys()
{
T11ItemSupport.Reset();
WorldObject w = Weapon();
Check.Eq(w.Values(T11Keys.IsT11, -5), 1, "IsT11");
Check.Eq(w.Values(T11Keys.EstimatedTier, -5), 12, "2,500 gate = T12");
Check.Eq(w.Values(T11Keys.WeaponGrade, -5), 13, "A- = 13");
Check.True(M(w, C(N.LongValKeyGE, "12", K(T11Keys.WeaponGrade))), "rule: grade B+ or better");
Check.False(M(w, C(N.LongValKeyGE, "14", K(T11Keys.WeaponGrade))), "rule: grade A or better");
Check.True(M(w, C(N.LongValKeyGE, "25", K(T11Keys.ForModifier(28)))), "rule: Damage Rating mod >= 25");
Check.True(M(w, C(N.LongValKeyE, "0", K(T11Keys.ZoneLocked))), "rule: not zone locked");
Check.Eq(w.Values(T11Keys.Base + 0x1FF, -5), -5, "unused virtual id = default");
Check.Eq(new Item("Tachi").Wo.Values(T11Keys.IsT11, -5), 0, "retail item: IsT11 = 0");
}
private static void StrippedWield()
{
T11ItemSupport.Reset();
WorldObject w = Weapon();
Check.Eq(w.Values(158, 0), T11Keys.WieldRequirementInt64Stat, "158 = Int64 Property");
Check.Eq(w.Values(159, 0), 9008, "159 = item augs");
Check.Eq(w.Values(160, 0), 2500, "160 = gate");
Check.True(M(w, C(N.LongValKeyLE, "2500", "160")), "rule: wield difficulty <= 2500");
Check.False(M(w, C(N.LongValKeyLE, "2000", "160")), "rule: wield difficulty <= 2000");
Check.Eq(w.Values(161, -1), -1, "other keys keep the default");
}
private static void ModifierRatings()
{
T11ItemSupport.Reset();
WorldObject w = Weapon();
Check.Eq(w.Values(370, 0), 30, "370 Damage Rating from text");
Check.Eq(w.Values(372, 0), 4, "372 Crit from text");
Check.True(M(w, C(N.TotalRatingsGE, "34")), "TotalRatings counts modifier ratings");
Check.False(M(w, C(N.TotalRatingsGE, "35")), "TotalRatings exact");
WorldObject armor = new Item("T11 - Celdon Breastplate", AcObjectClass.Armor).Str(14, ArmorUse);
Check.Eq(armor.Values(371, 0), 6, "371 from the Use string");
Check.True(M(armor, C(N.TotalRatingsGE, "106")), "armor TotalRatings 371 + 379");
}
private static void LiveRatingWins()
{
T11ItemSupport.Reset();
WorldObject w = Weapon().Int(370, 7);
Check.Eq(w.Values(370, 0), 7, "a property the item has is never replaced");
}
private static void RetailUntouched()
{
T11ItemSupport.Reset();
WorldObject retail = new Item("Tachi", AcObjectClass.MeleeWeapon).Str(16, WeaponLongDesc);
Check.Eq(retail.Values(160, 0), 0, "no T11 prefix: no stripped-key fallback");
Check.Eq(retail.Values(370, -1), -1, "no T11 prefix: rating default kept");
}
private static void CanWield()
{
T11ItemSupport.Reset();
WorldObject w = Weapon();
Check.Eq(w.Values(T11Keys.CanWield, -5), -1, "unknown before /aug");
T11ItemSupport.OnChat("Advanced Augmentation Levels:");
T11ItemSupport.OnChat("Item:2,400");
Check.Eq(w.Values(T11Keys.CanWield, -5), 0, "2,400 < 2,500");
Check.False(M(w, C(N.LongValKeyE, "1", K(T11Keys.CanWield))), "rule: wieldable fails");
T11ItemSupport.SyncOverride(2500);
Check.Eq(w.Values(T11Keys.CanWield, -5), 1, "override 2,500 meets the gate");
T11ItemSupport.SyncOverride(-1);
Check.Eq(w.Values(T11Keys.CanWield, -5), 0, "back to the /aug count");
Check.Eq(new Item("T11 - Robe").Wo.Values(T11Keys.CanWield, -5), -1, "not appraised yet: unknown");
Check.Eq(new Item("T11 - Robe").Str(16, "A robe.").Wo.Values(T11Keys.CanWield, -5), 1, "appraised, no gate: wieldable");
T11ItemSupport.Reset();
}
}