feat(rynthai): enhance T11 item support and logging

- Added new command `/ra t11` for T11 loot management, including wield counters and aug overrides.
- Improved logging for item info requests and decisions, providing clearer insights into item handling.
- Updated item info processing to accommodate T11-specific attributes and conditions.
- Enhanced settings to allow for T11 item augmentation overrides.
- Adjusted various components to ensure compatibility with T11 features, including loot rules and item descriptions.

This update aims to streamline the integration of T11 mechanics into the RynthAi plugin, enhancing user experience and functionality.
This commit is contained in:
BlankenshipG 2026-10-06 00:34:28 -04:00
commit 2f38fd6baf
25 changed files with 1993 additions and 39 deletions

View file

@ -0,0 +1,210 @@
using System;
using System.Linq;
using RynthCore.Loot.Editing;
using RynthCore.Loot.T11;
namespace RynthCore.LootSdkTests;
// T11 (ACECustom tier 11+) loot support: the item-text parser against the server's exact
// strings, tier estimates, the "/aug" reply reader, wield checks, virtual keys, the stripped
// wield/rating fallbacks, and the editor's key names and grade table.
internal static partial class Program
{
// A T13 weapon as ACECustom appraises it: Property Details then Modifiers in LongDesc.
private const string T11WeaponLongDesc =
"A finely made sword.\n\n" +
"Property Details:\n" +
"- Weapon Grade: B+ (86% of max damage)\n" +
"- Wield requires: 3,000 Item Augmentations\n" +
"- Wield requires: 25 Crashing Steel\n" +
"- Cast on Strike: Force Arc (13% proc chance)\n" +
"\n" +
"Modifiers:\n" +
"- Damage Rating +41 [14-69]\n" +
"- Crit Damage Rating +10 [5-15]\n" +
"- Pct HP Damage 2%\n" +
"- Zone Locked (Power Reduced)\n";
// T16 armor: gates in LongDesc without a dash, Modifiers in the Use string.
private const string T11ArmorLongDesc =
"Sturdy plate.\n" +
"Wield requires: 4.000 Item Augmentations\n" +
"Wield requires: 500 Triune Weave\n";
private const string T11ArmorUse =
"Modifiers:\n" +
"- Damage Resist +8 [2-12]\n" +
"- Max Health +120 [40-200]\n" +
"- Max Health Pct +2% [1-4]\n" +
"- Modifier 60 +3 [1-5]\n";
private static void RunT11Tests()
{
Console.WriteLine("\n-- T11 loot --");
TestT11WeaponParse();
TestT11ArmorParse();
TestT11NonT11();
TestT11Tier();
TestT11AugReport();
TestT11Keys();
TestT11Editor();
}
private static void TestT11WeaponParse()
{
T11ItemInfo w = T11ItemInfo.Parse("T11 - Tachi", T11WeaponLongDesc, null);
Check(w.IsT11 && w.HasNamePrefix, "weapon: T11 by prefix");
Eq(w.Grade, "B+", "weapon: grade label");
Eq(w.GradeRank, 12, "weapon: grade rank B+ = 12");
Eq(w.DamagePercent, 86, "weapon: damage % of max");
Eq(w.WieldItemAugs, 3000, "weapon: item-aug gate with group separator");
Eq(w.GateAmount(T11Counter.CrashingSteel), 25, "weapon: charm gate");
Eq(w.Procs.Count, 1, "weapon: one cast on strike");
Eq(w.Procs.Count > 0 ? w.Procs[0].Name : "", "Force Arc", "weapon: proc name");
Eq(w.Procs.Count > 0 ? w.Procs[0].ChancePercent : 0, 13.0, "weapon: proc chance");
Check(w.ZoneLocked, "weapon: zone locked line inside Modifiers");
Eq(w.Modifiers.Count, 3, "weapon: zone lock line is not a modifier");
T11Modifier dr = w.Modifiers.First(m => m.Key == 28);
Eq(dr.Value, 41, "weapon: Damage Rating value");
Eq((dr.Min, dr.Max), ((int?)14, (int?)69), "weapon: Damage Rating band");
Eq(dr.RollPercent, 49, "weapon: Damage Rating roll (41-14)/(69-14)");
Check(w.Modifiers.Any(m => m.Key == 44 && m.IsSlotSpecial), "weapon: slot special without a band");
Check(w.HasSlotSpecial, "weapon: HasSlotSpecial");
Eq(w.RatingFromModifiers(370), 41, "weapon: 370 from Damage Rating");
Eq(w.RatingFromModifiers(374), 10, "weapon: 374 from Crit Damage Rating");
Eq(w.ModifierRatingTotal, 51, "weapon: modifier rating total");
Eq(w.EstimatedTier, 13, "weapon: 3,000 gate = T13");
Eq(w.BestRollPercent, 50, "weapon: best roll (Crit Damage 10 in 5-15)");
}
private static void TestT11ArmorParse()
{
T11ItemInfo a = T11ItemInfo.Parse("T11 - Celdon Breastplate", T11ArmorLongDesc, T11ArmorUse);
Check(a.IsT11, "armor: T11");
Eq(a.Grade, null, "armor: no weapon grade");
Eq(a.WieldItemAugs, 4000, "armor: dot group separator, no dash");
Eq(a.GateAmount(T11Counter.TriuneWeave), 500, "armor: Triune Weave gate");
Eq(a.EstimatedTier, 16, "armor: 500 Triune Weave = T16");
Eq(T11Keys.TryGetValue(a, T11Keys.EstimatedTier, null, out int at) ? at : 0, 16, "armor: tier key reads T16");
Eq(a.Modifiers.Count, 4, "armor: modifiers from Use");
Check(a.Modifiers.Any(m => m.Key == 47 && m.Value == 2), "armor: Max Health Pct is not Max Health");
Check(a.Modifiers.Any(m => m.Key == 19 && m.Value == 120), "armor: Max Health");
Check(a.Modifiers.Any(m => m.Key == 60 && m.Name == "Modifier 60" && m.Value == 3), "armor: unknown server key kept");
Eq(a.RatingFromModifiers(371), 8, "armor: 371 from Damage Resist");
Eq(a.RatingFromModifiers(379), 120, "armor: 379 from Max Health");
Eq(a.ModifierRatingTotal, 128, "armor: rating total 371 + 379");
}
private static void TestT11NonT11()
{
Check(!T11ItemInfo.Parse("Tachi", "A finely made sword.", "").IsT11, "plain item is not T11");
Check(!T11ItemInfo.Parse(null, null, null).IsT11, "no text is not T11");
Check(!T11ItemInfo.Parse("Wand", "- Cast on Strike: Bolt (5% proc chance)", null).IsT11, "a proc alone doesn't mark T11");
Check(T11ItemInfo.Parse("T11 - Robe", null, null).IsT11, "unappraised T11 name still T11");
Eq(T11ItemInfo.Parse("T11 - Robe", null, null).EstimatedTier, 11, "unappraised T11 = tier 11");
Check(!T11ItemInfo.Parse("T11 - Robe", null, null).HasText, "unappraised T11 has no text");
Eq(T11Keys.TryGetValue(T11ItemInfo.Parse("T11 - Robe", null, null), T11Keys.CanWield, new T11PlayerAugs(), out int cw) ? cw : 99, -1,
"unappraised T11: Can Wield unknown");
Eq(T11Keys.TryGetValue(T11ItemInfo.Parse("T11 - Robe", "A robe.", null), T11Keys.CanWield, null, out int cw2) ? cw2 : 99, 1,
"appraised T11 without a gate: wieldable");
Check(!T11ItemInfo.Parse("x", "Modifiers:\n- ", "\n\n- [").IsT11, "malformed text doesn't throw or mark");
}
private static void TestT11Tier()
{
Eq(T11Catalog.EstimateTier(0, false), 0, "tier: nothing");
Eq(T11Catalog.EstimateTier(2000, true), 11, "tier: 2,000 = T11");
Eq(T11Catalog.EstimateTier(2500, true), 12, "tier: 2,500 = T12");
Eq(T11Catalog.EstimateTier(3500, true), 14, "tier: 3,500 = T14");
Eq(T11Catalog.EstimateTier(9000, true), 15, "tier: capped at 15");
// T16-T25: the item-aug gate is frozen at 4,000, the Triune Weave gate carries the tier.
Eq(T11Catalog.EstimateTier(4000, 0, true), 15, "tier: 4,000 without Triune = T15");
Eq(T11Catalog.EstimateTier(3000, 0, true), 13, "tier: no Triune falls back to the item-aug gate");
Eq(T11Catalog.EstimateTier(4000, 500, true), 16, "tier: 500 Triune = T16");
Eq(T11Catalog.EstimateTier(4000, 1500, true), 18, "tier: 1,500 Triune = T18");
Eq(T11Catalog.EstimateTier(4000, 5000, true), 25, "tier: 5,000 Triune = T25");
Eq(T11Catalog.EstimateTier(4000, 9000, true), T11Catalog.MaxTier, "tier: capped at T25");
Eq(T11Catalog.EstimateTier(4000, 250, true), 16, "tier: any Triune gate is at least T16");
Eq(T11Catalog.EstimateTier(0, 0, false), 0, "tier: nothing (three-argument)");
// A T25 weapon as appraised: item augs frozen at 4,000, Triune and family charm 5,000 each.
T11ItemInfo t25 = T11ItemInfo.Parse("T11 - Tachi",
"Property Details:\n" +
"- Weapon Grade: A (95% of max damage)\n" +
"- Wield requires: 4,000 Item Augmentations\n" +
"- Wield requires: 5,000 Triune Weave\n" +
"- Wield requires: 5,000 Crashing Steel\n", null);
Eq(t25.EstimatedTier, 25, "tier: T25 weapon from its Triune gate");
Eq(t25.GateAmount(T11Counter.CrashingSteel), 5000, "tier: T25 weapon charm gate");
}
private static void TestT11AugReport()
{
var p = new T11PlayerAugs();
var r = new T11AugReportParser();
Check(!r.Feed("Item:2,500", 0, p), "aug: Item line before the header ignored");
Check(!r.Feed("Advanced Augmentation Levels:", 1000, p), "aug: header opens the window");
Check(r.Feed("Item:2,500", 1100, p), "aug: Item line read");
Check(r.Feed("Triune Weave: 3 (adds 3% damage)", 1200, p), "aug: Triune Weave read");
Check(r.Feed("Crashing Steel Charm: 20", 1300, p), "aug: charm read");
Check(!r.Feed("Item:9999", 1300 + T11AugReportParser.WindowMs + 1, p), "aug: window closes");
Eq(p.Get(T11Counter.ItemAugmentations), (long?)2500, "aug: item count");
Eq(p.Get(T11Counter.TriuneWeave), (long?)3, "aug: triune count");
Eq(p.Get(T11Counter.NetherVeil), null, "aug: unreported counter unknown");
T11ItemInfo weapon = T11ItemInfo.Parse("T11 - Tachi", T11WeaponLongDesc, null);
Eq(p.CanWield(weapon), 0, "wield: 2,500 < 3,000");
p.ItemAugOverride = 3000;
Eq(p.CanWield(weapon), 0, "wield: crashing steel 20 < 25");
p.Set(T11Counter.CrashingSteel, 25);
Eq(p.CanWield(weapon), 1, "wield: override + charm met");
p.Clear();
Eq(p.Get(T11Counter.ItemAugmentations), (long?)3000, "aug: Clear keeps the override");
Eq(p.CanWield(weapon), -1, "wield: charm unknown after Clear");
}
private static void TestT11Keys()
{
T11ItemInfo w = T11ItemInfo.Parse("T11 - Tachi", T11WeaponLongDesc, null);
int V(int key, T11PlayerAugs? pl = null) => T11Keys.TryGetValue(w, key, pl, out int v) ? v : int.MinValue;
Eq(V(T11Keys.IsT11), 1, "key: IsT11");
Eq(V(T11Keys.EstimatedTier), 13, "key: tier");
Eq(V(T11Keys.WeaponGrade), 12, "key: grade");
Eq(V(T11Keys.DamagePercent), 86, "key: damage %");
Eq(V(T11Keys.WieldItemAugs), 3000, "key: wield item augs");
Eq(V(T11Keys.CanWield), -1, "key: can wield unknown without player");
Eq(V(T11Keys.ModifierCount), 3, "key: modifier count");
Eq(V(T11Keys.ModifierRatingTotal), 51, "key: modifier ratings");
Eq(V(T11Keys.CastOnStrikeCount), 1, "key: procs");
Eq(V(T11Keys.ZoneLocked), 1, "key: zone locked");
Eq(V(T11Keys.ForModifier(28)), 41, "key: per-modifier Damage Rating");
Eq(V(T11Keys.ForModifier(50)), 0, "key: absent modifier = 0");
Eq(V(T11Keys.ModifierBase + 999), int.MinValue, "key: unknown modifier id unused");
Eq(V(370), int.MinValue, "key: retail key isn't virtual");
Check(T11Keys.IsVirtual(T11Keys.IsT11) && !T11Keys.IsVirtual(T11Keys.Base) && !T11Keys.IsVirtual(T11Keys.End), "key: block bounds");
int S(T11ItemInfo item, int key) => T11Keys.TryGetStrippedValue(item, key, out int v) ? v : int.MinValue;
Eq(S(w, 158), 13, "stripped: 158 = Int64 Property");
Eq(S(w, 159), 9008, "stripped: 159 = item augs stat");
Eq(S(w, 160), 3000, "stripped: 160 = gate");
Eq(S(w, 370), 41, "stripped: 370 from modifier");
Eq(S(w, 371), int.MinValue, "stripped: no modifier for 371");
Eq(S(T11ItemInfo.None, 158), int.MinValue, "stripped: non-T11 gives nothing");
Eq(S(T11ItemInfo.Parse("T11 - Robe", null, null), 160), int.MinValue, "stripped: no gate read yet");
Check(T11Keys.IsStrippedKey(158) && T11Keys.IsStrippedKey(379) && !T11Keys.IsStrippedKey(161), "stripped: key set");
}
private static void TestT11Editor()
{
Check(LootRuleText.LongKeys.Any(k => k.Id == T11Keys.CanWield && k.Name == "T11: Can Wield"), "editor: Can Wield key named");
Check(LootRuleText.LongKeys.Any(k => k.Id == T11Keys.ForModifier(28) && k.Name == "T11 Mod: Damage Rating"), "editor: per-modifier key named");
Check(LootRuleText.LongKeys.Any(k => k.Id == 377), "editor: NetherResistRating listed");
Eq(LootRuleText.LongKeys.Select(k => k.Id).Distinct().Count(), LootRuleText.LongKeys.Length, "editor: long key ids unique");
Check(ReferenceEquals(LootRuleText.ValueTableFor(T11Keys.WeaponGrade), T11Catalog.Grades), "editor: grade value table");
Eq(LootRuleText.ValueName(T11Keys.WeaponGrade, "12"), "B+", "editor: grade 12 named B+");
Eq(LootRuleText.WieldRequirements.First(w => w.Id == 13).Name, "Int64 Property", "editor: wield requirement 13");
Check(LootRuleText.StringKeys.Any(k => k.Id == 14) && LootRuleText.StringKeys.Any(k => k.Id == 16), "editor: Use and LongDesc string keys");
Eq(T11Catalog.Grades.Select(g => g.Name).Distinct().Count(), T11Catalog.Grades.Length, "editor: grade names unique");
}
}

View file

@ -67,7 +67,7 @@ internal static partial class Program
Eq(LootRuleText.Materials.First(m => m.Id == 15).Name, "Black Garnet", "material 15");
Eq(LootRuleText.Materials.Length, 78, "materials 0..77");
Eq(LootRuleText.WieldRequirements.First(w => w.Id == 2).Name, "Base Skill", "wield requirement 2 (RawSkill)");
Eq(LootRuleText.WieldRequirements.Length, 13, "wield requirements 0..12");
Eq(LootRuleText.WieldRequirements.Length, 14, "wield requirements 0..13 (13 = ACECustom Int64 Property)");
Eq(LootRuleText.DamageTypes.First(d => d.Id == 64).Name, "Electric", "damage type 64");
// Lookup and labels; unknown and odd values stay expressible.

View file

@ -44,6 +44,7 @@ internal static partial class Program
TestMalformedInputs();
RunLootEditTests(args);
RunLootAddTests(args);
RunT11Tests();
Console.WriteLine($"\nGolden tests: {_asserts} assertions, {_fails} failed.");

View file

@ -37,6 +37,8 @@ internal static class Program
var runner = new Runner();
NativeLootTests.Register(runner);
VTankLootTests.Register(runner);
T11LootTests.Register(runner);
MagItemDescriberTests.Register(runner);
ExpressionTests.Register(runner);
MetaTests.Register(runner);
MetaSchedulerTests.Register(runner);

View file

@ -0,0 +1,125 @@
using System.Collections.Generic;
using RynthCore.Loot;
using RynthCore.Plugin.RynthAi.ItemInfo;
using RynthCore.RynthAiTests.Harness;
namespace RynthCore.RynthAiHostTests.Tests;
// The Mag-style item info line (/ra iteminfo, ID-on-click) against what the ACECustom appraisal
// panel shows for the same item: whole-number damage range, signed bonuses, Crushing Blow as the
// dealt multiplier, and the imbue strength / grade / wield gate that only exist as text.
internal static class MagItemDescriberTests
{
public static void Register(Runner r)
{
r.Add("iteminfo: T11 fire staff matches the appraisal panel", T11FireStaff);
r.Add("iteminfo: Biting Strike and a defense penalty", BitingStrikeAndPenalty);
r.Add("iteminfo: retail imbues stay bare labels without detail text", RetailImbuesBare);
r.Add("iteminfo: Int64 wield requirement never prints as a skill", Int64WieldHidden);
r.Add("iteminfo: T11 armor modifiers print on the ratings line", T11ArmorModifiers);
}
/// <summary>In-memory property bag standing in for the client object cache.</summary>
private sealed class FakeItem : IItemPropertySource
{
public readonly Dictionary<uint, int> Ints = new();
public readonly Dictionary<uint, double> Doubles = new();
public readonly Dictionary<uint, string> Strings = new();
public FakeItem(string name, AcObjectClass cls) { Name = name; ObjectClass = cls; }
public string Name { get; }
public AcObjectClass ObjectClass { get; }
public bool TryGetInt(uint stype, out int value) => Ints.TryGetValue(stype, out value);
public bool TryGetDouble(uint stype, out double value) => Doubles.TryGetValue(stype, out value);
public string GetString(uint stype) => Strings.TryGetValue(stype, out string? v) ? v : string.Empty;
public IReadOnlyList<int> SpellIds { get; } = new List<int>();
}
private static List<string> Pet(FakeItem item) => MagItemDescriber.Build(item, MagItemInfoOptions.Default).ToPetLines();
// The item from the bug report: ACECustom shows Damage 1790 - 2069, Bonus to Attack Skill
// +20%, Melee Defense +20.0%, Crushing Blow 3.66x, Fire Rending +176%, Grade S (100%),
// Crit Dam 24, Wield requires 2,000 Item Augmentations.
private static void T11FireStaff()
{
var staff = new FakeItem("Flaming Quarter Staff", AcObjectClass.MeleeWeapon);
staff.Ints[44] = 2069; // max damage
staff.Ints[45] = 0x10; // fire
staff.Ints[353] = 7; // staff mastery
staff.Ints[105] = 9; // workmanship
staff.Ints[179] = 0x0200; // Fire Rending
staff.Ints[374] = 24; // crit damage rating
staff.Doubles[22] = 0.135; // variance
staff.Doubles[62] = 1.20; // attack
staff.Doubles[29] = 1.20; // melee defense
staff.Doubles[136] = 2.66; // CriticalMultiplier (Crushing Blow 3.66x)
staff.Strings[16] =
"Property Details:\n" +
"- Weapon Grade: S (100% of max damage)\n" +
"- Properties: 2 of 5\n" +
"- Crushing Blow: 3.66x Crit Dmg\n" +
"- Fire Rending: +176% Dmg\n" +
"- Effective Melee Defense: 39851\n" +
"- Wield requires: 2,000 Item Augmentations\n";
List<string> lines = Pet(staff);
Check.Eq(lines.Count, 3, "line count");
Check.Eq(lines[0], "Flaming Quarter Staff (Fire Staff), Grade S (100%), Craft 9", "identity line");
Check.Eq(lines[1], "FireRend +176%, Crushing Blow 3.66x, 1790-2069, 0.135v, +20%a, +20%md", "combat line");
Check.Eq(lines[2], "[CD 24] Wield 2,000 Item Augs", "ratings / requirements line");
}
private static void BitingStrikeAndPenalty()
{
var sword = new FakeItem("Sword", AcObjectClass.MeleeWeapon);
sword.Ints[44] = 100;
sword.Doubles[147] = 0.15; // Biting Strike
sword.Doubles[136] = 1.0; // normal 2x crit, not Crushing Blow
sword.Doubles[29] = 0.95; // -5% melee defense
string line = MagItemDescriber.Describe(sword, MagItemInfoOptions.Default);
Check.True(line.Contains("Biting Strike 15%"), $"Biting Strike shown: {line}");
Check.False(line.Contains("Crushing Blow"), $"1.0 multiplier is not Crushing Blow: {line}");
Check.True(line.Contains("-5%md"), $"penalty keeps its sign: {line}");
Check.True(line.Contains(", 100,") || line.EndsWith(", 100"), $"no variance prints max only: {line}");
}
private static void RetailImbuesBare()
{
var axe = new FakeItem("Axe", AcObjectClass.MeleeWeapon);
axe.Ints[179] = 0x0001 | 0x0004; // CS + AR
string line = MagItemDescriber.Describe(axe, MagItemInfoOptions.Default);
Check.True(line.Contains(", CS AR"), $"bare Mag labels: {line}");
axe.Strings[16] =
"Property Details:\n" +
"- Critical Strike: +12.5 % Crit Chance\n" + // culture space before %
"- Armor Rending: 30.0% Ignored\n";
line = MagItemDescriber.Describe(axe, MagItemInfoOptions.Default);
Check.True(line.Contains("CS +12.5%, AR 30.0%"), $"strengths from detail text: {line}");
}
private static void Int64WieldHidden()
{
var mace = new FakeItem("Mace", AcObjectClass.MeleeWeapon);
mace.Ints[158] = 13; // WieldRequirement.Int64Stat
mace.Ints[159] = 9008; // LumAugItemCount
mace.Ints[160] = 2500;
string line = MagItemDescriber.Describe(mace, MagItemInfoOptions.Default);
Check.False(line.Contains("Skill 9008"), $"no fake skill name: {line}");
}
private static void T11ArmorModifiers()
{
var helm = new FakeItem("T11 - Helm", AcObjectClass.Armor);
helm.Strings[16] = "Wield requires: 500 Triune Weave\n";
helm.Strings[14] =
"Modifiers:\n" +
"- Damage Resist +6 [2-12]\n" +
"- Max Health +100 [40-200]\n";
List<string> lines = Pet(helm);
string last = lines[^1];
Check.True(last.Contains("Mods: Damage Resist +6, Max Health +100"), $"modifiers listed: {last}");
Check.True(last.Contains("Wield 500 Triune Weave"), $"triune gate listed: {last}");
}
}

View file

@ -0,0 +1,127 @@
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();
}
}