feat: SK backlog from test through 2026.11.22.48 (Trade Shop, Oracle, quests, loot, nav)

Squash of test/main-merge-2026-10-25 onto aelrynth main 2026.11.19.1 for the standing sk PR. Includes Trade Shop, Oracle wiki/ILT tracker, quest runs, loot checklist, RynthNav, VTank import. HandWrittenVersion remains 0.5.0-legacy-ui. See Changelog/2026-11-22-sk-backlog-test-merge.md.
This commit is contained in:
BlankenshipG 2026-11-23 00:08:38 -05:00
commit dc08e1abba
521 changed files with 47247 additions and 795 deletions

View file

@ -4,6 +4,7 @@ using System.Linq;
using System.Text.RegularExpressions;
using RynthCore.Loot;
using RynthCore.Loot.Editing;
using RynthCore.Loot.T11;
using RynthCore.Loot.VTank;
namespace RynthCore.LootSdkTests;
@ -24,6 +25,14 @@ internal static partial class Program
TestAttrPetEssence();
TestAttrNativeAndWire();
TestAttrVocab();
TestAttrImbues();
TestBlankRule();
TestAnyAndHasAll();
TestPlusARend();
TestImbuesByClass();
TestEditRoundTrip();
TestCardText();
TestIltGate();
}
private static LootItemFacts Sword() => new()
@ -93,13 +102,13 @@ internal static partial class Program
private static void TestAttrSpellTiers()
{
Eq(LootItemAttributes.SpellPattern("Major Strength", LootItemAttributeOp.SpellOrBetter), "^(Major|Epic|Legendary) Strength$", "spell: cantrip or better");
Eq(LootItemAttributes.SpellPattern("Major Strength", LootItemAttributeOp.SpellAnyTier), "^(Minor|Major|Epic|Legendary) Strength$", "spell: cantrip any tier");
Eq(LootItemAttributes.SpellPattern("Major Strength", LootItemAttributeOp.SpellOrBetter), "^(Major|Epic|Legendary|Paragon(?:'s)?) Strength$", "spell: cantrip or better");
Eq(LootItemAttributes.SpellPattern("Major Strength", LootItemAttributeOp.SpellAnyTier), "^(Minor|Major|Epic|Legendary|Paragon(?:'s)?) Strength$", "spell: cantrip any tier");
Eq(LootItemAttributes.SpellPattern("Major Strength", LootItemAttributeOp.SpellExact), "^Major Strength$", "spell: exact");
Eq(LootItemAttributes.SpellPattern("Blood Drinker Self VI", LootItemAttributeOp.SpellOrBetter), "^Blood Drinker Self (VI|VII|VIII)$", "spell: level or better");
Eq(LootItemAttributes.SpellPattern("Legendary Blood Thirst", LootItemAttributeOp.SpellOrBetter), "^(Legendary) Blood Thirst$", "spell: Legendary or better is Legendary");
Eq(LootItemAttributes.SpellPattern("Legendary Blood Thirst", LootItemAttributeOp.SpellOrBetter), "^(Legendary|Paragon(?:'s)?) Blood Thirst$", "spell: Legendary or better is Legendary");
Eq(LootItemAttributes.SpellPattern("Aura of Defender", LootItemAttributeOp.SpellOrBetter), "^Aura of Defender$", "spell: no tier: exact");
Eq(LootItemAttributes.SpellPattern("Major Strength (II)", LootItemAttributeOp.SpellOrBetter), "^(Major|Epic|Legendary) Strength \\(II\\)$", "spell: the rest is escaped");
Eq(LootItemAttributes.SpellPattern("Major Strength (II)", LootItemAttributeOp.SpellOrBetter), "^(Major|Epic|Legendary|Paragon(?:'s)?) Strength \\(II\\)$", "spell: the rest is escaped");
string orBetter = LootItemAttributes.SpellPattern("Epic Heart Thirst", LootItemAttributeOp.SpellOrBetter);
Check(Regex.IsMatch("Legendary Heart Thirst", orBetter, RegexOptions.IgnoreCase), "spell: Legendary is better than Epic");
@ -115,20 +124,20 @@ internal static partial class Program
var many = new LootItemFacts { Name = "Robe", ObjectClass = (int)AcObjectClass.Clothing, Spells = { "Minor Focus", "Major Willpower", "Epic Strength", "Legendary Endurance", "Major Coordination" } };
LootItemRuleDraft d = BuildOk(many, new() { Match = LootItemMatch.Like, Choices = Pick(("spell:Major Coordination", true, LootItemAttributeOp.SpellAnyTier, "")) });
Eq(d.Rule.Conditions.Count(x => x.NodeType == VTankNodeTypes.SpellNameMatch), 5, "spell: a fifth spell can be ticked");
Check(d.Rule.Conditions.Any(x => Lines(x) == "0:^(Minor|Major|Epic|Legendary) Coordination$"), "spell: any tier pattern in the rule");
Check(d.Rule.Conditions.Any(x => Lines(x) == "0:^(Minor|Major|Epic|Legendary|Paragon(?:'s)?) Coordination$"), "spell: any tier pattern in the rule");
}
private static void TestAttrCantripCounts()
{
List<LootItemAttribute> rows = BuildOk(Sword()).Attributes;
Eq(string.Join(",", rows.Where(r => r.Id.StartsWith("cantrips:")).Select(r => r.Label + "=" + r.ItemText)),
"Legendary cantrips=1,Epic-or-better cantrips=2,Major-or-better cantrips=3", "cantrips: a row per tier the item has, highest first");
"Legendary-or-better cantrips=1,Epic-or-better cantrips=2,Major-or-better cantrips=3", "cantrips: a row per tier the item has, highest first");
Check(rows.Any(r => r.Id == "spellcount" && r.ItemText == "4"), "cantrips: spell count");
LootItemRuleDraft d = BuildOk(Sword(), new() { Choices = Pick(("cantrips:Epic", true, LootItemAttributeOp.AtLeast, "2"), ("spellcount", true, LootItemAttributeOp.AtLeast, "3")) });
Check(d.Rule.Conditions.Any(x => Lines(x) == "9:^(Epic|Legendary) ||2"), "cantrips: Spell Match, Epic or Legendary, at least 2");
Check(d.Rule.Conditions.Any(x => Lines(x) == "9:^(Epic|Legendary|Paragon(?:'s)?) ||2"), "cantrips: Spell Match, Epic or Legendary, at least 2");
Check(d.Rule.Conditions.Any(x => Lines(x) == "8:3"), "cantrips: spell count >= 3");
Check(LootItemRules.PreviewLines(d.Rule).Any(l => l.Contains(">= 2 spells matching")), "cantrips: preview in words");
Check(LootItemRules.PreviewLines(d.Rule).Any(l => l.Contains("at least 2 spells matching")), "cantrips: preview in words");
}
private static void TestAttrPetEssence()
@ -181,12 +190,211 @@ internal static partial class Program
private static void TestAttrVocab()
{
Eq(LootRuleText.ValueName(353, "4"), "Armor Rending", "vocab: imbue names");
Eq(LootRuleText.ValueName(179, "4"), "Armor Rending", "vocab: imbue names (ImbuedEffect is 179)");
Eq(LootRuleText.ValueName(353, "9"), "Crossbow", "vocab: 353 is the weapon type, not the imbue");
Eq(LootRuleText.ValueName(353, "4"), "Mace", "vocab: 353 = 4 is a mace");
Check(LootRuleText.ValueTableIsFlags(179) && !LootRuleText.ValueTableIsFlags(353), "imbue is flags, weapon type isn't");
Eq(LootRuleText.ValueName(362, "3"), "Naturalist", "vocab: summoning mastery");
Check(LootRuleText.LongKeys.Any(k => k.Id == 9053) && LootRuleText.LongKeys.Any(k => k.Id == 9075), "vocab: pet keys named");
Check(LootRuleText.LongKeys.Any(k => k.Id == 92 && k.Name.StartsWith("UsesRemaining")), "vocab: 92 is uses remaining");
Check(LootRuleText.LongKeys.Any(k => k.Id == 107 && k.Name == "ItemCurMana") && LootRuleText.LongKeys.Any(k => k.Id == 108 && k.Name == "ItemMaxMana"), "vocab: current and max mana");
Check(LootRuleText.LongKeys.Any(k => k.Id == 92 && k.Name == "Uses left"), "vocab: 92 is uses remaining");
Check(LootRuleText.LongKeys.Any(k => k.Id == 107 && k.Name == "Current mana") && LootRuleText.LongKeys.Any(k => k.Id == 108 && k.Name == "Max mana"), "vocab: current and max mana");
var ids = LootRuleText.LongKeys.Select(k => k.Id).ToList();
Eq(ids.Count, ids.Distinct().Count(), "vocab: no long key named twice");
}
// 2026-11-07: imbues are 179 (with 303-306), "has any" picks several, and Add rule's blank checklist.
private static void TestAttrImbues()
{
var wand = new LootItemFacts
{
Id = 20, Name = "Fire Wand", ObjectClass = (int)AcObjectClass.WandStaffOrb,
Ints = { [179] = 4, [303] = 512, [353] = 12 },
};
Eq(wand.Int(179), 516, "imbues: 179 is ORed with ImbuedEffect2-5");
LootItemRuleDraft? d = LootItemRules.Build(wand, new LootItemRuleOptions { Match = LootItemMatch.Like }, out string err);
LootItemAttribute? imbue = d?.Attributes.FirstOrDefault(a => a.Id == "L:179");
LootItemAttribute? wtype = d?.Attributes.FirstOrDefault(a => a.Id == "L:353");
Check(imbue != null && imbue.Ops[0] == LootItemAttributeOp.HasAny, "imbues: the Imbue row is 179 and starts at has any " + err);
Check(wtype != null && wtype.Label == "Weapon type" && wtype.ItemText == "Magic", "imbues: 353 is the weapon type row");
// Any elemental rend, in one rule.
LootItemRuleDraft b = LootItemRules.BuildBlank(new LootItemRuleOptions
{
BlankRule = true,
Choices = Pick(("L:179", true, LootItemAttributeOp.HasAny, "17400")),
});
VTankLootCondition c = b.Rule.Conditions.Single();
Eq(c.NodeType, VTankNodeTypes.LongValKeyFlagExists, "has any: Long Key Has Flag");
Eq(string.Join(",", c.DataLines), "17400,179", "has any: the flags then the key");
Eq(LootRuleText.Condition(c), "Imbue has Any elemental rend", "has any: in words");
bool Takes(LootItemFacts f) => LootFactsMatcher.Match(b.Rule.Conditions, f, true) == LootFactsVerdict.Match;
Check(Takes(wand), "has any: a fire rend in ImbuedEffect2 counts");
Check(!Takes(new LootItemFacts { ObjectClass = (int)AcObjectClass.MeleeWeapon, Ints = { [179] = 4 } }), "has any: armor rending alone is no elemental rend");
Check(Takes(new LootItemFacts { ObjectClass = (int)AcObjectClass.MeleeWeapon, Ints = { [179] = 128 } }), "has any: cold rend counts");
Eq(LootRuleText.ValueName(179, "17344"), "Any magical-element rend", "has any: acid, cold, electric, fire, nether");
}
private static void TestBlankRule()
{
LootItemRuleDraft b = LootItemRules.BuildBlank(new LootItemRuleOptions
{
BlankRule = true, Action = VTankLootAction.KeepUpTo, KeepCount = 5,
Choices = Pick(("class", true, LootItemAttributeOp.Exactly, ((int)AcObjectClass.Jewelry).ToString()), ("L:105", true, LootItemAttributeOp.AtLeast, "7")),
});
Eq(b.Rule.Action, VTankLootAction.KeepUpTo, "blank rule: the action");
Eq(b.Rule.KeepCount, 5, "blank rule: the keep count");
Eq(b.Rule.Conditions.Count, 2, "blank rule: the ticked rows");
Check(b.Rule.Name.StartsWith("Keep 5: Class is Jewelry"), "blank rule: named from the action and conditions: " + b.Rule.Name);
LootItemRuleDraft f = LootItemRules.BuildBlank(new LootItemRuleOptions());
Eq(f.Rule.Name, "Filter", "blank filter: still named Filter");
}
// 2026-11-07 (2): any slayer, multi imbues, imbues by class, editing a rule, ACECustom's card text.
private static void TestAnyAndHasAll()
{
LootItemRuleDraft b = LootItemRules.BuildBlank(new LootItemRuleOptions
{
BlankRule = true,
Choices = Pick(("L:166", true, LootItemAttributeOp.Any, ""), ("L:179", true, LootItemAttributeOp.HasAll, (4 | 512).ToString())),
});
var c = b.Rule.Conditions;
Eq(c.Count, 3, "any + has all: slayer >= 1 and two has-flag conditions");
Check(c.Any(x => x.NodeType == VTankNodeTypes.LongValKeyGE && string.Join(",", x.DataLines) == "1,166"), "any slayer: Long Key >= 1 on 166");
Eq(string.Join("|", c.Where(x => x.NodeType == VTankNodeTypes.LongValKeyFlagExists).Select(x => x.DataLines[0] + "@" + x.DataLines[1])),
"4@179|512@179", "has all: one has-flag per imbue");
bool Takes(LootItemFacts f) => LootFactsMatcher.Match(b.Rule.Conditions, f, true) == LootFactsVerdict.Match;
Check(Takes(new LootItemFacts { ObjectClass = (int)AcObjectClass.MeleeWeapon, Ints = { [166] = 31, [179] = 4 | 512 } }), "has all: armor rend + fire rend slayer");
Check(!Takes(new LootItemFacts { ObjectClass = (int)AcObjectClass.MeleeWeapon, Ints = { [166] = 31, [179] = 512 } }), "has all: fire rend alone isn't enough");
Check(!Takes(new LootItemFacts { ObjectClass = (int)AcObjectClass.MeleeWeapon, Ints = { [179] = 4 | 512 } }), "any slayer: no slayer, no match");
// The rule's name and view say "any", not the value numbered 1 (2026-11-08: "any defaults to Olthoi in name").
LootItemRuleDraft only = LootItemRules.BuildBlank(new LootItemRuleOptions { BlankRule = true, Choices = Pick(("L:166", true, LootItemAttributeOp.Any, "")) });
Eq(only.Rule.Name, "Keep: any Slayer type", "any slayer: the name says any, not Olthoi");
Eq(LootRuleText.Condition(c.First(x => x.NodeType == VTankNodeTypes.LongValKeyGE)), "any Slayer type", "any slayer: the rule view says any");
}
// 2026-11-08: "armor rend + bs + cs, but also with any elemental on it" (Copper Frost Knife: Armor Rending, Cold
// Rending, Biting Strike). The Imbue row "has all" Armor Rending + Critical Strike, the "Plus a rend" row any element.
private static void TestPlusARend()
{
LootItemRuleDraft b = LootItemRules.BuildBlank(new LootItemRuleOptions
{
BlankRule = true,
Choices = Pick(("class", true, LootItemAttributeOp.Exactly, ((int)AcObjectClass.MeleeWeapon).ToString()),
("L:179", true, LootItemAttributeOp.HasAll, (4 | 1).ToString()),
(LootItemAttributes.RendRowId, true, LootItemAttributeOp.HasAny, "17400")),
});
Eq(string.Join("|", b.Rule.Conditions.Where(x => x.NodeType == VTankNodeTypes.LongValKeyFlagExists).Select(x => x.DataLines[0] + "@" + x.DataLines[1])),
"1@179|4@179|17400@179", "plus a rend: crit and armor rend each, then any rend");
bool Takes(int imbues) => LootFactsMatcher.Match(b.Rule.Conditions,
new LootItemFacts { ObjectClass = (int)AcObjectClass.MeleeWeapon, Ints = { [179] = imbues } }, true) == LootFactsVerdict.Match;
Check(Takes(4 | 1 | 128), "plus a rend: armor rend + crit + cold rend");
Check(Takes(4 | 1 | 8), "plus a rend: armor rend + crit + slash rend");
Check(!Takes(4 | 1), "plus a rend: no rend, no match");
Check(!Takes(4 | 128), "plus a rend: no crit, no match");
Check(!Takes(128), "plus a rend: a rend alone, no match");
// Read back into the checklist: both rows, nothing left over.
List<LootEditItemChoice> ch = LootItemAttributes.ChoicesFromRule(LootItemAttributes.ForBlank(), b.Rule.Conditions, out List<VTankLootCondition> kept);
Eq(kept.Count, 0, "plus a rend: none kept as written");
Check(ch.Any(x => x.Id == "L:179" && x.Op == (int)LootItemAttributeOp.HasAll && x.Value == "5"), "plus a rend: imbue reads back as has all crit + armor rend");
Check(ch.Any(x => x.Id == LootItemAttributes.RendRowId && x.Value == "17400"), "plus a rend: the rend row reads back");
// Armor has no rend row; an item with two imbues starts at "has all".
LootItemRuleDraft ar = LootItemRules.BuildBlank(new LootItemRuleOptions
{
BlankRule = true, Choices = Pick(("class", true, LootItemAttributeOp.Exactly, ((int)AcObjectClass.Armor).ToString())),
});
Check(!ar.Attributes.Any(x => x.Id == LootItemAttributes.RendRowId), "plus a rend: none for armor");
List<LootItemAttribute> item = LootItemAttributes.For(new LootItemFacts { ObjectClass = (int)AcObjectClass.MeleeWeapon, Ints = { [179] = 4 | 128 } }, false, false);
Check(item.Any(x => x.Id == "L:179" && x.Op == LootItemAttributeOp.HasAll), "an item's two imbues: has all, not has any");
Check(item.Any(x => x.Id == LootItemAttributes.RendRowId), "an item's checklist has the rend row");
}
private static void TestImbuesByClass()
{
(int Id, string Name)[]? ChoicesFor(int cls, out LootItemAttribute row)
{
LootItemRuleDraft b = LootItemRules.BuildBlank(new LootItemRuleOptions
{
BlankRule = true,
Choices = Pick(("class", true, LootItemAttributeOp.Exactly, cls.ToString())),
});
row = b.Attributes.First(a => a.Id == "L:179");
return row.ToWire().Choices?.Select(x => (x.Id, x.Name)).ToArray();
}
var caster = ChoicesFor((int)AcObjectClass.WandStaffOrb, out LootItemAttribute cr)!;
Check(caster.Any(x => x.Name == "Nether Rending") && caster.Any(x => x.Name == "Armor Rending"), "casters: nether rend and armor rend");
Check(cr.Ops.Contains(LootItemAttributeOp.HasAll), "casters: several imbues");
var melee = ChoicesFor((int)AcObjectClass.MeleeWeapon, out _)!;
Check(melee.Any(x => x.Name == "Armor Rending") && !melee.Any(x => x.Name == "Nether Rending"), "melee: armor rend, no nether");
var armor = ChoicesFor((int)AcObjectClass.Armor, out LootItemAttribute ar)!;
Check(armor.All(x => x.Name.Contains("defense", StringComparison.OrdinalIgnoreCase)), "armor: defense imbues only");
Check(!ar.Ops.Contains(LootItemAttributeOp.HasAll), "armor: one imbue at a time");
Check(ar.ToWire().Flags, "imbue row is flags on the wire");
}
private static void TestEditRoundTrip()
{
var rule = new VTankLootRule { Name = "Fire rend slayer", Action = VTankLootAction.Keep, CustomExpression = string.Empty };
void Add(int type, params string[] d) => rule.Conditions.Add(new VTankLootCondition(type, "0", d));
Add(VTankNodeTypes.ObjectClass, ((int)AcObjectClass.MeleeWeapon).ToString());
Add(VTankNodeTypes.LongValKeyFlagExists, "4", "179");
Add(VTankNodeTypes.LongValKeyFlagExists, "512", "179");
Add(VTankNodeTypes.LongValKeyGE, "1", "166");
Add(VTankNodeTypes.DoubleValKeyGE, "0.4", "147");
Add(VTankNodeTypes.StringValueMatch, "Sword", "1"); // no checklist row: kept as written
var rows = LootItemAttributes.ForBlank();
List<LootEditItemChoice> ch = LootItemAttributes.ChoicesFromRule(rows, rule.Conditions, out List<VTankLootCondition> kept);
Eq(kept.Count, 1, "edit: the name match is kept as written");
LootEditItemChoice? imb = ch.FirstOrDefault(x => x.Id == "L:179");
Check(imb != null && imb.Op == (int)LootItemAttributeOp.HasAll && imb.Value == "516", "edit: two has-flags read back as has all");
Check(ch.Any(x => x.Id == "L:166" && x.Op == (int)LootItemAttributeOp.Any), "edit: slayer >= 1 reads back as any");
LootItemRuleDraft b = LootItemRules.BuildBlank(new LootItemRuleOptions { BlankRule = true, Choices = ch, KeepConditions = kept, RuleName = rule.Name });
Eq(string.Join(";", b.Rule.Conditions.Select(LootRuleText.Condition).OrderBy(x => x)),
string.Join(";", rule.Conditions.Select(LootRuleText.Condition).OrderBy(x => x)), "edit: rebuilding gives the same tests");
Eq(b.Rule.Name, "Fire rend slayer", "edit: the name stays");
// Four "has flag" on the imbue (a caster rule: Nether + Armor Rending + Crit + Cripple): one has all, nothing left over.
var four = new VTankLootRule { Name = "[Wpn C] T11+ Caster", Action = VTankLootAction.Keep, CustomExpression = string.Empty };
four.Conditions.Add(new VTankLootCondition(VTankNodeTypes.ObjectClass, "0", new[] { ((int)AcObjectClass.WandStaffOrb).ToString() }));
foreach (string bit in new[] { "16384", "4", "1", "2" })
four.Conditions.Add(new VTankLootCondition(VTankNodeTypes.LongValKeyFlagExists, "0", new[] { bit, "179" }));
List<LootEditItemChoice> ch4 = LootItemAttributes.ChoicesFromRule(LootItemAttributes.ForBlank(), four.Conditions, out List<VTankLootCondition> kept4);
Eq(kept4.Count, 0, "edit: four imbues, none kept as written");
Check(ch4.Any(x => x.Id == "L:179" && x.Op == (int)LootItemAttributeOp.HasAll && x.Value == (16384 | 4 | 1 | 2).ToString()), "edit: four imbues read back as has all");
LootItemRuleDraft b4 = LootItemRules.BuildBlank(new LootItemRuleOptions { BlankRule = true, Choices = ch4, KeepConditions = kept4 });
Eq(b4.Rule.Conditions.Count(x => x.NodeType == VTankNodeTypes.LongValKeyFlagExists), 4, "edit: the caster keeps all four imbues");
Eq(LootRuleText.Condition(four.Conditions[1]), "Imbue has Nether Rending", "rule view: a has-flag value by name");
}
private static void TestCardText()
{
const string desc = "Property Details:\n- Fire Rending: +213% Dmg\n- Spell Armor Rend: 35% Spell Armor Ignored\n- All Creatures Slayer: 2.10x Damage\n- Phantom: Ignores Magic Protections";
T11ItemInfo t = T11ItemInfo.Parse("T11 - Zealous Wand", desc, "Tier 11");
Eq(t.RendPowerPercent, 213, "cards: rend power");
Eq(t.SpellArmorRendPercent, 35, "cards: spell armor rend");
Check(t.AllCreaturesSlayer && t.SlayerDamagePercent == 210, "cards: all creatures slayer 2.1x");
Check(t.Phantom, "cards: phantom");
var f = new LootItemFacts { Name = "T11 - Zealous Wand", ObjectClass = (int)AcObjectClass.WandStaffOrb, T11 = t };
Eq(f.Int(T11Keys.SpellArmorRend), 35, "cards: the virtual key reads from the text");
}
// 2026-11-07: T11, weapon cards and pets only on Infinite Leaftide.
private static void TestIltGate()
{
var off = LootItemAttributes.ForBlank(ilt: false);
var on = LootItemAttributes.ForBlank(ilt: true);
Check(on.Any(r => r.Group == LootItemAttributes.GroupT11) && !off.Any(r => r.Group == LootItemAttributes.GroupT11), "gate: T11 rows only on Leaftide");
Check(on.Any(r => r.Group == LootItemAttributes.GroupPet) && !off.Any(r => r.Group == LootItemAttributes.GroupPet), "gate: pet rows only on Leaftide");
Check(!off.Any(r => r.Id == "L:" + T11Keys.SpellArmorRend) && on.Any(r => r.Id == "L:" + T11Keys.SpellArmorRend), "gate: text-only cards only on Leaftide");
Check(off.Any(r => r.Id == "D:147") && off.Any(r => r.Id == "L:179"), "gate: ACE's real cards and imbues stay everywhere");
var vOff = LootRuleText.BuildVocab(ilt: false);
Check(!vOff.Ilt && !vOff.LongKeys.Any(k => T11Keys.IsVirtual(k.Id) || k.Id == 9053), "gate: the pickers offer no T11 / pet keys off Leaftide");
Check(LootRuleText.BuildVocab(ilt: true).LongKeys.Any(k => T11Keys.IsVirtual(k.Id)), "gate: and do on Leaftide");
// A Leaftide rule edited elsewhere keeps its T11 test as written.
var rule = new VTankLootRule { Name = "t11", Action = VTankLootAction.Keep, CustomExpression = string.Empty };
rule.Conditions.Add(new VTankLootCondition(VTankNodeTypes.LongValKeyGE, "11", new[] { "11", T11Keys.EstimatedTier.ToString() }));
LootItemAttributes.ChoicesFromRule(off, rule.Conditions, out List<VTankLootCondition> kept);
Eq(kept.Count, 1, "gate: off Leaftide a T11 condition is kept as written");
}
}

View file

@ -177,7 +177,7 @@ internal static partial class Program
{
Console.WriteLine("\n-- LootAdd: preview and placement --");
List<string> p = LootItemRules.PreviewLines(BuildOk(Opal(), new() { Match = LootItemMatch.Like }).Rule);
Eq(string.Join(" / ", p), "Rule: Keep like Black Opal / Action: Keep / If: Class is Gem / and MaterialType = Black Opal / and ItemWorkmanship >= 6",
Eq(string.Join(" / ", p), "Rule: Keep like Black Opal / Action: Keep / If: Class is Gem / and Material is Black Opal / and Workmanship at least 6",
"preview lines (values by name)");
List<string> k = LootItemRules.PreviewLines(BuildOk(Pea()).Rule);
Eq(k[1], "Action: Keep # 100", "Keep # preview");

View file

@ -0,0 +1,45 @@
using System.Collections.Generic;
using RynthCore.Loot;
using RynthCore.Loot.Editing;
using RynthCore.Loot.T11;
using RynthCore.Loot.VTank;
namespace RynthCore.LootSdkTests;
// 2026-11-15, Silentkelpie: "is the any slayer rule working for looting". ACECustom never sends the slayer bonus
// (float 138), only "- Shadow Slayer: 1.5x Damage" in the weapon's text, so "Slayer damage bonus at least 1.01"
// never matched. The slayer type (int 166, "any slayer") always worked.
internal static partial class Program
{
private static void RunSlayerTextTests()
{
System.Console.WriteLine("\n-- Slayer: the damage bonus from the weapon's text --");
Eq(SlayerText.BonusOf("Property Details:\n- Weapon Grade: C+ (70% of max damage)\n- Shadow Slayer: 1.5x Damage\n- Biting Strike: +35% Crit Chance\n"),
1.5, "slayer: the bonus from a Property Details line");
Eq(SlayerText.BonusOf("- Banderling Slayer: 2.1x Damage"), 2.1, "slayer: two words before Slayer");
Eq(SlayerText.BonusOf(null, "- All Creatures Slayer: 1.25x Damage"), 1.25, "slayer: All Creatures, from the second text");
Eq(SlayerText.BonusOf("- Undead Slayer: 1.3x Damage\n- Olthoi Slayer: 1.8x Damage"), 1.8, "slayer: the best of two");
Eq(SlayerText.BonusOf("A fine sword.", null, ""), 0.0, "slayer: no slayer line, 0");
Eq(SlayerText.BonusOf("- Biting Strike: +35% Crit Chance"), 0.0, "slayer: other card lines, 0");
// The rule reader: float 138 missing (as on ACECustom) reads the text's bonus.
var t11 = T11ItemInfo.Parse("Khanda-handled Mace",
"Property Details:\n- Weapon Grade: C+ (70% of max damage)\n- Properties: 2 of 5\n- Shadow Slayer: 1.5x Damage\n", null);
var f = new LootItemFacts { Name = "Khanda-handled Mace", ObjectClass = 1, T11 = t11 };
f.Ints[166] = 22;
Eq(f.Double(SlayerText.SlayerDamageBonusKey), 1.5, "slayer: Double(138) falls back to the text");
f.Doubles[138] = 1.7;
Eq(f.Double(SlayerText.SlayerDamageBonusKey), 1.7, "slayer: a sent value wins");
f.Doubles.Remove(138);
// The profile's rule shape: any slayer AND Slayer damage bonus at least 1.01.
var conds = new List<VTankLootCondition>
{
new(VTankNodeTypes.LongValKeyGE, "0", new[] { "1", "166" }),
new(VTankNodeTypes.DoubleValKeyGE, "0", new[] { "1.01", "138" }),
};
Eq(LootFactsMatcher.Match(conds, f, identified: true), LootFactsVerdict.Match, "slayer: 'any slayer + bonus >= 1.01' matches a Shadow Slayer");
var plain = new LootItemFacts { Name = "Spada", ObjectClass = 1, T11 = T11ItemInfo.Parse("Spada", "Property Details:\n- Weapon Grade: B (80% of max damage)\n", null) };
Eq(LootFactsMatcher.Match(conds, plain, identified: true), LootFactsVerdict.NoMatch, "slayer: and not a weapon without one");
}
}

View file

@ -0,0 +1,48 @@
using System;
using System.Collections.Generic;
using System.Linq;
using RynthCore.Loot;
using RynthCore.Loot.Editing;
using RynthCore.Loot.T11;
using RynthCore.Loot.VTank;
namespace RynthCore.LootSdkTests;
// ACECustom's newer T11-era loot items (2026-11-11): the "T11 item" keys and the checklist rows.
internal static partial class Program
{
private static void RunT11ItemTests()
{
Console.WriteLine("\n-- T11 items: bounties, school gems, infusion gems, tokens --");
const string bounty = "Kill 250 Banderlings in Tier 15. Only your own kills count, and only in Tier 15. Reward: 5 x Bounty Reward Token, paid to your pack automatically when done. Use it on a ring or bracelet you have to start it; /bounty shows your slots.";
Eq(T11Items.KindOf(0, bounty), T11Items.ItemBounty, "t11 item: a bounty by its description");
Eq(T11Items.TierOf(T11Items.ItemBounty, bounty, 0), 15, "t11 item: the bounty's tier");
Eq(T11Items.TierOf(T11Items.ItemBounty, "Kill 400 creatures in Valley of Death. Use it on a ring or bracelet you have to start it", 0), 0, "t11 item: a region bounty has no tier");
Eq(T11Items.KindOf(777700057, null), T11Items.SchoolGem, "t11 item: a school gem by WCID");
Eq(T11Items.TierOf(T11Items.SchoolGem, null, 17), 17, "t11 item: the gem's earned tier");
Eq(T11Items.KindOf(777700094, null), T11Items.InfusionGem, "t11 item: an infusion gem");
Eq(T11Items.CoinsOf(777700094), 100, "t11 item: its coins");
Eq(T11Items.KindOf(777700038, null), T11Items.LevelledCharm, "t11 item: Improved Cleave is a levelled charm");
Eq(T11Items.KindOf(777708010, null), T11Items.BountyRewardToken, "t11 item: a bounty reward token");
Eq(T11Items.KindOf(99980078, null), T11Items.EventLumToken, "t11 item: an event lum token");
Eq(T11Items.KindOf(78780032, null), T11Items.UniversalQuiver, "t11 item: the Universal Quiver Charm");
Eq(T11Items.KindOf(273, "A pile of pyreals."), T11Items.None, "t11 item: anything else");
// A clicked school gem: "T11 item is School gem" ticked, its tier offered.
var f = new LootItemFacts { Name = "School Gem", ObjectClass = (int)AcObjectClass.Gem };
f.Ints[T11Keys.ItemKind] = T11Items.SchoolGem;
f.Ints[T11Keys.ItemTier] = 16;
LootItemRuleDraft? d = LootItemRules.Build(f, new LootItemRuleOptions(), out string err);
Check(d != null, "t11 item: a rule for a school gem builds " + err);
if (d != null)
{
var conds = d.Rule.Conditions.Select(c => $"{c.NodeType}:{string.Join(",", c.DataLines)}").ToList();
Check(conds.Any(c => c.EndsWith("," + T11Keys.ItemKind) && c.Contains(":" + T11Items.SchoolGem + ",")), "t11 item: the kind is required: " + string.Join(" ; ", conds));
Check(!conds.Any(c => c.EndsWith("," + T11Keys.ItemTier)), "t11 item: the tier is offered, not ticked");
Check(LootItemRules.PreviewLines(d.Rule).Any(l => l.Contains("School gem")), "t11 item: the preview names the kind");
}
// The blank checklist (Add rule) has the rows too.
var blank = LootItemAttributes.ForBlank();
Check(blank.Exists(r => r.Id == "t11:itemkind") && blank.Exists(r => r.Id == "t11:itemtier"), "t11 item: Add rule offers the T11 item rows");
}
}

View file

@ -144,7 +144,7 @@ internal static partial class Program
// A low stamped tier on a plain item doesn't make it T11.
Check(!T11ItemInfo.Parse("Celdon Breastplate", null, null, new T11ServerProps(7, 0, -1)).IsT11, "server: tier 7 is not T11");
Check(LootRuleText.LongKeys.Any(k => k.Id == T11Catalog.PropZcTier && k.Name == "ZcTier"), "server: editor names ZcTier");
Check(LootRuleText.LongKeys.Any(k => k.Id == T11Catalog.PropZcTier && k.Name == "T11 zone tier"), "server: editor names ZcTier");
Check(LootRuleText.LongKeys.Any(k => k.Id == T11Catalog.PropWeaponAugScaleQuality), "server: editor lists WeaponAugScaleQuality");
Check(LootRuleText.LongKeys.Any(k => k.Id == T11Catalog.PropWeaponAugScaleTier), "server: editor lists WeaponAugScaleTier");
Eq(LootRuleText.ValueName(T11Keys.GearGrade, "16"), "S", "server: gear grade value table");

View file

@ -47,7 +47,7 @@ internal static partial class Program
Eq(table.Select(t => t.Name).Distinct().Count(), table.Length, $"{label}: names unique");
}
Check(ReferenceEquals(LootRuleText.ValueTableFor(166), LootRuleText.CreatureTypes), "166 Slayer Type -> creature types");
Eq(LootRuleText.LongKeys.First(k => k.Id == 166).Name, "Slayer Type", "166 player-facing name");
Eq(LootRuleText.LongKeys.First(k => k.Id == 166).Name, "Slayer type", "166 player-facing name");
Eq(LootRuleText.ValueName(166, "1"), "Olthoi", "ValueName 166/1 Olthoi");
Check(LootRuleText.CreatureTypes.Select(t => t.Name)
.SequenceEqual(LootRuleText.CreatureTypes.Select(t => t.Name).OrderBy(n => n, StringComparer.OrdinalIgnoreCase)),
@ -84,10 +84,10 @@ internal static partial class Program
Eq(LootRuleText.ValueName(159, "999"), null, "ValueName unknown value");
Eq(LootRuleText.ValueName(160, "45"), null, "ValueName key without a table");
Eq(LootRuleText.ValueName(159, "abc"), null, "ValueName not a number");
Eq(LootRuleText.ValueLabel(159, "45"), "Light Weapons (45)", "ValueLabel named");
Eq(LootRuleText.ValueLabel(131, "999"), "value 999", "ValueLabel unknown");
Eq(LootRuleText.ValueLabel(45, "7"), "value 7", "ValueLabel flag combination not named");
Eq(LootRuleText.ValueLabel(160, "300"), "value 300", "ValueLabel plain key");
Eq(LootRuleText.ValueLabel(159, "45"), "Light Weapons", "ValueLabel named");
Eq(LootRuleText.ValueLabel(131, "999"), "999", "ValueLabel unknown");
Eq(LootRuleText.ValueLabel(45, "7"), "7", "ValueLabel flag combination not named");
Eq(LootRuleText.ValueLabel(160, "300"), "300", "ValueLabel plain key");
Check(LootRuleText.TryParseValue("-3", out int neg) && neg == -3, "TryParseValue negative");
Check(!LootRuleText.TryParseValue("4.5", out _), "TryParseValue refuses a fraction");
@ -95,7 +95,7 @@ internal static partial class Program
Check(LootRuleText.UsesValueNames(VTankNodeTypes.LongValKeyE), "= uses names");
Check(LootRuleText.UsesValueNames(VTankNodeTypes.LongValKeyGE), ">= uses names");
Check(LootRuleText.UsesValueNames(VTankNodeTypes.BuffedLongValKeyGE), "buffed >= uses names");
Check(!LootRuleText.UsesValueNames(VTankNodeTypes.LongValKeyFlagExists), "has flag does not");
Check(LootRuleText.UsesValueNames(VTankNodeTypes.LongValKeyFlagExists), "has flag names its flag too (2026-11-07)");
Check(!LootRuleText.UsesValueNames(VTankNodeTypes.DoubleValKeyGE), "double keys do not");
// Vocabulary: the tables reach the face, and survive JSON.
@ -107,7 +107,7 @@ internal static partial class Program
Check(wst != null && wst.Values.Any(n => n.Id == 45 && n.Name == "Light Weapons"), "vocab JSON keeps 159's names");
Check(back?.LongValueTables.First(t => t.Key == 45).Flags == true, "vocab JSON keeps the flags mark");
Check(back?.NodeTypes.First(n => n.Id == VTankNodeTypes.LongValKeyE).NamedValues == true, "vocab marks = as named");
Check(back?.NodeTypes.First(n => n.Id == VTankNodeTypes.LongValKeyFlagExists).NamedValues == false, "vocab leaves has flag unnamed");
Check(back?.NodeTypes.First(n => n.Id == VTankNodeTypes.LongValKeyFlagExists).NamedValues == true, "vocab names has-flag values (2026-11-07)");
// An older RynthAi's vocabulary (no LongValueTables) still reads: the face falls back to the text box.
LootEditVocab? old = JsonSerializer.Deserialize("{\"LongKeys\":[{\"Id\":159,\"Name\":\"WieldSkilltype\"}]}",
LootEditJsonContext.Default.LootEditVocab);
@ -115,11 +115,11 @@ internal static partial class Program
// Summaries name the value.
var cond = new VTankLootCondition(VTankNodeTypes.LongValKeyE, "0", new[] { "45", "159" });
Eq(LootRuleText.Condition(cond), "WieldSkilltype = Light Weapons", "summary names the skill");
Eq(LootRuleText.Condition(cond), "Wield skill is Light Weapons", "summary names the skill");
Eq(LootRuleText.Condition(new VTankLootCondition(VTankNodeTypes.LongValKeyGE, "0", new[] { "300", "160" })),
"WieldDifficulty >= 300", "summary of a plain key unchanged");
"Wield difficulty at least 300", "summary of a plain key unchanged");
Eq(LootRuleText.Condition(new VTankLootCondition(VTankNodeTypes.LongValKeyE, "0", new[] { "999", "131" })),
"MaterialType = 999", "summary of an unknown value is the number");
"Material is 999", "summary of an unknown value is the number");
// Round trip: values picked by name through the wire, saved, reopened: the same numbers.
string Pick((int Id, string Name)[] table, string name) =>
@ -153,7 +153,7 @@ internal static partial class Program
Check(text.Contains("\n45\n159\n") && text.Contains("\n64\n131\n"), "file holds plain numbers (format unchanged)");
Check(re.Encode().AsSpan().SequenceEqual(File.ReadAllBytes(s.Path)), "reopened file re-encodes byte for byte");
string sum = LootRuleText.Summary(saved, 400);
Check(sum.Contains("WieldSkilltype = Light Weapons") && sum.Contains("MaterialType != Steel") && sum.Contains("WieldRequirements = Base Skill"),
Check(sum.Contains("Wield skill is Light Weapons") && sum.Contains("Material is not Steel") && sum.Contains("Wield requirement is Base Skill"),
"summary: " + sum);
}
}

View file

@ -46,8 +46,11 @@ internal static partial class Program
RunLootAddTests(args);
RunT11Tests();
RunLootAddT11Tests();
RunT11ItemTests();
RunSlayerTextTests();
RunLootAddAttributeTests();
RunUnknownNodeTests();
TestQuestLootProfiles();
Console.WriteLine($"\nGolden tests: {_asserts} assertions, {_fails} failed.");

View file

@ -0,0 +1,70 @@
using System;
using System.IO;
using System.Linq;
using System.Text.RegularExpressions;
using RynthCore.Loot.Editing;
using RynthCore.Loot.VTank;
namespace RynthCore.LootSdkTests;
// Quest loot profiles (2026-11-05): base-quest-dynamic.utl plus a Keep rule per quest item, in front.
internal static partial class Program
{
// The player's template as he made it (no rules, the salvage combine settings), and one with a rule.
private const string EmptyTemplate = "UTL\n1\n0\nSalvageCombine\n0\n1\n1-6, 7-8, 9, 10\n0\n0\n";
private const string RareTemplate = "UTL\n1\n1\n(*) Rare\n\n0;1;12\n18\n23308\n218103850\nSalvageCombine\n0\n1\n1-6, 7-8, 9, 10\n0\n0\n";
private static void TestQuestLootProfiles()
{
Console.WriteLine("\n-- Quest loot profiles --");
bool M(string pattern, string name) => Regex.IsMatch(name, pattern, RegexOptions.IgnoreCase);
// Patterns: the exact name, any case; a wiki note in brackets is optional.
string p = QuestLootProfiles.PatternFor("Vial of The Architect's Blood");
Check(M(p, "Vial of The Architect's Blood") && M(p, "vial of the architect's blood") && !M(p, "Vial of The Architect's Blood x2") && !M(p, "Empty Vial of The Architect's Blood"), "pattern: exact name: " + p);
string n = QuestLootProfiles.PatternFor("Shard of Harraag's Dagger (Quest Item)");
Check(M(n, "Shard of Harraag's Dagger") && M(n, "Shard of Harraag's Dagger (Quest Item)") && !M(n, "Shard of Harraag's Dagger (Other)"), "pattern: a note in brackets is optional: " + n);
Check(M(QuestLootProfiles.PatternFor("Pyreal Mote [x5]."), "Pyreal Mote [x5].") && !M(QuestLootProfiles.PatternFor("A.B"), "AxB"), "pattern: regex characters escaped");
// Build: the quest's rules first, then the template's; the template itself unchanged; duplicates once.
VTankLootProfile rare = VTankLootParser.LoadFromText(RareTemplate);
VTankLootProfile q = QuestLootProfiles.Build(rare, new[] { "Shiny Red Stone", "Vial of The Architect's Blood", "shiny red stone", " " });
Eq(q.Rules.Count, 3, "build: two quest rules and the template's one");
Check(q.Rules[0].Name == "Quest: Shiny Red Stone" && q.Rules[1].Name == "Quest: Vial of The Architect's Blood" && q.Rules[2].Name == "(*) Rare", "build: quest rules in front, in order");
Check(q.Rules[0].Action == VTankLootAction.Keep && q.Rules[0].Conditions.Count == 1 && q.Rules[0].Conditions[0].NodeType == VTankNodeTypes.StringValueMatch
&& q.Rules[0].Conditions[0].DataLines.SequenceEqual(new[] { "^Shiny Red Stone$", "1" }), "build: Keep, the name (string key 1)");
Eq(rare.Rules.Count, 1, "build: the template is not changed");
Check(q.SalvageCombine != null && q.SalvageCombine.DefaultBands == "1-6, 7-8, 9, 10", "build: the template's salvage combine kept");
// The file parses back the same, and building from a quest profile doesn't pile up quest rules.
string text = VTankLootWriter.Serialize(q);
VTankLootProfile back = VTankLootParser.LoadFromText(text);
Check(back.Rules.Count == 3 && VTankLootWriter.Serialize(back) == text, "file: round-trips");
Eq(QuestLootProfiles.Build(back, new[] { "Other Item" }).Rules.Count, 2, "build: a template saved from a quest profile loses its old quest rules");
Eq(QuestLootProfiles.Build(VTankLootParser.LoadFromText(EmptyTemplate), new[] { "A" }).Rules.Count, 1, "build: the empty template gives the quest's rules only");
Eq(QuestLootProfiles.Build(null, new[] { "A", "B" }).Rules.Count, 2, "build: no template, the quest's rules only");
// File names.
Eq(QuestLootProfiles.FileNameFor("Aerbax's Prodigal Human"), "Aerbax's Prodigal Human.utl", "file name: kept");
Eq(QuestLootProfiles.FileNameFor("\"Pistol\" Pete: Trophy/Hunts?"), "_Pistol_ Pete_ Trophy_Hunts_.utl", "file name: characters a file can't have");
Eq(QuestLootProfiles.FileNameFor(" "), "quest.utl", "file name: an empty title");
// Write: to <folder>\Quests from <folder>\base-quest-dynamic.utl.
string dir = Path.Combine(Path.GetTempPath(), "QuestLootProfileTests-" + Guid.NewGuid().ToString("N"));
Directory.CreateDirectory(dir);
try
{
string path = QuestLootProfiles.Write(dir, "Mistreated Virindi", new[] { "Shiny Red Stone" }, out int rules, out string note);
Check(File.Exists(path) && rules == 1 && note.Contains("base-quest-dynamic.utl"), "write: no template, said so: " + note);
File.WriteAllText(Path.Combine(dir, QuestLootProfiles.TemplateFileName), RareTemplate);
path = QuestLootProfiles.Write(dir, "Mistreated Virindi", new[] { "Shiny Red Stone", "Vial" }, out rules, out note);
VTankLootProfile w = VTankLootParser.Load(path);
Check(path == Path.Combine(dir, "Quests", "Mistreated Virindi.utl") && rules == 2 && note == "" && w.Rules.Count == 3 && w.Rules[2].Name == "(*) Rare",
"write: the template's rules after the quest's, built again over the last one");
Check(QuestLootProfiles.IsQuestProfile(path, dir) && !QuestLootProfiles.IsQuestProfile(Path.Combine(dir, "Base.utl"), dir) && !QuestLootProfiles.IsQuestProfile("", dir),
"a quest profile is one in the Quests folder");
Check(!Directory.GetFiles(Path.Combine(dir, "Quests"), "*.tmp").Any(), "write: no temp file left");
}
finally { try { Directory.Delete(dir, true); } catch { } }
}
}