Snapshot for release 2026.10.6.2 (internal e3a94cf)
Faster weapon switches; T11 loot support (by SilentKelpie, rynth/RynthSuite PR #3).
This commit is contained in:
parent
5416e8066a
commit
dafd6084a7
24 changed files with 1645 additions and 34 deletions
210
Tools/RynthCore.LootSdkTests/LootT11Tests.cs
Normal file
210
Tools/RynthCore.LootSdkTests/LootT11Tests.cs
Normal 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");
|
||||
}
|
||||
}
|
||||
|
|
@ -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.
|
||||
|
|
|
|||
|
|
@ -44,6 +44,7 @@ internal static partial class Program
|
|||
TestMalformedInputs();
|
||||
RunLootEditTests(args);
|
||||
RunLootAddTests(args);
|
||||
RunT11Tests();
|
||||
|
||||
Console.WriteLine($"\nGolden tests: {_asserts} assertions, {_fails} failed.");
|
||||
|
||||
|
|
|
|||
|
|
@ -43,6 +43,7 @@ internal static class Program
|
|||
var runner = new Runner();
|
||||
NativeLootTests.Register(runner);
|
||||
VTankLootTests.Register(runner);
|
||||
T11LootTests.Register(runner);
|
||||
ExpressionTests.Register(runner);
|
||||
MetaTests.Register(runner);
|
||||
NoKillTests.Register(runner);
|
||||
|
|
|
|||
|
|
@ -34,6 +34,8 @@ internal static class OffhandTests
|
|||
r.Add("offhand: two-hander -> the shield comes off first, back on with a one-hander", TwoHanderShieldOff);
|
||||
r.Add("offhand: bow -> the shield comes off, then the arrows still go on", BowShieldOffThenAmmo);
|
||||
r.Add("offhand: a caster -> the shield comes off first (swap gate held)", CasterShieldOff);
|
||||
r.Add("swap speed: a weapon in hand -> one use of the wand (the client swaps); the pack move only as the fallback", CasterDirectSwap);
|
||||
r.Add("swap speed: the gate lets the next step go once the server is done, else after 3 s", SwapGateSettles);
|
||||
r.Add("offhand: dual wield with the Dual Wield skill", DualWield);
|
||||
r.Add("offhand: no Dual Wield skill -> the shield", NoSkillShield);
|
||||
r.Add("offhand: None -> hands off (a worn shield is never taken off)", NoneHandsOff);
|
||||
|
|
@ -331,6 +333,56 @@ internal static class OffhandTests
|
|||
Check.Eq(FakeHost.Wields.Count, 0, "no shield with a caster");
|
||||
}
|
||||
|
||||
// 2026-10-06: Drakkon's axe -> wand took 4.2 s: the axe into the pack (1.2 s), then the swap
|
||||
// gate's flat 3 s before the wand. A use of the wand (the client's double-click) swaps by itself.
|
||||
private static void CasterDirectSwap()
|
||||
{
|
||||
var rig = new Rig(); // the sword in hand
|
||||
rig.List(Wand);
|
||||
rig.C.CanCastOverride = _ => true;
|
||||
Check.False(rig.Tick(), "not ready");
|
||||
Check.True(FakeHost.Uses.Contains(Wand), "UseObject(wand) with the sword still in hand");
|
||||
Check.Eq(FakeHost.Moves.Count, 0, "no pack move first");
|
||||
|
||||
// The use didn't swap in 2 s (SwapTracker retries at 2.5 s): the sword goes into the pack first from now on.
|
||||
var since = typeof(CombatManager).GetField("_combatDirectSwapSince", BindingFlags.Instance | BindingFlags.NonPublic)!;
|
||||
since.SetValue(rig.C, DateTime.Now.AddSeconds(-3));
|
||||
rig.C.SwapTracker.Reset(); // its 2.5 s resolve time is up
|
||||
rig.Tick();
|
||||
Check.True(FakeHost.Moves.Any(m => m.Id == Sword), "fallback: the sword into the pack");
|
||||
Check.True(FakeHost.Logs.Any(l => l.Contains("from now on the weapon goes into a pack first")), "logged once");
|
||||
}
|
||||
|
||||
private static void SwapGateSettles()
|
||||
{
|
||||
long t = 0;
|
||||
bool idle = true;
|
||||
var wielded = new Dictionary<int, bool> { [7] = true };
|
||||
var g = new WeaponSwapGate { NowMs = () => t, ServerIdle = () => idle, IsWielded = id => wielded[id] };
|
||||
Check.True(g.TryBeginSwap("shield off"), "first swap");
|
||||
g.NoteMove(7, wieldedNow: true);
|
||||
t = 500;
|
||||
Check.False(g.TryBeginSwap("weapon"), "the shield is still in hand");
|
||||
wielded[7] = false;
|
||||
Check.True(g.TryBeginSwap("weapon"), "the shield is off: the weapon goes at once (not at 3 s)");
|
||||
t = 700;
|
||||
Check.False(g.TryBeginSwap("off hand"), "under the 400 ms floor");
|
||||
t = 1000;
|
||||
idle = false;
|
||||
Check.False(g.TryBeginSwap("off hand"), "the weapon's use is still unanswered");
|
||||
idle = true;
|
||||
Check.True(g.TryBeginSwap("off hand"), "answered: the off hand goes");
|
||||
|
||||
// No pacing (ServerIdle unset): the flat 3 s, as before.
|
||||
t = 0;
|
||||
var flat = new WeaponSwapGate { NowMs = () => t };
|
||||
Check.True(flat.TryBeginSwap("a"), "first");
|
||||
t = 2999;
|
||||
Check.False(flat.TryBeginSwap("b"), "inside 3 s");
|
||||
t = 3000;
|
||||
Check.True(flat.TryBeginSwap("b"), "after 3 s");
|
||||
}
|
||||
|
||||
private static void DualWield()
|
||||
{
|
||||
var rig = new Rig(dualWieldSkill: true);
|
||||
|
|
|
|||
127
Tools/RynthCore.RynthAiHostTests/Tests/T11LootTests.cs
Normal file
127
Tools/RynthCore.RynthAiHostTests/Tests/T11LootTests.cs
Normal 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();
|
||||
}
|
||||
}
|
||||
Loading…
Reference in a new issue