feat: port SK test branch (2026.10.18.24) onto sk
Squash of test/hotbuild-2026-10-16 as merged onto aelrynth main 2026.10.17.1, matching the 2026.10.18.24 test installer. The test branch wins where both changed the same lines; sk-only changes kept; duplicate features cut to the test branch's copy. RynthAi HandWrittenVersion stays 0.5.0-legacy-ui on sk. Highlights: RynthOracle 0.6.0 (Legendary, Markers, Dynamic Stamps and Temple guardians merged into the Quests list, RynthNav Go to), RynthILT 0.2.20 (ub-IT auto-chunk rules, rating level, RynthILT.Data v3), RynthAi ub-IT /ub and VT/MT meta compatibility and the loot attribute checklist, RynthNav destination alternatives. Changelog/2026-10-18-sk-port-test-branch-2026.10.18.24.md.
This commit is contained in:
parent
23efcfee87
commit
7797901d69
287 changed files with 22602 additions and 1090 deletions
192
Tools/RynthCore.LootSdkTests/LootAddAttributeTests.cs
Normal file
192
Tools/RynthCore.LootSdkTests/LootAddAttributeTests.cs
Normal file
|
|
@ -0,0 +1,192 @@
|
|||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text.RegularExpressions;
|
||||
using RynthCore.Loot;
|
||||
using RynthCore.Loot.Editing;
|
||||
using RynthCore.Loot.VTank;
|
||||
|
||||
namespace RynthCore.LootSdkTests;
|
||||
|
||||
// "Add to loot profile"'s attribute checklist (2026-10-18): every attribute a clicked item has,
|
||||
// grouped, each ticked or not with a comparison and a value; spells by tier; pet essences.
|
||||
// The defaults (no choices) are covered by LootAddItemTests / LootAddT11Tests, which still
|
||||
// expect the rules "items like this" and "Include T11 attributes" always made.
|
||||
internal static partial class Program
|
||||
{
|
||||
private static void RunLootAddAttributeTests()
|
||||
{
|
||||
Console.WriteLine("\n-- LootAdd: attribute checklist --");
|
||||
TestAttrRowsAndGroups();
|
||||
TestAttrChoices();
|
||||
TestAttrSpellTiers();
|
||||
TestAttrCantripCounts();
|
||||
TestAttrPetEssence();
|
||||
TestAttrNativeAndWire();
|
||||
TestAttrVocab();
|
||||
}
|
||||
|
||||
private static LootItemFacts Sword() => new()
|
||||
{
|
||||
Id = 10, Name = "Gold Tachi", ObjectClass = (int)AcObjectClass.MeleeWeapon,
|
||||
Ints = { [131] = 60, [105] = 8, [159] = 45, [44] = 52, [5] = 300, [370] = 3, [374] = 2, [160] = 400, [158] = 2 },
|
||||
Doubles = { [62] = 1.18, [29] = 1.2 },
|
||||
Spells = { "Legendary Blood Thirst", "Epic Heart Thirst", "Major Strength", "Blood Drinker Self VI" },
|
||||
};
|
||||
|
||||
private static List<LootEditItemChoice> Pick(params (string Id, bool On, LootItemAttributeOp Op, string Value)[] p)
|
||||
=> p.Select(x => new LootEditItemChoice { Id = x.Id, On = x.On, Op = (int)x.Op, Value = x.Value }).ToList();
|
||||
|
||||
private static void TestAttrRowsAndGroups()
|
||||
{
|
||||
LootItemRuleDraft d = BuildOk(Sword());
|
||||
List<LootItemAttribute> rows = d.Attributes;
|
||||
Check(rows.Count > 0, "attr: rows for an item");
|
||||
Check(!rows.Any(r => r.On), "attr: name + class ticks nothing by default");
|
||||
string[] groups = rows.Select(r => r.Group).Distinct().ToArray();
|
||||
Eq(string.Join(",", groups), "Item,Weapon / Armor,Ratings,Spells,Requirements", "attr: groups in display order");
|
||||
LootItemAttribute mat = rows.Single(r => r.Id == "L:131");
|
||||
Eq(mat.ItemText, "Gold", "attr: named value shown by name");
|
||||
Check(!mat.Editable && mat.Ops[0] == LootItemAttributeOp.Exactly, "attr: material is = (or !=), not typed");
|
||||
LootItemAttribute burden = rows.Single(r => r.Id == "L:5");
|
||||
Eq(burden.Ops[0], LootItemAttributeOp.AtMost, "attr: burden defaults to at most");
|
||||
Check(rows.Any(r => r.Id == "ratings" && r.ItemText == "5"), "attr: total ratings row (3 + 2)");
|
||||
Check(rows.Any(r => r.Id == "D:62") && rows.Any(r => r.Id == "D:29"), "attr: weapon modifiers (doubles)");
|
||||
Check(!rows.Any(r => r.Group == LootItemAttributes.GroupPet), "attr: no pet rows on a sword");
|
||||
|
||||
// "Items like this" ticks what it always required, nothing more.
|
||||
LootItemRuleDraft like = BuildOk(Sword(), new() { Match = LootItemMatch.Like });
|
||||
Eq(string.Join(",", like.Attributes.Where(r => r.On).Select(r => r.Id)),
|
||||
"L:131,L:105,L:159,L:44,ratings,spell:Legendary Blood Thirst,spell:Epic Heart Thirst,spell:Major Strength,spell:Blood Drinker Self VI",
|
||||
"attr: like ticks material, workmanship, wield skill, damage, ratings, the first 4 spells");
|
||||
}
|
||||
|
||||
private static void TestAttrChoices()
|
||||
{
|
||||
// Burden at most 250 (typed), attack modifier exactly (two double conditions), material !=,
|
||||
// and a row the item doesn't have (ignored).
|
||||
List<LootEditItemChoice> c = Pick(
|
||||
("L:5", true, LootItemAttributeOp.AtMost, "250"),
|
||||
("D:62", true, LootItemAttributeOp.Exactly, ""),
|
||||
("L:131", true, LootItemAttributeOp.Not, ""),
|
||||
("L:9999", true, LootItemAttributeOp.AtLeast, "1"));
|
||||
LootItemRuleDraft d = BuildOk(Sword(), new() { Choices = c });
|
||||
string conds = string.Join(" ; ", d.Rule.Conditions.Select(Lines));
|
||||
Eq(conds, "7:1 ; 1:^Gold Tachi$|1 ; 13:60|131 ; 2:250|5 ; 5:1.18|62 ; 4:1.18|62",
|
||||
"attr: name + class, then the ticked rows in row order with their comparisons");
|
||||
Eq(d.Attributes.Single(r => r.Id == "L:5").ToWire().Value, "250", "attr: the typed value goes back to the popup");
|
||||
Check(d.Notes.Count == 0, "attr: no notes");
|
||||
|
||||
// A bad typed value keeps the item's and says so; an op the row doesn't offer is ignored.
|
||||
LootItemRuleDraft bad = BuildOk(Sword(), new() { Choices = Pick(("L:105", true, LootItemAttributeOp.SpellOrBetter, "lots")) });
|
||||
Check(bad.Rule.Conditions.Any(x => Lines(x) == "3:8|105"), "attr: bad value: the item's 8, at least");
|
||||
Check(bad.Notes.Any(n => n.StartsWith("Workmanship: 'lots'")), "attr: bad value: a note");
|
||||
LootItemRuleDraft frac = BuildOk(Sword(), new() { Choices = Pick(("L:105", true, LootItemAttributeOp.AtLeast, "7.5")) });
|
||||
Check(frac.Notes.Any(n => n.Contains("whole number")), "attr: a long row takes whole numbers only");
|
||||
|
||||
// "Items like this" with a row unticked: the choice wins over the default.
|
||||
LootItemRuleDraft like = BuildOk(Sword(), new() { Match = LootItemMatch.Like, Choices = Pick(("L:131", false, LootItemAttributeOp.Exactly, "")) });
|
||||
Check(!like.Rule.Conditions.Any(x => Lines(x) == "12:60|131"), "attr: like, material unticked");
|
||||
Check(like.Rule.Conditions.Any(x => Lines(x) == "3:8|105"), "attr: like, the other defaults stay");
|
||||
Check(!like.Notes.Any(n => n.Contains("more than 4 spells")), "attr: no 4-spell note once the player chooses");
|
||||
}
|
||||
|
||||
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.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("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");
|
||||
|
||||
string orBetter = LootItemAttributes.SpellPattern("Epic Heart Thirst", LootItemAttributeOp.SpellOrBetter);
|
||||
Check(Regex.IsMatch("Legendary Heart Thirst", orBetter, RegexOptions.IgnoreCase), "spell: Legendary is better than Epic");
|
||||
Check(!Regex.IsMatch("Major Heart Thirst", orBetter, RegexOptions.IgnoreCase), "spell: Major is not");
|
||||
Check(!Regex.IsMatch("Epic Heart Thirsty", orBetter, RegexOptions.IgnoreCase), "spell: still the whole name");
|
||||
|
||||
List<LootItemAttribute> rows = BuildOk(Sword()).Attributes;
|
||||
Eq(rows.Single(r => r.Id == "spell:Major Strength").Ops[0], LootItemAttributeOp.SpellOrBetter, "spell: a cantrip defaults to or better");
|
||||
Eq(rows.Single(r => r.Id == "spell:Blood Drinker Self VI").Ops[0], LootItemAttributeOp.SpellExact, "spell: a leveled spell defaults to exact (as before)");
|
||||
Eq(rows.Single(r => r.Id == "spell:Major Strength").ItemText, "Major cantrip", "spell: the tier is shown");
|
||||
|
||||
// Like with every spell ticked: no limit of four once chosen.
|
||||
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");
|
||||
}
|
||||
|
||||
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");
|
||||
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) == "8:3"), "cantrips: spell count >= 3");
|
||||
Check(LootItemRules.PreviewLines(d.Rule).Any(l => l.Contains(">= 2 spells matching")), "cantrips: preview in words");
|
||||
}
|
||||
|
||||
private static void TestAttrPetEssence()
|
||||
{
|
||||
var wolf = new LootItemFacts
|
||||
{
|
||||
Id = 20, Name = "Fire Wolf Essence", ObjectClass = (int)AcObjectClass.Misc,
|
||||
Ints = { [9053] = 12, [369] = 180, [9056] = 40, [362] = 1, [9075] = 2, [9070] = 1, [9054] = 16, [370] = 5, [92] = 30, [91] = 50 },
|
||||
};
|
||||
List<LootItemAttribute> rows = BuildOk(wolf).Attributes;
|
||||
Check(rows.Any(r => r.Group == LootItemAttributes.GroupPet), "pet: bond makes it an essence");
|
||||
Eq(rows.Single(r => r.Id == "L:362").ItemText, "Primalist", "pet: mastery by name");
|
||||
Eq(rows.Single(r => r.Id == "L:9054").ItemText, "Fire", "pet: captured damage type by name");
|
||||
Check(rows.Any(r => r.Id == "L:92" && r.Label == "Uses left"), "pet: uses (Item group)");
|
||||
|
||||
LootItemRuleDraft like = BuildOk(wolf, new() { Match = LootItemMatch.Like });
|
||||
string conds = string.Join(" ; ", like.Rule.Conditions.Select(Lines));
|
||||
Eq(conds, "7:8 ; 2007:5 ; 3:12|9053 ; 3:180|369 ; 3:40|9056 ; 12:1|362 ; 3:2|9075",
|
||||
"pet: like = class, ratings, bond, level, potency, mastery, mutations");
|
||||
|
||||
var flagged = new LootItemFacts { Name = "Odd Essence", ObjectClass = (int)AcObjectClass.Misc, IsPetEssence = true, Ints = { [9073] = 1 } };
|
||||
Check(BuildOk(flagged).Attributes.Any(r => r.Id == "L:9073"), "pet: the plugin's IsPetEssence shows the group");
|
||||
var notPet = new LootItemFacts { Name = "Jibril's Essence", ObjectClass = (int)AcObjectClass.Misc, Ints = { [9073] = 1 } };
|
||||
Check(!BuildOk(notPet).Attributes.Any(r => r.Group == LootItemAttributes.GroupPet), "pet: a name alone isn't an essence");
|
||||
}
|
||||
|
||||
private static void TestAttrNativeAndWire()
|
||||
{
|
||||
LootItemRuleDraft d = BuildOk(Sword(), new() { Choices = Pick(("L:5", true, LootItemAttributeOp.AtMost, ""), ("spell:Major Strength", true, LootItemAttributeOp.SpellOrBetter, ""), ("cantrips:Legendary", true, LootItemAttributeOp.AtLeast, "")) });
|
||||
var dropped = new List<string>();
|
||||
LootRule? n = LootItemRules.ToNative(d.Rule, dropped);
|
||||
Check(n != null && n.Conditions.Any(c => c.ToString().Contains("LongValKey") || c.ToString().Contains("[5]")), "native: burden converts");
|
||||
Eq(dropped.Count, 2, "native: the two spell conditions are named as left out");
|
||||
|
||||
var st = new LootEditState { ItemDraft = new LootEditItemDraft { Seq = 4, AttributesSupported = true } };
|
||||
foreach (LootItemAttribute r in d.Attributes) st.ItemDraft.Attributes.Add(r.ToWire());
|
||||
string json = System.Text.Json.JsonSerializer.Serialize(st, LootEditJsonContext.Default.LootEditState);
|
||||
LootEditState? back = System.Text.Json.JsonSerializer.Deserialize(json, LootEditJsonContext.Default.LootEditState);
|
||||
LootEditItemAttribute? spell = back?.ItemDraft?.Attributes.FirstOrDefault(a => a.Id == "spell:Major Strength");
|
||||
Check(back?.ItemDraft?.AttributesSupported == true, "wire: attributes supported round-trips");
|
||||
Check(spell != null && spell.On && spell.Op == (int)LootItemAttributeOp.SpellOrBetter && spell.Ops.Count == 3, "wire: a row round-trips");
|
||||
|
||||
var cmd = new LootEditCommand { Op = "item_preview", Item = new LootEditItemRequest { Choices = Pick(("L:5", true, LootItemAttributeOp.AtMost, "9")) } };
|
||||
string cj = System.Text.Json.JsonSerializer.Serialize(cmd, LootEditJsonContext.Default.LootEditCommand);
|
||||
LootEditCommand? cb = System.Text.Json.JsonSerializer.Deserialize(cj, LootEditJsonContext.Default.LootEditCommand);
|
||||
Eq(cb?.Item?.Choices?.Single().Value, "9", "wire: choices round-trip");
|
||||
LootEditCommand? old = System.Text.Json.JsonSerializer.Deserialize("{\"Op\":\"item_preview\",\"Item\":{\"Match\":2}}", LootEditJsonContext.Default.LootEditCommand);
|
||||
Check(old?.Item != null && old.Item.Choices == null, "wire: an older engine's ask has no choices (defaults)");
|
||||
}
|
||||
|
||||
private static void TestAttrVocab()
|
||||
{
|
||||
Eq(LootRuleText.ValueName(353, "4"), "Armor Rending", "vocab: imbue names");
|
||||
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");
|
||||
var ids = LootRuleText.LongKeys.Select(k => k.Id).ToList();
|
||||
Eq(ids.Count, ids.Distinct().Count(), "vocab: no long key named twice");
|
||||
}
|
||||
}
|
||||
|
|
@ -46,6 +46,7 @@ internal static partial class Program
|
|||
RunLootAddTests(args);
|
||||
RunT11Tests();
|
||||
RunLootAddT11Tests();
|
||||
RunLootAddAttributeTests();
|
||||
RunUnknownNodeTests();
|
||||
|
||||
Console.WriteLine($"\nGolden tests: {_asserts} assertions, {_fails} failed.");
|
||||
|
|
|
|||
|
|
@ -255,6 +255,18 @@
|
|||
</DataTemplate></DataGridTemplateColumn.CellEditingTemplate>
|
||||
</DataGridTemplateColumn>
|
||||
|
||||
<!-- Kite / pull-away -->
|
||||
<DataGridTemplateColumn Header="Kite" Width="90" MinWidth="70">
|
||||
<DataGridTemplateColumn.CellTemplate><DataTemplate>
|
||||
<TextBlock Text="{Binding Kite}" Padding="3,1" VerticalAlignment="Center"
|
||||
ToolTip.Tip="Default = DEFAULT row. Off = fight in place. PullAway = tag then run until pulled clear, then kill."/>
|
||||
</DataTemplate></DataGridTemplateColumn.CellTemplate>
|
||||
<DataGridTemplateColumn.CellEditingTemplate><DataTemplate>
|
||||
<ComboBox ItemsSource="{Binding $parent[Window].((local:MainWindow)DataContext).KiteOptions}"
|
||||
SelectedItem="{Binding Kite, Mode=TwoWay}"/>
|
||||
</DataTemplate></DataGridTemplateColumn.CellEditingTemplate>
|
||||
</DataGridTemplateColumn>
|
||||
|
||||
<!-- Delete -->
|
||||
<DataGridTemplateColumn Header="Del" Width="34" CanUserResize="False" CanUserSort="False">
|
||||
<DataGridTemplateColumn.CellTemplate><DataTemplate>
|
||||
|
|
|
|||
|
|
@ -29,6 +29,9 @@ public partial class MainWindow : Window
|
|||
{ "None", "Slash", "Pierce", "Bludgeon", "Fire", "Cold", "Lightning", "Acid", "Nether" };
|
||||
public string[] PetOptions { get; } =
|
||||
{ "PAuto", "Slash", "Pierce", "Bludgeon", "Fire", "Cold", "Lightning", "Acid", "Nether" };
|
||||
/// <summary>RynthAi KiteModes: Default follows the DEFAULT row; PullAway tags then runs clear.</summary>
|
||||
public string[] KiteOptions { get; } =
|
||||
{ "Default", "Off", "PullAway" };
|
||||
|
||||
private string _charFolder = string.Empty;
|
||||
private string _monstersPath = string.Empty;
|
||||
|
|
|
|||
|
|
@ -23,6 +23,7 @@ public class MonsterRule : INotifyPropertyChanged
|
|||
private int _offhandId;
|
||||
private int _preferredAmmoItemId;
|
||||
private string _petDamage = "PAuto";
|
||||
private string _kite = "Default";
|
||||
|
||||
public string Name { get => _name; set { _name = value; OnPropertyChanged(); } }
|
||||
/// <summary>The plugin's rule group label. Kept and editable here (before 2026-10-05 an
|
||||
|
|
@ -58,6 +59,8 @@ public class MonsterRule : INotifyPropertyChanged
|
|||
/// <summary>Optional loose ammo stack id for missile combat while this rule matches (0 = auto).</summary>
|
||||
public int PreferredAmmoItemId { get => _preferredAmmoItemId; set { _preferredAmmoItemId = value; OnPropertyChanged(); } }
|
||||
public string PetDamage { get => _petDamage; set { _petDamage = value; OnPropertyChanged(); } }
|
||||
/// <summary>Pull-away kite: Default (follow DEFAULT row), Off, or PullAway. RynthAi KiteModes.</summary>
|
||||
public string Kite { get => _kite; set { _kite = value ?? "Default"; OnPropertyChanged(); } }
|
||||
|
||||
/// <summary>Every field in the file this class doesn't know (e.g. the plugin's CustomDebuffs,
|
||||
/// or one added later), written back unchanged.</summary>
|
||||
|
|
@ -94,6 +97,7 @@ public class MonsterRule : INotifyPropertyChanged
|
|||
OffhandId = _offhandId,
|
||||
PreferredAmmoItemId = _preferredAmmoItemId,
|
||||
PetDamage = _petDamage,
|
||||
Kite = _kite,
|
||||
};
|
||||
}
|
||||
|
||||
|
|
@ -122,6 +126,7 @@ public class MonsterRule : INotifyPropertyChanged
|
|||
OffhandId = src.OffhandId;
|
||||
PreferredAmmoItemId = src.PreferredAmmoItemId;
|
||||
PetDamage = src.PetDamage;
|
||||
Kite = src.Kite;
|
||||
}
|
||||
|
||||
public event PropertyChangedEventHandler? PropertyChanged;
|
||||
|
|
|
|||
|
|
@ -328,6 +328,8 @@ internal static unsafe class FakeHost
|
|||
if (InstanceIds.Count > 0)
|
||||
api.GetObjectInstanceIdPropertyFn = (IntPtr)(delegate* unmanaged[Cdecl]<uint, uint, uint*, int>)&GetObjectInstanceIdProperty;
|
||||
api.SetAutoRunFn = (IntPtr)(delegate* unmanaged[Cdecl]<int, int>)&SetAutoRun;
|
||||
if (SetMotionCalls)
|
||||
api.SetMotionFn = (IntPtr)(delegate* unmanaged[Cdecl]<uint, int, int>)&SetMotion;
|
||||
api.TurnToHeadingFn = (IntPtr)(delegate* unmanaged[Cdecl]<float, int>)&TurnToHeading;
|
||||
api.JumpNonAutonomousFn = (IntPtr)(delegate* unmanaged[Cdecl]<float, int>)&JumpNonAutonomous;
|
||||
if (TapJumpCalls)
|
||||
|
|
@ -335,8 +337,6 @@ internal static unsafe class FakeHost
|
|||
api.CastSpellFn = (IntPtr)(delegate* unmanaged[Cdecl]<uint, int, int>)&CastSpell;
|
||||
if (StopCalls)
|
||||
api.StopCompletelyFn = (IntPtr)(delegate* unmanaged[Cdecl]<int>)&StopCompletely;
|
||||
if (SetMotionCalls)
|
||||
api.SetMotionFn = (IntPtr)(delegate* unmanaged[Cdecl]<uint, int, int>)&SetMotion;
|
||||
if (Nav3DCalls)
|
||||
{
|
||||
api.Nav3DClearFn = (IntPtr)(delegate* unmanaged[Cdecl]<void>)&Nav3DClear;
|
||||
|
|
|
|||
|
|
@ -54,7 +54,10 @@ internal static class Program
|
|||
PropertyDumpTests.Register(runner);
|
||||
T11LootTests.Register(runner);
|
||||
MagItemDescriberTests.Register(runner);
|
||||
SelfRatingsTests.Register(runner);
|
||||
IltClientLookupTests.Register(runner);
|
||||
ExpressionTests.Register(runner);
|
||||
GiveProfileTests.Register(runner);
|
||||
MetaTests.Register(runner);
|
||||
NoKillTests.Register(runner);
|
||||
MetaSchedulerTests.Register(runner);
|
||||
|
|
@ -71,6 +74,8 @@ internal static class Program
|
|||
AmmoTests.Register(runner);
|
||||
VTankYieldTests.Register(runner);
|
||||
OffhandTests.Register(runner);
|
||||
LauncherSwapTests.Register(runner);
|
||||
MissileCraftingTests.Register(runner);
|
||||
FloodPerfTests.Register(runner);
|
||||
LootSalvageTests.Register(runner);
|
||||
LootCorpseTests.Register(runner);
|
||||
|
|
@ -89,9 +94,13 @@ internal static class Program
|
|||
UseAtLoginTests.Register(runner);
|
||||
LearnSpellsTests.Register(runner);
|
||||
AttackLatencyTests.Register(runner);
|
||||
RingEscapeTests.Register(runner);
|
||||
TargetingTests.Register(runner);
|
||||
LootAddItemTests.Register(runner);
|
||||
GiveTests.Register(runner);
|
||||
UbCompatTests.Register(runner);
|
||||
MetaAuditTests.Register(runner);
|
||||
MetaSampleCompatTests.Register(runner);
|
||||
DungeonMapBakeTests.Register(runner);
|
||||
MonsterEditorTests.Register(runner);
|
||||
InstallPathsTests.Register(runner);
|
||||
|
|
@ -128,6 +137,9 @@ internal static class Program
|
|||
VTankHotkeyTests.Register(runner);
|
||||
OneTouchHealTests.Register(runner);
|
||||
SaveFailureTests.Register(runner);
|
||||
EnvironmentImpactTests.Register(runner);
|
||||
PetDamageTintTests.Register(runner);
|
||||
TinkerTests.Register(runner);
|
||||
DoorTests.Register(runner);
|
||||
ServerPolicyTests.Register(runner);
|
||||
BlankLoadTests.Register(runner);
|
||||
|
|
|
|||
514
Tools/RynthCore.RynthAiHostTests/Tests/EnvironmentImpactTests.cs
Normal file
514
Tools/RynthCore.RynthAiHostTests/Tests/EnvironmentImpactTests.cs
Normal file
|
|
@ -0,0 +1,514 @@
|
|||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using RynthCore.Plugin.RynthAi;
|
||||
using RynthCore.Plugin.RynthAi.LegacyUi;
|
||||
using RynthCore.Plugin.Shared;
|
||||
using RynthCore.RynthAiHostTests.Fakes;
|
||||
using RynthCore.RynthAiTests.Harness;
|
||||
|
||||
namespace RynthCore.RynthAiHostTests.Tests;
|
||||
|
||||
// Environment-impact throttle and per-monster attack power (2026-10-12). Arrows into a wall
|
||||
// ("Your missile attack hit the environment.") or war bolts stopping short of the target count
|
||||
// against that target; at the limit within the window, combat stops attacking it and moves closer,
|
||||
// switches target (this one skipped for a while), or moves closer once and then switches, as chosen
|
||||
// separately for missile and magic combat. The only monster in reach is never skipped. A monster
|
||||
// rule's Power picks High / Reckless / Variable / Reckless + Variable per monster.
|
||||
internal static class EnvironmentImpactTests
|
||||
{
|
||||
private const uint Player = 0x50000F01;
|
||||
private const uint Lb = 0xA9B40000;
|
||||
private const uint A = 0x80000401, B = 0x80000402, Bolt = 0x80000499;
|
||||
|
||||
public static void Register(Runner r)
|
||||
{
|
||||
r.Add("env impact: the response decision (move closer, new target, closer then new, the only monster)", Decide);
|
||||
r.Add("env impact: hits count per target inside the window; approaches are remembered", Throttle);
|
||||
r.Add("env impact: a projectile is short only when it stopped away from the target and nearer the caster", Judge);
|
||||
r.Add("env impact: missile lines trip New target: the attack stops, the target is skipped, the next is picked", MissileNewTarget);
|
||||
r.Add("env impact: Move closer runs toward the target and stops at the goal; the only monster is never skipped", MissileApproach);
|
||||
r.Add("env impact: Off, or not in Missile mode: the line is ignored", MissileOff);
|
||||
r.Add("env impact: a player's copy of the missile line (their chat type, or their name in front) is not a hit", MissileSpoof);
|
||||
r.Add("env impact: a bolt stopping short with no hit counts; one with a hit line, or reaching the target, doesn't", MagicShort);
|
||||
r.Add("env impact: an approach Think stops driving lets go of autorun", ApproachOrphan);
|
||||
r.Add("env impact (flight 63260): 3 magic casts landing nothing -> one short real sidestep; a hit resets; 30 s apart", ResyncSidestep);
|
||||
r.Add("env impact: the throttle switching target restarts the re-sync's miss count", ResyncCountResetByThrottle);
|
||||
r.Add("env impact: moving closer drops a wanted re-sync sidestep", ResyncDroppedByApproach);
|
||||
r.Add("env impact: a re-sync sidestep holding its key finishes before the throttle runs", ResyncStepFinishesFirst);
|
||||
r.Add("env impact: a re-sync sidestep Think stops driving, or a macro stop, lets go of the key", ResyncKeyReleased);
|
||||
r.Add("attack power: Default/High/Reckless/Variable/Reckless + Variable, the DEFAULT line, untrained Recklessness", Power);
|
||||
r.Add("attack power: an engine without the Power column keeps each rule's power", PowerCarriedOver);
|
||||
}
|
||||
|
||||
// ── Pure rules ───────────────────────────────────────────────────────────
|
||||
|
||||
private static void Decide()
|
||||
{
|
||||
var M = EnvironmentResponse.MoveCloser; var N = EnvironmentResponse.NewTarget; var C = EnvironmentResponse.CloserThenNewTarget;
|
||||
EnvironmentAction D(EnvironmentResponse r, int done, double dist, bool alt) => EnvironmentImpactPlanner.Decide(r, done, dist, 3, alt);
|
||||
|
||||
Check.Eq(D(EnvironmentResponse.Off, 0, 20, true), EnvironmentAction.None, "Off: nothing");
|
||||
Check.Eq(D(M, 0, 20, true), EnvironmentAction.Approach, "Move closer, far: approach");
|
||||
Check.Eq(D(M, 3, 20, false), EnvironmentAction.Approach, "Move closer approaches every time it trips");
|
||||
Check.Eq(D(M, 0, 3.2, true), EnvironmentAction.NewTarget, "Move closer, already at the closest: new target");
|
||||
Check.Eq(D(M, 0, 3.2, false), EnvironmentAction.None, "... but not the only monster: keep attacking");
|
||||
Check.Eq(D(N, 0, 20, true), EnvironmentAction.NewTarget, "New target with another in reach: switch");
|
||||
Check.Eq(D(N, 0, 20, false), EnvironmentAction.Approach, "New target, nothing else: approach instead of idling");
|
||||
Check.Eq(D(N, 0, 2, false), EnvironmentAction.None, "New target, nothing else, already close: keep attacking");
|
||||
Check.Eq(D(C, 0, 20, true), EnvironmentAction.Approach, "Closer then new: the first trip approaches");
|
||||
Check.Eq(D(C, 1, 14, true), EnvironmentAction.NewTarget, "... the second switches");
|
||||
Check.Eq(D(C, 1, 14, false), EnvironmentAction.Approach, "... unless it's the only monster");
|
||||
Check.Eq(D(M, 0, double.NaN, true), EnvironmentAction.NewTarget, "unknown distance: no approach");
|
||||
|
||||
Check.Near(EnvironmentImpactPlanner.ApproachGoal(20, 6, 3), 14, 1e-9, "goal: 6 m nearer");
|
||||
Check.Near(EnvironmentImpactPlanner.ApproachGoal(7, 6, 3), 3, 1e-9, "goal: never inside the closest distance");
|
||||
Check.Eq(EnvironmentImpactPlanner.Parse(9), EnvironmentResponse.Off, "an out-of-range saved value is Off");
|
||||
Check.Eq(EnvironmentImpactPlanner.Name(3), "Move closer, then new target", "labels follow the enum");
|
||||
}
|
||||
|
||||
private static void Throttle()
|
||||
{
|
||||
var t = new EnvironmentImpactThrottle();
|
||||
var t0 = new DateTime(2026, 10, 12, 12, 0, 0);
|
||||
Check.Eq(t.Record(1, t0, 20), 1, "first hit");
|
||||
Check.Eq(t.Record(2, t0, 20), 1, "per target");
|
||||
Check.Eq(t.Record(1, t0.AddSeconds(5), 20), 2, "second hit inside the window");
|
||||
Check.Eq(t.Count(1, t0.AddSeconds(21), 20), 1, "the first hit ages out");
|
||||
Check.Eq(t.Count(1, t0.AddSeconds(30), 20), 0, "both aged out");
|
||||
t.Record(1, t0.AddSeconds(31), 20);
|
||||
t.ResetHits(1);
|
||||
Check.Eq(t.Count(1, t0.AddSeconds(31), 20), 0, "reset after acting");
|
||||
t.NoteApproach(1);
|
||||
Check.Eq(t.Approaches(1), 1, "approach remembered");
|
||||
t.Forget(1);
|
||||
Check.Eq(t.Approaches(1), 0, "a deleted id forgets everything");
|
||||
Check.Eq(t.Record(0, t0, 20), 0, "no target: not counted");
|
||||
}
|
||||
|
||||
private static void Judge()
|
||||
{
|
||||
Check.True(ProjectileImpactJudge.StoppedShort(impactToTarget: 10, casterToImpact: 10, casterToTarget: 20), "into a wall halfway");
|
||||
Check.False(ProjectileImpactJudge.StoppedShort(1.5, 18.5, 20), "at the target's surface");
|
||||
Check.False(ProjectileImpactJudge.StoppedShort(3.5, 17, 20), "a big monster's surface (within 4 m)");
|
||||
Check.False(ProjectileImpactJudge.StoppedShort(6, 21, 20), "past the target (a miss beyond, not a wall in front)");
|
||||
Check.False(ProjectileImpactJudge.StoppedShort(double.NaN, 10, 20), "unknown: never short");
|
||||
}
|
||||
|
||||
// ── Through CombatManager ────────────────────────────────────────────────
|
||||
|
||||
private sealed class Rig
|
||||
{
|
||||
public readonly LegacyUiSettings S;
|
||||
public readonly CombatManager C;
|
||||
public readonly WorldObjectCache Cache;
|
||||
public DateTime Now = new(2026, 10, 12, 12, 0, 0);
|
||||
|
||||
/// <summary>The player at (96, 96) facing north; <paramref name="mobs"/> placed after the reset.</summary>
|
||||
public Rig(int mode, Action<LegacyUiSettings> set, params (uint Id, string Name, float X, float Y)[] mobs)
|
||||
: this(mode, set, setMotion: false, mobs) { }
|
||||
|
||||
/// <summary>As above; <paramref name="setMotion"/> installs SetMotion (the re-sync sidestep needs it).</summary>
|
||||
public Rig(int mode, Action<LegacyUiSettings> set, bool setMotion, params (uint Id, string Name, float X, float Y)[] mobs)
|
||||
{
|
||||
FakeHost.Reset();
|
||||
FakeHost.WeaponCalls = true;
|
||||
FakeHost.SetMotionCalls = setMotion;
|
||||
FakeHost.CombatModeValue = mode;
|
||||
Place(Player, "Me", 96, 96, creature: false);
|
||||
foreach (var m in mobs) Place(m.Id, m.Name, m.X, m.Y);
|
||||
FakeHost.PlayerPose = (Lb | 0x1C, 96f, 96f, 0f);
|
||||
FakeHost.HeadingDeg = 0;
|
||||
S = new LegacyUiSettings { MonsterRange = 50, IsMacroRunning = true, EnableCombat = true };
|
||||
set(S);
|
||||
var host = FakeHost.Create(Player); // Think measures distances from GetPlayerId
|
||||
Cache = FakeHost.MakeCache(host, Player, mobs.Select(m => m.Id));
|
||||
C = new CombatManager(host, S, Cache);
|
||||
C.SetPlayerId(Player);
|
||||
C.SetDamageStores(null, new RynthCore.Plugin.RynthAi.CreatureData.MonsterDamageStore());
|
||||
C.EnvClock = () => Now;
|
||||
C.ScanNearbyTargets();
|
||||
C.HandleCombatTrigger();
|
||||
FakeHost.MotionCalls.Clear(); // the trigger's turn-motion clear-out isn't under test
|
||||
}
|
||||
|
||||
public double Dist(uint id)
|
||||
{
|
||||
var p = FakeHost.Positions[id];
|
||||
double dx = p.X - FakeHost.PlayerPose.X, dy = p.Y - FakeHost.PlayerPose.Y;
|
||||
return Math.Sqrt(dx * dx + dy * dy);
|
||||
}
|
||||
|
||||
public bool Run() => C.RunEnvironmentImpact(Cache[C.activeTargetId]!, Dist((uint)C.activeTargetId));
|
||||
|
||||
public void MovePlayer(float x, float y)
|
||||
{
|
||||
FakeHost.PlayerPose = (Lb | 0x1C, x, y, 0f);
|
||||
FakeHost.Positions[Player] = FakeHost.PlayerPose;
|
||||
}
|
||||
}
|
||||
|
||||
private const string MissileLine = "Your missile attack hit the environment.";
|
||||
// 20 m north of the player (the pick), and 24 m east.
|
||||
private static readonly (uint, string, float, float) Skulker = (A, "Drudge Skulker", 96f, 116f);
|
||||
private static readonly (uint, string, float, float) Slinker = (B, "Drudge Slinker", 120f, 96f);
|
||||
|
||||
private static void MissileNewTarget()
|
||||
{
|
||||
var r = new Rig(CombatMode.Missile, s => { s.MissileEnvironmentResponse = 2; s.EnvironmentImpactLimit = 2; s.EnvironmentSkipSec = 30; }, Skulker, Slinker);
|
||||
Check.Eq((uint)r.C.activeTargetId, A, "the nearer Skulker is locked");
|
||||
|
||||
r.C.HandleChatForDamage(MissileLine);
|
||||
Check.False(r.Run(), "one hit: attacking on");
|
||||
r.Now = r.Now.AddSeconds(3);
|
||||
r.C.HandleChatForDamage(MissileLine);
|
||||
Check.True(FakeHost.Logs.Any(l => l.Contains("[EnvImpact] missile") && l.Contains("2/2")), "both hits logged against the target");
|
||||
|
||||
Check.True(r.Run(), "the limit: this tick belongs to the response");
|
||||
Check.Eq(r.C.activeTargetId, 0, "the Skulker is dropped");
|
||||
Check.True(FakeHost.Logs.Any(l => l.Contains("leaving") && l.Contains("skipping it 30s")), "logged with the skip");
|
||||
Rescan(r);
|
||||
Check.False(r.C.ScannedTargets.Any(t => (uint)t.Id == A), "the skipped Skulker is out of the scan");
|
||||
r.C.HandleCombatTrigger();
|
||||
Check.Eq((uint)r.C.activeTargetId, B, "the Slinker is fought next");
|
||||
|
||||
r.Now = r.Now.AddSeconds(31);
|
||||
Rescan(r);
|
||||
Check.True(r.C.ScannedTargets.Any(t => (uint)t.Id == A), "after the skip the Skulker is back");
|
||||
}
|
||||
|
||||
/// <summary>The scan runs at most every 50 ms of real time (SCAN_INTERVAL_MS).</summary>
|
||||
private static void Rescan(Rig r)
|
||||
{
|
||||
System.Threading.Thread.Sleep(60);
|
||||
r.C.ScanNearbyTargets();
|
||||
}
|
||||
|
||||
private static void MissileApproach()
|
||||
{
|
||||
// The Skulker is the only monster.
|
||||
var r = new Rig(CombatMode.Missile, s => { s.MissileEnvironmentResponse = 2; s.EnvironmentImpactLimit = 2; s.EnvironmentApproachMeters = 6; s.EnvironmentMinDistance = 3; }, Skulker);
|
||||
r.C.HandleChatForDamage(MissileLine);
|
||||
r.C.HandleChatForDamage(MissileLine);
|
||||
|
||||
Check.True(r.Run(), "New target with nothing else in reach: moves closer instead");
|
||||
Check.Eq((uint)r.C.activeTargetId, A, "the only monster is kept");
|
||||
Check.True(FakeHost.AutoRun, "running toward it");
|
||||
Check.True(r.C.EnvironmentApproachActive, "approach under way");
|
||||
Check.True(FakeHost.Logs.Any(l => l.Contains("moving closer") && l.Contains("stopping at 14.0m")), "goal: 6 m nearer");
|
||||
|
||||
r.Now = r.Now.AddMilliseconds(500);
|
||||
r.MovePlayer(96, 99); // 17 m
|
||||
Check.True(r.Run(), "still short of the goal: no attack");
|
||||
r.Now = r.Now.AddMilliseconds(500);
|
||||
r.MovePlayer(96, 102.5f); // 13.5 m
|
||||
Check.False(r.Run(), "reached: attacking again this tick");
|
||||
Check.False(FakeHost.AutoRun, "autorun off");
|
||||
Check.False(r.C.EnvironmentApproachActive, "approach over");
|
||||
|
||||
// Two more hits: already approached once, still far enough: Move closer goes again.
|
||||
r.S.MissileEnvironmentResponse = 1;
|
||||
r.C.HandleChatForDamage(MissileLine);
|
||||
r.C.HandleChatForDamage(MissileLine);
|
||||
Check.True(r.Run(), "Move closer trips again");
|
||||
Check.True(FakeHost.AutoRun, "running again");
|
||||
|
||||
// Blocked: no ground gained for 2.5 s.
|
||||
r.Now = r.Now.AddSeconds(3);
|
||||
Check.False(r.Run(), "no progress: the approach gives up and combat attacks");
|
||||
Check.False(FakeHost.AutoRun, "autorun off when blocked");
|
||||
Check.True(FakeHost.Logs.Any(l => l.Contains("ended: no progress")), "logged as blocked");
|
||||
|
||||
// At the closest distance with nothing else: keep attacking.
|
||||
r.MovePlayer(96, 113.2f); // 2.8 m
|
||||
r.C.HandleChatForDamage(MissileLine);
|
||||
r.C.HandleChatForDamage(MissileLine);
|
||||
Check.False(r.Run(), "already close and the only monster: attacking on");
|
||||
Check.Eq((uint)r.C.activeTargetId, A, "not dropped");
|
||||
}
|
||||
|
||||
private static void MissileOff()
|
||||
{
|
||||
var off = new Rig(CombatMode.Missile, s => { s.MissileEnvironmentResponse = 0; s.EnvironmentImpactLimit = 1; }, Skulker);
|
||||
off.C.HandleChatForDamage(MissileLine);
|
||||
Check.False(off.Run(), "Off: nothing happens");
|
||||
Check.False(FakeHost.Logs.Any(l => l.Contains("[EnvImpact]")), "Off: not even counted");
|
||||
|
||||
var melee = new Rig(CombatMode.Melee, s => { s.MissileEnvironmentResponse = 2; s.EnvironmentImpactLimit = 1; }, Skulker);
|
||||
melee.C.HandleChatForDamage(MissileLine);
|
||||
Check.False(melee.Run(), "not in Missile mode: ignored");
|
||||
}
|
||||
|
||||
private static void MissileSpoof()
|
||||
{
|
||||
var r = new Rig(CombatMode.Missile, s => { s.MissileEnvironmentResponse = 2; s.EnvironmentImpactLimit = 1; }, Skulker);
|
||||
r.C.HandleChatForDamage("Bob says, \"" + MissileLine + "\"", 2);
|
||||
r.C.HandleChatForDamage(MissileLine, 3); // a tell, whatever its text
|
||||
r.C.HandleChatForDamage("Bob " + MissileLine, 12); // an emote
|
||||
r.C.HandleChatForDamage("[Allegiance] Bob says, \"" + MissileLine + "\""); // type unknown: the anchor
|
||||
Check.False(r.Run(), "no spoofed line counts");
|
||||
Check.False(FakeHost.Logs.Any(l => l.Contains("[EnvImpact]")), "nothing recorded");
|
||||
|
||||
r.C.HandleChatForDamage(MissileLine, 0); // ACE's own line is a Broadcast
|
||||
Check.True(r.Run(), "the server's line still trips the limit");
|
||||
}
|
||||
|
||||
private static void MagicShort()
|
||||
{
|
||||
var r = new Rig(CombatMode.Magic, s => { s.MagicEnvironmentResponse = 2; s.EnvironmentImpactLimit = 2; }, Skulker, Slinker);
|
||||
Check.Eq((uint)r.C.activeTargetId, A, "the Skulker is locked");
|
||||
|
||||
void Cast(float stopY, bool hitLine = false) => CastBolt(r, stopY, hitLine);
|
||||
|
||||
Cast(105);
|
||||
Check.True(FakeHost.Logs.Any(l => l.Contains("[EnvImpact] magic") && l.Contains("1/2")), "a bolt stopping 9 m out, no hit: one environment hit");
|
||||
Cast(115);
|
||||
Check.False(FakeHost.Logs.Any(l => l.Contains("[EnvImpact] magic") && l.Contains("2/2")), "a bolt reaching the target: not counted");
|
||||
Cast(105, hitLine: true);
|
||||
Check.False(FakeHost.Logs.Any(l => l.Contains("[EnvImpact] magic") && l.Contains("2/2")), "a hit line for the cast: not counted");
|
||||
Cast(105);
|
||||
Check.True(FakeHost.Logs.Any(l => l.Contains("[EnvImpact] magic") && l.Contains("2/2")), "a second short bolt: the limit");
|
||||
Check.True(r.Run(), "the response runs");
|
||||
Check.Eq(r.C.activeTargetId, 0, "the Skulker is left for the Slinker");
|
||||
|
||||
// Rings and other casters' projectiles aren't ours to judge.
|
||||
Check.False(CombatManager.IsWatchedProjectileName("Flame Ring"), "a ring isn't watched");
|
||||
Check.True(CombatManager.IsWatchedProjectileName("Nether Bolt"), "void bolts are");
|
||||
Check.False(CombatManager.IsWatchedProjectileName("Drudge Skulker"), "a monster isn't");
|
||||
}
|
||||
|
||||
private static void ApproachOrphan()
|
||||
{
|
||||
var r = new Rig(CombatMode.Missile, s => { s.MissileEnvironmentResponse = 1; s.EnvironmentImpactLimit = 1; }, Skulker);
|
||||
r.C.HandleChatForDamage(MissileLine);
|
||||
Check.True(r.Run(), "approach starts");
|
||||
Check.True(FakeHost.AutoRun, "running");
|
||||
r.Now = r.Now.AddSeconds(2); // Think stopped calling (buffing took over)
|
||||
r.C.PollEnvironmentImpact();
|
||||
Check.False(FakeHost.AutoRun, "the heartbeat lets go of autorun");
|
||||
Check.False(r.C.EnvironmentApproachActive, "approach over");
|
||||
|
||||
r.C.HandleChatForDamage(MissileLine);
|
||||
Check.True(r.Run(), "a new approach");
|
||||
r.C.OnHeartbeat(); // a heartbeat sees the macro running
|
||||
Check.True(FakeHost.AutoRun, "still running while Think drives it");
|
||||
r.S.IsMacroRunning = false;
|
||||
r.C.OnHeartbeat();
|
||||
Check.False(FakeHost.AutoRun, "a macro stop ends it too");
|
||||
}
|
||||
|
||||
// ── Attack power ─────────────────────────────────────────────────────────
|
||||
|
||||
private static void Power()
|
||||
{
|
||||
float R(string mode, int global = -1, bool reck = false, bool trained = true, int min = 50, int max = 100, double rnd = 0.5)
|
||||
=> AttackPowerModes.Resolve(mode, global, reck, trained, min, max, () => rnd);
|
||||
|
||||
Check.Near(R("Default"), 1.0, 1e-6, "Default, Auto, no Recklessness: 100%");
|
||||
Check.Near(R("Default", reck: true), 0.8, 1e-6, "Default, Auto + Use Recklessness, trained: 80%");
|
||||
Check.Near(R("Default", reck: true, trained: false), 1.0, 1e-6, "... untrained: 100%");
|
||||
Check.Near(R("Default", global: 65), 0.65, 1e-6, "Default, a set power: that power");
|
||||
Check.Near(R("High", global: 40), 1.0, 1e-6, "High: 100% whatever the global");
|
||||
Check.Near(R("Reckless"), 0.8, 1e-6, "Reckless: 80%");
|
||||
Check.Near(R("Reckless", trained: false), 1.0, 1e-6, "Reckless untrained: High");
|
||||
Check.Near(R("Variable", rnd: 0), 0.5, 1e-6, "Variable: the min");
|
||||
Check.Near(R("Variable", rnd: 0.999), 1.0, 1e-6, "Variable: up to the max");
|
||||
Check.Near(R("Variable", min: 90, max: 30, rnd: 0), 0.3, 1e-6, "Variable: a reversed range is put in order");
|
||||
Check.Near(R("Reckless + Variable", rnd: 0), 0.5, 1e-6, "Reckless + Variable: the Variable min (inside the band)");
|
||||
Check.Near(R("Reckless + Variable", rnd: 0.999), 0.8, 1e-6, "... capped at the band's 80%");
|
||||
Check.Near(R("Reckless + Variable", min: 85, max: 100, rnd: 0), 0.2, 1e-6, "no overlap with the band: the whole band");
|
||||
Check.Near(R("Reckless + Variable", trained: false, rnd: 0.999), 1.0, 1e-6, "untrained: plain Variable");
|
||||
var seen = new HashSet<float>();
|
||||
foreach (double d in new[] { 0.1, 0.4, 0.7 }) seen.Add(R("Variable", rnd: d));
|
||||
Check.Eq(seen.Count, 3, "Variable changes with each draw");
|
||||
|
||||
Check.Eq(AttackPowerModes.Normalize("reckless+variable"), AttackPowerModes.RecklessVariable, "hand-typed spelling");
|
||||
Check.Eq(AttackPowerModes.Normalize(null), AttackPowerModes.Default, "missing: Default");
|
||||
Check.Eq(AttackPowerModes.Normalize("Huge"), AttackPowerModes.Default, "unknown: Default");
|
||||
var def = new MonsterRule { Name = "Default", AttackPower = "Reckless" };
|
||||
Check.Eq(AttackPowerModes.Effective(new MonsterRule { Name = "Drudge" }, def), "Reckless", "a Default rule follows the DEFAULT line");
|
||||
Check.Eq(AttackPowerModes.Effective(new MonsterRule { Name = "Drudge", AttackPower = "High" }, def), "High", "its own choice wins");
|
||||
Check.Eq(AttackPowerModes.Effective(null, null), "Default", "no rules: the global settings");
|
||||
Check.Eq(new MonsterRule().AttackPower, "Default", "a new rule (and an old file) is Default");
|
||||
|
||||
// Pull-away kite (2026-10-16): Default → DEFAULT row → Off on that row.
|
||||
Check.Eq(KiteModes.Normalize("pull away"), KiteModes.PullAway, "hand-typed PullAway");
|
||||
Check.Eq(KiteModes.Normalize(null), KiteModes.Default, "missing kite: Default");
|
||||
var kiteDef = new MonsterRule { Name = "Default", Kite = KiteModes.PullAway };
|
||||
Check.Eq(KiteModes.Effective(new MonsterRule { Name = "Drudge" }, kiteDef), KiteModes.PullAway, "a Default rule follows the DEFAULT kite");
|
||||
Check.Eq(KiteModes.Effective(new MonsterRule { Name = "Drudge", Kite = KiteModes.Off }, kiteDef), KiteModes.Off, "its own kite wins");
|
||||
Check.Eq(KiteModes.Effective(kiteDef, kiteDef), KiteModes.PullAway, "DEFAULT row PullAway is PullAway");
|
||||
Check.Eq(KiteModes.Effective(new MonsterRule { Name = "Default" }, new MonsterRule { Name = "Default" }), KiteModes.Off, "DEFAULT Default means Off");
|
||||
Check.True(KiteModes.WantsPullAway(new MonsterRule { Name = "X" }, kiteDef), "WantsPullAway follows DEFAULT");
|
||||
Check.Eq(new MonsterRule().Kite, "Default", "a new rule (and an old file) is Default kite");
|
||||
}
|
||||
|
||||
private static void PowerCarriedOver()
|
||||
{
|
||||
var current = new List<MonsterRule>
|
||||
{
|
||||
new() { Name = "Default", AttackPower = "High" },
|
||||
new() { Name = "Drudge", AttackPower = "Variable" },
|
||||
new() { Name = "Drudge", MatchExpression = "x", AttackPower = "Reckless" },
|
||||
};
|
||||
var incoming = new List<MonsterRule>
|
||||
{
|
||||
new() { Name = "Default" }, new() { Name = "drudge" }, new() { Name = "Drudge", MatchExpression = "x" }, new() { Name = "Mosswart" },
|
||||
};
|
||||
LegacyDashboardRenderer.CarryAttackPower(current, incoming);
|
||||
Check.Eq(incoming[0].AttackPower, "High", "Default keeps its power");
|
||||
Check.Eq(incoming[1].AttackPower, "Variable", "matched by name, any case");
|
||||
Check.Eq(incoming[2].AttackPower, "Reckless", "and by expression");
|
||||
Check.Eq(incoming[3].AttackPower, "Default", "a new rule stays Default");
|
||||
}
|
||||
|
||||
// ── Magic position re-sync (upstream 2026.10.12.1) and the throttle ──────
|
||||
|
||||
private const uint StepRight = 0x6500000F, StepLeft = 0x65000010;
|
||||
|
||||
/// <summary>Upstream's CastNoDamageTests.ResyncSidestep, on this file's rig.</summary>
|
||||
private static void ResyncSidestep()
|
||||
{
|
||||
var r = new Rig(CombatMode.Magic, s => { }, setMotion: true, Skulker, Slinker);
|
||||
var c = r.C;
|
||||
c.TargetClock = () => r.Now;
|
||||
MoveAudit.Reset();
|
||||
|
||||
c.MagicMissForTest(unchecked((int)A));
|
||||
c.MagicMissForTest(unchecked((int)B)); // a swap to the other monster doesn't reset the count
|
||||
Check.False(c.ResyncActive, "two misses: nothing yet");
|
||||
c.ReportDamageOnTarget(unchecked((int)A));
|
||||
c.MagicMissForTest(unchecked((int)A));
|
||||
c.MagicMissForTest(unchecked((int)A));
|
||||
Check.False(c.ResyncActive, "a hit reset the count");
|
||||
c.MagicMissForTest(unchecked((int)A));
|
||||
Check.True(c.ResyncActive, "three in a row: a re-sync is wanted");
|
||||
Check.Eq(FakeHost.Logs.Count(l => l.Contains("one short sidestep to re-sync")), 1, "said once");
|
||||
|
||||
Check.True(c.TickResyncStep(), "first tick: the step starts, no cast");
|
||||
Check.True(FakeHost.MotionCalls.SequenceEqual(new[] { (StepRight, true) }), "sidestep right key down");
|
||||
r.Now = r.Now.AddMilliseconds(200);
|
||||
Check.True(c.TickResyncStep(), "still stepping at 200 ms");
|
||||
r.Now = r.Now.AddMilliseconds(100);
|
||||
Check.True(c.TickResyncStep(), "300 ms: key up, settling");
|
||||
Check.True(FakeHost.MotionCalls.SequenceEqual(new[] { (StepRight, true), (StepRight, false) }), "key up");
|
||||
r.Now = r.Now.AddMilliseconds(400);
|
||||
Check.False(c.TickResyncStep(), "settled: casting may go on");
|
||||
Check.Eq(c.ResyncSteps, 1, "one step");
|
||||
|
||||
for (int i = 0; i < 3; i++) c.MagicMissForTest(unchecked((int)A));
|
||||
Check.False(c.ResyncActive, "within 30 s: no second step");
|
||||
r.Now = r.Now.AddSeconds(30);
|
||||
for (int i = 0; i < 3; i++) c.MagicMissForTest(unchecked((int)A));
|
||||
Check.True(c.ResyncActive, "30 s later: another one");
|
||||
c.TickResyncStep();
|
||||
Check.True(FakeHost.MotionCalls[2] == (StepLeft, true), "the other side this time");
|
||||
}
|
||||
|
||||
private static void ResyncCountResetByThrottle()
|
||||
{
|
||||
var r = new Rig(CombatMode.Magic, s => { s.MagicEnvironmentResponse = 2; s.EnvironmentImpactLimit = 2; }, setMotion: true, Skulker, Slinker);
|
||||
r.C.TargetClock = () => r.Now;
|
||||
r.C.MagicMissForTest(unchecked((int)A));
|
||||
r.C.MagicMissForTest(unchecked((int)A));
|
||||
CastBolt(r, 105);
|
||||
CastBolt(r, 105);
|
||||
Check.True(r.Run(), "two short bolts: the throttle switches target");
|
||||
Check.Eq(r.C.activeTargetId, 0, "the Skulker is left");
|
||||
|
||||
r.C.MagicMissForTest(unchecked((int)B));
|
||||
r.C.MagicMissForTest(unchecked((int)B));
|
||||
Check.False(r.C.ResyncActive, "the misses the wall explained no longer count toward a sidestep");
|
||||
r.C.MagicMissForTest(unchecked((int)B));
|
||||
Check.True(r.C.ResyncActive, "three fresh misses on the new target still ask for one");
|
||||
}
|
||||
|
||||
private static void ResyncDroppedByApproach()
|
||||
{
|
||||
var r = new Rig(CombatMode.Magic, s => { s.MagicEnvironmentResponse = 1; s.EnvironmentImpactLimit = 1; }, setMotion: true, Skulker);
|
||||
r.C.TargetClock = () => r.Now;
|
||||
for (int i = 0; i < 3; i++) r.C.MagicMissForTest(unchecked((int)A));
|
||||
Check.True(r.C.ResyncActive, "a sidestep is wanted");
|
||||
|
||||
CastBolt(r, 105);
|
||||
Check.True(r.Run(), "the throttle moves closer");
|
||||
Check.True(FakeHost.AutoRun, "running toward the Skulker");
|
||||
Check.False(r.C.ResyncActive, "the wanted sidestep is dropped: the run moves us anyway");
|
||||
Check.True(FakeHost.Logs.Any(l => l.Contains("re-sync sidestep dropped: moving closer")), "logged");
|
||||
Check.Eq(FakeHost.MotionCalls.Count, 0, "no sidestep key was sent");
|
||||
}
|
||||
|
||||
private static void ResyncStepFinishesFirst()
|
||||
{
|
||||
var r = new Rig(CombatMode.Magic, s => { s.MagicEnvironmentResponse = 1; s.EnvironmentImpactLimit = 1; }, setMotion: true, Skulker);
|
||||
r.C.TargetClock = () => r.Now;
|
||||
for (int i = 0; i < 3; i++) r.C.MagicMissForTest(unchecked((int)A));
|
||||
CastBolt(r, 105); // the throttle trips (its response waits for Think)
|
||||
Check.True(r.C.TickResyncStep(), "the sidestep key goes down");
|
||||
|
||||
Check.True(r.Run(), "the throttle's tick: no attack");
|
||||
Check.False(r.C.EnvironmentApproachActive, "but no run while the sidestep key is held");
|
||||
Check.False(FakeHost.AutoRun, "autorun not sent");
|
||||
|
||||
r.Now = r.Now.AddMilliseconds(300);
|
||||
Check.True(r.C.TickResyncStep(), "the sidestep key comes up");
|
||||
Check.True(r.Run(), "now the approach runs");
|
||||
Check.True(r.C.EnvironmentApproachActive, "approach under way");
|
||||
Check.True(FakeHost.MotionCalls.SequenceEqual(new[] { (StepRight, true), (StepRight, false) }), "the key went up before the run");
|
||||
}
|
||||
|
||||
private static void ResyncKeyReleased()
|
||||
{
|
||||
var r = new Rig(CombatMode.Magic, s => { }, setMotion: true, Skulker);
|
||||
r.C.TargetClock = () => r.Now;
|
||||
for (int i = 0; i < 3; i++) r.C.MagicMissForTest(unchecked((int)A));
|
||||
r.C.TickResyncStep();
|
||||
Check.True(FakeHost.MotionCalls.SequenceEqual(new[] { (StepRight, true) }), "key down");
|
||||
|
||||
r.Now = r.Now.AddSeconds(2); // Think stopped ticking it (left magic mode)
|
||||
r.C.PollEnvironmentImpact();
|
||||
Check.True(FakeHost.MotionCalls.SequenceEqual(new[] { (StepRight, true), (StepRight, false) }), "the heartbeat lets go of the key");
|
||||
Check.False(r.C.ResyncActive, "the sidestep is over");
|
||||
Check.True(FakeHost.Logs.Any(l => l.Contains("re-sync sidestep stopped: combat stopped driving it")), "logged");
|
||||
|
||||
r.C.OnHeartbeat(); // a heartbeat sees the macro running
|
||||
r.C.MagicMissForTest(unchecked((int)A));
|
||||
int before = FakeHost.MotionCalls.Count;
|
||||
r.C.TickResyncStep();
|
||||
Check.True(FakeHost.MotionCalls.Count == before + 1 && FakeHost.MotionCalls[^1] == (StepLeft, true), "a new sidestep, key down");
|
||||
r.S.IsMacroRunning = false;
|
||||
r.C.OnHeartbeat();
|
||||
Check.True(FakeHost.MotionCalls[^1] == (StepLeft, false), "a macro stop lets go of it too");
|
||||
Check.False(r.C.ResyncActive, "and ends it");
|
||||
}
|
||||
|
||||
// ── Helpers ──────────────────────────────────────────────────────────────
|
||||
|
||||
/// <summary>One cast at the active target whose bolt flies from the caster north to <paramref name="stopY"/> and stops.</summary>
|
||||
private static void CastBolt(Rig r, float stopY, bool hitLine = false)
|
||||
{
|
||||
r.C.RegisterCastWatch(r.C.activeTargetId, "Flame Bolt VI");
|
||||
r.Now = r.Now.AddMilliseconds(800); // the windup
|
||||
FakeHost.Names[Bolt] = "Flame Bolt";
|
||||
FakeHost.Positions[Bolt] = (Lb | 0x1C, 96f, 97f, 0f); // spawns at the caster
|
||||
r.C.OnEnvironmentObjectCreated(Bolt);
|
||||
r.C.PollEnvironmentImpact();
|
||||
for (float y = 99; y <= stopY; y += 2)
|
||||
{
|
||||
r.Now = r.Now.AddMilliseconds(100);
|
||||
FakeHost.Positions[Bolt] = (Lb | 0x1C, 96f, y, 0f);
|
||||
r.C.PollEnvironmentImpact();
|
||||
}
|
||||
if (hitLine) r.C.HandleChatForDamage("You singe Drudge Skulker for 40 points of fire damage!");
|
||||
for (int i = 0; i < 15; i++) { r.Now = r.Now.AddMilliseconds(100); r.C.PollEnvironmentImpact(); }
|
||||
r.C.OnObjectDeleted(Bolt);
|
||||
FakeHost.Positions.Remove(Bolt);
|
||||
}
|
||||
|
||||
private static void Place(uint id, string name, float x, float y, bool creature = true)
|
||||
{
|
||||
FakeHost.Names[id] = name;
|
||||
FakeHost.Positions[id] = (Lb | 0x1C, x, y, 0f);
|
||||
if (creature) FakeHost.ItemTypes[id] = 0x10;
|
||||
}
|
||||
}
|
||||
|
|
@ -41,6 +41,7 @@ internal static class ExpressionTests
|
|||
r.Add("expr: control flow (iif, if, ifthen, exec) is lazy", ControlFlow);
|
||||
r.Add("expr: delayexec fires on the pump when due, in order", DelayExec);
|
||||
r.Add("expr: stopwatches", Stopwatches);
|
||||
r.Add("expr: ub-IT's remaining functions answer (no-equivalent ones with ub-IT's empty values)", UbCompatFunctions);
|
||||
r.Add("expr: object type, options and unknown functions", TypesOptionsUnknown);
|
||||
r.Add("expr: RynthAi settings and meta state from expressions", SettingsAndState);
|
||||
r.Add("expr: character properties, skills, vitals through the host", CharacterFunctions);
|
||||
|
|
@ -516,10 +517,14 @@ internal static class ExpressionTests
|
|||
var e = Engine();
|
||||
long now = 5_000;
|
||||
e.TickMs = () => now;
|
||||
// ub-IT: delayexec returns its id (1, 2, ...), which clearexec takes.
|
||||
Is(e, "delayexec[1000, `setvar[x, first]`]", "1");
|
||||
Is(e, "delayexec[1000, `setvar[x, second]`]", "1");
|
||||
Is(e, "delayexec[-50, `setvar[neg, 1]`]", "1");
|
||||
Is(e, "delayexec[soon, `setvar[bad, 1]`]", "1");
|
||||
Is(e, "delayexec[1000, `setvar[x, second]`]", "2");
|
||||
Is(e, "delayexec[-50, `setvar[neg, 1]`]", "3");
|
||||
Is(e, "delayexec[soon, `setvar[bad, 1]`]", "4");
|
||||
Is(e, "delayexec[1000, `setvar[cancelled, 1]`]", "5");
|
||||
Is(e, "clearexec[5]", "1");
|
||||
Is(e, "clearexec[5]", "0"); // already gone
|
||||
e.PumpDelayedExecs();
|
||||
Is(e, "getvar[neg]", "1"); // negative delay: next pump
|
||||
Is(e, "getvar[bad]", "1"); // unreadable delay: next pump
|
||||
|
|
@ -530,16 +535,76 @@ internal static class ExpressionTests
|
|||
now += 1;
|
||||
e.PumpDelayedExecs();
|
||||
Is(e, "getvar[x]", "second"); // both fired, in the order scheduled
|
||||
Is(e, "testvar[cancelled]", "0"); // the cleared one never ran
|
||||
|
||||
// A delayexec scheduled by a firing one waits for a later pump.
|
||||
// (\` is an escaped backtick inside a backtick string.)
|
||||
Is(e, "delayexec[0, `delayexec[0, \\`setvar[chain, 1]\\`]`]", "1");
|
||||
Is(e, "delayexec[0, `delayexec[0, \\`setvar[chain, 1]\\`]`]", "6");
|
||||
e.PumpDelayedExecs();
|
||||
Is(e, "testvar[chain]", "0");
|
||||
e.PumpDelayedExecs();
|
||||
Is(e, "getvar[chain]", "1");
|
||||
}
|
||||
|
||||
private static void UbCompatFunctions()
|
||||
{
|
||||
FakeHost.Reset();
|
||||
var settings = new LegacyUiSettings();
|
||||
var e = Engine(FakeHost.Create(), settings);
|
||||
|
||||
// enlightenmentmaterials: levels 6-150 cost (level - 5) tokens; 1-5 and 151+ none.
|
||||
Is(e, "enlightenmentmaterials[0, 10]", "15"); // 1+2+3+4+5
|
||||
Is(e, "enlightenmentmaterials[149, 151]", "145"); // only 150 costs tokens
|
||||
Is(e, "enlightenmentmaterials[160, 165]", "0");
|
||||
Is(e, "enlightenmentmaterials[10, 5]", "0");
|
||||
|
||||
// Macro state, casting, quests.
|
||||
settings.IsMacroRunning = true;
|
||||
Is(e, "vtmacroenabled[]", "1");
|
||||
settings.IsMacroRunning = false;
|
||||
Is(e, "vtmacroenabled[]", "0");
|
||||
Is(e, "iscasting[]", "0");
|
||||
Is(e, "canrefreshquests[]", "1"); // no tracker: nothing throttles it
|
||||
Is(e, "isrefreshingquestbonuses[]", "0");
|
||||
Is(e, "getcooldownexpiration[515]", "0");
|
||||
|
||||
// Corpses opened by this character come from the plugin's hook.
|
||||
e.CorpseOpenedByMe = id => id == 0x50000123;
|
||||
Is(e, "hascorpsebeenopenedbyme[0x50000123]", "1");
|
||||
Is(e, "hascorpsebeenopenedbyme[0x50000124]", "0");
|
||||
Is(e, "getcorpsesunopenedbyme[]", "[]"); // no cache, no corpses
|
||||
|
||||
// Unknown or unreadable objects: ub-IT's -1 / 0.
|
||||
Is(e, "wobjectgethealthvalue[0]", "-1");
|
||||
Is(e, "actiontrymove[0, 0]", "0");
|
||||
Is(e, "actiontrysplit[0, 5]", "0");
|
||||
Is(e, "actiontrydrop[0x50000123]", "0");
|
||||
|
||||
// spelldata of an unknown spell is an empty dictionary.
|
||||
Is(e, "dictsize[spelldata[999999]]", "0");
|
||||
|
||||
// XP meter: starts at zero.
|
||||
Is(e, "xpreset[]", "1");
|
||||
Is(e, "xptotal[]", "0");
|
||||
Is(e, "lumtotal[]", "0");
|
||||
Is(e, "xpavg[]", "0");
|
||||
Check.True(e.Evaluate("xpmeter[]").Contains("XP/hr"), "xpmeter[] is the meter text");
|
||||
|
||||
// No RynthAi equivalent: they answer so the expression keeps going.
|
||||
Is(e, "statushud[kills, 5]", "1");
|
||||
Is(e, "statushudcolored[kills, 5, red]", "1");
|
||||
Is(e, "netclients[]", "[]");
|
||||
Is(e, "getcharacterindex[Bob]", "-1");
|
||||
Is(e, "setnextlogin[Bob]", "0");
|
||||
Is(e, "clearnextlogin[]", "1");
|
||||
Is(e, "uiviewexists[myview]", "0");
|
||||
Is(e, "uiviewvisible[myview]", "0");
|
||||
Is(e, "statushud[a, 1] && 7", "1"); // used inside a larger expression
|
||||
|
||||
// A real typo is still an unknown function.
|
||||
Is(e, "nosuchfunctionatall[]", "");
|
||||
}
|
||||
|
||||
private static void Stopwatches()
|
||||
{
|
||||
var e = Engine();
|
||||
|
|
|
|||
|
|
@ -27,6 +27,7 @@ internal static class GiveTests
|
|||
r.Add("give: /ub give with a count hands over that many", UbGiveCount);
|
||||
r.Add("give: /mt give hands over only the first match", MtGivesFirst);
|
||||
r.Add("give: /ub givep matches part of the name", UbGivePartial);
|
||||
r.Add("give: a meta's /ub give hands over every match too (it used to take /mt give's one)", MetaUbGivesAll);
|
||||
r.Add("give: the next give waits until the server took the last (it answers extra gives 'too busy')", WaitsForServer);
|
||||
}
|
||||
|
||||
|
|
@ -112,6 +113,14 @@ internal static class GiveTests
|
|||
Check.False(w.GivenItems.Contains(WornMote), "and never the worn one");
|
||||
}
|
||||
|
||||
private static void MetaUbGivesAll()
|
||||
{
|
||||
var w = new World();
|
||||
w.Call("HandleMetaChatCommand", "/ub give Mana Mote to Town Crier");
|
||||
for (int i = 0; i < 20; i++) w.Call("DrainGiveQueue");
|
||||
Check.Eq(FakeHost.Gives.Count, 3, "all three carried Mana Motes, as typed");
|
||||
}
|
||||
|
||||
private static void UbGivePartial()
|
||||
{
|
||||
var w = new World();
|
||||
|
|
|
|||
258
Tools/RynthCore.RynthAiHostTests/Tests/MetaAuditTests.cs
Normal file
258
Tools/RynthCore.RynthAiHostTests/Tests/MetaAuditTests.cs
Normal file
|
|
@ -0,0 +1,258 @@
|
|||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
using System.Reflection;
|
||||
using System.Runtime.CompilerServices;
|
||||
using System.Text;
|
||||
using System.Text.RegularExpressions;
|
||||
using RynthCore.Plugin.RynthAi;
|
||||
using RynthCore.Plugin.RynthAi.LegacyUi;
|
||||
using RynthCore.Plugin.RynthAi.Meta;
|
||||
using RynthCore.PluginCore;
|
||||
using RynthCore.RynthAiHostTests.Fakes;
|
||||
using RynthCore.RynthAiTests.Harness;
|
||||
|
||||
namespace RynthCore.RynthAiHostTests.Tests;
|
||||
|
||||
// Opt-in audit (RYNTH_META_AUDIT=<folder of .met files>): what each meta asks of RynthAi - its chat
|
||||
// commands through the real /vt /mt /ub dispatchers, its expression functions through the engine,
|
||||
// its VTank options against the option map - and a report of what isn't supported.
|
||||
internal static class MetaAuditTests
|
||||
{
|
||||
private const BindingFlags Any = BindingFlags.Instance | BindingFlags.Static | BindingFlags.NonPublic | BindingFlags.Public;
|
||||
|
||||
public static void Register(Runner r)
|
||||
{
|
||||
string? dir = Environment.GetEnvironmentVariable("RYNTH_META_AUDIT");
|
||||
if (!string.IsNullOrEmpty(dir) && Directory.Exists(dir)) r.Add("audit: sample metas (RYNTH_META_AUDIT)", () => Run(dir));
|
||||
}
|
||||
|
||||
private sealed class Found
|
||||
{
|
||||
public readonly SortedDictionary<string, SortedSet<string>> Commands = new(StringComparer.OrdinalIgnoreCase);
|
||||
public readonly SortedDictionary<string, SortedSet<string>> Functions = new(StringComparer.OrdinalIgnoreCase);
|
||||
public readonly SortedDictionary<string, SortedSet<string>> Options = new(StringComparer.OrdinalIgnoreCase);
|
||||
public readonly SortedDictionary<string, SortedSet<string>> Kinds = new(StringComparer.OrdinalIgnoreCase);
|
||||
public readonly SortedDictionary<string, SortedSet<string>> States = new(StringComparer.OrdinalIgnoreCase);
|
||||
public void Add(SortedDictionary<string, SortedSet<string>> d, string key, string meta)
|
||||
{
|
||||
if (!d.TryGetValue(key, out var s)) d[key] = s = new SortedSet<string>(StringComparer.OrdinalIgnoreCase);
|
||||
s.Add(meta);
|
||||
}
|
||||
}
|
||||
|
||||
private static readonly Regex FnRx = new(@"(?<![\$@&\w])([A-Za-z_][A-Za-z0-9_]*)\[", RegexOptions.CultureInvariant);
|
||||
private static readonly Regex CmdInExprRx = new(@"/(vt|mt|ub|ra)\s+[A-Za-z0-9_]+(?:\s+[A-Za-z0-9_]+)?", RegexOptions.IgnoreCase | RegexOptions.CultureInvariant);
|
||||
private static readonly Regex OptFnRx = new(@"\b(vtsetsetting|vtgetsetting|vtankgetsetting)\[\s*`?([A-Za-z0-9_\-]+)", RegexOptions.IgnoreCase | RegexOptions.CultureInvariant);
|
||||
|
||||
private static void Run(string dir)
|
||||
{
|
||||
var f = new Found();
|
||||
var report = new StringBuilder();
|
||||
var definedStates = new Dictionary<string, HashSet<string>>(StringComparer.OrdinalIgnoreCase);
|
||||
foreach (string path in Directory.GetFiles(dir, "*.met").OrderBy(p => p, StringComparer.OrdinalIgnoreCase))
|
||||
{
|
||||
string meta = Path.GetFileName(path);
|
||||
LoadedMeta m = MetFileParser.Load(path);
|
||||
report.AppendLine($"## {meta}: {m.Rules.Count} rules, {m.EmbeddedNavs.Count} navs" + (m.Warnings.Count > 0 ? ", warnings: " + string.Join(" | ", m.Warnings) : ""));
|
||||
var states = new HashSet<string>(StringComparer.OrdinalIgnoreCase);
|
||||
definedStates[meta] = states;
|
||||
foreach (MetaRule rule in m.Rules) { states.Add(rule.State); Walk(rule, meta, f); }
|
||||
}
|
||||
|
||||
// Chat commands through the dispatchers.
|
||||
var w = new PluginWorld();
|
||||
report.AppendLine("\n# Chat commands");
|
||||
foreach (var (cmd, metas) in f.Commands)
|
||||
report.AppendLine($" [{Classify(cmd, w)}] {cmd} <- {string.Join(", ", metas)}");
|
||||
|
||||
// Expression functions through the engine.
|
||||
report.AppendLine("\n# Expression functions not known to RynthAi");
|
||||
FakeHost.Reset();
|
||||
var host = FakeHost.Create();
|
||||
foreach (var (fn, metas) in f.Functions)
|
||||
{
|
||||
var e = new ExpressionEngine(host);
|
||||
int logs = FakeHost.Logs.Count;
|
||||
try { e.Evaluate(fn + "[]"); } catch { }
|
||||
bool unknown = FakeHost.Logs.Skip(logs).Any(l => l.Contains("unknown expression function '" + fn, StringComparison.OrdinalIgnoreCase));
|
||||
if (unknown) report.AppendLine($" {fn} <- {string.Join(", ", metas)}");
|
||||
}
|
||||
report.AppendLine(" (all functions used: " + string.Join(", ", f.Functions.Keys) + ")");
|
||||
|
||||
// VTank options against the option map / settings map / special options.
|
||||
report.AppendLine("\n# VTank options");
|
||||
var mm = new MetaManager(new LegacyUiSettings(), host, new PlayerVitalsCache());
|
||||
var map = (Dictionary<string, string>)typeof(MetaManager).GetField("VtOptionMap", Any)!.GetValue(null)!;
|
||||
var special = typeof(MetaManager).GetMethod("IsSpecialVtOption", Any)!;
|
||||
var settings = mm.Expressions.BuildSettingsMapPublic();
|
||||
var settingsCi = new HashSet<string>(settings.Keys, StringComparer.OrdinalIgnoreCase);
|
||||
foreach (var (opt, metas) in f.Options)
|
||||
{
|
||||
bool known = map.ContainsKey(opt) || settingsCi.Contains(opt) || (bool)special.Invoke(null, new object[] { opt })!;
|
||||
report.AppendLine($" [{(known ? "ok" : "NOT MAPPED")}] {opt}{(map.TryGetValue(opt, out string? ra) ? " -> " + ra : "")} <- {string.Join(", ", metas)}");
|
||||
}
|
||||
|
||||
// The same VTank values set two ways: '/vt opt set' and the vtsetsetting[] expression.
|
||||
report.AppendLine("\n# /vt opt set vs vtsetsetting[] (VTank units in, RynthAi setting out)");
|
||||
foreach (var (opt, val) in new[] { ("AttackDistance", "0.025"), ("ApproachDistance", "0.0208333"), ("NavCloseStopRange", "0.00625"), ("PetCustomRange", "0.0625"), ("LootOnlyRareCorpses", "1") })
|
||||
{
|
||||
var s1 = new LegacyUiSettings(); var m1 = new MetaManager(s1, host, new PlayerVitalsCache());
|
||||
m1.TryHandleVtCommand($"/vt opt set {opt} {val}");
|
||||
var s2 = new LegacyUiSettings(); var m2 = new MetaManager(s2, host, new PlayerVitalsCache());
|
||||
m2.Expressions.Evaluate($"vtsetsetting[{opt},`{val}`]");
|
||||
string Read(MetaManager mm2) => (string?)typeof(MetaManager).GetMethod("GetVtOption", Any)!.Invoke(mm2, new object[] { opt }) ?? "(null)";
|
||||
report.AppendLine($" {opt}={val}: /vt opt set -> {Read(m1)} vtsetsetting -> {Read(m2)} (MonsterRange {s1.MonsterRange} vs {s2.MonsterRange}, ApproachRange {s1.ApproachRange} vs {s2.ApproachRange}, CustomPetRange {s1.CustomPetRange} vs {s2.CustomPetRange})");
|
||||
}
|
||||
|
||||
report.AppendLine("\n# Rule kinds used");
|
||||
foreach (var (k, metas) in f.Kinds) report.AppendLine($" {k} <- {string.Join(", ", metas)}");
|
||||
|
||||
report.AppendLine("\n# States set or called but not defined");
|
||||
foreach (var (st, metas) in f.States)
|
||||
foreach (string meta in metas)
|
||||
if (definedStates.TryGetValue(meta, out var defined) && !defined.Contains(st)) report.AppendLine($" {meta}: '{st}'");
|
||||
|
||||
string outPath = Path.Combine(Path.GetTempPath(), "meta_audit.txt");
|
||||
File.WriteAllText(outPath, report.ToString());
|
||||
Console.WriteLine(" audit report: " + outPath);
|
||||
Check.True(true, "audit ran");
|
||||
}
|
||||
|
||||
private static void Walk(MetaRule r, string meta, Found f)
|
||||
{
|
||||
f.Add(f.Kinds, "if " + r.Condition, meta);
|
||||
if (r.Condition == MetaConditionType.Expression) Expr(r.ConditionData, meta, f);
|
||||
foreach (MetaRule c in r.Children) WalkCondition(c, meta, f);
|
||||
Action(r, meta, f);
|
||||
}
|
||||
|
||||
private static void WalkCondition(MetaRule c, string meta, Found f)
|
||||
{
|
||||
f.Add(f.Kinds, "if " + c.Condition, meta);
|
||||
if (c.Condition == MetaConditionType.Expression) Expr(c.ConditionData, meta, f);
|
||||
foreach (MetaRule cc in c.Children) WalkCondition(cc, meta, f);
|
||||
}
|
||||
|
||||
private static void Action(MetaRule r, string meta, Found f)
|
||||
{
|
||||
f.Add(f.Kinds, "do " + r.Action, meta);
|
||||
string d = r.ActionData ?? "";
|
||||
switch (r.Action)
|
||||
{
|
||||
case MetaActionType.ChatCommand:
|
||||
foreach (string line in d.Split('\n', StringSplitOptions.RemoveEmptyEntries))
|
||||
{
|
||||
string cmd = line.Trim();
|
||||
f.Add(f.Commands, cmd, meta);
|
||||
Match om = Regex.Match(cmd, @"^/vt\s+opt\s+(?:set|get)\s+(\S+)", RegexOptions.IgnoreCase);
|
||||
if (om.Success) f.Add(f.Options, om.Groups[1].Value, meta);
|
||||
}
|
||||
break;
|
||||
case MetaActionType.ExpressionAction:
|
||||
case MetaActionType.ChatExpression:
|
||||
Expr(d, meta, f);
|
||||
break;
|
||||
case MetaActionType.SetRAOption:
|
||||
{ string[] p = d.Split(';', 2); f.Add(f.Options, p[0].Trim(), meta); if (p.Length > 1) Expr(p[1], meta, f); }
|
||||
break;
|
||||
case MetaActionType.GetRAOption:
|
||||
{ string[] p = d.Split(';'); if (p.Length > 1) f.Add(f.Options, p[1].Trim(), meta); }
|
||||
break;
|
||||
case MetaActionType.SetMetaState:
|
||||
case MetaActionType.CallMetaState:
|
||||
f.Add(f.States, d.Split(';')[0].Trim(), meta);
|
||||
if (r.CallReturnState.Length > 0) f.Add(f.States, r.CallReturnState, meta);
|
||||
break;
|
||||
}
|
||||
foreach (MetaRule c in r.ActionChildren) Action(c, meta, f);
|
||||
}
|
||||
|
||||
private static void Expr(string? text, string meta, Found f)
|
||||
{
|
||||
if (string.IsNullOrWhiteSpace(text)) return;
|
||||
foreach (Match m in FnRx.Matches(text)) f.Add(f.Functions, m.Groups[1].Value.ToLowerInvariant(), meta);
|
||||
string plain = text.Replace("\\/", "/").Replace("\\", "");
|
||||
foreach (Match m in CmdInExprRx.Matches(plain)) f.Add(f.Commands, m.Value.Trim() + " (in an expression)", meta);
|
||||
foreach (Match m in OptFnRx.Matches(text)) f.Add(f.Options, m.Groups[2].Value, meta);
|
||||
Match setopt = Regex.Match(plain, @"/vt\s+opt\s+set\s+([A-Za-z0-9_]+)", RegexOptions.IgnoreCase);
|
||||
if (setopt.Success) f.Add(f.Options, setopt.Groups[1].Value, meta);
|
||||
}
|
||||
|
||||
/// <summary>A RynthAi plugin wired enough to run its /mt and /ub dispatchers, plus a meta manager for /vt.</summary>
|
||||
private sealed class PluginWorld
|
||||
{
|
||||
public readonly RynthAiPlugin P = new();
|
||||
public readonly MetaManager M;
|
||||
public readonly HashSet<string> RaVerbs;
|
||||
|
||||
public PluginWorld()
|
||||
{
|
||||
FakeHost.Reset();
|
||||
FakeHost.PluginCommandCalls = true;
|
||||
FakeHost.Create(playerId: 0x50000F99);
|
||||
typeof(RynthPluginBase).GetMethod("Attach", Any)!.Invoke(P, new object[] { FakeHost.LastApi });
|
||||
var s = new LegacyUiSettings();
|
||||
var dash = (LegacyDashboardRenderer)RuntimeHelpers.GetUninitializedObject(typeof(LegacyDashboardRenderer));
|
||||
typeof(LegacyDashboardRenderer).GetField("_settings", Any)!.SetValue(dash, s);
|
||||
Set("_dashboard", dash);
|
||||
Set("_initialized", true);
|
||||
Set("_loginComplete", true);
|
||||
M = new MetaManager(s, FakeHost.Create(playerId: 0x50000F99), new PlayerVitalsCache());
|
||||
M.SetRaCommandHandler(_ => { });
|
||||
RaVerbs = ReadRaVerbs();
|
||||
}
|
||||
|
||||
private void Set(string n, object? v) => typeof(RynthAiPlugin).GetField(n, Any)!.SetValue(P, v);
|
||||
public bool Meta(string cmd) => (bool)typeof(RynthAiPlugin).GetMethod("HandleMetaChatCommand", Any)!.Invoke(P, new object[] { cmd })!;
|
||||
|
||||
/// <summary>The /ra verbs: the case labels of DispatchRaCommand's switch (unknown ones are ignored silently).</summary>
|
||||
private static HashSet<string> ReadRaVerbs()
|
||||
{
|
||||
var verbs = new HashSet<string>(StringComparer.OrdinalIgnoreCase);
|
||||
string? root = AppContext.BaseDirectory;
|
||||
while (root != null && !Directory.Exists(Path.Combine(root, "Plugins"))) root = Path.GetDirectoryName(root);
|
||||
if (root == null) return verbs;
|
||||
string src = File.ReadAllText(Path.Combine(root, "Plugins", "RynthCore.Plugin.RynthAi", "RynthAiPlugin.cs"));
|
||||
int a = src.IndexOf("private void DispatchRaCommand(", StringComparison.Ordinal);
|
||||
int b = a >= 0 ? src.IndexOf("\n }\n", a, StringComparison.Ordinal) : -1;
|
||||
string body = a >= 0 ? src.Substring(a, (b > a ? b : src.Length) - a) : "";
|
||||
foreach (Match m in Regex.Matches(body, "case \"([a-z0-9_]+)\"")) verbs.Add(m.Groups[1].Value);
|
||||
return verbs;
|
||||
}
|
||||
}
|
||||
|
||||
private static string Classify(string cmd, PluginWorld w)
|
||||
{
|
||||
// A command an expression builds: its arguments only exist at run time, so only the
|
||||
// verb was captured; running it bare says nothing.
|
||||
if (cmd.EndsWith("(in an expression)", StringComparison.Ordinal)) return "built at run time (verb only)";
|
||||
string c = cmd.Trim();
|
||||
if (!c.StartsWith("/") && !c.StartsWith("@")) return "say (plain chat)";
|
||||
string[] parts = c.Split(' ', StringSplitOptions.RemoveEmptyEntries);
|
||||
string prefix = parts[0].ToLowerInvariant();
|
||||
string verb = parts.Length > 1 ? parts[1].ToLowerInvariant() : "";
|
||||
try
|
||||
{
|
||||
switch (prefix)
|
||||
{
|
||||
case "/vt":
|
||||
return w.M.TryHandleVtCommand(c) ? "vt ok" : "VT NOT HANDLED";
|
||||
case "/mt":
|
||||
case "/ub":
|
||||
int chat = FakeHost.Chat.Count;
|
||||
bool ok = w.Meta(c);
|
||||
bool noop = FakeHost.Chat.Skip(chat).Any(l => l.Contains("no RynthAi equivalent"));
|
||||
if (prefix == "/ub" && (bool)typeof(RynthAiPlugin).GetMethod("IsUbRythaiCommand", Any)!.Invoke(null, new object[] { verb, parts.Length > 2 ? string.Join(" ", parts, 2, parts.Length - 2) : "" })!)
|
||||
return "ub-Rythai";
|
||||
return !ok ? prefix.ToUpperInvariant().TrimStart('/') + " NOT HANDLED" : noop ? "accepted no-op" : prefix.TrimStart('/') + " ok";
|
||||
case "/ra":
|
||||
return w.RaVerbs.Contains(verb) || verb.StartsWith("jump") ? "ra ok" : "RA verb not in DispatchRaCommand (may be a hotkey verb)";
|
||||
default:
|
||||
return "game/server";
|
||||
}
|
||||
}
|
||||
catch (Exception ex) { return "THREW " + (ex.InnerException ?? ex).GetType().Name + ": " + (ex.InnerException ?? ex).Message; }
|
||||
}
|
||||
}
|
||||
146
Tools/RynthCore.RynthAiHostTests/Tests/MetaSampleCompatTests.cs
Normal file
146
Tools/RynthCore.RynthAiHostTests/Tests/MetaSampleCompatTests.cs
Normal file
|
|
@ -0,0 +1,146 @@
|
|||
using System;
|
||||
using System.Linq;
|
||||
using System.Reflection;
|
||||
using System.Runtime.CompilerServices;
|
||||
using RynthCore.Plugin.RynthAi;
|
||||
using RynthCore.Plugin.RynthAi.LegacyUi;
|
||||
using RynthCore.Plugin.RynthAi.Meta;
|
||||
using RynthCore.PluginCore;
|
||||
using RynthCore.RynthAiHostTests.Fakes;
|
||||
using RynthCore.RynthAiTests.Harness;
|
||||
|
||||
namespace RynthCore.RynthAiHostTests.Tests;
|
||||
|
||||
// What the sample metas (meta samples: PistolPete, S_Bulb/Caul/Colo/CountPhainor/Cows/Deewain,
|
||||
// Willow; audited 2026-10-18 with MetaAuditTests) needed that RynthAi didn't do.
|
||||
internal static class MetaSampleCompatTests
|
||||
{
|
||||
private const BindingFlags Any = BindingFlags.Instance | BindingFlags.Static | BindingFlags.NonPublic | BindingFlags.Public;
|
||||
|
||||
public static void Register(Runner r)
|
||||
{
|
||||
r.Add("meta samples: vtsetsetting[] takes VTank distances like /vt opt set (6 yd, not the 50 yd default)", VtSetSettingDistances);
|
||||
r.Add("meta samples: the options they set map to RynthAi settings (pet range, blacklist, rebuff, auto attack power)", MappedOptions);
|
||||
r.Add("meta samples: /vt deletemonster is accepted", DeleteMonster);
|
||||
r.Add("meta samples: /ub close corpse closes the open corpse", UbCloseCorpse);
|
||||
r.Add("meta samples: /ub <expression> is evaluated (the /ub bc vtsetmetastate[] broadcast)", UbExpression);
|
||||
r.Add("meta samples: /mt face and /ub face take decimals and coordinates, and hold nav while turning", Face);
|
||||
}
|
||||
|
||||
private static (LegacyUiSettings S, MetaManager M) Meta()
|
||||
{
|
||||
FakeHost.Reset();
|
||||
var s = new LegacyUiSettings();
|
||||
var m = new MetaManager(s, FakeHost.Create(), new PlayerVitalsCache());
|
||||
m.SetRaCommandHandler(_ => { });
|
||||
return (s, m);
|
||||
}
|
||||
|
||||
private static void VtSetSettingDistances()
|
||||
{
|
||||
var (s, m) = Meta();
|
||||
m.Expressions.Evaluate("vtsetsetting[AttackDistance,`0.025`]");
|
||||
Check.Eq(s.MonsterRange, 6, "vtsetsetting AttackDistance 0.025 = 6 yd (was left at 50)");
|
||||
m.Expressions.Evaluate("vtsetsetting[ApproachDistance,`0.0208333`]");
|
||||
Check.Eq(s.ApproachRange, 5, "ApproachDistance 0.0208333 = 5 yd");
|
||||
Check.Eq(m.Expressions.Evaluate("vtgetsetting[AttackDistance]"), "0.025", "vtgetsetting reads it back in VTank units");
|
||||
m.TryHandleVtCommand("/vt opt set AttackDistance 0.2166");
|
||||
Check.Eq(s.MonsterRange, 52, "/vt opt set the same way");
|
||||
m.Expressions.Evaluate("vtsetsetting[IdlePeaceMode,`1`]");
|
||||
Check.True(s.PeaceModeWhenIdle, "a bool through vtsetsetting");
|
||||
m.Expressions.Evaluate("rasetsetting[MonsterRange,`7`]");
|
||||
Check.Eq(s.MonsterRange, 7, "rasetsetting keeps RynthAi's own names and units");
|
||||
}
|
||||
|
||||
private static void MappedOptions()
|
||||
{
|
||||
var (s, m) = Meta();
|
||||
m.Expressions.Evaluate("vtsetsetting[PetCustomRange,`0.0625`]");
|
||||
Check.Eq(s.CustomPetRange, 15, "PetCustomRange 0.0625 = 15 yd");
|
||||
m.Expressions.Evaluate("vtsetsetting[BlacklistMonsterTimeoutSeconds,`45`]");
|
||||
Check.Eq(s.BlacklistTimeoutSec, 45, "BlacklistMonsterTimeoutSeconds");
|
||||
m.TryHandleVtCommand("/vt opt set rebufftimeremainingseconds 4500");
|
||||
Check.Eq(s.RebuffSecondsRemaining, 4500, "rebufftimeremainingseconds (VTank's spelling)");
|
||||
|
||||
// AutoAttackPower: on = automatic (-1); off = the attack bar's value.
|
||||
m.TryHandleVtCommand("/vt setattackbar .9");
|
||||
m.Expressions.Evaluate("vtsetsetting[AutoAttackPower,`1`]");
|
||||
Check.True(s.MeleeAttackPower == -1 && s.MissileAttackPower == -1, "AutoAttackPower on: automatic");
|
||||
Check.Eq(m.Expressions.Evaluate("vtgetsetting[AutoAttackPower]"), "true", "reads back on");
|
||||
m.TryHandleVtCommand("/vt opt set autoattackpower false");
|
||||
Check.True(s.MeleeAttackPower == 90 && s.MissileAttackPower == 90, "AutoAttackPower off: the bar's 90%");
|
||||
}
|
||||
|
||||
private static void DeleteMonster()
|
||||
{
|
||||
var (_, m) = Meta();
|
||||
Check.True(m.TryHandleVtCommand("/vt deletemonster"), "/vt deletemonster handled (not sent to AC as unknown)");
|
||||
}
|
||||
|
||||
private sealed class World
|
||||
{
|
||||
public readonly RynthAiPlugin P = new();
|
||||
public World(bool closeCalls = true)
|
||||
{
|
||||
FakeHost.Reset();
|
||||
FakeHost.CloseContainerCalls = closeCalls;
|
||||
FakeHost.Create(playerId: 0x50000F31);
|
||||
typeof(RynthPluginBase).GetMethod("Attach", Any)!.Invoke(P, new object[] { FakeHost.LastApi });
|
||||
var dash = (LegacyDashboardRenderer)RuntimeHelpers.GetUninitializedObject(typeof(LegacyDashboardRenderer));
|
||||
typeof(LegacyDashboardRenderer).GetField("_settings", Any)!.SetValue(dash, new LegacyUiSettings());
|
||||
Set("_dashboard", dash);
|
||||
Set("_initialized", true);
|
||||
Set("_loginComplete", true);
|
||||
}
|
||||
public void Set(string f, object? v) => typeof(RynthAiPlugin).GetField(f, Any)!.SetValue(P, v);
|
||||
public bool Ub(string line) => (bool)typeof(RynthAiPlugin).GetMethod("HandleUbCommand", Any)!.Invoke(P, new object[] { line })!;
|
||||
public bool Mt(string line) => (bool)typeof(RynthAiPlugin).GetMethod("HandleMtCommand", Any)!.Invoke(P, new object[] { line })!;
|
||||
}
|
||||
|
||||
private static void UbCloseCorpse()
|
||||
{
|
||||
var w = new World();
|
||||
Check.True(w.Ub("/ub close corpse"), "/ub close corpse handled with nothing open");
|
||||
Check.True(FakeHost.Chat.Any(c => c.Contains("No container is currently open")), "and says so, as ub-IT");
|
||||
FakeHost.GroundContainer = 0x80F00001;
|
||||
w.Ub("/ub close corpse");
|
||||
Check.True(FakeHost.Closes.Contains(0x80F00001), "closes the open container");
|
||||
Check.False(FakeHost.Chat.Any(c => c.Contains("Unrecognized")), "never 'Unrecognized /ub command'");
|
||||
}
|
||||
|
||||
private static void UbExpression()
|
||||
{
|
||||
var w = new World();
|
||||
Check.True(w.Ub("/ub vtsetmetastate[NavigatingToFlowerTwo]"), "/ub <expression> handled");
|
||||
Check.False(w.Ub("/ub notaverb x"), "a plain unknown verb is still unknown");
|
||||
}
|
||||
|
||||
private static void Face()
|
||||
{
|
||||
var w = new World();
|
||||
// No jumper (not logged in fully): one plain turn.
|
||||
Check.True(w.Mt("/mt face 135.5"), "/mt face 135.5 (decimal)");
|
||||
Check.True(Math.Abs(FakeHost.HeadingDeg - 135.5f) < 0.01f, "turned to 135.5");
|
||||
Check.True(w.Ub("/ub face 450"), "/ub face 450");
|
||||
Check.True(Math.Abs(FakeHost.HeadingDeg - 90f) < 0.01f, "450 wraps to 90");
|
||||
|
||||
// A coordinate: from 10N 10E, 20N 10E is due north and 10N 20E due east.
|
||||
FakeHost.SetNavPosition(10, 10);
|
||||
Check.True(w.Mt("/mt face 20N, 10E"), "/mt face <coords>");
|
||||
Check.True(FakeHost.HeadingDeg < 0.5f || FakeHost.HeadingDeg > 359.5f, "north is 0");
|
||||
Check.True(w.Ub("/ub face 10N 20E"), "/ub face <coords> (no comma)");
|
||||
Check.True(Math.Abs(FakeHost.HeadingDeg - 90f) < 0.5f, "east is 90");
|
||||
Check.False(w.Mt("/mt face somewhere"), "not a heading or a coordinate: not handled");
|
||||
|
||||
// With the jumper: nav is held while turning and given back once the heading is reached.
|
||||
var s = new LegacyUiSettings { EnableNavigation = true };
|
||||
var jumper = new Jumper(FakeHost.Create(playerId: 0x50000F31), s, _ => { });
|
||||
w.Set("_jumper", jumper);
|
||||
w.Mt("/mt face 200");
|
||||
Check.False(s.EnableNavigation, "nav held while turning");
|
||||
System.Threading.Thread.Sleep(120);
|
||||
jumper.Tick();
|
||||
Check.True(s.EnableNavigation, "nav back once facing 200");
|
||||
Check.False(jumper.IsBusy, "and the jumper is free");
|
||||
}
|
||||
}
|
||||
|
|
@ -45,6 +45,7 @@ internal static class MetaTests
|
|||
r.Add("meta: expression condition fails closed on errors", ExpressionCondition);
|
||||
r.Add("meta: need-to-buff with no buff manager, unknown condition types", NeedToBuffAndUnknown);
|
||||
r.Add("meta action: chat commands, /ra, /vt and /mt", ChatCommands);
|
||||
r.Add("meta action: the /vt verbs and options the metas use that were missing (2026-10-17)", VtPortedVerbs);
|
||||
r.Add("meta action: SetMetaState, CallMetaState and ReturnFromCall", CallReturn);
|
||||
r.Add("meta action: All runs every child in order", AllAction);
|
||||
r.Add("meta action: embedded nav route", EmbeddedNav);
|
||||
|
|
@ -915,6 +916,90 @@ internal static class MetaTests
|
|||
Check.Eq(reversed.S.ActiveNavIndex, 2, "index mirrored");
|
||||
}
|
||||
|
||||
// /vt verbs and options found in ub-IT and the metas on disk (universalremote.met, SASocietyTasks.met,
|
||||
// FoundryIzexi.met, DerethExploration (1).met) that RynthAi didn't handle.
|
||||
private static void VtPortedVerbs()
|
||||
{
|
||||
FakeHost.Reset();
|
||||
FakeHost.TapJumpCalls = true; // the engine's tap jump, for /vt tapjump
|
||||
var rig = new Rig(FakeHost.Create(), Player);
|
||||
|
||||
// /vt e toggles the macro. Straight to the /vt handler: a meta doesn't run with the macro off.
|
||||
rig.S.IsMacroRunning = false;
|
||||
Check.True(rig.M.TryHandleVtCommand("/vt e") && rig.Ra.Contains("/ra start"), "/vt e with the macro off starts it");
|
||||
rig.S.IsMacroRunning = true;
|
||||
Check.True(rig.M.TryHandleVtCommand("/vt e") && rig.Ra.Contains("/ra stop"), "/vt e with the macro on stops it");
|
||||
|
||||
// /vt jump heading shift holdms -> /ra jump[s] heading hold; /vt tapjump -> the engine's tap jump.
|
||||
RunAction(rig, A.ChatCommand, "/vt jump 90 true 750");
|
||||
Check.True(rig.Ra.Contains("/ra jumps 90 750"), "/vt jump 90 true 750 -> /ra jumps 90 750");
|
||||
RunAction(rig, A.ChatCommand, "/vt jump 180 false 300");
|
||||
Check.True(rig.Ra.Contains("/ra jump 180 300"), "shift false -> /ra jump");
|
||||
int taps = FakeHost.TapJumps;
|
||||
RunAction(rig, A.ChatCommand, "/vt tapjump");
|
||||
Check.Eq(FakeHost.TapJumps, taps + 1, "/vt tapjump");
|
||||
|
||||
// Settings profiles go to /ra settings; other /vt settings verbs are still swallowed.
|
||||
RunAction(rig, A.ChatCommand, "/vt settings savechar Banes");
|
||||
Check.True(rig.Ra.Contains("/ra settings savechar Banes"), "/vt settings savechar");
|
||||
RunAction(rig, A.ChatCommand, "/vt settings loadchar Base Profile");
|
||||
Check.True(rig.Ra.Contains("/ra settings loadchar Base Profile"), "/vt settings loadchar keeps spaces");
|
||||
|
||||
// looting load = loot load; equipitemsfor -> /ra equipfor.
|
||||
RunAction(rig, A.ChatCommand, "/vt looting load NoSuchProfile.utl");
|
||||
Check.True(FakeHost.Chat.Any(c => c.Contains("Loot profile not found: NoSuchProfile.utl")), "/vt looting load is handled as loot load");
|
||||
RunAction(rig, A.ChatCommand, "/vt equipitemsfor Pyre Skeleton");
|
||||
Check.True(rig.Ra.Contains("/ra equipfor Pyre Skeleton"), "/vt equipitemsfor -> /ra equipfor");
|
||||
|
||||
// Distances: VTank landblock units (x240) -> yards; a value over 1 is already yards.
|
||||
RunAction(rig, A.ChatCommand, "/vt opt set attackdistance .01666");
|
||||
Check.Eq(rig.S.MonsterRange, 4, "attackdistance .01666 -> 4 yd (was dropped: an int setter refused the decimal)");
|
||||
RunAction(rig, A.ChatCommand, "/vt opt set attackrange 0.04166");
|
||||
Check.Eq(rig.S.MonsterRange, 10, "attackrange 0.04166 -> 10 yd");
|
||||
RunAction(rig, A.ChatCommand, "/vt opt set approachdistance 0.0175");
|
||||
Check.Eq(rig.S.ApproachRange, 4, "approachdistance 0.0175 -> 4 yd");
|
||||
RunAction(rig, A.ChatCommand, "/vt opt set dooropenrange 0.005");
|
||||
Check.Near(rig.S.OpenDoorRange, 1.2, 1e-3, "dooropenrange 0.005 -> 1.2 yd (was 0.005 yd)");
|
||||
RunAction(rig, A.ChatCommand, "/vt opt set ringdistance 0.025");
|
||||
Check.Eq(rig.S.RingRange, 6, "ringdistance 0.025 -> 6 yd");
|
||||
RunAction(rig, A.ChatCommand, "/vt opt set corpseapproachrange-max 0.05");
|
||||
Check.Near(rig.S.CorpseApproachRangeMax, 12, 1e-3, "corpseapproachrange-max 0.05 -> 12 yd");
|
||||
RunAction(rig, A.ChatCommand, "/vt opt set minimumringtargets 3");
|
||||
Check.Eq(rig.S.MinRingTargets, 3, "minimumringtargets");
|
||||
RunAction(rig, A.ChatCommand, "/vt opt set attackdistance 25");
|
||||
Check.Eq(rig.S.MonsterRange, 25, "a value over 1 is yards already");
|
||||
|
||||
// An option written as a verb (DerethExploration: /vt navclosestoprange 0.005).
|
||||
RunAction(rig, A.ChatCommand, "/vt navclosestoprange 0.005");
|
||||
Check.Near(rig.S.FollowNavMin, 1.2, 1e-3, "/vt navclosestoprange 0.005 -> nav point reach 1.2 yd");
|
||||
RunAction(rig, A.ChatCommand, "/vt opt set navclosetoprange .00625");
|
||||
Check.Near(rig.S.FollowNavMin, 1.5, 1e-3, "the misspelt navclosetoprange too");
|
||||
|
||||
// Options whose value means something else in RynthAi.
|
||||
RunAction(rig, A.ChatCommand, "/vt opt set defaultmeleeattackheight 3");
|
||||
Check.Eq(rig.S.MeleeAttackHeight, 2, "VTank height 3 (high) -> RynthAi 2");
|
||||
RunAction(rig, A.ChatCommand, "/vt opt set defaultmeleeattackheight 2");
|
||||
Check.Eq(rig.S.MeleeAttackHeight, 1, "VTank height 2 (medium) -> RynthAi 1");
|
||||
rig.S.LootOwnership = 0;
|
||||
RunAction(rig, A.ChatCommand, "/vt opt set lootfellowcorpses true");
|
||||
Check.Eq(rig.S.LootOwnership, 1, "lootfellowcorpses -> fellowship kills");
|
||||
RunAction(rig, A.ChatCommand, "/vt opt set lootallcorpses true");
|
||||
Check.Eq(rig.S.LootOwnership, 2, "lootallcorpses -> all corpses");
|
||||
RunAction(rig, A.ChatCommand, "/vt opt set lootallcorpses false");
|
||||
Check.Eq(rig.S.LootOwnership, 0, "lootallcorpses false -> my kills");
|
||||
RunAction(rig, A.ChatCommand, "/vt opt set usearcs 3");
|
||||
Check.True(rig.S.UseArcs, "usearcs 3 -> on");
|
||||
RunAction(rig, A.ChatCommand, "/vt opt set usearcs 0");
|
||||
Check.False(rig.S.UseArcs, "usearcs 0 -> off");
|
||||
RunAction(rig, A.ChatCommand, "/vt opt set minimumhealkitsuccesschance 55");
|
||||
Check.Eq(rig.S.KitMinSuccessPct, 55, "minimumhealkitsuccesschance 55 %");
|
||||
RunAction(rig, A.ChatCommand, "/vt opt set minimumhealkitsuccesschance 0.8");
|
||||
Check.Eq(rig.S.KitMinSuccessPct, 80, "a fraction is scaled to a percent");
|
||||
RunAction(rig, A.ChatCommand, "/vt opt set defaultmeleeattackheight 3");
|
||||
RunAction(rig, A.ChatCommand, "/vt opt get defaultmeleeattackheight");
|
||||
Check.True(FakeHost.Chat.Any(c => c.Contains("defaultmeleeattackheight = 3")), "read back in VTank's own 1-3");
|
||||
}
|
||||
|
||||
private static void CallReturn()
|
||||
{
|
||||
var rig = new Rig(rules: new[]
|
||||
|
|
|
|||
|
|
@ -3,6 +3,7 @@ using System.IO;
|
|||
using System.Linq;
|
||||
using System.Text.Json;
|
||||
using RynthCore.Plugin.RynthAi;
|
||||
using RynthCore.Plugin.RynthAi.Huds;
|
||||
using RynthCore.Plugin.RynthAi.LegacyUi;
|
||||
using RynthCore.Plugin.RynthAi.MiniRemote;
|
||||
using RynthCore.Plugin.Shared;
|
||||
|
|
@ -126,20 +127,22 @@ internal static class MiniRemoteMoveTests
|
|||
Check.True(c.HandleCommand("pets", new[] { "show" }), "pets show");
|
||||
Check.True(FakeHost.Chat.Any(x => x.Contains("tab pets:show")), "same tab");
|
||||
FakeHost.Chat.Clear();
|
||||
// The Pets tab's Breeding sub-tab is RynthILT's (Infinite Leaftide only): without RynthILT there is none.
|
||||
Check.False(c.Pets.BreedingOffered, "no Breeding sub-tab without RynthILT");
|
||||
Check.True(c.HandleCommand("hub", new[] { "open", "breeding" }), "hub open breeding is answered");
|
||||
Check.True(FakeHost.Chat.Any(x => x.Contains(IltClient.NotLoaded)), "it says RynthILT is needed");
|
||||
Check.False(FakeHost.Chat.Any(x => x.Contains("tab pets:")), "and opens nothing");
|
||||
Check.False(SelectBreedingPending(c.Pets), "no Breeding sub-tab request");
|
||||
// RynthOracle's Pet Breeding tab links back here: the Pets tab, on its Breeding sub-tab.
|
||||
Check.False(SelectBreedingPending(c.Pets), "no Breeding sub-tab request yet");
|
||||
Check.True(c.HandleCommand("hub", new[] { "open", "breeding" }), "hub open breeding");
|
||||
Check.True(FakeHost.Chat.Any(x => x.Contains("tab pets:show")), "shows the Pets tab");
|
||||
Check.True(SelectBreedingPending(c.Pets), "and asks for the Breeding sub-tab on the next frame");
|
||||
SelectBreedingPending(c.Pets) = false;
|
||||
FakeHost.Chat.Clear();
|
||||
Check.True(c.HandleCommand("hub", new[] { "tab", "Breed" }), "hub tab breed (the dashboard)");
|
||||
Check.False(FakeHost.Chat.Any(), "tab switches quietly");
|
||||
Check.False(SelectBreedingPending(c.Pets), "still no Breeding sub-tab request without RynthILT");
|
||||
Check.True(c.HandleCommand("hub", new[] { "tab", "Breed" }), "hub tab breed");
|
||||
Check.False(FakeHost.Chat.Any(), "tab selects quietly");
|
||||
Check.True(SelectBreedingPending(c.Pets), "the Breeding sub-tab again");
|
||||
Check.Eq(MovedTabs.OracleBreeding, "/ro breeding", "the Character menu's Pet Breeding opens RynthOracle's tab");
|
||||
Check.Eq(MovedTabs.HomeOf(MovedTabs.OracleBreeding), "RynthOracle's Pet Breeding tab", "and names it");
|
||||
FakeHost.Chat.Clear();
|
||||
Check.True(c.HandleCommand("hub", new[] { "bank" }), "hub bank is handled (answered)");
|
||||
Check.True(FakeHost.Chat.Any(x => x.Contains("RynthILT")), "it says the ILT verbs come with RynthILT");
|
||||
Check.True(FakeHost.Chat.Any(x => x.Contains("/ra hub open pets|crafting [show|hide|toggle] /ra hub open breeding")), "and lists what RynthAi still has");
|
||||
Check.True(FakeHost.Chat.Any(x => x.Contains("/ra hub open pets|breeding|crafting")), "and lists what RynthAi still has");
|
||||
FakeHost.Chat.Clear();
|
||||
// The Quests tab moved to RynthOracle (2026-10-13): its verbs and tab names say so.
|
||||
Check.True(c.HandleCommand("hub", new[] { "open", "quests" }), "hub open quests is answered");
|
||||
|
|
|
|||
182
Tools/RynthCore.RynthAiHostTests/Tests/MissileCraftingTests.cs
Normal file
182
Tools/RynthCore.RynthAiHostTests/Tests/MissileCraftingTests.cs
Normal file
|
|
@ -0,0 +1,182 @@
|
|||
using System;
|
||||
using System.Linq;
|
||||
using System.Reflection;
|
||||
using RynthCore.Plugin.RynthAi;
|
||||
using RynthCore.Plugin.RynthAi.LegacyUi;
|
||||
using RynthCore.Plugin.Shared;
|
||||
using RynthCore.PluginSdk;
|
||||
using RynthCore.RynthAiHostTests.Fakes;
|
||||
using RynthCore.RynthAiTests.Harness;
|
||||
|
||||
namespace RynthCore.RynthAiHostTests.Tests;
|
||||
|
||||
// Silentkelpie, 2026-10-15: with Missile Crafting on, combat swapped Electric Bow + arrows for
|
||||
// Fire Crossbow + quarrels, and crafting kept wielding 'Infinite Deadly Prismatic Arrow' every
|
||||
// 5 s (784 tries in one session). The stowed bow still read wielded (the client keeps a stowed
|
||||
// item's old wielder and slot), the crossbow in hand read slot 0, the server ignored each arrow
|
||||
// wield, and every try stopped the nav route while it waited.
|
||||
internal static class MissileCraftingTests
|
||||
{
|
||||
private const uint Player = 0x50000C01;
|
||||
private const uint Crossbow = 0x80000601, Bow = 0x80000602, Quarrels = 0x80000603, Arrows = 0x80000604;
|
||||
private const int MissileSlot = 0x00400000, AmmoSlot = 0x00800000;
|
||||
|
||||
public static void Register(Runner r)
|
||||
{
|
||||
r.Add("missile crafting: a stowed bow that still reads wielded is not the launcher (no arrows at a crossbow)", StowedBowNotLauncher);
|
||||
r.Add("missile crafting: wielded quarrels are not taken for a bow launcher", AmmoNotLauncher);
|
||||
r.Add("missile crafting: an ammo wield the server ignores backs off after 2 tries", IgnoredWieldBacksOff);
|
||||
r.Add("missile crafting: a bow in hand with its arrows in the pack still gets them wielded", BowInHandArrowsInPack);
|
||||
}
|
||||
|
||||
/// <summary>Kelpie's state at 13:36: crossbow and quarrels in hand (slot 0), bow and arrows in the main pack.</summary>
|
||||
private static void StowedBowNotLauncher()
|
||||
{
|
||||
var cm = Rig(crossbowInHand: true);
|
||||
Idle(cm);
|
||||
Check.Eq(cm.State, MissileCraftingManager.CraftState.Idle, "crossbow with quarrels on: nothing to do");
|
||||
Check.Eq(FakeHost.Uses.Count, 0, "no arrow wield");
|
||||
Check.False(FakeHost.Logs.Any(l => l.Contains("MissileCraft: no")), "no evaluation logged");
|
||||
}
|
||||
|
||||
/// <summary>The quarrels wielded at login (slot set, typed MissileWeapon) and no launcher readable.</summary>
|
||||
private static void AmmoNotLauncher()
|
||||
{
|
||||
var cm = Rig(crossbowInHand: false, arrange: () =>
|
||||
{
|
||||
FakeHost.Containers.Remove(Bow); // no bow anywhere
|
||||
FakeHost.Wielded.Remove(Bow);
|
||||
FakeHost.Containers.Remove(Quarrels); // the quarrels on, the crossbow in the pack
|
||||
FakeHost.Wielded[Quarrels] = AmmoSlot;
|
||||
});
|
||||
Idle(cm);
|
||||
Check.Eq(cm.State, MissileCraftingManager.CraftState.Idle, "no launcher: crafting idles");
|
||||
Check.Eq(FakeHost.Uses.Count, 0, "the quarrels never pass for a bow");
|
||||
}
|
||||
|
||||
/// <summary>Bow in hand, arrows in the pack, and the server never puts them on.</summary>
|
||||
private static void IgnoredWieldBacksOff()
|
||||
{
|
||||
var cm = BowRig();
|
||||
for (int i = 0; i < 4; i++) Cycle(cm);
|
||||
Check.Eq(FakeHost.Uses.Count(u => u == Arrows), 2, "two arrow wields, then no more");
|
||||
Check.Eq(cm.State, MissileCraftingManager.CraftState.Idle, "crafting let go");
|
||||
Check.True(FakeHost.Logs.Any(l => l.Contains("didn't wield") && l.Contains("2 tries")), "the back-off is logged");
|
||||
|
||||
Cycle(cm);
|
||||
Check.Eq(FakeHost.Uses.Count(u => u == Arrows), 2, "inside the back-off: still two");
|
||||
}
|
||||
|
||||
/// <summary>The fix must not stop crafting doing its job: no ammo on, the pack's arrows go on.</summary>
|
||||
private static void BowInHandArrowsInPack()
|
||||
{
|
||||
var cm = BowRig();
|
||||
Cycle(cm);
|
||||
Check.Eq(FakeHost.Uses.LastOrDefault(), Arrows, "UseObject(arrows)");
|
||||
Check.True(FakeHost.Logs.Any(l => l.Contains("MissileCraft: no Arrow") && l.Contains("'Longbow'")), "the launcher it saw is logged");
|
||||
}
|
||||
|
||||
// ── The rig ─────────────────────────────────────────────────────────────
|
||||
|
||||
private static WorldObjectCache? _cache;
|
||||
|
||||
/// <param name="arrange">Changes to the fake world, made before the host and cache read it.</param>
|
||||
private static MissileCraftingManager Rig(bool crossbowInHand, Action? arrange = null)
|
||||
{
|
||||
PaceOff();
|
||||
FakeHost.Reset();
|
||||
FakeHost.WeaponCalls = true; // UseObject, GetCurrentCombatMode
|
||||
FakeHost.SalvageCalls = true; // GetObjectWielderInfo (answers from Wielded)
|
||||
FakeHost.Names[Player] = "Silentkelpie";
|
||||
Item(Crossbow, "Fire Crossbow", MissileSlot);
|
||||
Item(Bow, "Electric Bow", MissileSlot);
|
||||
Item(Quarrels, "Infinite Deadly Prismatic Quarrel", AmmoSlot);
|
||||
Item(Arrows, "Infinite Deadly Prismatic Arrow", AmmoSlot);
|
||||
|
||||
// The pack listing holds only what is in the pack; the stowed bow's description still
|
||||
// names the player and the missile slot.
|
||||
FakeHost.Containers[Bow] = Player;
|
||||
FakeHost.Containers[Arrows] = Player;
|
||||
FakeHost.Wielded[Bow] = MissileSlot;
|
||||
if (crossbowInHand)
|
||||
{
|
||||
FakeHost.Wielded[Crossbow] = 0; // wielded after login: slot reads 0
|
||||
FakeHost.Wielded[Quarrels] = 0;
|
||||
}
|
||||
else
|
||||
{
|
||||
FakeHost.Containers[Crossbow] = Player;
|
||||
FakeHost.Containers[Quarrels] = Player;
|
||||
}
|
||||
arrange?.Invoke();
|
||||
|
||||
var host = FakeHost.Create(Player);
|
||||
_cache = FakeHost.MakeCache(host, Player, new[] { Crossbow, Bow, Quarrels, Arrows });
|
||||
var cm = new MissileCraftingManager(host, new LegacyUiSettings { EnableMissileCrafting = true });
|
||||
cm.SetObjectCache(_cache);
|
||||
return cm;
|
||||
}
|
||||
|
||||
/// <summary>A real bow in hand (slot set) with nothing in the ammo slot and arrows in the pack.</summary>
|
||||
private static MissileCraftingManager BowRig() => Rig(crossbowInHand: false, arrange: () =>
|
||||
{
|
||||
FakeHost.Containers.Remove(Bow);
|
||||
FakeHost.Names[Bow] = "Longbow";
|
||||
});
|
||||
|
||||
private static void Item(uint id, string name, int validSlots)
|
||||
{
|
||||
FakeHost.Names[id] = name;
|
||||
FakeHost.ItemTypes[id] = 0x100; // MissileWeapon, as the server types ammo too
|
||||
FakeHost.Ints[(id, 9)] = validSlots;
|
||||
}
|
||||
|
||||
private static readonly FieldInfo LastAmmoCheck =
|
||||
typeof(MissileCraftingManager).GetField("_lastAmmoCheck", BindingFlags.Instance | BindingFlags.NonPublic)!;
|
||||
private static readonly FieldInfo PhaseStart =
|
||||
typeof(MissileCraftingManager).GetField("_phaseStart", BindingFlags.Instance | BindingFlags.NonPublic)!;
|
||||
|
||||
/// <summary>One idle tick with the 5 s ammo-check interval already passed.</summary>
|
||||
private static void Idle(MissileCraftingManager cm)
|
||||
{
|
||||
LastAmmoCheck.SetValue(cm, DateTime.MinValue);
|
||||
ForceRescan();
|
||||
cm.ProcessCrafting();
|
||||
}
|
||||
|
||||
/// <summary>One ammo check through to its wield (or its back-off), the clocks moved past each wait.</summary>
|
||||
private static void Cycle(MissileCraftingManager cm)
|
||||
{
|
||||
for (int i = 0; i < 4 && (i == 0 || cm.State != MissileCraftingManager.CraftState.Idle); i++)
|
||||
{
|
||||
if (cm.State == MissileCraftingManager.CraftState.Idle)
|
||||
{
|
||||
// The back-off moves _lastAmmoCheck into the future; only an expired check is reset.
|
||||
if ((DateTime)LastAmmoCheck.GetValue(cm)! <= DateTime.Now)
|
||||
LastAmmoCheck.SetValue(cm, DateTime.MinValue);
|
||||
}
|
||||
else
|
||||
{
|
||||
PhaseStart.SetValue(cm, DateTime.Now.AddSeconds(-1)); // past EQUIP_DELAY_MS
|
||||
}
|
||||
ForceRescan();
|
||||
cm.ProcessCrafting();
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>GetDirectInventory re-serves a scan under 1 s old; the test can't wait on the wall clock.</summary>
|
||||
private static void ForceRescan() =>
|
||||
typeof(WorldObjectCache).GetField("_lastDirectInventoryScan", BindingFlags.Instance | BindingFlags.NonPublic)!
|
||||
.SetValue(_cache, DateTime.MinValue);
|
||||
|
||||
private static void PaceOff()
|
||||
{
|
||||
ActionPacer.Enabled = false;
|
||||
ActionPacer.Reset();
|
||||
ActionPacer.NowMs = () => Environment.TickCount64;
|
||||
UseAudit.Reset("?", null);
|
||||
UseAudit.NowMs = () => Environment.TickCount64;
|
||||
MoveAudit.Reset();
|
||||
MoveAudit.NowMs = () => Environment.TickCount64;
|
||||
}
|
||||
}
|
||||
|
|
@ -45,6 +45,7 @@ internal static class MonsterEditorTests
|
|||
GravityWell = true, Imperil = true, Yield = true, Vuln = true, UseArc = true, UseRing = true,
|
||||
UseStreak = true, UseBolt = false, UseBlast = true, UseWall = true, ExVuln = "Fire", OffhandId = 2,
|
||||
PetDamage = "Cold", CustomDebuffs = "Corrosion Vulnerability Other, Fire Vulnerability Other VII",
|
||||
Kite = "PullAway",
|
||||
},
|
||||
new PluginRule { Name = "", Category = "Expression only", MatchExpression = "wobjectfindnearestbytemplatetype[1]" },
|
||||
};
|
||||
|
|
|
|||
56
Tools/RynthCore.RynthAiHostTests/Tests/PetDamageTintTests.cs
Normal file
56
Tools/RynthCore.RynthAiHostTests/Tests/PetDamageTintTests.cs
Normal file
|
|
@ -0,0 +1,56 @@
|
|||
using RynthCore.Plugin.RynthAi.MiniRemote;
|
||||
using RynthCore.RynthAiTests.Harness;
|
||||
|
||||
namespace RynthCore.RynthAiHostTests.Tests;
|
||||
|
||||
// Pets roster tint (2026-10-12): every essence showed white because ILT essences mostly carry
|
||||
// neither the captured damage type (9054) nor DamageType (45). As UB-ILT (PetDamageTypeTintPolicy,
|
||||
// v2.0.1119), the essence name gives the school then, and an elemental name beats a physical-only
|
||||
// 9054 (ILT reuses that id for the min-summon aug, where 1/2/4 read as Slash/Pierce/Bludgeon).
|
||||
internal static class PetDamageTintTests
|
||||
{
|
||||
public static void Register(Runner r)
|
||||
{
|
||||
r.Add("pet tint: the school comes from the properties, else the essence name (UB-ILT v2.0.1119)", PickSchool);
|
||||
r.Add("pet tint: the palette is UB-ILT's Leaftide damage-type colours", Palette);
|
||||
}
|
||||
|
||||
private static void PickSchool()
|
||||
{
|
||||
string N(int captured, int mask, string name) => PetDamageTint.Name(PetDamageTint.PickPetFlag(captured, mask, name));
|
||||
|
||||
Check.Eq(N(0, 0, "Fire Banshee Essence (300)"), "Fire", "no properties: the name says Fire");
|
||||
Check.Eq(N(0, 0, "Acid Phyntos Swarm Essence (250)"), "Acid", "Acid");
|
||||
Check.Eq(N(0, 0, "Blizzard Wisp Essence (250)"), "Cold", "a Blizzard is Cold");
|
||||
Check.Eq(N(0, 0, "Incendiary Knight Essence"), "Fire", "an ILT synonym");
|
||||
Check.Eq(N(0, 0, "Shocked Grievver Essence"), "Lightning", "Lightning synonym");
|
||||
Check.Eq(N(0, 0, "Novice Essence"), "", "'ice' inside a word doesn't count");
|
||||
Check.Eq(N(0, 0, "Tremendous Monouga Essence"), "", "no school in the name: unknown");
|
||||
Check.Eq(N(1024, 0, "Fire Banshee Essence"), "Nether", "an elemental 9054 wins over the name");
|
||||
Check.Eq(N(1, 0, "Fire Banshee Essence"), "Fire", "a physical-only 9054 loses to an elemental name");
|
||||
Check.Eq(N(4, 0, "Monouga Essence"), "Bludgeon", "... but stands when the name says nothing");
|
||||
Check.Eq(N(0, 32, ""), "Acid", "the DamageType mask when 9054 is missing");
|
||||
Check.Eq(N(0, 1024 | 1, ""), "Nether", "a combined mask: elements before physical");
|
||||
Check.Eq(N(0, 3, ""), "Slash/Pierce", "Slash/Pierce is its own school");
|
||||
}
|
||||
|
||||
private static void Palette()
|
||||
{
|
||||
static void Rgb(string school, int r, int g, int b)
|
||||
{
|
||||
var c = PetDamageTint.ForName(school);
|
||||
Check.Near(c.X, r / 255f, 1e-4, school + " red");
|
||||
Check.Near(c.Y, g / 255f, 1e-4, school + " green");
|
||||
Check.Near(c.Z, b / 255f, 1e-4, school + " blue");
|
||||
}
|
||||
Rgb("Slash", 255, 180, 120);
|
||||
Rgb("Pierce", 240, 200, 140);
|
||||
Rgb("Bludgeon", 220, 190, 140);
|
||||
Rgb("Cold", 160, 210, 255);
|
||||
Rgb("Fire", 255, 130, 70);
|
||||
Rgb("Acid", 160, 255, 140);
|
||||
Rgb("Lightning", 255, 240, 120);
|
||||
Rgb("Nether", 200, 160, 255);
|
||||
Check.Eq(PetDamageTint.ForName(""), PetDamageTint.Unknown, "unknown: white");
|
||||
}
|
||||
}
|
||||
186
Tools/RynthCore.RynthAiHostTests/Tests/RingEscapeTests.cs
Normal file
186
Tools/RynthCore.RynthAiHostTests/Tests/RingEscapeTests.cs
Normal file
|
|
@ -0,0 +1,186 @@
|
|||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using RynthCore.Plugin.RynthAi;
|
||||
using RynthCore.Plugin.RynthAi.LegacyUi;
|
||||
using RynthCore.RynthAiHostTests.Fakes;
|
||||
using RynthCore.RynthAiTests.Harness;
|
||||
|
||||
namespace RynthCore.RynthAiHostTests.Tests;
|
||||
|
||||
// Empyrean Handler lethal-ring escape (2026-10-17). Silentkelpie heard the Handler's channel at
|
||||
// 1.7 m, did the old single back-jump (backwards, after a 150 ms turn settle that hadn't taken),
|
||||
// was still 1.5 m from it 1.6 s later and died 3.2 s after the line. The escape now faces
|
||||
// directly away and runs, re-aiming away from the Handler, until outside the ring plus a margin,
|
||||
// then holds attacks until the ring has gone off (running again if the Handler closes back in).
|
||||
internal static class RingEscapeTests
|
||||
{
|
||||
private const uint Player = 0x50000E21;
|
||||
private const uint Handler = 0x80000E31;
|
||||
private const uint Lb = 0xA9B40000;
|
||||
private const string Channel = "The handler briefly channels infused Empyrean hatred to release a lethal ring.";
|
||||
private const int Emote = 0x0C;
|
||||
|
||||
public static void Register(Runner r)
|
||||
{
|
||||
r.Add("handler ring: the channel inside the ring runs away (faces away, autorun on), no back-jump", RunsAway);
|
||||
r.Add("handler ring: outside the ring + margin the run stops, attacks stay held until the ring has gone off", StopsWhenClear);
|
||||
r.Add("handler ring: the Handler closing back in before the ring goes off starts the run again", RunsAgain);
|
||||
r.Add("handler ring: outside the ring at the channel nothing happens", OutsideStaysPut);
|
||||
r.Add("handler ring: death / macro stop ends the run (autorun off, never carried through the portal)", StopEndsRun);
|
||||
r.Add("handler ring: a player quoting the line in chat doesn't trigger it", PlayerQuoteIgnored);
|
||||
r.Add("chaser ring: an Empyrean Chaser's lethal ring runs away from the Chaser too", ChaserRunsAway);
|
||||
r.Add("chaser ring: 'The chaser ...' flees the Chaser even with a Handler nearer", ChaserNamedWins);
|
||||
r.Add("ring: a line naming no caster flees the nearest Handler or Chaser; the line is logged once", NearestCasterWithoutSubject);
|
||||
}
|
||||
|
||||
private const uint Chaser = 0x80000E32;
|
||||
|
||||
private static CombatManager Rig(float handlerNorthMeters, out LegacyUiSettings s, float? chaserSouthMeters = null)
|
||||
{
|
||||
FakeHost.Reset();
|
||||
Place(Player, "Silentkelpie", 96, 96, creature: false);
|
||||
FakeHost.PlayerPose = (Lb | 0x1C, 96f, 96f, 0f);
|
||||
Place(Handler, "Empyrean Handler", 96, 96 + handlerNorthMeters);
|
||||
var ids = new List<uint> { Handler };
|
||||
if (chaserSouthMeters is float cs)
|
||||
{
|
||||
Place(Chaser, "Empyrean Chaser", 96, 96 - cs);
|
||||
ids.Add(Chaser);
|
||||
}
|
||||
s = new LegacyUiSettings { MonsterRange = 60, EnableCombat = true, IsMacroRunning = true };
|
||||
// The escape measures from the player: the fake answers GetPlayerId only when created with it.
|
||||
var host = FakeHost.Create(Player);
|
||||
var cache = FakeHost.MakeCache(host, Player, ids.ToArray());
|
||||
var c = new CombatManager(host, s, cache);
|
||||
c.SetPlayerId(Player);
|
||||
c.SetDamageStores(null, new RynthCore.Plugin.RynthAi.CreatureData.MonsterDamageStore());
|
||||
c.ScanNearbyTargets();
|
||||
c.HandleCombatTrigger();
|
||||
return c;
|
||||
}
|
||||
|
||||
private static void RunsAway()
|
||||
{
|
||||
var c = Rig(1.7f, out _);
|
||||
bool jumped = false;
|
||||
c.RequestBackJump = (_, _) => { jumped = true; return true; };
|
||||
c.HandleChatForRingEvade(Channel, Emote);
|
||||
|
||||
Check.True(FakeHost.AutoRun, "autorun is on");
|
||||
Check.False(jumped, "the old back-jump isn't used when autorun and turning are there");
|
||||
// The Handler is due north (0°): away is south (180°).
|
||||
Check.True(Math.Abs(FakeHost.HeadingDeg - 180.0) < 1.0, $"faces directly away from the Handler (180°, got {FakeHost.HeadingDeg:0})");
|
||||
Check.True(c.RingEvadeActive, "the evade holds combat");
|
||||
Check.True(FakeHost.Logs.Any(l => l.Contains("[CombatEvade]") && l.Contains("running away")), "logged as a run");
|
||||
|
||||
Check.True(c.Think(), "Think is held while running");
|
||||
Check.Eq(c.LastCombatSkipReason, "handler-ring-run", "skip reason: the run");
|
||||
Check.True(FakeHost.AutoRun, "still running inside the ring");
|
||||
}
|
||||
|
||||
private static void StopsWhenClear()
|
||||
{
|
||||
var c = Rig(1.7f, out _);
|
||||
c.HandleChatForRingEvade(Channel, Emote);
|
||||
MovePlayer(96, 96 - 16); // 17.7 m from the Handler: past the 12 m ring + 4 m margin
|
||||
Check.True(c.Think(), "Think still held right after reaching safety (the ring hasn't gone off)");
|
||||
Check.False(FakeHost.AutoRun, "the run stops outside the ring");
|
||||
Check.Eq(c.LastCombatSkipReason, "handler-ring-wait", "now waiting for the ring");
|
||||
Check.True(FakeHost.Logs.Any(l => l.Contains("Ring run stopped") && l.Contains("outside the ring")), "logged why it stopped");
|
||||
Check.True(c.RingEvadeActive, "still holding attacks");
|
||||
}
|
||||
|
||||
private static void RunsAgain()
|
||||
{
|
||||
var c = Rig(1.7f, out _);
|
||||
c.HandleChatForRingEvade(Channel, Emote);
|
||||
MovePlayer(96, 96 - 16);
|
||||
c.Think();
|
||||
Check.False(FakeHost.AutoRun, "stopped at a safe distance");
|
||||
// The Handler follows back inside the ring before it has gone off.
|
||||
FakeHost.Positions[Handler] = (Lb | 0x1C, 96f, 96f - 14f, 0f);
|
||||
Check.True(c.Think(), "held");
|
||||
Check.True(FakeHost.AutoRun, "running again");
|
||||
Check.Eq(c.LastCombatSkipReason, "handler-ring-run", "back to the run");
|
||||
Check.True(FakeHost.Logs.Any(l => l.Contains("back inside the ring")), "logged");
|
||||
}
|
||||
|
||||
private static void OutsideStaysPut()
|
||||
{
|
||||
var c = Rig(20f, out _);
|
||||
c.HandleChatForRingEvade(Channel, Emote);
|
||||
Check.False(FakeHost.AutoRun, "no run at 20 m");
|
||||
Check.False(c.RingEvadeActive, "combat isn't held");
|
||||
Check.True(FakeHost.Logs.Any(l => l.Contains("staying put")), "logged as outside");
|
||||
}
|
||||
|
||||
private static void StopEndsRun()
|
||||
{
|
||||
var c = Rig(1.7f, out _);
|
||||
c.HandleChatForRingEvade(Channel, Emote);
|
||||
Check.True(FakeHost.AutoRun, "running");
|
||||
c.StopRingEscape("died");
|
||||
Check.False(FakeHost.AutoRun, "autorun off");
|
||||
Check.False(c.RingEvadeActive, "evade cleared");
|
||||
Check.True(FakeHost.Logs.Any(l => l.Contains("Ring escape stopped: died")), "logged");
|
||||
c.StopRingEscape("again");
|
||||
Check.Eq(FakeHost.Logs.Count(l => l.Contains("Ring escape stopped")), 1, "a second stop is a no-op");
|
||||
}
|
||||
|
||||
private static void PlayerQuoteIgnored()
|
||||
{
|
||||
var c = Rig(1.7f, out _);
|
||||
c.HandleChatForRingEvade("Bob says, \"The handler briefly channels infused Empyrean hatred to release a lethal ring.\"", 0x02);
|
||||
Check.False(FakeHost.AutoRun, "a player's quote doesn't start the run");
|
||||
Check.False(c.RingEvadeActive, "combat isn't held");
|
||||
}
|
||||
|
||||
private const string ChaserChannel = "The chaser briefly channels infused Empyrean hatred to release a lethal ring.";
|
||||
|
||||
private static void ChaserRunsAway()
|
||||
{
|
||||
// Handler far away (40 m north), a Chaser 2 m south: the Chaser's ring is the danger.
|
||||
var c = Rig(40f, out _, chaserSouthMeters: 2f);
|
||||
c.HandleChatForRingEvade(ChaserChannel, Emote);
|
||||
Check.True(FakeHost.AutoRun, "running from the Chaser");
|
||||
// The Chaser is due south (180°): away is north (0°).
|
||||
Check.True(Math.Abs(((FakeHost.HeadingDeg % 360) + 360) % 360) < 1.0 || Math.Abs(FakeHost.HeadingDeg - 360) < 1.0,
|
||||
$"faces away from the Chaser (0°, got {FakeHost.HeadingDeg:0})");
|
||||
Check.True(FakeHost.Logs.Any(l => l.Contains("running away from 'Empyrean Chaser'")), "logged against the Chaser");
|
||||
}
|
||||
|
||||
private static void ChaserNamedWins()
|
||||
{
|
||||
// Handler 1.5 m north, Chaser 3 m south; the emote names the Chaser.
|
||||
var c = Rig(1.5f, out _, chaserSouthMeters: 3f);
|
||||
c.HandleChatForRingEvade(ChaserChannel, Emote);
|
||||
Check.True(FakeHost.Logs.Any(l => l.Contains("running away from 'Empyrean Chaser'")), "the named caster is the one fled");
|
||||
Check.True(Math.Abs(FakeHost.HeadingDeg) < 1.0 || Math.Abs(FakeHost.HeadingDeg - 360) < 1.0, $"away from the Chaser (0°, got {FakeHost.HeadingDeg:0})");
|
||||
}
|
||||
|
||||
private static void NearestCasterWithoutSubject()
|
||||
{
|
||||
// A line without "The handler/chaser" (a client that strips it): the nearest caster, the Chaser at 2 m.
|
||||
var c = Rig(9f, out _, chaserSouthMeters: 2f);
|
||||
c.HandleChatForRingEvade("briefly channels infused Empyrean hatred to release a lethal ring.", Emote);
|
||||
Check.True(FakeHost.Logs.Any(l => l.Contains("running away from 'Empyrean Chaser'")), "the nearest caster (the Chaser)");
|
||||
Check.Eq(FakeHost.Logs.Count(l => l.Contains("lethal-ring line heard")), 1, "the line that triggered is logged");
|
||||
c.StopRingEscape("test");
|
||||
c.HandleChatForRingEvade("briefly channels infused Empyrean hatred to release a lethal ring.", Emote);
|
||||
Check.Eq(FakeHost.Logs.Count(l => l.Contains("lethal-ring line heard")), 1, "logged once per session");
|
||||
}
|
||||
|
||||
private static void MovePlayer(float x, float y)
|
||||
{
|
||||
FakeHost.Positions[Player] = (Lb | 0x1C, x, y, 0f);
|
||||
FakeHost.PlayerPose = (Lb | 0x1C, x, y, 0f);
|
||||
}
|
||||
|
||||
private static void Place(uint id, string name, float x, float y, bool creature = true)
|
||||
{
|
||||
FakeHost.Names[id] = name;
|
||||
FakeHost.Positions[id] = (Lb | 0x1C, x, y, 0f);
|
||||
if (creature) FakeHost.ItemTypes[id] = 0x10;
|
||||
}
|
||||
}
|
||||
|
|
@ -10,8 +10,7 @@ namespace RynthCore.RynthAiHostTests.Tests;
|
|||
// Mini Remote sections (RynthCore 2026.10.5.46+): RynthCore sends its server verdicts (V lines) and
|
||||
// section rail (X lines) in the "servermenu" payload, and reads RynthAi's views from
|
||||
// RynthPluginGetSectionsJson. RynthAi lists its own views (Pets, Crafting, Spells, Fellowship) and
|
||||
// hosts RynthILT's ILT tabs (RynthILT.Hub: Gear, Charms, Banking, Games); Quests are RynthOracle's,
|
||||
// and RynthILT's Character tab moved out (RynthOracle's Character tab, Session Stats). The manifest is checked
|
||||
// hosts RynthILT's ILT tabs (RynthILT.Hub); Quests are RynthOracle's. The manifest is checked
|
||||
// against the engine's own parser and catalog (UI/Sections, linked), so the two sides can't drift.
|
||||
internal static class SectionsTests
|
||||
{
|
||||
|
|
@ -22,20 +21,20 @@ internal static class SectionsTests
|
|||
r.Add("sections: RynthAi's manifest passes the engine parser unchanged", ManifestRoundTrip);
|
||||
r.Add("sections: the engine catalog places RynthAi's views by server", CatalogPlacement);
|
||||
r.Add("sections: tab surfaces map back to their tabs; foreign ids are refused", SurfaceRoundTrip);
|
||||
r.Add("sections: Character and Banking redirect; other ILT tabs stay on the Mini Remote", MovedTabRedirects);
|
||||
r.Add("sections: Character / Charms / Banking redirect to RynthOracle and Global Inventory", MovedTabRedirects);
|
||||
}
|
||||
|
||||
private static void MovedTabRedirects()
|
||||
{
|
||||
foreach (string tab in new[] { "character", "Char", " rates " })
|
||||
foreach (string tab in new[] { "character", "Char", " rates ", "charms", "CHARM" })
|
||||
Check.Eq(MovedTabs.CommandFor(tab), MovedTabs.OracleCharacter, tab + " -> RynthOracle's Character tab");
|
||||
foreach (string tab in new[] { "banking", "bank" })
|
||||
Check.Eq(MovedTabs.CommandFor(tab), MovedTabs.GlobalBank, tab + " -> Global Inventory");
|
||||
foreach (string tab in new[] { "charms", "gear", "games", "pets", "crafting", "", null })
|
||||
foreach (string tab in new[] { "banking", "Bank" })
|
||||
Check.Eq(MovedTabs.CommandFor(tab), MovedTabs.GlobalBank, tab + " -> Global Inventory > Banking");
|
||||
foreach (string tab in new[] { "gear", "games", "pets", "crafting", "", null })
|
||||
Check.True(MovedTabs.CommandFor(tab) == null, (tab ?? "null") + " is still a Mini Remote tab (or none)");
|
||||
Check.Eq(MovedTabs.OracleCharacter, "/ro character", "the Oracle command");
|
||||
Check.Eq(MovedTabs.GlobalBank, "/ginv bank", "the Global Inventory banking alias");
|
||||
Check.Eq(MovedTabs.GlobalInventory, "/ginv", "the Global Inventory command");
|
||||
Check.Eq(MovedTabs.GlobalBank, "/ginv bank", "the Global Inventory command");
|
||||
Check.Eq(MovedTabs.GlobalInventory, "/ginv", "the Global Inventory window command");
|
||||
Check.Eq(MovedTabs.Diagnostics, "/rc diagnostics", "the engine's Diagnostics command");
|
||||
}
|
||||
|
||||
|
|
@ -49,8 +48,8 @@ internal static class SectionsTests
|
|||
|
||||
/// <summary>
|
||||
/// RynthILT's tabs as its GetTabs would give them (Gear not reported yet, Games hidden), plus the
|
||||
/// Character tab an older RynthILT still reports: it moved out of the Mini Remote (2026-10-13)
|
||||
/// and must not be placed any more.
|
||||
/// Character / Charms / Banking tabs an older RynthILT still reports: those moved out of the Mini
|
||||
/// Remote (2026-10-13) and must not be placed any more.
|
||||
/// </summary>
|
||||
private static readonly IltTabInfo[] IltTabs =
|
||||
{
|
||||
|
|
@ -128,12 +127,8 @@ internal static class SectionsTests
|
|||
SectionContribution gear = m.Contributions.Single(c => c.Surface == SectionsManifest.SurfaceOf("gear"));
|
||||
Check.False(gear.Enabled, "unavailable Gear is disabled");
|
||||
Check.True(gear.Note.Length > 0, "with a note");
|
||||
Check.False(views.Any(v => v.Surface == SectionsManifest.SurfaceOf("character")), "character moved out: not placed even if RynthILT reports it");
|
||||
foreach (string kept in new[] { "charms", "banking" })
|
||||
{
|
||||
SectionsManifest.View v = views.Single(x => x.Surface == SectionsManifest.SurfaceOf(kept));
|
||||
Check.True(v.Section == "inventory" && v.Server == SectionsManifest.IltServer && v.Enabled, kept + ": an ILT view in Inventory");
|
||||
}
|
||||
foreach (string moved in new[] { "character", "charms", "banking" })
|
||||
Check.False(views.Any(v => v.Surface == SectionsManifest.SurfaceOf(moved)), moved + " moved out: not placed even if RynthILT reports it");
|
||||
Check.True(json.Length < SectionManifestParser.MaxJsonLength / 16, "small");
|
||||
|
||||
SectionsManifest.View session = views.Single(v => v.Surface == SectionsManifest.SessionSurface);
|
||||
|
|
@ -168,26 +163,24 @@ internal static class SectionsTests
|
|||
List<SectionView> on = SectionCatalog.Build(new[] { m }, _ => false, new[] { iltOn });
|
||||
SectionView charOn = on.Single(v => v.Id == "char");
|
||||
Check.True(charOn.Panes.Length == 1 && charOn.Panes[0].Contribution?.Surface == SectionsManifest.SessionSurface,
|
||||
"Session Stats on ILT: session stats only (no ILT Character tab)");
|
||||
"Session Stats on ILT: session stats only (no ILT Character / Charms)");
|
||||
SectionView inventoryOn = on.Single(v => v.Id == "inventory");
|
||||
Check.True(inventoryOn.Panes.Any(p => p.Title == "Gear") && inventoryOn.Panes.Any(p => p.Title == "Charms")
|
||||
&& inventoryOn.Panes.Any(p => p.Title == "Banking"),
|
||||
"Inventory on ILT: RynthILT's Gear, Charms and Banking");
|
||||
SectionView inventoryOff = off.Single(v => v.Id == "inventory");
|
||||
Check.False(inventoryOff.Panes.Any(p => p.Title is "Gear" or "Charms" or "Banking"), "Inventory off ILT: none of RynthILT's tabs");
|
||||
Check.True(inventoryOn.Panes.Any(p => p.Title == "Gear") && !inventoryOn.Panes.Any(p => p.Title == "Banking"),
|
||||
"Inventory: Gear on ILT; Banking is Global Inventory's");
|
||||
Check.True(on.Single(v => v.Id == "spells").Panes.Any(p => p.Contribution?.Surface == SectionsManifest.SpellsSurface), "Spells");
|
||||
Check.True(on.Single(v => v.Id == "fellowship").Panes.Any(p => p.Contribution?.Surface == SectionsManifest.FellowshipSurface), "Fellowship");
|
||||
}
|
||||
|
||||
private static void SurfaceRoundTrip()
|
||||
{
|
||||
foreach (string id in new[] { "gear", "games", "charms", "banking" })
|
||||
foreach (string id in new[] { "gear", "games" })
|
||||
{
|
||||
string surface = SectionsManifest.SurfaceOf(id);
|
||||
Check.True(SectionsManifest.TryIltTabOf(surface, out string back) && back == id, "round trip " + surface);
|
||||
Check.Eq(SectionManifestParser.Surface(surface), surface, "the engine accepts " + surface);
|
||||
}
|
||||
Check.False(SectionsManifest.TryIltTabOf(SectionsManifest.SurfaceOf("character"), out _), "character isn't a section tab any more");
|
||||
foreach (string moved in new[] { "character", "charms", "banking" })
|
||||
Check.False(SectionsManifest.TryIltTabOf(SectionsManifest.SurfaceOf(moved), out _), moved + " isn't a section tab any more");
|
||||
Check.Eq(SectionManifestParser.Surface(SectionsManifest.SessionSurface), SectionsManifest.SessionSurface, "the engine accepts the session surface");
|
||||
Check.True(SectionsManifest.TryOwnTabOf(SectionsManifest.PetsSurface, out string pets) && pets == MiniRemoteTabs.Pets, "pets is RynthAi's");
|
||||
Check.True(SectionsManifest.TryOwnTabOf(SectionsManifest.CraftingSurface, out string craft) && craft == MiniRemoteTabs.Crafting, "crafting is RynthAi's");
|
||||
|
|
|
|||
|
|
@ -4,18 +4,15 @@ using System.Linq;
|
|||
using RynthCore.Loot;
|
||||
using RynthCore.Plugin.RynthAi.MiniRemote;
|
||||
using RynthCore.Plugin.RynthAi.MiniRemote.Crafting;
|
||||
using RynthCore.Plugin.Shared;
|
||||
using RynthCore.RynthAiTests.Harness;
|
||||
|
||||
namespace RynthCore.RynthAiHostTests.Tests;
|
||||
|
||||
// The Crafting tab's tinkering (SilentKelpie's, 2026-10-12): ACE's retail chance
|
||||
// (RecipeManager.GetTinkerChance), the planner's caps and order (imbue once, rend last), bag
|
||||
// matching / choice, and the universal Crafting tab id. Server rows come from the server plugin's
|
||||
// profile ("salvage", ServerSalvageView) and carry their own rules, checked here on rows shaped
|
||||
// like Infinite Leaftide's (RynthILT serves those; RynthILT.Tests checks its data): no tink slot,
|
||||
// applied ints, stack groups (Steel + Serpentine 10), after-cap rows (Leather), an own order, and
|
||||
// prepared rows (tier bags, Ammunition).
|
||||
// The Crafting tab's tinkering (2026-10-12): ACE's retail chance (RecipeManager.GetTinkerChance),
|
||||
// the planner's caps and order (imbue once, ILT no-slot salvage, Steel + Serpentine 10, Leather
|
||||
// after the cap, rend last), bag matching / choice, and the universal Crafting tab id.
|
||||
// Phase 2: ILT trinkets (flags 384-387, tier-prepared bags, Ammunition) and the Rings
|
||||
// inscription chain (UB-IT's ingredient names, queue order and scroll pairing).
|
||||
internal static class TinkerTests
|
||||
{
|
||||
public static void Register(Runner r)
|
||||
|
|
@ -23,15 +20,18 @@ internal static class TinkerTests
|
|||
r.Add("tinker: retail difficulty and chance (ACE GetTinkerChance)", Chance);
|
||||
r.Add("tinker: slot cap, one imbue, attempts this run", SlotsAndImbue);
|
||||
r.Add("tinker: damage-type rend and rend last", Rend);
|
||||
r.Add("tinker: server weapon rows (no slot, an after-cap row last only when the slots are full)", AfterCap);
|
||||
r.Add("tinker: server jewelry rows (applied ints skip, a stack group shares one cap)", StackAndApplied);
|
||||
r.Add("tinker: ILT weapon rows (no slot, Leather after the cap)", IltWeapon);
|
||||
r.Add("tinker: ILT jewelry flags and Steel + Serpentine cap", IltJewelry);
|
||||
r.Add("tinker: item rows (Moonstone, Leather, Sandstone)", ItemRows);
|
||||
r.Add("tinker: scan filters", Filters);
|
||||
r.Add("tinker: bag matching (full, Abyssal, Foolproof)", Bags);
|
||||
r.Add("tinker: bag choice by chance and minimum", BagChoice);
|
||||
r.Add("tinker: Crafting is a universal Mini Remote tab", Section);
|
||||
r.Add("tinker: prepared server rows (applied ints, order, tier bags, Ammunition)", Trinkets);
|
||||
r.Add("tinker: a server plugin's salvage (per tab, own keys, own order, no rules unless asked)", PluginSalvage);
|
||||
r.Add("tinker: ILT trinkets (flags, order, tier bags, Ammunition)", Trinkets);
|
||||
r.Add("tinker: a server plugin's salvage (per tab, own keys, no Leaftide rules)", PluginSalvage);
|
||||
r.Add("rings: ingredient names, alternates and excludes", RingIngredients);
|
||||
r.Add("rings: craft queue runs Step 1, then 2, then 3", RingQueue);
|
||||
r.Add("rings: scroll glyph and UB-IT pairing", RingScrolls);
|
||||
}
|
||||
|
||||
private static TinkerBenchSettings Settings(params (string Key, int Count)[] counts)
|
||||
|
|
@ -48,41 +48,6 @@ internal static class TinkerTests
|
|||
|
||||
private static List<int> Mats(List<TinkerStep> plan) => plan.Select(p => p.Material).ToList();
|
||||
|
||||
private static ServerSalvageView Row(string bench, int material, string kind, bool slot = false, string nameMatch = "",
|
||||
int applied = 0, bool prepared = false, int order = 0, bool afterCap = false,
|
||||
string group = "", int cap = 0)
|
||||
=> new(bench, material, kind, "server row", slot, nameMatch, applied, prepared, order, afterCap, group, cap);
|
||||
|
||||
/// <summary>The tab's rows with these server rows (as the Crafting tab builds them).</summary>
|
||||
private static List<TinkerMaterial> WithServer(TinkerBench bench, params ServerSalvageView[] server)
|
||||
=> TinkerPlanner.Rows(bench, TinkerCatalog.FromServerPlugin(bench, server), null);
|
||||
|
||||
// ILT-shaped rows (RynthILT's Hub/IltSalvage.cs has the real ones).
|
||||
private const int JewelSilverInt = 374, TrinketDiamondInt = 384, TrinketGromnieInt = 386;
|
||||
|
||||
private static readonly ServerSalvageView[] Weapon =
|
||||
{
|
||||
Row("melee", TinkerCatalog.YellowGarnet, "once", order: 70),
|
||||
Row("melee", TinkerCatalog.BlackGarnet, "once", slot: true, nameMatch: "Abyssal", order: 100),
|
||||
Row("melee", TinkerCatalog.Leather, "once", order: 995, afterCap: true),
|
||||
};
|
||||
|
||||
private static readonly ServerSalvageView[] Jewelry =
|
||||
{
|
||||
Row("jewelry", TinkerCatalog.Silver, "once", applied: JewelSilverInt, order: 10),
|
||||
Row("jewelry", TinkerCatalog.Copper, "once", applied: 370, order: 20),
|
||||
Row("jewelry", TinkerCatalog.Serpentine, "tink", order: 50, group: "jewelry-stack", cap: 10),
|
||||
Row("jewelry", TinkerCatalog.Steel, "tink", order: 60, group: "jewelry-stack", cap: 10),
|
||||
};
|
||||
|
||||
private static readonly ServerSalvageView[] TrinketRows =
|
||||
{
|
||||
Row("trinkets", TinkerCatalog.Diamond, "once", applied: TrinketDiamondInt, prepared: true, order: 10),
|
||||
Row("trinkets", TinkerCatalog.Ruby, "once", applied: 385, prepared: true, order: 20),
|
||||
Row("trinkets", TinkerCatalog.GromnieHide, "once", applied: TrinketGromnieInt, prepared: true, order: 30),
|
||||
Row("trinkets", TinkerCatalog.Pyreal, "once", applied: 387, prepared: true, order: 40),
|
||||
};
|
||||
|
||||
/// <summary>A plan's materials as "a,b,c" (Check.Eq compares lists by reference).</summary>
|
||||
private static string Seq(List<TinkerStep> plan) => string.Join(",", Mats(plan));
|
||||
|
||||
|
|
@ -109,7 +74,7 @@ internal static class TinkerTests
|
|||
|
||||
private static void SlotsAndImbue()
|
||||
{
|
||||
var rows = TinkerPlanner.Rows(TinkerBench.Melee, null, null);
|
||||
var rows = TinkerPlanner.Rows(TinkerBench.Melee, false, null);
|
||||
var s = Settings(("r" + TinkerCatalog.Iron, 10), ("r" + TinkerCatalog.BlackOpal, 1), ("r" + TinkerCatalog.FireOpal, 1));
|
||||
var plan = TinkerPlanner.Plan(TinkerBench.Melee, Item(AcObjectClass.MeleeWeapon, tinks: 6), s, rows);
|
||||
Check.Eq(Mats(plan).Count(m => m == TinkerCatalog.BlackOpal), 1, "first imbue in order");
|
||||
|
|
@ -136,7 +101,7 @@ internal static class TinkerTests
|
|||
Check.Eq(TinkerCatalog.RendFor(0x400, false), TinkerCatalog.Onyx, "nether");
|
||||
Check.Eq(TinkerCatalog.RendFor(0, false), 0, "no damage type, no rend");
|
||||
|
||||
var rows = TinkerPlanner.Rows(TinkerBench.Melee, null, null);
|
||||
var rows = TinkerPlanner.Rows(TinkerBench.Melee, false, null);
|
||||
var s = Settings(("r" + TinkerCatalog.RendId, 1), ("r" + TinkerCatalog.Iron, 2));
|
||||
var first = TinkerPlanner.Plan(TinkerBench.Melee, Item(AcObjectClass.MeleeWeapon, damageType: 32), s, rows);
|
||||
Check.Eq(first[0].Material, TinkerCatalog.Emerald, "acid weapon: Emerald first");
|
||||
|
|
@ -147,9 +112,9 @@ internal static class TinkerTests
|
|||
}
|
||||
|
||||
/// <summary>
|
||||
/// Rows from a server plugin's profile (ServerPackInfo.Salvage): only the tab's own, in kind order
|
||||
/// unless a row gives its own, keyed "p" (never sharing a count with retail "r"), and with no rule
|
||||
/// the row doesn't ask for (a Leather without "afterCap" doesn't wait for the 10 ordinary tinks).
|
||||
/// Rows from a server plugin's profile (ServerPackInfo.Salvage): only the tab's own, in kind order,
|
||||
/// keyed "p" (never sharing a count with retail "r" or Leaftide "s"), and free of the Leaftide
|
||||
/// rules (a plugin's Leather on a weapon doesn't wait for the 10 ordinary tinks).
|
||||
/// </summary>
|
||||
private static void PluginSalvage()
|
||||
{
|
||||
|
|
@ -173,83 +138,46 @@ internal static class TinkerTests
|
|||
var plan = TinkerPlanner.Plan(TinkerBench.Melee, Item(AcObjectClass.MeleeWeapon, tinks: 5), s, rows);
|
||||
Check.Eq(Seq(plan), Seq(TinkerCatalog.Emerald, TinkerCatalog.Iron, TinkerCatalog.Iron, TinkerCatalog.Leather),
|
||||
"imbue, tinks, then once; Leather doesn't wait for the cap");
|
||||
Check.True(server.All(r => !r.AfterCap && r.StackGroup.Length == 0 && r.AppliedInt == 0 && !r.Prepared), "no rules unless asked");
|
||||
|
||||
// A row's own order: this once-row runs before the retail imbues (101) and the plugin's tinks.
|
||||
var ordered = TinkerCatalog.FromServerPlugin(TinkerBench.Melee, new[]
|
||||
{
|
||||
Row("melee", TinkerCatalog.Iron, "tink", slot: true),
|
||||
Row("melee", TinkerCatalog.Turquoise, "once", order: 80),
|
||||
});
|
||||
Check.Eq(ordered[1].Order, 80, "the row's order");
|
||||
Check.Eq(ordered[0].Order, 400, "no order: the kind's default");
|
||||
var first = TinkerPlanner.Plan(TinkerBench.Melee, Item(AcObjectClass.MeleeWeapon),
|
||||
Settings(("r" + TinkerCatalog.BlackOpal, 1), ("p" + TinkerCatalog.Iron, 1), ("p" + TinkerCatalog.Turquoise, 1)),
|
||||
TinkerPlanner.Rows(TinkerBench.Melee, ordered, null));
|
||||
Check.Eq(Seq(first), Seq(TinkerCatalog.Turquoise, TinkerCatalog.BlackOpal, TinkerCatalog.Iron), "order 80 goes first");
|
||||
|
||||
// The optional fields map onto the planner's row.
|
||||
var mapped = TinkerCatalog.FromServerPlugin(TinkerBench.Jewelry, Jewelry.Concat(new[]
|
||||
{
|
||||
Row("jewelry", TinkerCatalog.Moonstone, "tink", group: "no-cap"),
|
||||
}));
|
||||
Check.Eq(mapped[0].AppliedInt, JewelSilverInt, "applied int");
|
||||
Check.Eq(mapped[2].StackGroup + "/" + mapped[2].StackCap, "jewelry-stack/10", "stack group and cap");
|
||||
Check.Eq(mapped[4].StackGroup, "", "a group without a cap is no group");
|
||||
Check.True(TinkerCatalog.FromServerPlugin(TinkerBench.Melee, Weapon)[2].AfterCap, "after cap");
|
||||
Check.True(TinkerCatalog.FromServerPlugin(TinkerBench.Trinkets, TrinketRows).All(r => r.Prepared), "prepared");
|
||||
}
|
||||
|
||||
private static void AfterCap()
|
||||
private static void IltWeapon()
|
||||
{
|
||||
var rows = WithServer(TinkerBench.Melee, Weapon);
|
||||
var s = Settings(("p" + TinkerCatalog.YellowGarnet, 1), ("r" + TinkerCatalog.Iron, 10), ("p" + TinkerCatalog.Leather, 1));
|
||||
var rows = TinkerPlanner.Rows(TinkerBench.Melee, true, null);
|
||||
var s = Settings(("s" + TinkerCatalog.YellowGarnet, 1), ("r" + TinkerCatalog.Iron, 10), ("s" + TinkerCatalog.Leather, 1));
|
||||
var full = TinkerPlanner.Plan(TinkerBench.Melee, Item(AcObjectClass.MeleeWeapon, tinks: 10), s, rows);
|
||||
Check.Eq(Seq(full), Seq(TinkerCatalog.YellowGarnet, TinkerCatalog.Leather), "capped item: no-slot rows, then Leather");
|
||||
|
||||
var some = TinkerPlanner.Plan(TinkerBench.Melee, Item(AcObjectClass.MeleeWeapon, tinks: 5), s, rows);
|
||||
Check.Eq(some[^1].Material, TinkerCatalog.Leather, "Irons fill the last 5 slots, then Leather");
|
||||
Check.Eq(Mats(some).Count(m => m == TinkerCatalog.Iron), 5, "five Irons");
|
||||
Check.Eq(Mats(some).Count(m => m == TinkerCatalog.Leather), 1, "Leather once");
|
||||
|
||||
var open = TinkerPlanner.Plan(TinkerBench.Melee, Item(AcObjectClass.MeleeWeapon, tinks: 5),
|
||||
Settings(("p" + TinkerCatalog.Leather, 1), ("r" + TinkerCatalog.Iron, 2)), rows);
|
||||
Settings(("s" + TinkerCatalog.Leather, 1), ("r" + TinkerCatalog.Iron, 2)), rows);
|
||||
Check.True(!Mats(open).Contains(TinkerCatalog.Leather), "Leather waits for the 10 ordinary tinks");
|
||||
|
||||
var retailOnly = TinkerPlanner.Plan(TinkerBench.Melee, Item(AcObjectClass.MeleeWeapon, tinks: 10), s,
|
||||
TinkerPlanner.Rows(TinkerBench.Melee, null, null));
|
||||
Check.Eq(retailOnly.Count, 0, "no server rows: nothing offered past the cap");
|
||||
TinkerPlanner.Rows(TinkerBench.Melee, false, null));
|
||||
Check.Eq(retailOnly.Count, 0, "off ILT: the server rows aren't offered");
|
||||
}
|
||||
|
||||
private static void StackAndApplied()
|
||||
private static void IltJewelry()
|
||||
{
|
||||
var rows = WithServer(TinkerBench.Jewelry, Jewelry);
|
||||
var s = Settings(("p" + TinkerCatalog.Serpentine, 8), ("p" + TinkerCatalog.Steel, 8),
|
||||
("p" + TinkerCatalog.Silver, 1), ("p" + TinkerCatalog.Copper, 1));
|
||||
var rows = TinkerPlanner.Rows(TinkerBench.Jewelry, true, null);
|
||||
var s = Settings(("s" + TinkerCatalog.Serpentine, 8), ("s" + TinkerCatalog.Steel, 8),
|
||||
("s" + TinkerCatalog.Silver, 1), ("s" + TinkerCatalog.Copper, 1));
|
||||
var plan = TinkerPlanner.Plan(TinkerBench.Jewelry, Item(AcObjectClass.Jewelry, tinks: 0,
|
||||
flags: k => k == JewelSilverInt ? 2 : 0), s, rows);
|
||||
flags: k => k == TinkerCatalog.IntJewelSilver ? 2 : 0), s, rows);
|
||||
var m = Mats(plan);
|
||||
Check.Eq(m.Count(x => x == TinkerCatalog.Serpentine), 8, "8 Serpentine");
|
||||
Check.Eq(m.Count(x => x == TinkerCatalog.Steel), 2, "Steel stops at 10 combined");
|
||||
Check.True(!m.Contains(TinkerCatalog.Silver), "Silver's applied int already reads 2");
|
||||
Check.Eq(m[0], TinkerCatalog.Copper, "flag rows first (their order)");
|
||||
|
||||
// Two groups don't share; a row outside any group isn't capped.
|
||||
var split = WithServer(TinkerBench.Jewelry,
|
||||
Row("jewelry", TinkerCatalog.Serpentine, "tink", order: 50, group: "a", cap: 3),
|
||||
Row("jewelry", TinkerCatalog.Steel, "tink", order: 60, group: "b", cap: 4),
|
||||
Row("jewelry", TinkerCatalog.Iron, "tink", order: 70));
|
||||
var p2 = Mats(TinkerPlanner.Plan(TinkerBench.Jewelry, Item(AcObjectClass.Jewelry),
|
||||
Settings(("p" + TinkerCatalog.Serpentine, 9), ("p" + TinkerCatalog.Steel, 9), ("p" + TinkerCatalog.Iron, 9)), split));
|
||||
Check.Eq(p2.Count(x => x == TinkerCatalog.Serpentine), 3, "group a: its cap");
|
||||
Check.Eq(p2.Count(x => x == TinkerCatalog.Steel), 4, "group b: its own cap");
|
||||
Check.Eq(p2.Count(x => x == TinkerCatalog.Iron), 9, "no group, no slot: all 9");
|
||||
Check.True(TinkerCatalog.IsTrinket("Ornate Compass") && !TinkerCatalog.IsTrinket("Yellow Topaz Ring"), "trinkets left to their tab");
|
||||
Check.True(!m.Contains(TinkerCatalog.Silver), "Silver flag already 2");
|
||||
Check.Eq(m[0], TinkerCatalog.Copper, "flag rows first");
|
||||
Check.True(TinkerCatalog.IsTrinket("Ornate Compass") && !TinkerCatalog.IsTrinket("Yellow Topaz Ring"), "trinkets left to their recipes");
|
||||
}
|
||||
|
||||
private static void ItemRows()
|
||||
{
|
||||
var rows = TinkerPlanner.Rows(TinkerBench.Items, null, null);
|
||||
var rows = TinkerPlanner.Rows(TinkerBench.Items, false, null);
|
||||
var s = Settings(("r" + TinkerCatalog.Moonstone, 2), ("r" + TinkerCatalog.Leather, 1), ("r" + TinkerCatalog.Sandstone, 1));
|
||||
var noMana = TinkerPlanner.Plan(TinkerBench.Items, Item(AcObjectClass.Armor), s, rows);
|
||||
Check.Eq(Seq(noMana), Seq(TinkerCatalog.Leather), "no mana: no Moonstone; not retained: Leather, not Sandstone");
|
||||
|
|
@ -279,7 +207,7 @@ internal static class TinkerTests
|
|||
|
||||
private static void Bags()
|
||||
{
|
||||
var melee = WithServer(TinkerBench.Melee, Weapon);
|
||||
var melee = TinkerPlanner.Rows(TinkerBench.Melee, true, null);
|
||||
var rend = new TinkerStep(melee.First(r => r.Id == TinkerCatalog.RendId), TinkerCatalog.BlackGarnet);
|
||||
var abyssal = new TinkerStep(melee.First(r => r.NameMatch == "Abyssal"), TinkerCatalog.BlackGarnet);
|
||||
var iron = new TinkerStep(melee.First(r => r.Id == TinkerCatalog.Iron), TinkerCatalog.Iron);
|
||||
|
|
@ -318,18 +246,18 @@ internal static class TinkerTests
|
|||
|
||||
private static void Trinkets()
|
||||
{
|
||||
Check.Eq(TinkerPlanner.Rows(TinkerBench.Trinkets, null, null).Count, 0, "retail has no trinket rows");
|
||||
var rows = WithServer(TinkerBench.Trinkets, TrinketRows);
|
||||
var s = Settings(("p" + TinkerCatalog.Pyreal, 1), ("p" + TinkerCatalog.Diamond, 1), ("p" + TinkerCatalog.Ruby, 1),
|
||||
("p" + TinkerCatalog.GromnieHide, 1));
|
||||
Check.Eq(TinkerPlanner.Rows(TinkerBench.Trinkets, false, null).Count, 0, "off ILT: no trinket rows");
|
||||
var rows = TinkerPlanner.Rows(TinkerBench.Trinkets, true, null);
|
||||
var s = Settings(("s" + TinkerCatalog.Pyreal, 1), ("s" + TinkerCatalog.Diamond, 1), ("s" + TinkerCatalog.Ruby, 1),
|
||||
("s" + TinkerCatalog.GromnieHide, 1));
|
||||
var all = TinkerPlanner.Plan(TinkerBench.Trinkets, Item(AcObjectClass.Jewelry), s, rows);
|
||||
Check.Eq(Seq(all), Seq(TinkerCatalog.Diamond, TinkerCatalog.Ruby, TinkerCatalog.GromnieHide, TinkerCatalog.Pyreal),
|
||||
"the rows' order: Diamond, Ruby, Gromnie Hide, Pyreal");
|
||||
"UB-IT order: Diamond, Ruby, Gromnie Hide, Pyreal");
|
||||
var some = TinkerPlanner.Plan(TinkerBench.Trinkets, Item(AcObjectClass.Jewelry,
|
||||
flags: k => k is TrinketDiamondInt or TrinketGromnieInt ? 2 : 0), s, rows);
|
||||
Check.Eq(Seq(some), Seq(TinkerCatalog.Ruby, TinkerCatalog.Pyreal), "applied ints 384 / 386 already 2");
|
||||
flags: k => k is TinkerCatalog.IntTrinketDiamond or TinkerCatalog.IntTrinketGromnie ? 2 : 0), s, rows);
|
||||
Check.Eq(Seq(some), Seq(TinkerCatalog.Ruby, TinkerCatalog.Pyreal), "flags 384 / 386 already 2");
|
||||
var capped = TinkerPlanner.Plan(TinkerBench.Trinkets, Item(AcObjectClass.Jewelry, tinks: 10), s, rows);
|
||||
Check.Eq(capped.Count, 4, "no-slot rows ignore the tink cap");
|
||||
Check.Eq(capped.Count, 4, "trinket salvage doesn't use tink slots");
|
||||
|
||||
var diamond = new TinkerStep(rows.First(r => r.Id == TinkerCatalog.Diamond), TinkerCatalog.Diamond);
|
||||
Check.True(TinkerPlanner.BagMatches(diamond, "Major Diamond Salvage", TinkerCatalog.Diamond, 100, 2), "Major bag at Major");
|
||||
|
|
@ -349,4 +277,48 @@ internal static class TinkerTests
|
|||
&& !TinkerCatalog.IsTrinket("Imperial Topaz Necklace"), "trinket names (topaz isn't a top)");
|
||||
Check.True(TinkerCatalog.Targets(TinkerBench.Trinkets, AcObjectClass.Jewelry), "trinkets are jewelry");
|
||||
}
|
||||
|
||||
private static void RingIngredients()
|
||||
{
|
||||
var step1 = RingChain.Recipes[0];
|
||||
Check.True(RingChain.Matches("Quill of Infliction", step1.Tool), "base quill");
|
||||
Check.True(RingChain.Matches("Infliction Quill", step1.Tool), "alternate name");
|
||||
Check.True(!RingChain.Matches("Enlightened Quill of Infliction", step1.Tool), "Enlightened excluded from Step 1");
|
||||
Check.True(RingChain.Matches("Empyrean Trophy", step1.Target) && RingChain.Matches("Royal Summons", step1.Target), "trophies");
|
||||
Check.True(!RingChain.Matches("Trophy Kit", step1.Target), "not every Trophy");
|
||||
|
||||
var step2 = RingChain.Recipes[1];
|
||||
Check.True(RingChain.Matches("Enlightened Quill of Infliction", step2.Tool), "Step 2 quill");
|
||||
Check.True(!RingChain.Matches("Enlightened Infliction Quill of Partition", step2.Tool), "partition quill excluded from Step 2");
|
||||
Check.True(RingChain.Matches("Vial of Ink of Partition", step2.Target), "ink");
|
||||
|
||||
var flame = RingChain.Recipes.First(r => r.Id == "ring2_glyph_flame");
|
||||
Check.True(RingChain.Matches("Enlightened Infliction Quill of Partition", flame.Tool), "Step 3 quill");
|
||||
Check.True(RingChain.Matches("Glyph of Flame", flame.Target) && !RingChain.Matches("Glyph of Frost", flame.Target), "glyph by full name");
|
||||
Check.True(!RingChain.Matches(null, flame.Target), "no name");
|
||||
}
|
||||
|
||||
private static void RingQueue()
|
||||
{
|
||||
var runs = new Dictionary<string, int> { ["ring2_glyph_frost"] = 1, ["ring2_step2_ink"] = 2, ["ring2_step1_quill_trophy"] = 2, ["ring2_glyph_bludgeoning"] = 1 };
|
||||
var q = RingChain.Expand(id => runs.TryGetValue(id, out int n) ? n : 0);
|
||||
Check.Eq(string.Join(",", q.Select(r => r.Tier)), "1,1,2,2,3,3", "tiers in order");
|
||||
Check.Eq(q[4].Id, "ring2_glyph_bludgeoning", "glyphs in definition order");
|
||||
Check.Eq(RingChain.Expand(_ => 500).Count, RingChain.Recipes.Length * RingChain.MaxRuns, "runs capped at 99");
|
||||
Check.Eq(RingChain.Expand(_ => 0).Count, 0, "nothing queued");
|
||||
}
|
||||
|
||||
private static void RingScrolls()
|
||||
{
|
||||
Check.Eq(RingChain.GlyphOf("Inscription of Halo of Frost")?.Id, "ring2_glyph_frost", "Halo of Frost");
|
||||
Check.Eq(RingChain.GlyphOf("Inscription of Cassius' Ring of Fire")?.Id, "ring2_glyph_flame", "Ring of Fire");
|
||||
Check.Eq(RingChain.GlyphOf("Inscription of Something"), null, "unknown scroll");
|
||||
Check.True(RingChain.IsInscriptionScroll("Inscription of Clouded Soul") && !RingChain.IsInscriptionScroll("Glyph of Nether"), "scroll marker");
|
||||
|
||||
var scrolls = new[] { (30, "Inscription of Searing Disc"), (10, "Inscription of Tectonic Rifts"), (20, "Inscription of Mystery") };
|
||||
var pairs = RingChain.PairScrolls(scrolls, new[] { 900, 500, 700, 800 });
|
||||
// Recipe ids sort bludgeoning < corrosion, unknown last; targets by id.
|
||||
Check.Eq(string.Join(";", pairs.Select(p => $"{p.Scroll}>{p.Target}")), "10>500;30>700;20>800", "glyph order onto target id order");
|
||||
Check.Eq(RingChain.PairScrolls(scrolls, Array.Empty<int>()).Count, 0, "no targets");
|
||||
}
|
||||
}
|
||||
|
|
|
|||
146
Tools/RynthCore.RynthAiHostTests/Tests/UbCompatTests.cs
Normal file
146
Tools/RynthCore.RynthAiHostTests/Tests/UbCompatTests.cs
Normal file
|
|
@ -0,0 +1,146 @@
|
|||
using System;
|
||||
using System.Linq;
|
||||
using System.Reflection;
|
||||
using System.Runtime.CompilerServices;
|
||||
using RynthCore.Plugin.RynthAi;
|
||||
using RynthCore.Plugin.RynthAi.LegacyUi;
|
||||
using RynthCore.PluginCore;
|
||||
using RynthCore.RynthAiHostTests.Fakes;
|
||||
using RynthCore.RynthAiTests.Harness;
|
||||
|
||||
namespace RynthCore.RynthAiHostTests.Tests;
|
||||
|
||||
// ub-IT's remaining /ub verbs (2026-10-18): metas written for ub-IT send them, so every one is
|
||||
// handled: mapped where RynthAi, RynthNav, RynthSort or the server has the feature, left to
|
||||
// ub-Rythai for its verbs, and accepted quietly where nothing here matches (videopatch, ...).
|
||||
internal static class UbCompatTests
|
||||
{
|
||||
private const uint Player = 0x50000F21;
|
||||
private const uint Robe = 0x80282101, WornRobe = 0x80282102;
|
||||
private const BindingFlags Any = BindingFlags.Instance | BindingFlags.NonPublic | BindingFlags.Public;
|
||||
|
||||
public static void Register(Runner r)
|
||||
{
|
||||
r.Add("ub compat: ub-IT verbs with no RynthAi equivalent are accepted, said once", NoEquivalentAccepted);
|
||||
r.Add("ub compat: ub-Rythai's verbs get no RynthAi reply, and a meta passes them on", UbRythaiVerbsLeftAlone);
|
||||
r.Add("ub compat: aliases and features map onto RynthAi, RynthNav, RynthSort and the server", AliasesAndFeatures);
|
||||
r.Add("ub compat: a meta's /ub line uses the /ub meaning, not /mt's", MetaUsesUbMeaning);
|
||||
}
|
||||
|
||||
private sealed class World
|
||||
{
|
||||
public readonly RynthAiPlugin P = new();
|
||||
public readonly LegacyUiSettings S = new();
|
||||
|
||||
public World()
|
||||
{
|
||||
FakeHost.Reset();
|
||||
FakeHost.PluginCommandCalls = true;
|
||||
FakeHost.SalvageCalls = true; // GetObjectWielderInfo: the worn robe reads as worn
|
||||
FakeHost.Names[Player] = "Kelpie";
|
||||
FakeHost.PlayerIdValue = Player;
|
||||
foreach (var (id, name) in new[] { (Robe, "Faran Robe"), (WornRobe, "Faran Robe") })
|
||||
{
|
||||
FakeHost.Names[id] = name;
|
||||
FakeHost.Containers[id] = Player;
|
||||
FakeHost.ItemTypes[id] = 0x2; // clothing
|
||||
}
|
||||
FakeHost.Wielded[WornRobe] = 0x0400;
|
||||
var host = FakeHost.Create(playerId: Player);
|
||||
typeof(RynthPluginBase).GetMethod("Attach", Any)!.Invoke(P, new object[] { FakeHost.LastApi });
|
||||
var dash = (LegacyDashboardRenderer)RuntimeHelpers.GetUninitializedObject(typeof(LegacyDashboardRenderer));
|
||||
typeof(LegacyDashboardRenderer).GetField("_settings", Any)!.SetValue(dash, S);
|
||||
Set("_dashboard", dash);
|
||||
var cache = new WorldObjectCache(host);
|
||||
cache.SetPlayerId(Player);
|
||||
Set("_objectCache", cache);
|
||||
Set("_playerId", Player);
|
||||
Set("_initialized", true);
|
||||
Set("_loginComplete", true);
|
||||
foreach (uint id in new[] { Robe, WornRobe }) cache.OnCreateObject(id);
|
||||
cache.Tick();
|
||||
}
|
||||
|
||||
public void Set(string f, object? v) => typeof(RynthAiPlugin).GetField(f, Any)!.SetValue(P, v);
|
||||
public bool Ub(string line) => (bool)typeof(RynthAiPlugin).GetMethod("HandleUbCommand", Any)!.Invoke(P, new object[] { line })!;
|
||||
public bool Meta(string line) => (bool)typeof(RynthAiPlugin).GetMethod("HandleMetaChatCommand", Any)!.Invoke(P, new object[] { line })!;
|
||||
public int ChatWith(string text) => FakeHost.Chat.Count(c => c.Contains(text, StringComparison.OrdinalIgnoreCase));
|
||||
}
|
||||
|
||||
private static void NoEquivalentAccepted()
|
||||
{
|
||||
var w = new World();
|
||||
Check.True(w.Ub("/ub videopatch on"), "/ub videopatch is handled");
|
||||
Check.True(w.Ub("/ub videopatch off"), "again");
|
||||
Check.Eq(w.ChatWith("/ub videopatch"), 1, "said once per session, not per meta pulse");
|
||||
foreach (string line in new[] { "/ub chat max", "/ub playeroption AutoRepeatAttack on", "/ub statushud toggle", "/ub professor war 7", "/ub xp level" })
|
||||
Check.True(w.Ub(line), line + " is handled");
|
||||
Check.Eq(w.ChatWith("Unrecognized"), 0, "no 'Unrecognized /ub command'");
|
||||
Check.False(w.Ub("/ub notaubitcommand"), "a verb ub-IT doesn't have is still unknown");
|
||||
}
|
||||
|
||||
private static void UbRythaiVerbsLeftAlone()
|
||||
{
|
||||
var w = new World();
|
||||
int chat = FakeHost.Chat.Count;
|
||||
foreach (string line in new[] { "/ub bank status", "/ub periodic add 5 /say hi", "/ub xpmeter", "/ub portal use Aerlinthe", "/ub portal list", "/ub leaftide status" })
|
||||
Check.True(w.Ub(line), line + ": not unknown");
|
||||
Check.Eq(FakeHost.Chat.Count, chat, "RynthAi says nothing; ub-Rythai answers these");
|
||||
// A meta hands them to the chat parser, which every plugin (ub-Rythai too) sees.
|
||||
Check.False(w.Meta("/ub bank status"), "a meta's /ub bank goes on to the chat parser");
|
||||
// "/ub portal <name>" is RynthAi's (the nearest portal), not a portal gem.
|
||||
Check.False(RynthAiPluginIsUbRythai("portal", "Town Network"), "/ub portal <name> stays RynthAi's");
|
||||
}
|
||||
|
||||
private static bool RynthAiPluginIsUbRythai(string cmd, string args)
|
||||
=> (bool)typeof(RynthAiPlugin).GetMethod("IsUbRythaiCommand", BindingFlags.Static | BindingFlags.NonPublic)!.Invoke(null, new object[] { cmd, args })!;
|
||||
|
||||
private static void AliasesAndFeatures()
|
||||
{
|
||||
var w = new World();
|
||||
|
||||
// wear: the carried copy, never the worn one (using a worn item takes it off).
|
||||
Check.True(w.Ub("/ub wear Faran Robe"), "/ub wear");
|
||||
Check.True(FakeHost.Uses.Contains(Robe) && !FakeHost.Uses.Contains(WornRobe), "wears the carried robe only");
|
||||
|
||||
// Frame limits are RynthAi's FPS settings.
|
||||
w.Ub("/ub globalframelimit 45");
|
||||
Check.Eq(w.S.TargetFPSFocused, 45, "globalframelimit");
|
||||
Check.True(w.S.EnableFPSLimit, "and the limit is on");
|
||||
w.Ub("/ub bgframelimit 20");
|
||||
Check.Eq(w.S.TargetFPSBackground, 20, "bgframelimit");
|
||||
w.Ub("/ub globalframelimit 0");
|
||||
Check.False(w.S.EnableFPSLimit, "0 turns the limit off");
|
||||
|
||||
// RynthNav and RynthSort through the plugin broker.
|
||||
w.Ub("/ub arrow point 42.1N, 33.6E");
|
||||
Check.True(FakeHost.PluginCommands.Contains(("RynthNav", "rnav", "arrow 42.1N, 33.6E")), "arrow point -> /rnav arrow");
|
||||
w.Ub("/ub navgoto -12.5 40.25 walk");
|
||||
Check.True(FakeHost.PluginCommands.Contains(("RynthNav", "rnav", "go 12.5S, 40.25E")), "navgoto signed coords -> /rnav go");
|
||||
w.Ub("/ub packsort");
|
||||
Check.True(FakeHost.PluginCommands.Contains(("RynthSort", "rsort", "now")), "packsort -> /rsort now");
|
||||
|
||||
// Server and engine commands go to the chat parser.
|
||||
w.Ub("/ub qblist");
|
||||
w.Ub("/ub augs");
|
||||
w.Ub("/ub window save");
|
||||
w.Ub("/ub fellow dismiss Storm");
|
||||
Check.True(FakeHost.ChatCommands.Contains("/qb list"), "qblist -> /qb list");
|
||||
Check.True(FakeHost.ChatCommands.Contains("/aug"), "augs -> /aug");
|
||||
Check.True(FakeHost.ChatCommands.Contains("/rc window save"), "window save -> /rc window save");
|
||||
Check.True(FakeHost.ChatCommands.Contains("/fellowship dismiss Storm"), "fellow dismiss -> /fellowship dismiss");
|
||||
|
||||
// stfl / getxy are the /mt strafe / cursor commands (no game window here: they say so).
|
||||
Check.True(w.Ub("/ub stfl 500"), "stfl handled");
|
||||
Check.True(w.Ub("/ub getxy"), "getxy handled");
|
||||
}
|
||||
|
||||
private static void MetaUsesUbMeaning()
|
||||
{
|
||||
var w = new World();
|
||||
// A /ub verb /mt doesn't know used to fall to the chat parser and come back round.
|
||||
Check.True(w.Meta("/ub videopatch on"), "a meta's /ub line runs the /ub dispatcher");
|
||||
Check.Eq(FakeHost.ChatCommands.Count(c => c.StartsWith("/ub", StringComparison.Ordinal)), 0, "not re-sent to the chat parser");
|
||||
Check.True(w.Meta("/mt get xy"), "/mt lines still go to /mt");
|
||||
}
|
||||
}
|
||||
|
|
@ -22,6 +22,8 @@
|
|||
<!-- Combat: the melee/missile stall ladder (pure timing state, time passed in). -->
|
||||
<Compile Include="..\..\Plugins\RynthCore.Plugin.RynthAi\Combat\CombatStallWatchdog.cs" Link="Linked\CombatStallWatchdog.cs" />
|
||||
<Compile Include="..\..\Plugins\RynthCore.Plugin.RynthAi\Combat\PointBlankFacing.cs" Link="Linked\PointBlankFacing.cs" />
|
||||
<!-- Pets: ACECustom siphon-lens capture thresholds (Mini Remote auto-capture). -->
|
||||
<Compile Include="..\..\Plugins\RynthCore.Plugin.RynthAi\MiniRemote\PetCaptureRules.cs" Link="Linked\PetCaptureRules.cs" />
|
||||
<!-- Weapon weakness selection: element ranking per monster. Its only outside reference is
|
||||
CreatureProfileStore.Folder (the user override folder), faked in Fakes\. -->
|
||||
<Compile Include="..\..\Plugins\RynthCore.Plugin.RynthAi\CreatureData\CreatureWeakness.cs" Link="Linked\CreatureWeakness.cs" />
|
||||
|
|
@ -30,7 +32,6 @@
|
|||
<Compile Include="..\..\Plugins\RynthCore.Plugin.RynthAi\CreatureData\PlayerWeenies.cs" Link="Linked\PlayerWeenies.cs" />
|
||||
<!-- Loot: the measured loot-timer baseline and its [LootSettings] log line. -->
|
||||
<Compile Include="..\..\Plugins\RynthCore.Plugin.RynthAi\LootBaseline.cs" Link="Linked\LootBaseline.cs" />
|
||||
<Compile Include="..\..\Plugins\RynthCore.Plugin.RynthAi\MiniRemote\PetCaptureRules.cs" Link="Linked\PetCaptureRules.cs" />
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
|
|
|
|||
|
|
@ -6,16 +6,25 @@ namespace RynthILT.Tests;
|
|||
// The Lugian-hammer aetheria rules (Hub/IltChunkClap.cs): Infinite Leaftide aetheria goes up to
|
||||
// level 10, and aetheria carrying a C, CD or CDR rating is kept unless its keep switch is off.
|
||||
// Only the Lugian Aetheria Hammer chunks, and ILT's result lines name the item and the tool.
|
||||
// The cap covers Coalesced Aetheria too, and /clap needs a colour with its own trinket.
|
||||
// The cap covers levelled Coalesced Aetheria; an unlevelled one chunks, as in ub-IT. Corrupted
|
||||
// weapons follow ub-IT's hard rules and its optional keep rules, and /clap needs a colour with its
|
||||
// own trinket.
|
||||
internal static class AetheriaChunkTests
|
||||
{
|
||||
public static void Register(Runner r)
|
||||
{
|
||||
r.Add("aetheria: the chunk cap runs to one past ILT's level 10", Cap);
|
||||
r.Add("aetheria: C / CD / CDR ratings are kept by default, each with its own switch", Ratings);
|
||||
r.Add("aetheria: rating level - at or above keeps, below chunks (Coalesced too)", RatingLevel);
|
||||
r.Add("chunk: only the Lugian Aetheria Hammer is the tool, never a Lugian Hammer weapon", HammerOnly);
|
||||
r.Add("chunk: ILT's result lines (item and tool named) end the wait; combat lines don't", ResultLines);
|
||||
r.Add("aetheria: the level cap applies to Coalesced Aetheria too; no level read = never chunked", CoalescedCap);
|
||||
r.Add("aetheria: the level cap applies to levelled Coalesced Aetheria; unlevelled Coalesced chunks (ub-IT)", CoalescedCap);
|
||||
r.Add("aetheria: never-chunk, tinker / imbue, item XP, ratings and the cap each keep a piece", AetheriaRules);
|
||||
r.Add("chunk: kind by class and name; chunks and powder are clap material", Kinds);
|
||||
r.Add("corrupted: ub-IT hard rules (workmanship, cleave 1, or 2 on two-handed non-thrust)", CorruptedHardRules);
|
||||
r.Add("corrupted: ub-IT keep rules, all off by default", CorruptedKeepRules);
|
||||
r.Add("chunk: busy blocks peace mode, not combat with chunk-in-combat on (ub-IT v2.0.1059)", BusyGate);
|
||||
r.Add("chunk: a target that leaves the pack counts as chunked; still carried after 10 s times out", WaitOutcome);
|
||||
r.Add("clap: the server's WCIDs, each colour paired with its trinket, Coalesced only unrevealed level 1-3", ClapPairs);
|
||||
}
|
||||
|
||||
|
|
@ -29,7 +38,110 @@ internal static class AetheriaChunkTests
|
|||
Check.False(IltChunkClap.UnderChunkCap(9, 9), "level 9 is not below 9");
|
||||
Check.False(IltChunkClap.UnderChunkCap(10, 9), "a level 10 Coalesced piece is kept");
|
||||
Check.True(IltChunkClap.UnderChunkCap(10, 11), "11 chunks every level");
|
||||
Check.False(IltChunkClap.UnderChunkCap(0, 11), "no level read: never chunked");
|
||||
Check.False(IltChunkClap.UnderChunkCap(0, 11), "revealed aetheria with no level read: never chunked");
|
||||
Check.False(IltChunkClap.UnderChunkCap(9, 9, coalesced: true), "a levelled Coalesced piece keeps the cap");
|
||||
Check.True(IltChunkClap.UnderChunkCap(0, 4, coalesced: true), "an unlevelled Coalesced piece chunks (it used to be kept forever)");
|
||||
Check.True(IltChunkClap.UnderChunkCap(0, 1, coalesced: true), "even with the lowest cap");
|
||||
}
|
||||
|
||||
private static readonly IltChunkClap.AetheriaFacts PlainCoalesced = new(
|
||||
Coalesced: true, MaxLevel: 0, NeverChunk: false, ItemXp: 0, Tinkers: 0, Imbue: 0, Crit: 0, CritDamage: 0, CritDamageResist: 0);
|
||||
|
||||
private static void AetheriaRules()
|
||||
{
|
||||
var g = new IltGearState();
|
||||
Check.Eq(IltChunkClap.AetheriaSkip(g, PlainCoalesced), null, "a plain unlevelled Coalesced piece chunks");
|
||||
Check.Eq(IltChunkClap.AetheriaSkip(g, PlainCoalesced with { MaxLevel = 3 }), null, "level 3 under the default cap of 4");
|
||||
Check.Eq(IltChunkClap.AetheriaSkip(g, PlainCoalesced with { MaxLevel = 4 }), "level at or above the cap", "level 4 at the default cap");
|
||||
Check.Eq(IltChunkClap.AetheriaSkip(g, PlainCoalesced with { NeverChunk = true }), "never-chunk flag", "bool 9030");
|
||||
Check.Eq(IltChunkClap.AetheriaSkip(g, PlainCoalesced with { Tinkers = 1 }), "tinkered or imbued", "tinkered");
|
||||
Check.Eq(IltChunkClap.AetheriaSkip(g, PlainCoalesced with { Imbue = 4 }), "tinkered or imbued", "imbued");
|
||||
Check.Eq(IltChunkClap.AetheriaSkip(g, PlainCoalesced with { ItemXp = 100 }), "has item XP", "levelled by use");
|
||||
Check.Eq(IltChunkClap.AetheriaSkip(g, PlainCoalesced with { Crit = 2 }), "kept for its C / CD / CDR rating", "a C 2 piece is kept by default");
|
||||
g.KeepAetheriaWithCrit = false;
|
||||
Check.Eq(IltChunkClap.AetheriaSkip(g, PlainCoalesced with { Crit = 2 }), null, "C switch off: a C 2 piece chunks");
|
||||
Check.Eq(IltChunkClap.AetheriaSkip(g, PlainCoalesced with { Coalesced = false }), "no level read", "revealed aetheria needs a level");
|
||||
}
|
||||
|
||||
private static void Kinds()
|
||||
{
|
||||
var gem = RynthCore.Loot.AcObjectClass.Gem;
|
||||
Check.Eq(IltChunkClap.KindOf(gem, "Coalesced Aetheria"), IltChunkClap.ChunkKind.Aetheria, "Coalesced");
|
||||
Check.Eq(IltChunkClap.KindOf(gem, "Blue Aetheria"), IltChunkClap.ChunkKind.Aetheria, "revealed sigil");
|
||||
Check.Eq(IltChunkClap.KindOf(gem, "Red Aetheria Chunk"), IltChunkClap.ChunkKind.None, "chunk");
|
||||
Check.Eq(IltChunkClap.KindOf(gem, "Aetheria Powder"), IltChunkClap.ChunkKind.None, "powder");
|
||||
Check.Eq(IltChunkClap.KindOf(RynthCore.Loot.AcObjectClass.MeleeWeapon, "Corrupted Greatsword"), IltChunkClap.ChunkKind.Corrupted, "melee");
|
||||
Check.Eq(IltChunkClap.KindOf(RynthCore.Loot.AcObjectClass.MissileWeapon, "Corrupted Bow"), IltChunkClap.ChunkKind.Corrupted, "missile");
|
||||
Check.Eq(IltChunkClap.KindOf(RynthCore.Loot.AcObjectClass.WandStaffOrb, "Corrupted Orb"), IltChunkClap.ChunkKind.None, "casters are not chunked (ub-IT)");
|
||||
Check.Eq(IltChunkClap.KindOf(RynthCore.Loot.AcObjectClass.MeleeWeapon, "Greatsword"), IltChunkClap.ChunkKind.None, "not corrupted");
|
||||
}
|
||||
|
||||
private static readonly IltChunkClap.CorruptedFacts PlainSword = new() { Workmanship = 6, AttackType = 4, WieldSkill = 45 };
|
||||
|
||||
private static void CorruptedHardRules()
|
||||
{
|
||||
var g = new IltGearState();
|
||||
Check.Eq(IltChunkClap.CorruptedSkip(g, PlainSword), null, "a plain corrupted sword chunks");
|
||||
Check.Eq(IltChunkClap.CorruptedSkip(g, PlainSword with { Workmanship = 0 }), "no workmanship", "workmanship 0");
|
||||
Check.Eq(IltChunkClap.CorruptedSkip(g, PlainSword with { Tinkers = 1 }), "tinkered or imbued", "tinkered");
|
||||
Check.Eq(IltChunkClap.CorruptedSkip(g, PlainSword with { Imbue = 1 }), "tinkered or imbued", "imbued");
|
||||
Check.Eq(IltChunkClap.CorruptedSkip(g, PlainSword with { NeverChunk = true }), "never-chunk flag", "bool 9030");
|
||||
Check.Eq(IltChunkClap.CorruptedSkip(g, PlainSword with { Cleaving = 1 }), null, "one-handed cleave 1");
|
||||
Check.Eq(IltChunkClap.CorruptedSkip(g, PlainSword with { Cleaving = 2 }), "cleave over the limit", "one-handed cleave 2");
|
||||
|
||||
var twoHanded = PlainSword with { WieldSkill = 41, Cleaving = 2 };
|
||||
Check.Eq(IltChunkClap.CorruptedSkip(g, twoHanded), null, "two-handed cleave 2 chunks (it never did before)");
|
||||
Check.Eq(IltChunkClap.CorruptedSkip(g, twoHanded with { Cleaving = 3 }), "cleave over the limit", "two-handed cleave 3");
|
||||
Check.Eq(IltChunkClap.CorruptedSkip(g, twoHanded with { AttackType = 2 }), "cleave over the limit", "a two-handed thrust weapon keeps the 1 limit");
|
||||
Check.Eq(IltChunkClap.MaxChunkCleave(0, 11, 4), 2, "WeaponType TwoHanded counts too");
|
||||
Check.Eq(IltChunkClap.MaxChunkCleave(45, 0, 4), 1, "one-handed");
|
||||
}
|
||||
|
||||
private static void CorruptedKeepRules()
|
||||
{
|
||||
var g = new IltGearState();
|
||||
var loaded = PlainSword with
|
||||
{
|
||||
CritFrequency = 0.1, CritMultiplier = 1.5, IgnoreArmor = 0.2, Slayer = 5, AttackType = 160,
|
||||
ElementalBonus = 10, MaxDamage = 400, Spells = new[] { 2072 },
|
||||
};
|
||||
Check.Eq(IltChunkClap.CorruptedSkip(g, loaded), null, "every keep rule is off by default");
|
||||
|
||||
Check.Eq(IltChunkClap.CorruptedSkip(new IltGearState { KeepCorruptedCrushingBlow = true }, loaded), "kept: Crushing Blow", "Crushing Blow");
|
||||
Check.Eq(IltChunkClap.CorruptedSkip(new IltGearState { KeepCorruptedBitingStrike = true }, loaded), "kept: Biting Strike", "Biting Strike");
|
||||
Check.Eq(IltChunkClap.CorruptedSkip(new IltGearState { KeepCorruptedArmorCleaving = true }, loaded), "kept: Armor Cleaving", "Armor Cleaving");
|
||||
Check.Eq(IltChunkClap.CorruptedSkip(new IltGearState { KeepCorruptedAnySlayer = true }, loaded), "kept: slayer", "slayer");
|
||||
Check.Eq(IltChunkClap.CorruptedSkip(new IltGearState { KeepCorruptedMultiStrike = true }, loaded), "kept: multi-strike", "multi-strike 160");
|
||||
Check.Eq(IltChunkClap.CorruptedSkip(new IltGearState { KeepCorruptedMultiStrike = true }, PlainSword), null, "a single slash is not multi-strike");
|
||||
Check.Eq(IltChunkClap.CorruptedSkip(new IltGearState { KeepCorruptedElementalBonus = true }, loaded), "kept: elemental bonus", "elemental");
|
||||
Check.Eq(IltChunkClap.CorruptedSkip(new IltGearState { KeepCorruptedMaxDamageAtLeast = 400 }, loaded), "kept: max damage", "max damage at the limit");
|
||||
Check.Eq(IltChunkClap.CorruptedSkip(new IltGearState { KeepCorruptedMaxDamageAtLeast = 401 }, loaded), null, "max damage under the limit");
|
||||
Check.Eq(IltChunkClap.CorruptedSkip(new IltGearState { KeepCorruptedAnySpell = true }, loaded), "kept: has a spell", "any spell");
|
||||
Check.Eq(IltChunkClap.CorruptedSkip(new IltGearState { KeepCorruptedSpellIds = "100, 2072" }, loaded), "kept: listed spell", "listed spell id");
|
||||
Check.Eq(IltChunkClap.CorruptedSkip(new IltGearState { KeepCorruptedSpellIds = "100 200" }, loaded), null, "other spell ids");
|
||||
|
||||
Check.Eq(IltChunkClap.ParseSpellIds("1, 2;3 x -4 0").Count, 3, "positive ids only, any separator");
|
||||
Check.Eq(IltChunkClap.ParseSpellIds(null).Count, 0, "no list");
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Silentkelpie 2026-10-18: a Coalesced piece was chunked (Red Aetheria Chunk arrived) with no
|
||||
/// result line, and it was filed as skipped after 10 s instead of counted.
|
||||
/// </summary>
|
||||
private static void WaitOutcome()
|
||||
{
|
||||
Check.Eq(IltChunkClap.WaitOutcome(500, targetStillCarried: true), IltChunkClap.ChunkWait.Waiting, "still carried, within the wait");
|
||||
Check.Eq(IltChunkClap.WaitOutcome(1_100, targetStillCarried: false), IltChunkClap.ChunkWait.Gone, "gone from the pack: chunked");
|
||||
Check.Eq(IltChunkClap.WaitOutcome(12_000, targetStillCarried: false), IltChunkClap.ChunkWait.Gone, "gone beats the timeout");
|
||||
Check.Eq(IltChunkClap.WaitOutcome(10_000, targetStillCarried: true), IltChunkClap.ChunkWait.TimedOut, "still carried at 10 s: timed out");
|
||||
}
|
||||
|
||||
private static void BusyGate()
|
||||
{
|
||||
Check.True(IltChunkClap.AllowsChunkWhileBusy(isBusy: false, isPeace: true, chunkInCombat: false), "idle in peace");
|
||||
Check.False(IltChunkClap.AllowsChunkWhileBusy(isBusy: true, isPeace: true, chunkInCombat: true), "busy in peace waits");
|
||||
Check.True(IltChunkClap.AllowsChunkWhileBusy(isBusy: true, isPeace: false, chunkInCombat: true), "busy swinging with chunk-in-combat");
|
||||
Check.False(IltChunkClap.AllowsChunkWhileBusy(isBusy: true, isPeace: false, chunkInCombat: false), "busy in combat without it");
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
|
@ -117,4 +229,35 @@ internal static class AetheriaChunkTests
|
|||
g.KeepAetheriaWithCritDamageResist = false;
|
||||
Check.False(IltChunkClap.KeptForRatings(g, 3, 3, 3), "every switch off: ratings don't protect");
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// The rating level: a C / CD / CDR rating at or above it keeps the piece, a lower one chunks
|
||||
/// (if the level cap allows). The default of 1 keeps any rating, as before.
|
||||
/// </summary>
|
||||
private static void RatingLevel()
|
||||
{
|
||||
var g = new IltGearState();
|
||||
Check.Eq(g.KeepAetheriaRatingAtLeast, 1, "default: any rating keeps");
|
||||
Check.True(IltChunkClap.KeptForRatings(g, 1, 0, 0), "C 1 kept at the default");
|
||||
|
||||
g.KeepAetheriaRatingAtLeast = 2;
|
||||
Check.False(IltChunkClap.KeptForRatings(g, 1, 0, 0), "C 1 below level 2: chunks");
|
||||
Check.True(IltChunkClap.KeptForRatings(g, 2, 0, 0), "C 2 at level 2: kept");
|
||||
Check.True(IltChunkClap.KeptForRatings(g, 3, 0, 0), "C 3 above level 2: kept");
|
||||
Check.True(IltChunkClap.KeptForRatings(g, 1, 0, 2), "CDR 2 keeps a C 1 + CDR 2 piece");
|
||||
Check.False(IltChunkClap.KeptForRatings(g, 1, 1, 1), "every rating below the level: chunks");
|
||||
|
||||
g.KeepAetheriaWithCrit = false;
|
||||
Check.False(IltChunkClap.KeptForRatings(g, 5, 0, 0), "a switch that is off ignores the level");
|
||||
|
||||
Check.Eq(IltChunkClap.ClampRatingLevel(0), 1, "below 1 clamps to 1");
|
||||
Check.Eq(IltChunkClap.ClampRatingLevel(99), IltChunkClap.MaxRatingLevel, "clamped to the maximum");
|
||||
|
||||
var coalescedC1 = PlainCoalesced with { Crit = 1 };
|
||||
var level2 = new IltGearState { KeepAetheriaRatingAtLeast = 2 };
|
||||
Check.Eq(IltChunkClap.AetheriaSkip(level2, coalescedC1), null, "an unlevelled C 1 Coalesced piece chunks at rating level 2");
|
||||
Check.Eq(IltChunkClap.AetheriaSkip(level2, PlainCoalesced with { Crit = 2 }), "kept for its C / CD / CDR rating", "a C 2 one is kept");
|
||||
Check.Eq(IltChunkClap.AetheriaSkip(level2, coalescedC1 with { MaxLevel = 6 }), "level at or above the cap",
|
||||
"a low rating does not override the level cap");
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -12,7 +12,7 @@ namespace RynthILT.Tests;
|
|||
// The pet breeding tracker (IltBreedingRules / IltBreedingEssence / IltBreedingSupplies / IltPetBreeding):
|
||||
// the server's rules and where each value came from, the parsers for ACECustom's appraisal block,
|
||||
// chat and "@breed-debug" (formats copied from PetDevice_Breeding.cs / PetDevice_Maturity.cs), each
|
||||
// breeding gate, the pair planner's odds, the supply refusals, and the "RynthILT.Data" v2 reader JSON.
|
||||
// breeding gate, the pair planner's odds, the supply refusals, and the JSON RynthOracle reads.
|
||||
internal static class BreedingTests
|
||||
{
|
||||
public static void Register(Runner r)
|
||||
|
|
@ -26,7 +26,7 @@ internal static class BreedingTests
|
|||
r.Add("breeding: each gate (charges, rest, growth, neutered, shiny, bond, tier, ID)", Gates);
|
||||
r.Add("breeding: pair planner blocks wrong sexes and ranges the inherited mutations", Planner);
|
||||
r.Add("breeding: supplies are refused where the server would refuse them", Supplies);
|
||||
r.Add("breeding: reader JSON round-trips through the shared reader view", ReaderJson);
|
||||
r.Add("breeding: reader JSON round-trips through RynthOracle's view", ReaderJson);
|
||||
r.Add("breeding: saved state survives the hub.json source-generated serializer", StateJson);
|
||||
r.Add("breeding: RynthILT.Data v2 keeps v1 readers working", DataApiVersion);
|
||||
}
|
||||
|
|
@ -363,12 +363,15 @@ internal static class BreedingTests
|
|||
|
||||
private static unsafe void DataApiVersion()
|
||||
{
|
||||
Check.Eq(RynthIltDataApiV1.InterfaceVersion, 2u, "version 2");
|
||||
Check.True(RynthIltDataApiV1.V1Size < (uint)sizeof(RynthIltDataApiV1), "v2 appends to v1");
|
||||
// Version 3 (the Temple guardians) appends after the breeding pair; a v2 reader sees the same breeding layout.
|
||||
Check.Eq(RynthIltDataApiV1.InterfaceVersion, 3u, "version 3");
|
||||
Check.True(RynthIltDataApiV1.V1Size < RynthIltDataApiV1.V2Size && RynthIltDataApiV1.V2Size < (uint)sizeof(RynthIltDataApiV1),
|
||||
"v2 appends to v1, v3 to v2");
|
||||
Check.Eq(RynthIltDataApiV1.V1Size, (uint)(8 + 4 * sizeof(IntPtr)), "v1 = two uints and four function pointers");
|
||||
Check.True(DataInterface.Query(RynthIltDataApiV1.InterfaceName, 1) != IntPtr.Zero, "v1 readers still get the table");
|
||||
Check.True(DataInterface.Query(RynthIltDataApiV1.InterfaceName, 2) != IntPtr.Zero, "v2 readers too");
|
||||
Check.True(DataInterface.Query(RynthIltDataApiV1.InterfaceName, 3) == IntPtr.Zero, "a future version isn't claimed");
|
||||
Check.True(DataInterface.Query(RynthIltDataApiV1.InterfaceName, 3) != IntPtr.Zero, "v3 readers too");
|
||||
Check.True(DataInterface.Query(RynthIltDataApiV1.InterfaceName, 4) == IntPtr.Zero, "a future version isn't claimed");
|
||||
var t = (RynthIltDataApiV1*)DataInterface.Query(RynthIltDataApiV1.InterfaceName, 1);
|
||||
Check.True(t->GetPetBreedingJson != null && t->PetBreedingCommand != null, "breeding functions filled");
|
||||
Check.Eq(RynthIltHub.SectionPetBreeding, "pets-breeding", "section id");
|
||||
|
|
|
|||
|
|
@ -19,6 +19,7 @@ internal static class DataApiTests
|
|||
r.Add("data: the bank JSON reads back whole: characters (current first), choices, notes, log", BankRoundTrip);
|
||||
r.Add("data: the bank verb lines carry their fields in RunVerb's order", BankVerbs);
|
||||
r.Add("data: bad bank JSON reads as nothing", BankBadJson);
|
||||
r.Add("data: the Temple guardian JSON reads back whole (switches, answer, hand-in, rows)", GuardianRoundTrip);
|
||||
// Last: Release() switches the table off for the rest of the process.
|
||||
r.Add("data: the RynthILT.Data table: query, functions, release", DataTable);
|
||||
}
|
||||
|
|
@ -82,17 +83,53 @@ internal static class DataApiTests
|
|||
Check.True(empty.Loaded && !empty.Available && empty.Enabled == -1 && empty.Characters.Count == 0, "missing fields read as nothing known");
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Version 3: the guardian JSON RynthILT builds (IltGuardian.BuildJson) read back by the reader
|
||||
/// RynthOracle's Quests tab uses, quotes and all.
|
||||
/// </summary>
|
||||
private static void GuardianRoundTrip()
|
||||
{
|
||||
var rows = new[]
|
||||
{
|
||||
new IltTempleAttrStatus("Strength", "Fiun \"Big\" Strongarm", 3, "Ready", "", true, true),
|
||||
new IltTempleAttrStatus("Focus", "Fiun Thinker", 1, "Cooldown", "in 5h 2m", false, false),
|
||||
};
|
||||
string json = IltGuardian.BuildJson("InfiniteLeaftide", chat: true, auto: false, buy: true, cooldownHours: 20,
|
||||
answer: "Pyreal", npc: "Guardian of Attribute Enlightenment", answerAgeSec: 42, heard: "What is \"coin\"?",
|
||||
running: true, status: "handing Pyreal to Guardian...", syncedUtc: new DateTime(2026, 10, 18, 19, 5, 0, DateTimeKind.Utc), rows);
|
||||
Check.True(json.All(c => c >= 0x20 && c <= 0x7E), "plain printable ASCII");
|
||||
|
||||
IltGuardianView v = IltGuardianView.Parse(json);
|
||||
Check.True(v.Loaded && v.Available && v.World == "InfiniteLeaftide", "loaded, the world");
|
||||
Check.True(v.Chat && !v.Auto && v.Buy && v.CooldownHours == 20, "the switches");
|
||||
Check.True(v.Answer == "Pyreal" && v.Npc == "Guardian of Attribute Enlightenment" && v.AnswerAgeSec == 42 && v.Heard == "What is \"coin\"?",
|
||||
"the last answer");
|
||||
Check.True(v.Running && v.Status.StartsWith("handing Pyreal"), "the hand-in");
|
||||
Check.Eq(v.SyncedUtc, new DateTime(2026, 10, 18, 19, 5, 0, DateTimeKind.Utc), "the /qb read time");
|
||||
Check.Eq(v.Rows.Count, 2, "both rows");
|
||||
Check.True(v.Rows[0].Npc == "Fiun \"Big\" Strongarm" && v.Rows[0].Count == 3 && v.Rows[0].Ready && v.Rows[0].Exact, "an exact, ready row");
|
||||
Check.True(v.Rows[1].Eta == "in 5h 2m" && !v.Rows[1].Ready && !v.Rows[1].Exact, "an estimated row on cooldown");
|
||||
|
||||
IltGuardianView none = IltGuardianView.Parse(IltGuardian.BuildJson("x", false, false, false, 1, "", "", -1, "", false, "idle",
|
||||
DateTime.MinValue, Array.Empty<IltTempleAttrStatus>()));
|
||||
Check.True(none.Answer.Length == 0 && none.AnswerAgeSec == -1 && none.SyncedUtc == DateTime.MinValue && none.Rows.Count == 0,
|
||||
"no answer, no /qb read, no rows");
|
||||
}
|
||||
|
||||
private static unsafe void DataTable()
|
||||
{
|
||||
Check.Eq(DataInterface.Query("RynthILT.Hub", 1), IntPtr.Zero, "another interface's name: not ours");
|
||||
Check.Eq(DataInterface.Query(RynthIltDataApiV1.InterfaceName, 3), IntPtr.Zero, "a newer version than we have: none");
|
||||
Check.Eq(DataInterface.Query(RynthIltDataApiV1.InterfaceName, 4), IntPtr.Zero, "a newer version than we have: none");
|
||||
var t = (RynthIltDataApiV1*)DataInterface.Query(RynthIltDataApiV1.InterfaceName, 1);
|
||||
Check.True(t != null, "v1 is served");
|
||||
Check.Eq(t->Version, 2u, "Version 2 (v1 readers take it: it starts with the v1 table)");
|
||||
Check.Eq(t->Version, 3u, "Version 3 (v1 and v2 readers take it: it starts with their tables)");
|
||||
Check.Eq(t->StructSize, (uint)sizeof(RynthIltDataApiV1), "StructSize");
|
||||
Check.Eq(sizeof(RynthIltDataApiV1), 8 + 6 * IntPtr.Size, "header + 6 functions (v1's 4, then the breeding pair)");
|
||||
Check.Eq(sizeof(RynthIltDataApiV1), 8 + 8 * IntPtr.Size, "header + 8 functions (v1's 4, the breeding pair, the guardian pair)");
|
||||
Check.Eq(RynthIltDataApiV1.V1Size, (uint)(8 + 4 * IntPtr.Size), "a v1 table ends before the breeding pair");
|
||||
Check.Eq(RynthIltDataApiV1.V2Size, (uint)(8 + 6 * IntPtr.Size), "a v2 table ends before the guardian pair (readers still see breeding on it)");
|
||||
Check.True(t->GetCharmsJson != null && t->GetBankJson != null && t->ToggleCharm != null && t->BankCommand != null
|
||||
&& t->GetPetBreedingJson != null && t->PetBreedingCommand != null, "every function is filled in");
|
||||
&& t->GetPetBreedingJson != null && t->PetBreedingCommand != null
|
||||
&& t->GetGuardianJson != null && t->GuardianCommand != null, "every function is filled in");
|
||||
Check.Eq((IntPtr)t, DataInterface.Query(RynthIltDataApiV1.InterfaceName, 1), "the same table each time");
|
||||
|
||||
// No plugin instance here (not logged in): nothing to report, every action refused.
|
||||
|
|
@ -104,6 +141,8 @@ internal static class DataApiTests
|
|||
Check.Eq(t->BankCommand(verb), 0, "no bank command before login");
|
||||
Check.Eq(t->GetPetBreedingJson(buf, 64), 0, "no breeding JSON before login");
|
||||
Check.Eq(t->PetBreedingCommand(verb), 0, "no breeding command before login");
|
||||
Check.Eq(t->GetGuardianJson(buf, 64), 0, "no guardian JSON before login");
|
||||
Check.Eq(t->GuardianCommand(verb), 0, "no guardian command before login");
|
||||
|
||||
DataInterface.Release();
|
||||
Check.Eq(t->Version, 0u, "Release zeroes Version (readers re-query)");
|
||||
|
|
|
|||
|
|
@ -1,21 +1,24 @@
|
|||
using System;
|
||||
using System.Text;
|
||||
using System.Text.Json;
|
||||
using RynthCore.Plugin.RynthILT;
|
||||
using RynthCore.Plugin.RynthILT.Hub;
|
||||
using RynthCore.RynthAiTests.Harness;
|
||||
|
||||
namespace RynthILT.Tests;
|
||||
|
||||
// Leaftide feature list (IltFeatureCatalog): every feature the player asked RynthILT to cover is
|
||||
// listed and the states follow the server bits. Also the NUL-terminated copy RynthILT's interfaces
|
||||
// ("RynthServer.Profile", "RynthILT.Data") hand their JSON out with.
|
||||
// Leaftide feature list (IltFeatureCatalog) and the "RynthILT.Server" profile it builds: every
|
||||
// feature the player asked RynthILT to cover is listed, states follow the server bits, and the JSON
|
||||
// other plugins read (RynthOracle's Fellowship tab) is valid ASCII with the fellowship rules.
|
||||
internal static class FeatureCatalogTests
|
||||
{
|
||||
public static void Register(Runner r)
|
||||
{
|
||||
r.Add("features: banking, guardian, attributes, augs, paragon x3, split arrows, T11 and fellowship are listed", Listed);
|
||||
r.Add("features: state follows the server bit on ILT, built-ins are on, nothing is known off ILT", States);
|
||||
r.Add("features: profile JSON is valid ASCII with features and the fellowship rules", ProfileJson);
|
||||
r.Add("features: the interface copies the JSON only when it fits, NUL-terminated", InterfaceWrite);
|
||||
r.Add("features: the /qb list rides the profile JSON on ILT worlds only", QuestBonusJson);
|
||||
r.Add("features: the ILT profile is on with the world; a refusal in chat turns a feature off", ProfileOnWithTheWorld);
|
||||
r.Add("features: probed features read checking; options ILT runs off are off until chat shows them", ProbedAndOffInIlt);
|
||||
r.Add("features: charms are on with the ILT world unless refused; rows describe themselves", Charms);
|
||||
|
|
@ -86,6 +89,27 @@ internal static class FeatureCatalogTests
|
|||
Check.Eq(IltFeatureCatalog.Describe("something_new").Group, IltFeatureCatalog.GroupOther, "an unknown bit goes to Other");
|
||||
}
|
||||
|
||||
private static void QuestBonusJson()
|
||||
{
|
||||
var qb = new IltQuestBonusInfo(false, 2, 41, "2 completed, 1 incomplete",
|
||||
new[] { "flag\"one", "flagTwo" }, new[] { "flagThree" });
|
||||
string json = IltFeatureCatalog.BuildProfileJson(true, "Infinite Leaftide", false, "probe", DateTime.MinValue, _ => IltTri.On, qb);
|
||||
using JsonDocument doc = JsonDocument.Parse(json);
|
||||
JsonElement q = doc.RootElement.GetProperty("questBonus");
|
||||
Check.False(q.GetProperty("disabled").GetBoolean(), "enabled");
|
||||
Check.Eq(q.GetProperty("generation").GetInt32(), 2, "generation");
|
||||
Check.Eq(q.GetProperty("count").GetInt64(), 41L, "count");
|
||||
Check.Eq(q.GetProperty("status").GetString(), "2 completed, 1 incomplete", "status");
|
||||
Check.Eq(q.GetProperty("completed").GetArrayLength(), 2, "completed flags");
|
||||
Check.Eq(q.GetProperty("completed")[0].GetString(), "flag\"one", "quotes in a flag survive");
|
||||
Check.Eq(q.GetProperty("incomplete")[0].GetString(), "flagThree", "incomplete flags");
|
||||
Check.True(doc.RootElement.TryGetProperty("fellowship", out _), "the fellowship rules are still there");
|
||||
|
||||
string off = IltFeatureCatalog.BuildProfileJson(false, "", false, "", DateTime.MinValue, _ => IltTri.On, qb);
|
||||
using JsonDocument d2 = JsonDocument.Parse(off);
|
||||
Check.False(d2.RootElement.TryGetProperty("questBonus", out _), "off ILT: no /qb list");
|
||||
}
|
||||
|
||||
private static readonly string[] Requested =
|
||||
{
|
||||
"bank", "guardian", "attributes", "augmentations", "paragon_armor", "paragon_weapons",
|
||||
|
|
@ -121,19 +145,45 @@ internal static class FeatureCatalogTests
|
|||
Check.Eq(IltFeatureCatalog.FellowshipMax(false), 9, "retail fellowships hold 9");
|
||||
}
|
||||
|
||||
private static void ProfileJson()
|
||||
{
|
||||
string json = IltFeatureCatalog.BuildProfileJson(true, "Infinite \"Leaftide\"", false, "probe",
|
||||
new DateTime(2026, 10, 13, 21, 25, 37, DateTimeKind.Utc),
|
||||
key => key == IltFeature.FBlackjack ? IltTri.Off : IltTri.On);
|
||||
bool ascii = true;
|
||||
foreach (char c in json) if (c < 0x20 || c > 0x7E) ascii = false;
|
||||
Check.True(ascii, "plain printable ASCII");
|
||||
|
||||
using JsonDocument doc = JsonDocument.Parse(json);
|
||||
JsonElement root = doc.RootElement;
|
||||
Check.True(root.GetProperty("ilt").GetBoolean(), "ilt");
|
||||
Check.Eq(root.GetProperty("world").GetString(), "Infinite \"Leaftide\"", "quotes in the world name survive");
|
||||
Check.Eq(root.GetProperty("checked").GetString(), "2026-10-13T21:25:37Z", "checked time in UTC");
|
||||
Check.Eq(root.GetProperty("features").GetArrayLength(), IltFeatureCatalog.All.Length, "every feature in the JSON");
|
||||
JsonElement fel = root.GetProperty("fellowship");
|
||||
Check.Eq(fel.GetProperty("maxMembers").GetInt32(), 29, "fellowship size");
|
||||
Check.Eq(fel.GetProperty("zoneShare").GetInt32(), 1, "Zone Share on (built in)");
|
||||
Check.Eq(fel.GetProperty("blackjack").GetInt32(), 0, "Fellowship Blackjack off (server bit)");
|
||||
|
||||
string off = IltFeatureCatalog.BuildProfileJson(false, "", false, "", DateTime.MinValue, _ => IltTri.On);
|
||||
using JsonDocument d2 = JsonDocument.Parse(off);
|
||||
Check.Eq(d2.RootElement.GetProperty("fellowship").GetProperty("maxMembers").GetInt32(), 9, "off ILT: retail size");
|
||||
Check.Eq(d2.RootElement.GetProperty("checked").GetString(), "", "never checked: empty time");
|
||||
}
|
||||
|
||||
private static unsafe void InterfaceWrite()
|
||||
{
|
||||
const string json = "{\"ilt\":true}";
|
||||
byte* small = stackalloc byte[4];
|
||||
small[0] = 0x55;
|
||||
Check.Eq(ProfileInterface.Write(json, small, 4), json.Length, "too small: the length is returned");
|
||||
Check.Eq(ServerInterface.Write(json, small, 4), json.Length, "too small: the length is returned");
|
||||
Check.Eq(small[0], (byte)0x55, "too small: nothing written");
|
||||
|
||||
byte* exact = stackalloc byte[json.Length];
|
||||
Check.Eq(ProfileInterface.Write(json, exact, json.Length), json.Length, "no room for the NUL: too small");
|
||||
Check.Eq(ServerInterface.Write(json, exact, json.Length), json.Length, "no room for the NUL: too small");
|
||||
|
||||
byte* big = stackalloc byte[64];
|
||||
int n = ProfileInterface.Write(json, big, 64);
|
||||
int n = ServerInterface.Write(json, big, 64);
|
||||
Check.Eq(n, json.Length, "fits: the length without the NUL");
|
||||
Check.Eq(big[n], (byte)0, "NUL-terminated");
|
||||
Check.Eq(Encoding.UTF8.GetString(big, n), json, "the JSON copied whole");
|
||||
|
|
|
|||
|
|
@ -1,20 +1,23 @@
|
|||
using System;
|
||||
using System.Linq;
|
||||
using RynthCore.Plugin.RynthAi.Huds;
|
||||
using RynthCore.Plugin.RynthILT.IltFellowship;
|
||||
using RynthCore.Plugin.Shared;
|
||||
using RynthCore.RynthAiTests.Harness;
|
||||
|
||||
namespace RynthILT.Tests;
|
||||
|
||||
// ILT's fellowship commands (IltFellowship/IltFellowshipCommands.cs, ACECustom /fship) and the
|
||||
// "servercommands" format they are kept in (Plugins/Shared/ServerCommandShare.cs), checked together.
|
||||
// ILT's fellowship commands (IltFellowship/IltFellowshipCommands.cs, ACECustom /fship), the
|
||||
// "servercommands" format both plugins compile (Plugins/Shared/ServerCommandShare.cs), and
|
||||
// RynthAi's store for it (Huds/ServerCommandModel.cs), checked together.
|
||||
internal static class FellowshipCommandTests
|
||||
{
|
||||
public static void Register(Runner r)
|
||||
{
|
||||
r.Add("ilt fellowship: the /fship list round-trips through the servercommands format", RoundTrip);
|
||||
r.Add("ilt fellowship: the /fship list round-trips to RynthAi", RoundTrip);
|
||||
r.Add("ilt fellowship: chat lines quote multi-word names and need a name for create", Compose);
|
||||
r.Add("ilt fellowship: bad commands and payloads are dropped", Rejects);
|
||||
r.Add("ilt fellowship: RynthAi drops a list that is cleared or stops arriving", Store);
|
||||
r.Add("ilt fellowship: RynthCore's verdict decides, else the world name", Active);
|
||||
}
|
||||
|
||||
|
|
@ -83,6 +86,28 @@ internal static class FellowshipCommandTests
|
|||
Check.Eq(c.Tooltip, "line one line two", "newline in a field becomes a space");
|
||||
}
|
||||
|
||||
private static void Store()
|
||||
{
|
||||
ServerCommandModel.Clear();
|
||||
long t = 1_000_000;
|
||||
ServerCommandModel.Apply(IltFellowshipCommands.Payload(active: true), t);
|
||||
Check.True(ServerCommandModel.For("fellowship", t + 1000) != null, "current");
|
||||
Check.True(ServerCommandModel.For("FELLOWSHIP", t + 1000) != null, "section id ignores case");
|
||||
Check.True(ServerCommandModel.For("char", t + 1000) == null, "other sections empty");
|
||||
Check.True(ServerCommandModel.For("fellowship", t + ServerCommandModel.StaleMs + 1) == null, "stale after the window");
|
||||
|
||||
ServerCommandModel.Apply(IltFellowshipCommands.Payload(active: true), t + 10_000);
|
||||
Check.True(ServerCommandModel.For("fellowship", t + ServerCommandModel.StaleMs + 1) != null, "a re-send keeps it");
|
||||
ServerCommandModel.Apply(IltFellowshipCommands.Payload(active: false), t + 12_000);
|
||||
Check.True(ServerCommandModel.For("fellowship", t + 12_000) == null, "the clear removes it");
|
||||
|
||||
ServerCommandModel.Apply(IltFellowshipCommands.Payload(active: true), t);
|
||||
ServerCommandModel.Apply("garbage", t);
|
||||
Check.True(ServerCommandModel.For("fellowship", t) != null, "garbage changes nothing");
|
||||
ServerCommandModel.Clear();
|
||||
Check.True(ServerCommandModel.For("fellowship", t) == null, "logout clears");
|
||||
}
|
||||
|
||||
private static void Active()
|
||||
{
|
||||
Check.True(IltFellowshipCommands.IsActive(true, "Coldeve"), "RynthCore says ILT");
|
||||
|
|
|
|||
|
|
@ -2,82 +2,110 @@ using System;
|
|||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using RynthCore.Plugin.RynthILT.IltSettingsView;
|
||||
using RynthCore.Plugin.Shared;
|
||||
using RynthCore.RynthAiTests.Harness;
|
||||
|
||||
namespace RynthILT.Tests;
|
||||
|
||||
// RynthILT's copy of the ILT settings (IltSettingsView/IltSettingsModel.cs): RynthCore's server
|
||||
// list (plugin API v86, GetServerStateJson: verdict, override, reason), the Hub's feature read, the
|
||||
// engine verdict the Hub follows (IltEngineVerdict), and the RynthCore commands the view sends.
|
||||
// RynthILT's copy of the ILT settings (IltSettingsView/IltSettingsModel.cs): RynthCore's "servermenu"
|
||||
// push (verdict, override, world names), the Hub's feature read (and the older "iltfeatures" text),
|
||||
// the engine verdict the Hub follows (IltEngineVerdict), and the RynthCore commands the view sends.
|
||||
internal static class IltSettingsTests
|
||||
{
|
||||
public static void Register(Runner r)
|
||||
{
|
||||
r.Add("ilt settings: RynthCore's server list gives the ILT verdict, override and reason", ServerList);
|
||||
r.Add("ilt settings: a list without ILT, or no list at all, reads as such", NoIlt);
|
||||
r.Add("ilt settings: the Hub's feature read is published whole", FeatureRead);
|
||||
r.Add("ilt settings: RynthCore's push gives the ILT verdict, override, reason and world names", EnginePush);
|
||||
r.Add("ilt settings: an older RynthCore push (no reason, no names) still reads", OlderEnginePush);
|
||||
r.Add("ilt settings: malformed or foreign payloads publish nothing", Malformed);
|
||||
r.Add("ilt settings: the Hub's feature read and the older text form both read", FeatureRoundTrip);
|
||||
r.Add("ilt settings: the Hub follows RynthCore's ILT verdict once one arrives", EngineVerdict);
|
||||
r.Add("ilt settings: override and world-name commands are checked before sending", Commands);
|
||||
r.Add("ilt settings: logout clears the copy", ClearOnLogout);
|
||||
}
|
||||
|
||||
// GetServerStateJson as RynthCore writes it (UI/Sections/ServerStateJson.cs, schema 1).
|
||||
private const string State =
|
||||
"{\"schema\":1,\"revision\":3,\"host\":\"infiniteleaftide.online\",\"world\":\"InfiniteLeaftide\",\"pick\":\"auto\"," +
|
||||
"\"active\":\"ilt\",\"activeName\":\"Infinite Leaftide\",\"activePlugin\":\"RynthILT\",\"servers\":[" +
|
||||
"{\"id\":\"ilt\",\"name\":\"Infinite Leaftide\",\"active\":true,\"detected\":false,\"force\":\"on\",\"builtIn\":true," +
|
||||
"\"plugin\":\"RynthILT\",\"reason\":\"forced on for this character\"}," +
|
||||
"{\"id\":\"aelrynth\",\"name\":\"Aelrynth\",\"active\":false,\"detected\":false,\"force\":\"auto\",\"builtIn\":true," +
|
||||
"\"plugin\":\"\",\"reason\":\"not detected\"}]}";
|
||||
private const string Push =
|
||||
"V\tilt\tInfinite Leaftide\t1\ton\t0\tforced on for this character\n" +
|
||||
"V\taelrynth\tAelrynth\t0\tauto\t0\tnot detected\n" +
|
||||
"X\tchar\tChar\n" +
|
||||
"S\tilt\tInfinite Leaftide\t1\t/rc server ilt on\n" +
|
||||
"I\tBounties\t/rc bounties toggle\tBounties.\t\n" +
|
||||
"N\tilt\tInfiniteLeaftide\tengine.json\n" +
|
||||
"N\tilt\t*Frost*\tengine.json\n" +
|
||||
"N\taelrynth\tAel*\tdefault\n";
|
||||
|
||||
private const string NoIltState =
|
||||
"{\"schema\":1,\"revision\":1,\"active\":\"\",\"servers\":[" +
|
||||
"{\"id\":\"aelrynth\",\"name\":\"Aelrynth\",\"active\":true,\"detected\":true,\"force\":\"auto\"}]}";
|
||||
|
||||
private static void ServerList()
|
||||
private static void EnginePush()
|
||||
{
|
||||
IltEngineView? v = IltSettingsModel.FromServerState(EngineServerState.Parse(State));
|
||||
Check.True(v?.Server != null, "the ILT server is there");
|
||||
Check.Eq(v!.Server!.Name, "Infinite Leaftide", "name");
|
||||
IltEngineView? v = IltSettingsModel.ParseEngine(Push);
|
||||
Check.True(v != null, "parsed");
|
||||
Check.True(v!.Server != null, "the ILT server is there");
|
||||
Check.Eq(v.Server!.Name, "Infinite Leaftide", "name");
|
||||
Check.True(v.Server.Active, "active");
|
||||
Check.False(v.Server.Detected, "not detected (forced)");
|
||||
Check.Eq(v.Server.Force, "on", "override");
|
||||
Check.Eq(v.Server.Reason, "forced on for this character", "reason");
|
||||
|
||||
IltEngineView? odd = IltSettingsModel.FromServerState(EngineServerState.Parse(
|
||||
"{\"schema\":1,\"servers\":[{\"id\":\"ILT\",\"force\":\"WEIRD\"}]}"));
|
||||
Check.True(odd?.Server != null, "the id ignores case");
|
||||
Check.Eq(odd!.Server!.Force, "auto", "an unknown override shows as auto");
|
||||
Check.Eq(odd.Server.Name, "Infinite Leaftide", "a missing name gets the server's");
|
||||
Check.False(odd.Server.Active, "a missing flag is off");
|
||||
Check.Eq(string.Join(",", v.Names), "InfiniteLeaftide,*Frost*", "only ILT's world names");
|
||||
Check.False(v.NamesDefault, "from engine.json");
|
||||
}
|
||||
|
||||
private static void NoIlt()
|
||||
private static void OlderEnginePush()
|
||||
{
|
||||
IltEngineView? none = IltSettingsModel.FromServerState(EngineServerState.Parse(NoIltState));
|
||||
Check.True(none != null && none.Server == null, "a list without ILT says so (not 'waiting')");
|
||||
Check.True(IltSettingsModel.FromServerState(null) == null, "no list: nothing");
|
||||
Check.True(EngineServerState.Parse("") == null && EngineServerState.Parse("{\"schema\":2}") == null, "empty or another schema: no list");
|
||||
IltEngineView? v = IltSettingsModel.ParseEngine("V\tilt\tInfinite Leaftide\t0\tWEIRD\t0\n");
|
||||
Check.True(v?.Server != null, "parsed");
|
||||
Check.Eq(v!.Server!.Reason, "", "no reason field");
|
||||
Check.Eq(v.Server.Force, "auto", "an unknown override shows as auto");
|
||||
Check.Eq(v.Names.Length, 0, "no names");
|
||||
|
||||
var model = new IltSettingsModel();
|
||||
model.ApplyServerState(EngineServerState.Parse(State));
|
||||
model.ApplyServerState(null);
|
||||
Check.True(model.Engine?.Server?.Active == true, "no answer keeps the last list");
|
||||
IltEngineView? none = IltSettingsModel.ParseEngine("V\taelrynth\tAelrynth\t1\tauto\t1\tx\n");
|
||||
Check.True(none != null && none.Server == null, "a push without ILT says so (not 'waiting')");
|
||||
}
|
||||
|
||||
private static void FeatureRead()
|
||||
private static void Malformed()
|
||||
{
|
||||
Check.True(IltSettingsModel.ParseEngine(null) == null, "null");
|
||||
Check.True(IltSettingsModel.ParseEngine("") == null, "empty");
|
||||
Check.True(IltSettingsModel.ParseEngine("S\tilt\tx\t1\t\nI\ta\tb\tc\td\n") == null, "RynthAi-only lines aren't a verdict");
|
||||
Check.True(IltSettingsModel.ParseEngine("V\tilt\n\t\t\n") == null, "short V line skipped");
|
||||
Check.True(IltSettingsModel.ParseEngine(new string('V', IltSettingsModel.MaxPayload + 1)) == null, "oversized");
|
||||
Check.True(IltSettingsModel.ParseFeatures("F\tbank\tnotanumber\n") == null, "bad value skipped");
|
||||
|
||||
var model = new IltSettingsModel();
|
||||
var read = new IltFeatureView("Infinite Leaftide", "probe", "12:00:00", Checking: true, IltLike: true,
|
||||
model.ApplyEngine(Push);
|
||||
model.ApplyEngine("garbage");
|
||||
Check.True(model.Engine?.Server?.Active == true, "garbage keeps the last good push");
|
||||
}
|
||||
|
||||
private static void FeatureRoundTrip()
|
||||
{
|
||||
// The older "iltfeatures" text form (W / R / F lines) still parses.
|
||||
const string payload =
|
||||
"W\tInfinite Leaftide\n" +
|
||||
"R\tprobe\t12:00:00\t0\t1\n" +
|
||||
"F\tbank\t1\n" +
|
||||
"F\tpowerball\t0\n" +
|
||||
"F\tcharm:guardianhand\t-1\n" +
|
||||
"F\tclamped\t5\n";
|
||||
IltFeatureView? f = IltSettingsModel.ParseFeatures(payload);
|
||||
Check.True(f != null, "parsed");
|
||||
Check.Eq(f!.World, "Infinite Leaftide", "world");
|
||||
Check.Eq(f.Source, "probe", "source");
|
||||
Check.Eq(f.LastCheck, "12:00:00", "last check");
|
||||
Check.True(f.IltLike, "ilt-like");
|
||||
Check.False(f.Checking, "not checking");
|
||||
Check.Eq(f.Features.Length, 4, "every feature");
|
||||
Check.Eq(f.Features.Single(k => k.Key == "bank").Value, 1, "on");
|
||||
Check.Eq(f.Features.Single(k => k.Key == "powerball").Value, 0, "off");
|
||||
Check.Eq(f.Features.Single(k => k.Key == "charm:guardianhand").Value, -1, "unknown");
|
||||
Check.Eq(f.Features.Single(k => k.Key == "clamped").Value, 1, "out-of-range value clamped");
|
||||
Check.Eq(IltSettingsModel.StateText(0), "off", "0 is off (not unknown)");
|
||||
Check.Eq(IltSettingsModel.StateText(-1), "unknown", "-1 is unknown");
|
||||
|
||||
// The Hub's own read is published as a whole snapshot; null clears it.
|
||||
var model = new IltSettingsModel();
|
||||
var read = new IltFeatureView("Infinite Leaftide", "dump", "", Checking: true, IltLike: true,
|
||||
new[] { new KeyValuePair<string, int>("bank", 1) });
|
||||
model.PublishFeatures(read);
|
||||
Check.True(ReferenceEquals(model.Features, read), "published as is");
|
||||
model.PublishFeatures(null);
|
||||
Check.True(model.Features == null, "cleared while there is no Hub");
|
||||
Check.Eq(IltSettingsModel.StateText(1), "on", "1 is on");
|
||||
Check.Eq(IltSettingsModel.StateText(0), "off", "0 is off (not unknown)");
|
||||
Check.Eq(IltSettingsModel.StateText(-1), "unknown", "-1 is unknown");
|
||||
}
|
||||
|
||||
private static void EngineVerdict()
|
||||
|
|
@ -86,13 +114,13 @@ internal static class IltSettingsTests
|
|||
try
|
||||
{
|
||||
IltEngineVerdict.Attach(model);
|
||||
Check.False(IltEngineVerdict.Pushed, "nothing sent yet");
|
||||
Check.False(IltEngineVerdict.Pushed, "nothing pushed yet");
|
||||
Check.True(IltEngineVerdict.Active == null, "no verdict: RynthILT's own list decides");
|
||||
model.ApplyServerState(EngineServerState.Parse(State));
|
||||
Check.True(IltEngineVerdict.Pushed, "sent");
|
||||
model.ApplyEngine(Push);
|
||||
Check.True(IltEngineVerdict.Pushed, "pushed");
|
||||
Check.True(IltEngineVerdict.Active == true, "RynthCore says ILT");
|
||||
model.ApplyServerState(EngineServerState.Parse(NoIltState));
|
||||
Check.True(IltEngineVerdict.Pushed && IltEngineVerdict.Active == null, "a list without ILT gives no ILT verdict");
|
||||
model.ApplyEngine("V\taelrynth\tAelrynth\t1\tauto\t1\tx\n");
|
||||
Check.True(IltEngineVerdict.Pushed && IltEngineVerdict.Active == null, "a push without ILT gives no ILT verdict");
|
||||
model.Clear();
|
||||
Check.False(IltEngineVerdict.Pushed, "logout forgets it");
|
||||
}
|
||||
|
|
@ -105,7 +133,6 @@ internal static class IltSettingsTests
|
|||
Check.Eq(IltSettingsModel.ForceCommand("on"), "/rc server ilt on", "on");
|
||||
Check.Eq(IltSettingsModel.ForceCommand("auto"), "/rc server ilt auto", "auto");
|
||||
Check.Eq(IltSettingsModel.ForceCommand("maybe"), "", "unknown mode sends nothing");
|
||||
Check.Eq(IltSettingsModel.NamesListCommand, "/rc server names ilt", "the names are listed by RynthCore");
|
||||
|
||||
Check.Eq(IltSettingsModel.NamesCommand(true, " *Frost* ", out _), "/rc server names ilt add *Frost*", "add, trimmed");
|
||||
Check.Eq(IltSettingsModel.NamesCommand(false, "Infinite Leaftide", out _), "/rc server names ilt remove Infinite Leaftide", "remove");
|
||||
|
|
@ -119,8 +146,8 @@ internal static class IltSettingsTests
|
|||
private static void ClearOnLogout()
|
||||
{
|
||||
var model = new IltSettingsModel();
|
||||
model.ApplyServerState(EngineServerState.Parse(State));
|
||||
model.PublishFeatures(new IltFeatureView("w", "", "", false, true, Array.Empty<KeyValuePair<string, int>>()));
|
||||
model.ApplyEngine(Push);
|
||||
model.ApplyFeatures("F\tbank\t1\n");
|
||||
Check.True(model.Engine != null && model.Features != null, "both copies");
|
||||
model.Clear();
|
||||
Check.True(model.Engine == null && model.Features == null, "cleared");
|
||||
|
|
|
|||
|
|
@ -32,9 +32,8 @@ internal static class MoveTests
|
|||
r.Add("move: the interface structs have the agreed layout", InterfaceLayout);
|
||||
r.Add("move: server-list status lines", DescribeLines);
|
||||
r.Add("move: off ILT nothing is sent, no tab or section shows; on ILT the login probe runs", DormantOffIlt);
|
||||
r.Add("move: the charms JSON for RynthILT.Data readers carries the Guardian Hands", CharmsReaderJson);
|
||||
r.Add("move: Character redirects to RynthOracle; Charms and Banking stay RynthILT's tabs", MovedSections);
|
||||
r.Add("sections: RynthILT's manifest (rates, /fship, /qb) is valid schema-1 JSON with its own surfaces", SectionsManifest);
|
||||
r.Add("move: Character / Charms / Banking redirect to RynthOracle and Global Inventory", MovedSections);
|
||||
r.Add("move: the charms JSON RynthOracle reads carries the Guardian Hands", CharmsReaderJson);
|
||||
// Last: Release() switches the table off for the rest of the process.
|
||||
r.Add("move: the RynthILT.Hub table: query, functions, release", HubTable);
|
||||
}
|
||||
|
|
@ -365,8 +364,8 @@ internal static class MoveTests
|
|||
Check.Eq(sizeof(IltTabV1), 24 + 32 + 4 + 4 + 4, "IltTabV1: id, label, width, height, flags");
|
||||
Check.Eq((int)Marshal.OffsetOf<IltTabV1>(nameof(IltTabV1.Flags)), 64, "IltTabV1.Flags offset");
|
||||
Check.Eq(sizeof(RynthIltHubApiV1), 8 + 9 * IntPtr.Size, "RynthIltHubApiV1: header + 9 functions");
|
||||
// SessionStatsMore was appended (2026-10-13); readers accept any table at least
|
||||
// BaseStructSize long, so an older RynthAi still connects.
|
||||
// 10 functions in the first release, then SessionStatsMore appended (2026-10-13); readers accept
|
||||
// any table at least BaseStructSize long, so an older RynthAi still connects.
|
||||
Check.Eq(sizeof(RynthAiHubApiV1), 8 + 11 * IntPtr.Size, "RynthAiHubApiV1: header + 11 functions");
|
||||
Check.Eq((int)RynthAiHubApiV1.BaseStructSize, 8 + 10 * IntPtr.Size, "RynthAiHubApiV1.BaseStructSize: the first release's 10 functions");
|
||||
Check.Eq(RynthAiHubApiV1.SessionStatsMoreOffset, (int)RynthAiHubApiV1.BaseStructSize, "SessionStatsMore right after the base table");
|
||||
|
|
@ -401,6 +400,21 @@ internal static class MoveTests
|
|||
while (DateTime.UtcNow < until) { hub.Tick(); System.Threading.Thread.Sleep(50); }
|
||||
}
|
||||
|
||||
/// <summary>The Mini Remote tabs that moved out (2026-10-13) map to their new homes' commands.</summary>
|
||||
private static void MovedSections()
|
||||
{
|
||||
Check.Eq(IltSections.MovedCommand(IltSection.Character), IltSections.OracleCharacterCommand, "Character -> RynthOracle Character");
|
||||
Check.Eq(IltSections.MovedCommand(IltSection.Charms), IltSections.OracleCharacterCommand, "Charms -> RynthOracle Character");
|
||||
Check.Eq(IltSections.MovedCommand(IltSection.Banking), IltSections.GlobalBankCommand, "Banking -> Global Inventory Banking");
|
||||
Check.True(IltSections.MovedCommand(IltSection.Gear) == null && IltSections.MovedCommand(IltSection.Games) == null,
|
||||
"Gear and Games are still Mini Remote tabs");
|
||||
Check.True(IltSections.Tabs.SequenceEqual(new[] { IltSection.Gear, IltSection.Games }), "the tab list is Gear, Games");
|
||||
foreach (var moved in new[] { IltSection.Character, IltSection.Charms, IltSection.Banking })
|
||||
Check.False(IltSections.IsTab(moved), $"{IltSections.Label(moved)} isn't a tab");
|
||||
Check.Eq(IltSections.OracleCharacterCommand, "/ro character", "Oracle command");
|
||||
Check.Eq(IltSections.GlobalBankCommand, "/ginv bank", "Global Inventory command");
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// The charms JSON behind "RynthILT.Data" is valid JSON; on ILT it has a "hands" array (empty
|
||||
/// with no hand carried) that the shared reader parses, off ILT it has none and still parses.
|
||||
|
|
@ -428,48 +442,6 @@ internal static class MoveTests
|
|||
Check.True(IltCharmsView.Parse(offJson).Hands.Count == 0, "and the reader shows none");
|
||||
}
|
||||
|
||||
/// <summary>The Character tab moved out (2026-10-13); every other ILT tab is still RynthILT's.</summary>
|
||||
private static void MovedSections()
|
||||
{
|
||||
Check.Eq(IltSections.MovedCommand(IltSection.Character), IltSections.OracleCharacterCommand, "Character -> RynthOracle Character");
|
||||
foreach (var kept in new[] { IltSection.Banking, IltSection.Gear, IltSection.Charms, IltSection.Games })
|
||||
{
|
||||
Check.True(IltSections.MovedCommand(kept) == null, $"{IltSections.Label(kept)} is still RynthILT's");
|
||||
Check.True(IltSections.IsTab(kept), $"{IltSections.Label(kept)} is a Mini Remote tab");
|
||||
}
|
||||
Check.True(IltSections.Tabs.SequenceEqual(new[] { IltSection.Banking, IltSection.Gear, IltSection.Charms, IltSection.Games }),
|
||||
"the tab list is Banking, Gear, Charms, Games");
|
||||
Check.False(IltSections.IsTab(IltSection.Character) || IltSections.IsTab(IltSection.Guardian), "Character and the Guardian aren't tabs");
|
||||
Check.True(IltSections.TryParse("char", out IltSection c) && c == IltSection.Character, "old Character names still parse (for the redirect)");
|
||||
Check.Eq(IltSections.OracleCharacterCommand, "/ro character", "Oracle command");
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// RynthILT's RynthPluginGetSectionsJson: schema 1 (UI/Sections/SectionManifest.cs in RynthCore),
|
||||
/// every view an ILT one, each surface one RenderEmbed answers.
|
||||
/// </summary>
|
||||
private static void SectionsManifest()
|
||||
{
|
||||
using var doc = System.Text.Json.JsonDocument.Parse(RynthILTPlugin.SectionsJson);
|
||||
var root = doc.RootElement;
|
||||
Check.Eq(root.GetProperty("version").GetInt32(), 1, "schema 1");
|
||||
var sections = root.GetProperty("sections");
|
||||
Check.Eq(sections.GetArrayLength(), 1, "one section of RynthILT's own");
|
||||
Check.Eq(sections[0].GetProperty("id").GetString(), "quests", "a Quests section (the /qb list)");
|
||||
var surfaces = new System.Collections.Generic.List<string>();
|
||||
foreach (var c in root.GetProperty("contributions").EnumerateArray())
|
||||
{
|
||||
Check.Eq(c.GetProperty("server").GetString(), "ilt", "an Infinite Leaftide view");
|
||||
surfaces.Add(c.GetProperty("surface").GetString() ?? "");
|
||||
}
|
||||
Check.True(surfaces.SequenceEqual(new[] { RynthILTPlugin.RatesSurface, RynthILTPlugin.FellowshipSurface, RynthILTPlugin.QuestBonusSurface }),
|
||||
"rates, fellowship, quest bonus: " + string.Join(",", surfaces));
|
||||
Check.True(surfaces.All(s => s.StartsWith("section:ilt-", StringComparison.Ordinal) && s.Length <= 64), "short section:ilt-* surfaces");
|
||||
Check.True(RynthILTPlugin.SectionsJson.All(ch => ch < 128), "ASCII only");
|
||||
Check.True(RynthILTPlugin.IsParsedRemoteAction("servermenu") && RynthILTPlugin.IsParsedRemoteAction("ServerMenu")
|
||||
&& !RynthILTPlugin.IsParsedRemoteAction("prog"), "RynthCore's servermenu push is answered, never queued as a verb");
|
||||
}
|
||||
|
||||
private static void DormantOffIlt()
|
||||
{
|
||||
var off = NewHub("Aeshnidae", "dormant");
|
||||
|
|
@ -492,11 +464,10 @@ internal static class MoveTests
|
|||
Check.True(RynthCore.RynthAiHostTests.Fakes.FakeHost.ChatCommands.Count > 0, "on ILT the login probe asks the server");
|
||||
Check.False(RynthCore.RynthAiHostTests.Fakes.FakeHost.ChatCommands.Any(c => c.Contains("/ilt features", StringComparison.OrdinalIgnoreCase)),
|
||||
"the server is never asked for a feature list (the ILT profile is Rynth-side)");
|
||||
// Character moved out of the Mini Remote (RynthOracle's Character tab, Session Stats);
|
||||
// Charms and Banking are Infinite Leaftide's own screens and stay RynthILT's tabs.
|
||||
Check.False(on.TabShown(IltSection.Character), "Character is no Mini Remote tab any more");
|
||||
// Character, Charms and Banking moved out of the Mini Remote (RynthOracle / Global Inventory).
|
||||
foreach (var moved in new[] { IltSection.Character, IltSection.Charms, IltSection.Banking })
|
||||
Check.False(on.TabShown(moved), $"{IltSections.Label(moved)} is no Mini Remote tab any more");
|
||||
Check.Eq(on.TabShown(IltSection.Gear), on.Available, "Gear shows once the server features are known");
|
||||
Check.Eq(on.TabShown(IltSection.Charms), on.Available, "Charms too");
|
||||
on.OnLogout();
|
||||
|
||||
var forced = NewHub("Aeshnidae", "forced");
|
||||
|
|
|
|||
|
|
@ -39,15 +39,12 @@ internal static class Program
|
|||
SigilChainTests.Register(runner);
|
||||
BankCommandTests.Register(runner);
|
||||
MoveTests.Register(runner);
|
||||
ChunkTests.Register(runner);
|
||||
ProfileTests.Register(runner);
|
||||
FeatureCatalogTests.Register(runner);
|
||||
IltSettingsTests.Register(runner);
|
||||
FellowshipCommandTests.Register(runner);
|
||||
AetheriaChunkTests.Register(runner);
|
||||
RingChainTests.Register(runner);
|
||||
// Before DataApiTests: its last test releases the RynthILT.Data table, which the breeding version test queries.
|
||||
BreedingTests.Register(runner);
|
||||
// Last: its table test calls DataInterface.Release(), which switches the table off for the rest of the run.
|
||||
DataApiTests.Register(runner);
|
||||
return runner.Run("RynthILT tests", args.Length > 0 ? args[0] : null);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -35,6 +35,9 @@
|
|||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<!-- ILT's /fship commands: RynthILT's list and the shared "servercommands" format (both in the
|
||||
plugin above) checked against RynthAi's store for them. -->
|
||||
<Compile Include="..\..\Plugins\RynthCore.Plugin.RynthAi\Huds\ServerCommandModel.cs" Link="RynthAi\ServerCommandModel.cs" />
|
||||
<!-- The RynthAi test tools' check/runner harness and fake engine host (no plugin code in them). -->
|
||||
<Compile Include="..\RynthCore.RynthAiTests\Harness\Check.cs" Link="Harness\Check.cs" />
|
||||
<Compile Include="..\RynthCore.RynthAiTests\Harness\Runner.cs" Link="Harness\Runner.cs" />
|
||||
|
|
|
|||
|
|
@ -64,6 +64,8 @@ namespace RynthInventory.Tests
|
|||
Run("scheduler: unchanged content is not rewritten", SchedulerUnchanged);
|
||||
Run("window display lists parse in the engine", Pages);
|
||||
Run("window events", Events);
|
||||
Run("banking: roster, totals and amounts", BankRosterTests);
|
||||
Run("banking: the tab draws and sends RynthILT's verbs", BankingTab);
|
||||
Run("vault feed (/mule-data)", VaultTests);
|
||||
}
|
||||
finally
|
||||
|
|
@ -633,6 +635,103 @@ namespace RynthInventory.Tests
|
|||
ParseAll(host, "after forget", out _);
|
||||
}
|
||||
|
||||
// ── Banking (the Mini Remote's Banking tab moved here 2026-10-13) ───
|
||||
|
||||
/// <summary>RynthILT's bank JSON for the sample index: Buffy (here) and Ghost (another account, no inventory file).</summary>
|
||||
private const string BankJson = "{\"available\":true,\"enabled\":1,\"world\":\"Aelrynth\",\"character\":\"Buffy\","
|
||||
+ "\"characters\":[{\"name\":\"Buffy\",\"current\":true,\"pyreals\":100,\"luminance\":2000,\"legendaryKeys\":1,\"mythicalKeys\":0,"
|
||||
+ "\"enlightenedCoins\":3,\"weaklyEnlightenedCoins\":0,\"prestigeCoins\":0,\"updated\":\"2026-10-03T11:00:00Z\"},"
|
||||
+ "{\"name\":\"Ghost\",\"current\":false,\"pyreals\":50,\"luminance\":0,\"legendaryKeys\":2,\"mythicalKeys\":1,"
|
||||
+ "\"enlightenedCoins\":0,\"weaklyEnlightenedCoins\":4,\"prestigeCoins\":5,\"updated\":\"2026-10-01T11:00:00Z\"}],"
|
||||
+ "\"deposits\":[\"Everything\",\"Pyreals\"],\"withdrawals\":[{\"label\":\"Pyreals\",\"notes\":false},{\"label\":\"Trade notes\",\"notes\":true}],"
|
||||
+ "\"transfers\":[{\"label\":\"Pyreals\",\"notes\":false}],\"notes\":[{\"label\":\"MMD\",\"value\":250000}],"
|
||||
+ "\"result\":\"Deposited everything.\",\"transactions\":[{\"when\":\"2026-10-03 11:30\",\"type\":\"Sent\",\"amount\":10,\"currency\":\"Pyreals\",\"player\":\"Willow\"}]}";
|
||||
|
||||
private static void BankRosterTests()
|
||||
{
|
||||
InventoryIndex index = SampleIndex(out _);
|
||||
var bank = RynthCore.Plugin.Shared.IltBankView.Parse(BankJson);
|
||||
List<BankRosterEntry> roster = BankRoster.Build(bank, index);
|
||||
Eq(string.Join(",", roster.Select(e => e.Name)), "Buffy,Ghost,Willow", "you first, then by name; Conquest's characters left out");
|
||||
Check(roster[0].Current && roster[0].Bank != null && roster[0].Account == "tom", "Buffy: RynthILT's balance and the inventory's account");
|
||||
Check(roster[1].Bank != null && roster[1].Account == "", "Ghost: only RynthILT knows it (another account on this PC)");
|
||||
Check(roster[2].Bank == null && roster[2].Account == "tom", "Willow: in the inventory, no bank read yet");
|
||||
var total = BankRoster.Totals(roster);
|
||||
Check(total.Pyreals == 150 && total.Luminance == 2000 && total.LegendaryKeys == 3 && total.PrestigeCoins == 5, "totals add every balance");
|
||||
|
||||
Eq(BankRoster.Build(RynthCore.Plugin.Shared.IltBankView.None, null).Count, 0, "nothing without RynthILT or the index");
|
||||
var noWorld = RynthCore.Plugin.Shared.IltBankView.Parse("{\"available\":true,\"characters\":[]}");
|
||||
Eq(string.Join(",", BankRoster.Build(noWorld, index).Select(e => e.Name)), "Buffy,Willow", "no world named: the server you're on");
|
||||
|
||||
Eq(BankRoster.ParseAmount("1,000"), 1000L, "commas allowed");
|
||||
Eq(BankRoster.ParseAmount(" 25 "), 25L, "spaces trimmed");
|
||||
foreach (string bad in new[] { "", "0", "-5", "1.5", "abc", "1e6" })
|
||||
Eq(BankRoster.ParseAmount(bad), 0L, $"'{bad}' isn't an amount");
|
||||
}
|
||||
|
||||
private static void BankingTab()
|
||||
{
|
||||
InventoryContext c = Context(false);
|
||||
var sent = new List<string>();
|
||||
c.BankCommand = v => { sent.Add(v); return true; };
|
||||
var view = new InventoryView(c);
|
||||
var host = new UiHost();
|
||||
UiWindow w = host.Add(new UiWindow("RynthInventory/Main", "Global Inventory") { Visible = true });
|
||||
|
||||
// Without RynthILT the tab button stays hidden; /ginv bank still opens it and says why.
|
||||
Draw(w, view);
|
||||
Check(!BodyText(w).Contains("###tab.bank"), "no Banking button without RynthILT");
|
||||
view.ShowBanking();
|
||||
Draw(w, view);
|
||||
Check(BodyText(w).Contains("Load RynthILT"), "asked for: says RynthILT is needed");
|
||||
w.MarkSubmitted(true);
|
||||
|
||||
c.Bank = RynthCore.Plugin.Shared.IltBankView.Parse(BankJson);
|
||||
view.Tab = InventoryView.TabSearch;
|
||||
Draw(w, view);
|
||||
Check(BodyText(w).Contains("###tab.bank"), "the Banking button shows on an ILT world");
|
||||
Apply(host, Event(1, 1, w.Hash, w.KeyOf("tab.bank"), new byte[] { 1, 0 }));
|
||||
Check(view.Tab == InventoryView.TabBanking, "a click opens it");
|
||||
Draw(w, view);
|
||||
ParseAll(host, "banking tab", out int ops);
|
||||
string body = BodyText(w);
|
||||
Check(ops > 5 && ops <= 1500, $"banking tab: {ops} ops");
|
||||
Check(body.Contains("Buffy (you)") && body.Contains("Ghost") && body.Contains("Willow") && !body.Contains("Spike"),
|
||||
"every character on this server, none from another");
|
||||
Check(body.Contains("not read yet"), "a character without a balance says so");
|
||||
Check(body.Contains("150") && body.Contains("Deposited everything."), "the total and RynthILT's last reply");
|
||||
|
||||
Apply(host, Event(1, 2, w.Hash, w.KeyOf("b.dep.go"), new byte[] { 1, 0 }));
|
||||
Eq(sent.LastOrDefault(), "deposit 0", "Deposit sends the chosen deposit");
|
||||
|
||||
Apply(host, Event(5, 3, w.Hash, w.KeyOf("b.wd.amt"), TextPayload("5")));
|
||||
Draw(w, view);
|
||||
Apply(host, Event(1, 4, w.Hash, w.KeyOf("b.wd.go"), new byte[] { 1, 0 }));
|
||||
Eq(sent.LastOrDefault(), "withdraw 0 5 0", "Withdraw sends currency, amount and note");
|
||||
|
||||
// A transfer asks first; only "Yes, send" sends it.
|
||||
Apply(host, Event(5, 5, w.Hash, w.KeyOf("b.tx.amt"), TextPayload("1,000")));
|
||||
Apply(host, Event(5, 6, w.Hash, w.KeyOf("b.tx.to"), TextPayload("Willow")));
|
||||
Draw(w, view);
|
||||
int before = sent.Count;
|
||||
Apply(host, Event(1, 7, w.Hash, w.KeyOf("b.tx.go"), new byte[] { 1, 0 }));
|
||||
Check(sent.Count == before, "one click doesn't transfer");
|
||||
Draw(w, view);
|
||||
Check(BodyText(w).Contains("Send 1,000 Pyreals to Willow?"), "it asks, naming amount and recipient");
|
||||
Apply(host, Event(1, 8, w.Hash, w.KeyOf("b.tx.yes"), new byte[] { 1, 0 }));
|
||||
Eq(sent.LastOrDefault(), "transfer 0 1000 0 Willow", "confirmed: the transfer verb");
|
||||
|
||||
// A bad amount is refused here, nothing sent.
|
||||
Apply(host, Event(5, 9, w.Hash, w.KeyOf("b.wd.amt"), TextPayload("lots")));
|
||||
Draw(w, view);
|
||||
before = sent.Count;
|
||||
Apply(host, Event(1, 10, w.Hash, w.KeyOf("b.wd.go"), new byte[] { 1, 0 }));
|
||||
Check(sent.Count == before, "a bad amount isn't sent");
|
||||
Draw(w, view);
|
||||
Check(BodyText(w).Contains("Type a whole number"), "and it says why");
|
||||
ParseAll(host, "banking after actions", out _);
|
||||
}
|
||||
|
||||
// ── Helpers ─────────────────────────────────────────────────────────
|
||||
|
||||
private static void Draw(UiWindow w, InventoryView view)
|
||||
|
|
|
|||
|
|
@ -31,6 +31,8 @@
|
|||
<Compile Include="..\..\..\RynthCore\src\RynthCore.Engine\UI\ScriptWindows\DisplayListParser.cs" Link="Engine\DisplayListParser.cs" />
|
||||
<!-- The plugin links this one from Plugins/Shared (the glob above only covers the plugin's folder). -->
|
||||
<Compile Include="..\..\Plugins\Shared\ChatSource.cs" Link="Shared\ChatSource.cs" />
|
||||
<!-- RynthILT's "RynthILT.Data" reader: the Banking tab's bank view and verbs. -->
|
||||
<Compile Include="..\..\Plugins\Shared\RynthIltDataApi.cs" Link="Shared\RynthIltDataApi.cs" />
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
|
|
|
|||
|
|
@ -400,6 +400,13 @@ internal static partial class Program
|
|||
Check(atlas.Search("glimmering cave", null, 50).Count == 1, "case-insensitive");
|
||||
Check(atlas.Search("cave glimmering", null, 50).Count == 1, "every word, any order");
|
||||
|
||||
// "a || b || c" (Oracle's Dynamic Stamps): the first candidate on the map, whole words only.
|
||||
Check(atlas.FirstOnMap("8.8S, 53.1E || Holtburg", false, 0, 0) == "8.8S, 53.1E", "coordinates first");
|
||||
Check(atlas.FirstOnMap("Nowhere Keep || Holtburg || Glimmering Cave", false, 0, 0) == "Holtburg", "the first place on the map");
|
||||
Check(atlas.FirstOnMap("Cave Hermit || Holtburg", false, 0, 0) == "Holtburg", "a place with no map position is skipped");
|
||||
Check(atlas.FirstOnMap("olt || Holtburg", false, 0, 0) == "Holtburg", "inside a word ('olt' in Holtburg) doesn't count");
|
||||
Check(atlas.FirstOnMap("zzz || qqq", false, 0, 0) == null, "none on the map");
|
||||
|
||||
var p2 = atlas.ById(2)!;
|
||||
Check(p2.HasDest && p2.DestOnMap, "portal destination");
|
||||
Near(p2.DestNs, 42.08, 1e-9, "portal destination NS");
|
||||
|
|
|
|||
92
Tools/RynthOracle.QuestPackGen/Make-DynamicStamps.ps1
Normal file
92
Tools/RynthOracle.QuestPackGen/Make-DynamicStamps.ps1
Normal file
|
|
@ -0,0 +1,92 @@
|
|||
<#
|
||||
Make-DynamicStamps.ps1 - rebuilds RynthOracle's Resources\dynstamps.csv (the Dynamic Stamps tab,
|
||||
Infinite Leaftide) from the players' "ExtraDyn" Google sheet (one sheet per area; the
|
||||
leaftidewiki Dynamic Stamps page needs a login, the sheet doesn't).
|
||||
|
||||
Each area sheet: "Town NPCs, Stamp, Reward, Korwith, Korwith II, Notes". A row with only the
|
||||
first column is a sub-area heading (Frost Haven, Dark Isle). The first column of a stamp row is
|
||||
the place when the reward reads "X gives you Y" (X is the NPC), else it is the NPC. Rows without
|
||||
a Dynamic_ stamp (NO STAMP, duplicates) are skipped; a stamp is kept once.
|
||||
|
||||
Run: .\Make-DynamicStamps.ps1 (writes ..\..\Plugins\RynthCore.Plugin.RynthOracle\Resources\dynstamps.csv)
|
||||
.\Make-DynamicStamps.ps1 -Xlsx path\to\ExtraDyn.xlsx (use a downloaded copy)
|
||||
#>
|
||||
param(
|
||||
[string]$SheetId = "1SyG2GDjZ0CoS2URFPMcUnI8R0geh03KkYzRYzsPhJGg",
|
||||
[string]$Xlsx = "",
|
||||
[string]$Dst = (Join-Path $PSScriptRoot "..\..\Plugins\RynthCore.Plugin.RynthOracle\Resources\dynstamps.csv")
|
||||
)
|
||||
$ErrorActionPreference = "Stop"
|
||||
Add-Type -AssemblyName System.IO.Compression.FileSystem
|
||||
|
||||
if (-not $Xlsx) {
|
||||
$Xlsx = Join-Path $env:TEMP "ExtraDyn.xlsx"
|
||||
Invoke-WebRequest -UseBasicParsing "https://docs.google.com/spreadsheets/d/$SheetId/export?format=xlsx" -OutFile $Xlsx -TimeoutSec 120
|
||||
}
|
||||
|
||||
# Areas in list order (the workbook's tab order, Odd Stamps after Looking Around).
|
||||
$order = "Facility Hub","Looking Around","Odd Stamps","Odd Stamps 2","Bandit Castle","Bur","Gear Knight","Wai Jhou","Rynthid",
|
||||
"Paradox Camp","Graveyard","Neftet","Frozen Valley","Hoshino Tent","Viridian Rise","Ayan","Candeth Keep"
|
||||
|
||||
# ── Read every sheet's rows (cells by column) out of the .xlsx ──────────────────
|
||||
$zip = [System.IO.Compression.ZipFile]::OpenRead($Xlsx)
|
||||
function ReadXml($name) {
|
||||
$e = $zip.GetEntry($name); if (-not $e) { return $null }
|
||||
$sr = New-Object IO.StreamReader($e.Open()); $t = $sr.ReadToEnd(); $sr.Close(); [xml]$t
|
||||
}
|
||||
$strings = @()
|
||||
$ss = ReadXml "xl/sharedStrings.xml"
|
||||
if ($ss) { foreach ($si in $ss.sst.si) { $strings += $si.InnerText } }
|
||||
$wb = ReadXml "xl/workbook.xml"
|
||||
$rels = ReadXml "xl/_rels/workbook.xml.rels"
|
||||
$relMap = @{}; foreach ($r in $rels.Relationships.Relationship) { $relMap[$r.Id] = $r.Target }
|
||||
$sheets = @{}
|
||||
foreach ($s in $wb.workbook.sheets.sheet) {
|
||||
$rid = $s.GetAttribute("id", "http://schemas.openxmlformats.org/officeDocument/2006/relationships")
|
||||
$sx = ReadXml ("xl/" + ($relMap[$rid] -replace '^/xl/', ''))
|
||||
$rows = New-Object System.Collections.Generic.List[object]
|
||||
foreach ($row in $sx.worksheet.sheetData.row) {
|
||||
$cells = @{}
|
||||
foreach ($c in $row.c) {
|
||||
$idx = 0; foreach ($ch in (($c.r -replace '\d', '')).ToCharArray()) { $idx = $idx * 26 + ([int]$ch - 64) }
|
||||
$v = if ($c.t -eq "s") { $strings[[int]$c.v] } elseif ($c.t -eq "inlineStr") { $c.is.InnerText } else { $c.v }
|
||||
if ($v) { $cells[$idx] = ($v -replace "`r?`n", " / ") }
|
||||
}
|
||||
if ($cells.Count -gt 0) { $rows.Add($cells) }
|
||||
}
|
||||
$sheets[$s.name] = $rows
|
||||
}
|
||||
$zip.Dispose()
|
||||
|
||||
# ── Build the stamp rows ────────────────────────────────────────────────────────
|
||||
$enDash = [string][char]0x2013; $emDash = [string][char]0x2014; $arrow = [string][char]0x2192
|
||||
function Clean([string]$s) { if (-not $s) { return "" }; ($s.Replace($enDash, "-").Replace($emDash, "-").Replace($arrow, "->")).Trim() }
|
||||
function Q([string]$s) { '"' + ($s -replace '"', '""') + '"' }
|
||||
$coordRx = '\d{1,3}(?:\.\d)?\s*[NSns][,\s]+\d{1,3}(?:\.\d)?\s*[EWew]'
|
||||
|
||||
$out = New-Object System.Collections.Generic.List[string]
|
||||
$out.Add("Area,Place,Npc,Reward,Stamp,Note")
|
||||
$seen = @{}; $skipped = 0
|
||||
foreach ($area in $order) {
|
||||
if (-not $sheets.ContainsKey($area)) { Write-Warning "sheet '$area' not in the workbook"; continue }
|
||||
$place = ""
|
||||
foreach ($cells in ($sheets[$area] | Select-Object -Skip 1)) { # row 1 is the header
|
||||
$a = ((Clean $cells[1]) -replace '\s*-+\s*$', '').Trim()
|
||||
$stamp = Clean $cells[2]; $rew = Clean $cells[3]; $note = Clean $cells[6]
|
||||
if ($a -and -not $stamp -and -not $rew) { $place = $a; continue }
|
||||
if ($stamp -notmatch '(?i)^dynamic_\d+_\S+') { $skipped++; continue }
|
||||
$key = $stamp.ToLowerInvariant()
|
||||
if ($seen.ContainsKey($key)) { continue }
|
||||
$seen[$key] = 1
|
||||
$npc = ""; $reward = $rew
|
||||
if ($rew -match '^(?<n>.+?) gives you (?<r>.+?)\.?\s*$') { $npc = $Matches.n; $reward = $Matches.r }
|
||||
elseif ($rew -match '^You allow (?<n>.+?) to examine your (?<r>.+?)\.?\s*$') { $npc = $Matches.n; $reward = "examines your " + $Matches.r }
|
||||
$rowPlace = $place
|
||||
if ($a) { if ($npc) { $rowPlace = $a } else { $npc = $a } }
|
||||
$cm = [regex]::Match($rowPlace, $coordRx)
|
||||
if ($cm.Success -and $note.IndexOf($cm.Value) -lt 0) { $note = ($cm.Value + " " + $note).Trim() }
|
||||
$out.Add(((Q $area), (Q $rowPlace), (Q $npc), (Q $reward.TrimEnd('.').Trim()), (Q $stamp), (Q $note)) -join ",")
|
||||
}
|
||||
}
|
||||
[IO.File]::WriteAllLines([IO.Path]::GetFullPath($Dst), $out, (New-Object Text.UTF8Encoding($false)))
|
||||
"dynstamps.csv: $($out.Count - 1) stamps ($skipped rows without a stamp skipped) -> $([IO.Path]::GetFullPath($Dst))"
|
||||
|
|
@ -9,6 +9,7 @@ using RynthCore.Plugin.RynthOracle;
|
|||
using RynthCore.Plugin.RynthOracle.Data;
|
||||
using RynthCore.Plugin.RynthOracle.Ui;
|
||||
using RynthCore.Plugin.RynthOracle.Views;
|
||||
using IltBreedingView = RynthCore.Plugin.Shared.IltBreedingView;
|
||||
|
||||
// The engine parser's only outside dependency: the registry's limits (the engine's values).
|
||||
namespace RynthCore.Engine.UI.ScriptWindows
|
||||
|
|
@ -44,12 +45,15 @@ namespace RynthOracle.Tests
|
|||
Catalog();
|
||||
Servers();
|
||||
EngineServers();
|
||||
IltProfile();
|
||||
QuestNotes();
|
||||
ConquestReplies();
|
||||
AelrynthReplies();
|
||||
Void();
|
||||
Pages();
|
||||
CharacterExtras();
|
||||
Breeding();
|
||||
Trackers();
|
||||
Events();
|
||||
Console.WriteLine($"{_pass} passed, {_fail} failed");
|
||||
return _fail == 0 ? 0 : 1;
|
||||
|
|
@ -61,6 +65,145 @@ namespace RynthOracle.Tests
|
|||
else { _fail++; Console.WriteLine("FAIL: " + what); }
|
||||
}
|
||||
|
||||
/// <summary>The Legendary tab's list (legendary.csv) and its have / missing / timer rules.</summary>
|
||||
private static void Legendary()
|
||||
{
|
||||
Check(LegendaryList.All.Count == 40, $"legendary quests: {LegendaryList.All.Count} (40 expected)");
|
||||
Check(LegendaryList.Groups.SequenceEqual(new[] { "Graveyard", "Rynthid", "Hoshino", "Frozen Valley", "Neftet", "Random Locations" }),
|
||||
"legendary groups: " + string.Join(",", LegendaryList.Groups));
|
||||
Check(LegendaryList.All.All(q => q.Flags.Length > 0 && q.Luminance > 0), "every legendary quest has a flag and luminance");
|
||||
var catalog = new QuestCatalog();
|
||||
catalog.Load("", _ => { });
|
||||
var unknown = LegendaryList.All.SelectMany(q => q.Flags).Where(f => !catalog.TryGet(f, out _)).ToList();
|
||||
Check(unknown.Count == 0, "every legendary flag is a known quest flag: " + string.Join(",", unknown));
|
||||
LegendaryQuest rtw = LegendaryList.All.First(q => q.CommonName == "RTW");
|
||||
Check(rtw.Flags[0] == "rtwcompleted_1013" && rtw.Label == "Defeating the Curator of Torment (RTW)", "RTW row: " + rtw.Label);
|
||||
|
||||
var lf = new QuestFlagStore();
|
||||
long t = 900_000;
|
||||
long done = DateTimeOffset.UtcNow.AddHours(-2).ToUnixTimeSeconds();
|
||||
long old = DateTimeOffset.UtcNow.AddDays(-3).ToUnixTimeSeconds();
|
||||
// RTW done 2 h ago on a 20 h timer; End of Days done 3 days ago (ready); Lugian Assault never.
|
||||
lf.OnChatLine($"rtwcompleted_1013 - 4 solves ({done})\"RTW\" -1 72000", t);
|
||||
lf.OnChatLine($"eodcompleted_1013 - 1 solves ({old})\"EoD\" -1 72000", t + 1);
|
||||
lf.OnChatLine($"legendaryquestcounter_0913 - 12 solves ({old})\"John\" -1 0", t + 2);
|
||||
lf.Tick(t + 5_000);
|
||||
DateTime now = DateTime.UtcNow;
|
||||
TimeSpan? rtwLeft = rtw.TimeLeft(lf, now);
|
||||
Check(rtw.Have(lf) && rtwLeft is { } l && l.TotalHours > 17.9 && l.TotalHours < 18.1, $"RTW: done, ~18 h left ({rtwLeft})");
|
||||
LegendaryQuest eod = LegendaryList.All.First(q => q.CommonName == "EoD");
|
||||
Check(eod.Have(lf) && eod.Status(lf, now) == "ready", "EoD: done, timer up -> ready: " + eod.Status(lf, now));
|
||||
LegendaryQuest la = LegendaryList.All.First(q => q.CommonName == "LA");
|
||||
Check(!la.Have(lf) && la.TimeLeft(lf, now) == null && la.Status(lf, now) == "missing", "Lugian Assault: missing");
|
||||
Check(LegendaryList.JohnCount(lf) == 12, "John's counter read: " + LegendaryList.JohnCount(lf));
|
||||
Check(LegendaryList.JohnCount(new QuestFlagStore()) == null, "no counter on a fresh character");
|
||||
|
||||
// A quest with a second timer flag: the longest wait of the two counts.
|
||||
LegendaryQuest erq = LegendaryList.All.First(q => q.Name == "Empyrean Rescue Quest");
|
||||
var ef = new QuestFlagStore();
|
||||
ef.OnChatLine($"empyreanrescuecompleted_1010 - 1 solves ({old})\"ERQ\" -1 0", t);
|
||||
ef.OnChatLine($"erqlegkeypickuptimer - 1 solves ({done})\"key\" -1 36000", t + 1);
|
||||
ef.Tick(t + 5_000);
|
||||
TimeSpan? erqLeft = erq.TimeLeft(ef, now);
|
||||
Check(erqLeft is { } e && e.TotalHours > 7.9 && e.TotalHours < 8.1, $"ERQ: key pickup timer decides (~8 h): {erqLeft}");
|
||||
|
||||
// Since 2026-10-18 Legendary quests and markers are rows of the Quests tab, on every server.
|
||||
var lc = new OracleContext { InWorld = true };
|
||||
var lv = new OracleView(lc);
|
||||
lc.Server.Force("", "Coldeve");
|
||||
Check(lv.AvailableKinds().Contains(QuestKind.Legendary) && lv.AvailableKinds().Contains(QuestKind.Marker),
|
||||
"Legendary and marker rows on every server");
|
||||
Check(!lv.VisibleTabs().Contains("Legendary") && !lv.VisibleTabs().Contains("Markers"), "no separate Legendary / Markers tabs");
|
||||
}
|
||||
|
||||
/// <summary>The Dynamic Stamps tab's list (dynstamps.csv), its have / missing rules, and that the
|
||||
/// tab is Infinite Leaftide only.</summary>
|
||||
private static void DynamicStamps()
|
||||
{
|
||||
var all = DynamicStampList.All;
|
||||
Check(all.Count == 243, $"dynamic stamps: {all.Count} (243 expected from the ExtraDyn sheet)");
|
||||
Check(DynamicStampList.Areas.Count == 17 && DynamicStampList.Areas[0] == "Facility Hub" && DynamicStampList.Areas[^1] == "Candeth Keep",
|
||||
"dynamic areas: " + string.Join(",", DynamicStampList.Areas));
|
||||
Check(all.All(s => s.Stamp.StartsWith("dynamic_") && s.Stamp == s.Stamp.ToLowerInvariant()), "every stamp is a lower-case dynamic_ flag");
|
||||
Check(all.Select(s => s.Stamp).Distinct().Count() == all.Count, "no stamp listed twice");
|
||||
Check(all.All(s => s.Label.Length > 0), "every row names an NPC or a place");
|
||||
|
||||
DynamicStamp felscuda = all.First(s => s.Npc == "Felscuda");
|
||||
Check(felscuda.Stamp == "dynamic_1_&9jiytb!" && felscuda.Place == "Folthid Cellar" && felscuda.Reward == "Healing Rabbit Pie"
|
||||
&& felscuda.Note == "8.8S, 53.1E", $"Felscuda row: {felscuda.Place} / {felscuda.Reward} / {felscuda.Note}");
|
||||
|
||||
// /myquests keys flags as \S+ lower case, so the stamps' ! & # ^ $ survive.
|
||||
var f = new QuestFlagStore();
|
||||
long t = 900_000, at = DateTimeOffset.UtcNow.AddDays(-1).ToUnixTimeSeconds();
|
||||
f.OnChatLine($"Dynamic_1_&9jiyTB! - 1 solves ({at})\"Dynamic\" 1 0", t);
|
||||
f.OnChatLine($"Dynamic_1_ANND! - 1 solves ({at})\"Dynamic\" 1 0", t + 1); // the sheet lost the closing !
|
||||
f.OnChatLine($"Dynamic_1_ZZZnewNPC! - 1 solves ({at})\"Dynamic\" 1 0", t + 2); // not on the sheet
|
||||
f.OnChatLine($"rtwcompleted_1013 - 1 solves ({at})\"RTW\" -1 72000", t + 3);
|
||||
f.Tick(t + 5_000);
|
||||
Check(felscuda.Have(f), "Felscuda's stamp read from /myquests");
|
||||
DynamicStamp annd = all.First(s => s.Stamp == "dynamic_1_annd");
|
||||
Check(annd.Have(f) && annd.MatchedFlag(f) == "dynamic_1_annd!", "a stamp the sheet lost its ! on still matches");
|
||||
Check(!all.First(s => s.Npc == "Raxanza Folthid").Have(f), "an NPC not done is missing");
|
||||
List<string> extra = DynamicStampList.Unlisted(f);
|
||||
Check(extra.Count == 1 && extra[0] == "dynamic_1_zzznewnpc!", "unlisted: only the stamp the sheet doesn't have: " + string.Join(",", extra));
|
||||
DynamicStamp shortStamp = all.First(s => s.Stamp == "dynamic_1_s");
|
||||
var sf = new QuestFlagStore();
|
||||
sf.OnChatLine($"Dynamic_1_SomethingElse! - 1 solves ({at})\"Dynamic\" 1 0", t);
|
||||
sf.Tick(t + 5_000);
|
||||
Check(!shortStamp.Have(sf), "a cut-short stem under 14 characters isn't matched by prefix");
|
||||
|
||||
// Quest walkthroughs: every coordinate pair, labelled with its step, duplicates once.
|
||||
var grael = NavTargets.Stops("Give Progenitor's Ichor to Hoshar. - Speak with Hoshar ibn Jalaq 59.6S 88.0W - Kill Mukkir Progenitor 86.5N 57.3E"
|
||||
+ " - Speak with Hoshar ibn Jalaq - Abyssal Totem Gateway 86.5N 57.3E - Abyssal Totem Temple 86.5N 57.3E");
|
||||
Check(string.Join(" | ", grael.ConvertAll(s => s.Display)) == "Speak with Hoshar ibn Jalaq - 59.6S, 88.0W | Kill Mukkir Progenitor - 86.5N, 57.3E",
|
||||
"Splitting Grael stops: " + string.Join(" | ", grael.ConvertAll(s => s.Display)));
|
||||
Check(grael[0].Target == "59.6S, 88.0W Speak with Hoshar ibn Jalaq", "a stop's RynthNav target is the coordinates, then its label");
|
||||
var shadow = NavTargets.Stops("Xarabydun 41.8S 15.8E - Speak with Ciandra Arcanum Alchemist - Empyrean Workshop 66.9N 15.9E - Cragstone 26.0N 47.0E Speak with Bretself the Translator - Xarabydun - Shade of Farelaith 74.3N 58.6E");
|
||||
Check(string.Join(" | ", shadow.ConvertAll(s => s.Label)) == "Xarabydun | Empyrean Workshop | Cragstone | Shade of Farelaith",
|
||||
"Shadowfire Stone labels: " + string.Join(" | ", shadow.ConvertAll(s => s.Label)));
|
||||
Check(NavTargets.Stops("Kill 20 drudges near Holtburg.").Count == 0, "no coordinates: no stops");
|
||||
Check(NavTargets.Stops("Meet at 42.6n 62.4e").Count == 1 && NavTargets.Stops("Meet at 42.6n 62.4e")[0].Display == "Meet - 42.6N, 62.4E",
|
||||
"lower-case letters; 'at' dropped from the label");
|
||||
|
||||
// RynthNav targets, best first (RynthNav takes the first on its map).
|
||||
Check(string.Join(" | ", felscuda.NavCandidates()) == "8.8S, 53.1E | Folthid Cellar | Felscuda | Facility Hub",
|
||||
"Felscuda nav: " + string.Join(" | ", felscuda.NavCandidates()));
|
||||
var gerent = new DynamicStamp { Area = "Graveyard", Place = "Gerent's Compound at 87.2S, 17.5W", Npc = "Gerent" };
|
||||
Check(string.Join(" | ", gerent.NavCandidates()) == "87.2S, 17.5W | Gerent's Compound | Gerent | Graveyard",
|
||||
"coordinates inside the place, 'at' dropped: " + string.Join(" | ", gerent.NavCandidates()));
|
||||
var lost = new DynamicStamp { Area = "Odd Stamps", Place = "Lost Wish Cottages (Arwic) 42.6n 62.4e", Npc = "Bob" };
|
||||
Check(string.Join(" | ", lost.NavCandidates()) == "42.6N, 62.4E | Lost Wish Cottages (Arwic) | Lost Wish Cottages | Arwic",
|
||||
"lower-case n/e, a bracketed town, no grouping area, a 3-letter NPC left out: " + string.Join(" | ", lost.NavCandidates()));
|
||||
var mhoire = new DynamicStamp { Area = "Looking Around", Place = "Mhoire Castle - Great Hall" };
|
||||
Check(string.Join(" | ", mhoire.NavCandidates()) == "Mhoire Castle - Great Hall | Mhoire Castle | Great Hall",
|
||||
"a place's parts: " + string.Join(" | ", mhoire.NavCandidates()));
|
||||
Check(all.Count(s => s.NavCandidates().Count > 0) >= 200, "most stamps have somewhere to go: " + all.Count(s => s.NavCandidates().Count > 0));
|
||||
|
||||
// Since 2026-10-18 the stamps are rows of the Quests tab, on Infinite Leaftide only (the guardians too).
|
||||
var dc = new OracleContext { InWorld = true };
|
||||
var dv = new OracleView(dc);
|
||||
dc.Server.Force("", "Coldeve");
|
||||
Check(!dv.AvailableKinds().Contains(QuestKind.Dynamic) && !dv.AvailableKinds().Contains(QuestKind.Guardian),
|
||||
"no stamp or guardian rows off Infinite Leaftide");
|
||||
Check(!dv.VisibleTabs().Contains("Dynamic Stamps"), "no separate Dynamic Stamps tab");
|
||||
dc.Server.Force(ServerTags.InfiniteLeaftide, "InfiniteLeaftide");
|
||||
Check(dv.AvailableKinds().Contains(QuestKind.Dynamic) && dv.AvailableKinds().Contains(QuestKind.Guardian),
|
||||
"stamp and guardian rows on Infinite Leaftide");
|
||||
|
||||
// Show: Dynamic Stamps: all 243 listed and paged, so the page stays under the engine's ops limit.
|
||||
var host = new UiHost();
|
||||
UiWindow main = host.Add(new UiWindow("RynthOracle/Oracle", "Oracle") { Visible = true });
|
||||
dv.ShowTrackers(QuestKind.Dynamic);
|
||||
main.Begin(); dv.Draw(main); main.End();
|
||||
ParseAll(host, "Quests: Dynamic Stamps", out int ops);
|
||||
string body = Encoding.UTF8.GetString(main.Body);
|
||||
Check(ops > 40 && ops < 1400, $"Quests showing Dynamic Stamps: {ops} ops");
|
||||
Check(body.Contains($"{all.Count} shown") && body.Contains("listed Dynamic stamps") && body.Contains("DYN")
|
||||
&& body.Contains("Page 1 of 7") && !body.Contains("list cut short"),
|
||||
"every stamp listed, 40 a page, with the stamps' status above");
|
||||
Console.WriteLine($" InfiniteLeaftide/Quests showing Dynamic Stamps ({all.Count} rows, paged): {ops} ops, {main.Body.Length} bytes");
|
||||
}
|
||||
|
||||
private static void Lists()
|
||||
{
|
||||
Check(AugmentationList.All.Count == 88, $"augmentations: {AugmentationList.All.Count} rows (88 expected)");
|
||||
|
|
@ -72,6 +215,8 @@ namespace RynthOracle.Tests
|
|||
mf.OnChatLine("explorationmarkersfoundingroupa - 129 solves (1719432000)\"Markers\" 1023 0", 0);
|
||||
mf.Tick(5000);
|
||||
Check(MarkerList.All[0].IsFound(mf) && MarkerList.All[1].IsFound(mf) && !MarkerList.All[2].IsFound(mf), "marker bits 1 and 128 found, the rest not");
|
||||
Legendary();
|
||||
DynamicStamps();
|
||||
Check(SpellTable.Count > 6000, $"spell table: {SpellTable.Count} spells");
|
||||
Check(SpellTable.Name(5393) == "Corrosion VII", "spell 5393 is Corrosion VII: " + SpellTable.Name(5393));
|
||||
Check(SpellTable.TryGet(5395, out SpellInfo s) && s.IsDebuff && s.Duration == 31, "Corruption I is a 31 s debuff");
|
||||
|
|
@ -116,6 +261,37 @@ namespace RynthOracle.Tests
|
|||
s2.NoteTypedCommand(); // the player typing it
|
||||
s2.Tick(51_200);
|
||||
Check(!s2.AwaitingOurs, "a typed /myquests shows its reply");
|
||||
|
||||
// A second reply that lost most of its lines on the way (the engine's chat queue dropped
|
||||
// the head of the burst) updates the flags instead of blanking them.
|
||||
var s3 = new QuestFlagStore();
|
||||
long t3 = 200_000;
|
||||
for (int i = 0; i < 100; i++)
|
||||
s3.OnChatLine($"flag{i:D3} - 1 solves (1719432000)\"Q{i}\" -1 0", t3 + i);
|
||||
s3.Tick(t3 + 5_000);
|
||||
Check(s3.Flags.Count == 100, "first full reply: 100 flags");
|
||||
long t4 = t3 + 120_000;
|
||||
for (int i = 90; i < 100; i++)
|
||||
s3.OnChatLine($"flag{i:D3} - 2 solves (1719500000)\"Q{i}\" -1 0", t4 + i);
|
||||
s3.Tick(t4 + 5_000);
|
||||
Check(s3.Flags.Count == 100 && s3.LastPartialReply is { Got: 10, Had: 100 },
|
||||
"a cut-short reply (10 of 100) is merged, not a replacement");
|
||||
Check(s3.TryGet("flag095", out QuestFlag f95) && f95.Solves == 2 && s3.TryGet("flag001", out _),
|
||||
"merged reply updates the lines it had and keeps the rest");
|
||||
long t5 = t4 + 120_000;
|
||||
for (int i = 0; i < 95; i++)
|
||||
s3.OnChatLine($"flag{i:D3} - 3 solves (1719600000)\"Q{i}\" -1 0", t5 + i);
|
||||
s3.Tick(t5 + 5_000);
|
||||
Check(s3.Flags.Count == 95 && !s3.TryGet("flag099", out _), "a near-full reply still replaces (a dropped flag goes away)");
|
||||
|
||||
// ACECustom's once-a-minute limit: the throttle line ends "Reading..." and keeps the flags.
|
||||
int had = s3.Flags.Count;
|
||||
long t6 = t5 + 30_000;
|
||||
Check(s3.Request(_ => true, t6) && s3.AwaitingOurs, "refresh sent");
|
||||
Check(s3.OnChatLine("[MyQuests] This command may only be run once every 60 seconds.", t6 + 200) == MyQuestsLine.Throttled
|
||||
&& !s3.AwaitingOurs && s3.Flags.Count == had, "throttle reply: not loading, flags kept");
|
||||
Check(s3.ThrottleSecondsLeft(t6 + 1_000) > 50 && !s3.Request(_ => true, t6 + 10_000), "no resend while the server's minute runs");
|
||||
Check(s3.ThrottleSecondsLeft(t6 + 61_000) == 0 && s3.Request(_ => true, t6 + 61_000), "refresh allowed again after the minute");
|
||||
}
|
||||
|
||||
private static void Catalog()
|
||||
|
|
@ -184,7 +360,7 @@ namespace RynthOracle.Tests
|
|||
|
||||
// Identity from it.
|
||||
ServerIdentity.FromEngine(st, "Launcher Profile", out string tag, out string world, out string source);
|
||||
Check(tag == "" && world == "InfiniteLeaftide" && source.Contains("no RynthOracle pages"), "engine: ILT active has no Oracle tag (its screens are RynthILT's): " + source);
|
||||
Check(tag == ServerTags.InfiniteLeaftide && world == "InfiniteLeaftide", "engine: ILT active is the ILT tag: " + source);
|
||||
Check(source.Contains("host matches"), "engine: the reason is shown: " + source);
|
||||
|
||||
var picked = RynthCore.Plugin.Shared.EngineServerState.Parse(EngineJson("conquest", "ConquestAC", "RynthConquest", "conquest", "",
|
||||
|
|
@ -206,7 +382,7 @@ namespace RynthOracle.Tests
|
|||
Check(tag == "" && source.Contains("Coldeve"), "engine: a server without Oracle pages has no tag: " + source);
|
||||
|
||||
Check(ServerIdentity.TagForEngineId("AELRYNTH") == ServerTags.Aelrynth && ServerIdentity.TagForEngineId(null) == "", "engine id to tag");
|
||||
Check(ServerIdentity.EngineIdForTag(ServerTags.Aelrynth) == "aelrynth" && ServerIdentity.EngineIdForTag("") == "", "tag to engine id");
|
||||
Check(ServerIdentity.EngineIdForTag(ServerTags.InfiniteLeaftide) == "ilt" && ServerIdentity.EngineIdForTag("") == "", "tag to engine id");
|
||||
|
||||
// The owner's profile, read leniently (a server plugin's, and RynthILT's).
|
||||
var prof = RynthCore.Plugin.Shared.ServerProfileView.Parse(
|
||||
|
|
@ -224,6 +400,8 @@ namespace RynthOracle.Tests
|
|||
Check(!RynthCore.Plugin.Shared.EngineServerState.MatchesNameList(coldeve, "InfiniteLeaftide", list), "names: Coldeve active beats a Leaftide world name");
|
||||
Check(!RynthCore.Plugin.Shared.EngineServerState.MatchesNameList(off, "InfiniteLeaftide", list), "names: ILT listed and off stays off");
|
||||
Check(RynthCore.Plugin.Shared.EngineServerState.MatchesNameList(unknown, "Conquest", list), "names: a server the engine doesn't list still matches by world");
|
||||
Check(RynthCore.Plugin.Shared.ServerStateClient.InterfaceFor("RynthILT") == "RynthILT.Server"
|
||||
&& RynthCore.Plugin.Shared.ServerStateClient.InterfaceFor("RynthColdeve") == "RynthServer.Profile", "profile: which interface to ask");
|
||||
}
|
||||
|
||||
private static void Servers()
|
||||
|
|
@ -233,7 +411,8 @@ namespace RynthOracle.Tests
|
|||
Check(ServerIdentity.TagForWorld("Conquest") == ServerTags.Conquest, "Conquest");
|
||||
Check(ServerIdentity.TagForWorld("Levistras") == ServerTags.Levistras, "Levistras");
|
||||
Check(ServerIdentity.TagForWorld("Coldeve") == "" && ServerIdentity.TagForWorld("") == "", "other servers have no tag");
|
||||
Check(ServerIdentity.TagForWorld("InfiniteLeaftide") == "", "Infinite Leaftide has no Oracle tag (RynthILT draws its screens)");
|
||||
Check(ServerIdentity.TagForWorld("InfiniteLeaftide") == ServerTags.InfiniteLeaftide, "InfiniteLeaftide");
|
||||
Check(ServerIdentity.TagForWorld("Infinite Leaftide Staging") == ServerTags.InfiniteLeaftide, "a Leaftide staging world is ILT");
|
||||
var id = new ServerIdentity();
|
||||
id.Force("", "Coldeve");
|
||||
Check(id.Allows(null) && id.Allows("") && !id.Allows(ServerTags.Conquest) && !id.Allows(ServerTags.Aelrynth), "untagged everywhere, tagged nowhere else");
|
||||
|
|
@ -257,6 +436,38 @@ namespace RynthOracle.Tests
|
|||
Check(view.Tab == OracleView.TabQuests, "a Conquest tab left selected falls back to Quests elsewhere");
|
||||
}
|
||||
|
||||
/// <summary>RynthILT's "RynthILT.Server" profile JSON as the Fellowship tab reads it.</summary>
|
||||
private static void IltProfile()
|
||||
{
|
||||
const string json = "{\"ilt\":true,\"world\":\"InfiniteLeaftide\",\"forced\":false,\"source\":\"probe\",\"checked\":\"2026-10-13T21:25:37Z\","
|
||||
+ "\"features\":[{\"key\":\"bank\",\"label\":\"Banking\",\"group\":\"Character\",\"state\":1,\"where\":\"Mini Remote > Banking tab\"},"
|
||||
+ "{\"key\":\"zone_share\",\"label\":\"Zone Share\",\"group\":\"Fellowship\",\"state\":1,\"where\":\"server\"},"
|
||||
+ "{\"key\":\"fellowship_blackjack\",\"label\":\"Fellowship Blackjack\",\"group\":\"Fellowship\",\"state\":0,\"where\":\"/fblackjack\"}],"
|
||||
+ "\"fellowship\":{\"maxMembers\":29,\"zoneShare\":1,\"blackjack\":0,\"luminanceShare\":-1},\"later\":{\"x\":1}}";
|
||||
IltServerProfile p = IltServerProfile.Parse(json);
|
||||
Check(p.Available && p.Ilt && p.World == "InfiniteLeaftide" && p.Source == "probe", "ILT profile header");
|
||||
Check(p.FellowshipMax == 29 && p.ZoneShare == 1 && p.Blackjack == 0 && p.LuminanceShare == -1, "ILT fellowship rules");
|
||||
Check(p.Features.Count == 3 && p.InGroup("Fellowship").Count() == 2, $"ILT features: {p.Features.Count}");
|
||||
Check(p.CheckedUtc == new DateTime(2026, 10, 13, 21, 25, 37, DateTimeKind.Utc), "checked time is UTC: " + p.CheckedUtc.ToString("o"));
|
||||
|
||||
IltServerProfile none = IltServerProfile.Parse("");
|
||||
Check(!none.Available && none.FellowshipMax == 9, "no RynthILT: a retail fellowship");
|
||||
Check(!IltServerProfile.Parse("not json").Available, "garbage is ignored");
|
||||
Check(IltServerProfile.Parse("{\"ilt\":false}").FellowshipMax == 9, "an older profile without fellowship rules: retail size");
|
||||
Check(IltServerProfile.Parse("{\"fellowship\":{\"maxMembers\":5000}}").FellowshipMax == 9, "an absurd size is not believed");
|
||||
Check(IltServerProfile.StateText(1) == "on" && IltServerProfile.StateText(0) == "off" && IltServerProfile.StateText(-1) == "checking", "state words");
|
||||
|
||||
// The /qb list RynthILT 0.2.3 adds to the profile.
|
||||
Check(p.QuestBonus == null, "no questBonus object: no /qb list");
|
||||
IltServerProfile qb = IltServerProfile.Parse(QbProfileJson);
|
||||
Check(qb.QuestBonus is { Disabled: false, Generation: 3, Count: 41 } b && b.Completed.Count == 2 && b.Incomplete.Count == 1
|
||||
&& b.Incomplete[0] == "qbflagthree" && b.Status == "2 completed, 1 incomplete", "quest bonus list parsed");
|
||||
}
|
||||
|
||||
private const string QbProfileJson = "{\"ilt\":true,\"world\":\"InfiniteLeaftide\",\"fellowship\":{\"maxMembers\":29},"
|
||||
+ "\"questBonus\":{\"disabled\":false,\"generation\":3,\"count\":41,\"status\":\"2 completed, 1 incomplete\","
|
||||
+ "\"completed\":[\"qbflagone\",\"qbflagtwo\"],\"incomplete\":[\"qbflagthree\"]}}";
|
||||
|
||||
// Quest notes: tracking and rewards saved per character, UB's reward format and import, kill-task timers.
|
||||
private static void QuestNotes()
|
||||
{
|
||||
|
|
@ -507,22 +718,26 @@ namespace RynthOracle.Tests
|
|||
main.MarkSubmitted(true);
|
||||
}
|
||||
}
|
||||
// The Quests tab with a quest opened (rewards editor) and the Tracked filter on.
|
||||
c.Server.Force("", "Coldeve");
|
||||
// Infinite Leaftide: the Quests tab with a quest opened (rewards editor) and the /qb list open.
|
||||
c.Server.Force(ServerTags.InfiniteLeaftide, "InfiniteLeaftide");
|
||||
c.Ilt.SetJson(QbProfileJson);
|
||||
c.Settings.TabName = OracleView.TabQuests;
|
||||
main.Begin(); view.Draw(main); main.End();
|
||||
Apply(host, Event(2, 89, main.Hash, main.KeyOf("q.tracked"), new byte[] { 1 }));
|
||||
main.Begin(); view.Draw(main); main.End();
|
||||
Check(Encoding.UTF8.GetString(main.Body).Contains("2 shown"), "the Tracked filter lists the two tracked quests");
|
||||
Apply(host, Event(1, 90, main.Hash, main.KeyOf("q.r.30minattributes"), new byte[] { 1, 0, 0 }));
|
||||
Apply(host, Event(6, 91, main.Hash, main.KeyOf("q.qb"), new byte[] { 1 }));
|
||||
main.Begin(); view.Draw(main); main.End(); // the inner header exists once the outer one is open
|
||||
Apply(host, Event(6, 92, main.Hash, main.KeyOf("q.qb.todo"), new byte[] { 1 }));
|
||||
main.Begin(); view.Draw(main); main.End();
|
||||
ParseAll(host, "quests with a quest opened", out int openOps);
|
||||
string openBody = Encoding.UTF8.GetString(main.Body);
|
||||
Check(openOps > 5 && openOps < 1400, $"quests page with a quest opened: {openOps} ops");
|
||||
Check(openBody.Contains("Save rewards") && openBody.Contains("Level: 126"), "the opened quest shows the rewards editor");
|
||||
Check(openBody.Contains("1.5%XP 2C L126"), "the Rewards column shows the recorded rewards");
|
||||
Check(!openBody.Contains("/qb"), "no quest bonus list here (Infinite Leaftide's /qb is RynthILT's)");
|
||||
Console.WriteLine($" Quests (opened): {openOps} ops, {main.Body.Length} bytes");
|
||||
ParseAll(host, "ILT quests with a quest opened", out int iltOps);
|
||||
string iltBody = Encoding.UTF8.GetString(main.Body);
|
||||
Check(iltOps > 5 && iltOps < 1400, $"ILT quests page: {iltOps} ops");
|
||||
Check(iltBody.Contains("Save rewards") && iltBody.Contains("Level: 126"), "the opened quest shows the rewards editor");
|
||||
Check(iltBody.Contains("1.5%XP 2C L126"), "the Rewards column shows the recorded rewards");
|
||||
Check(iltBody.Contains("Quest bonus (/qb) - count 41") && iltBody.Contains("qbflagthree"), "the /qb list from RynthILT");
|
||||
Console.WriteLine($" InfiniteLeaftide/Quests (opened, /qb): {iltOps} ops, {main.Body.Length} bytes");
|
||||
main.MarkSubmitted(true);
|
||||
|
||||
// The Conquest tab's sub-pages and the Aelrynth board views.
|
||||
|
|
@ -566,25 +781,34 @@ namespace RynthOracle.Tests
|
|||
}
|
||||
|
||||
/// <summary>
|
||||
/// The Character tab's RynthAi session (the generic part of the Mini Remote's old Character
|
||||
/// tab, moved here 2026-10-13). Infinite Leaftide's charms are RynthILT's and never drawn here.
|
||||
/// The Character tab's RynthAi session and RynthILT charms (the Mini Remote's Character and
|
||||
/// Charms tabs moved here 2026-10-13): drawn from what the plugin read, Toggle routed to RynthILT.
|
||||
/// </summary>
|
||||
private static void CharacterExtras()
|
||||
{
|
||||
const string charmsJson = "{\"available\":true,\"world\":\"InfiniteLeaftide\",\"acquiredCount\":2,\"activeCount\":1,"
|
||||
+ "\"charms\":[{\"name\":\"Mana Barrier\",\"effect\":\"Absorbs damage\",\"acquired\":\"carried\",\"count\":1,\"tier\":3,\"maxTier\":5,"
|
||||
+ "\"active\":\"on\",\"server\":\"on\",\"toggleId\":5001},"
|
||||
+ "{\"name\":\"Swift Feet\",\"acquired\":\"seen\",\"lastSeen\":\"2026-10-12\",\"active\":\"unknown\",\"server\":\"off\"}],"
|
||||
+ "\"hands\":[{\"id\":7001,\"name\":\"Guardian Hand\",\"active\":\"off\",\"server\":\"on\"}]}";
|
||||
|
||||
OracleContext c = Context();
|
||||
c.Server.Force("", "InfiniteLeaftide");
|
||||
c.Server.Force(ServerTags.InfiniteLeaftide, "InfiniteLeaftide");
|
||||
c.Settings.TabName = OracleView.TabCharacter;
|
||||
var view = new OracleView(c);
|
||||
var host = new UiHost();
|
||||
UiWindow main = host.Add(new UiWindow("RynthOracle/Oracle", "Oracle") { Visible = true });
|
||||
|
||||
// Nothing from RynthAi yet: the tab says what to load.
|
||||
// Nothing from RynthILT or RynthAi yet: the tab says what to load.
|
||||
main.Begin(); view.Draw(main); main.End();
|
||||
string empty = Encoding.UTF8.GetString(main.Body);
|
||||
Check(empty.Contains("Load RynthILT to list your Infinite Leaftide charms"), "ILT without RynthILT: says to load it");
|
||||
Check(empty.Contains("Load RynthAi for the session rates"), "without RynthAi: says to load it");
|
||||
Check(!empty.Contains("Charms") && !empty.Contains("RynthILT"), "no charms section on any world (RynthILT's Charms tab)");
|
||||
main.MarkSubmitted(true);
|
||||
|
||||
uint toggled = 0;
|
||||
c.ToggleCharm = id => { toggled = id; return true; };
|
||||
c.Charms = RynthCore.Plugin.Shared.IltCharmsView.Parse(charmsJson);
|
||||
c.Session = new RynthCore.Plugin.Shared.SessionStatsV1
|
||||
{
|
||||
StartUtcTicks = DateTime.UtcNow.AddHours(-1).Ticks, SessionSeconds = 3600, Xp = 1_234_567, XpPerHour = 1_234_567,
|
||||
|
|
@ -592,12 +816,256 @@ namespace RynthOracle.Tests
|
|||
};
|
||||
c.SessionKnown = true;
|
||||
main.Begin(); view.Draw(main); main.End();
|
||||
ParseAll(host, "Character with the session", out int ops);
|
||||
ParseAll(host, "Character with charms and session", out int ops);
|
||||
string body = Encoding.UTF8.GetString(main.Body);
|
||||
Check(ops > 5 && ops < 1400, $"Character with the session: {ops} ops");
|
||||
Check(ops > 5 && ops < 1400, $"Character with charms: {ops} ops");
|
||||
Check(body.Contains("1,234,567") && body.Contains("4,000") && body.Contains("42 (42/h)"), "the session shows RynthAi's XP, luminance and kills");
|
||||
Check(OracleView.SessionStatsCommand == "/rc miniremote section char", "Session Stats opens the section, not the moved tab");
|
||||
Check(body.Contains("Charms (2)") && body.Contains("Mana Barrier") && body.Contains("T3/5") && body.Contains("seen 2026-10-12"),
|
||||
"the charms RynthILT listed, with tier and acquired state");
|
||||
Check(body.Contains("server off"), "a charm the server switched off is marked");
|
||||
Check(body.Contains("Guardian Hands (1)"), "the Guardian Hands are listed");
|
||||
|
||||
Apply(host, Event(1, 10, main.Hash, main.KeyOf("c.charm.0"), new byte[] { 1, 0, 0 }));
|
||||
Check(toggled == 5001, "the carried charm's Toggle goes to RynthILT with its id");
|
||||
Check(body.Contains("###c.charm.0") && !body.Contains("###c.charm.1"), "an uncarried charm has no Toggle");
|
||||
Apply(host, Event(1, 11, main.Hash, main.KeyOf("c.hand.0"), new byte[] { 1, 0, 0 }));
|
||||
Check(toggled == 7001, "the Guardian Hand's Toggle goes to RynthILT with its id");
|
||||
main.MarkSubmitted(true);
|
||||
|
||||
// Another world: RynthILT answers "not available", so no charms section at all.
|
||||
c.Server.Force("", "");
|
||||
c.Charms = RynthCore.Plugin.Shared.IltCharmsView.Parse("{\"available\":false,\"charms\":[]}");
|
||||
main.Begin(); view.Draw(main); main.End();
|
||||
Check(!Encoding.UTF8.GetString(main.Body).Contains("Charms ("), "off ILT: no charms section");
|
||||
Check(OracleView.SessionStatsCommand == "/rc miniremote section char", "Session Stats opens the section, not the moved tab");
|
||||
}
|
||||
|
||||
/// <summary>RynthILT's breeding JSON with <paramref name="essences"/> essences (one ready stud and one ready dam first).</summary>
|
||||
private static string BreedingJson(int essences)
|
||||
{
|
||||
var sb = new StringBuilder("{\"available\":true,\"world\":\"InfiniteLeaftide\",\"enabled\":\"on\",\"maturity\":\"on\",\"bond\":\"on\","
|
||||
+ "\"room\":\"landblock 0x0106 variant 2\",\"freeSlots\":12,\"message\":\"\",\"essences\":[");
|
||||
for (int i = 0; i < essences; i++)
|
||||
{
|
||||
if (i > 0) sb.Append(',');
|
||||
bool male = i % 2 == 0, ready = i < 2;
|
||||
sb.Append("{\"id\":").Append(1000 + i).Append(",\"name\":\"Essence ").Append(i).Append("\",\"sex\":\"").Append(male ? 'M' : 'F')
|
||||
.Append("\",\"tier\":125,\"bond\":100,\"ready\":").Append(ready ? "true" : "false")
|
||||
.Append(",\"status\":\"").Append(ready ? "Ready" : "Rest 1h 05m").Append("\",\"readyIn\":").Append(ready ? 0 : 3900)
|
||||
.Append(",\"charges\":7,\"chargesMax\":10,\"juvenile\":false,\"stage\":\"\",\"kills\":0,\"killsRequired\":300,")
|
||||
.Append("\"mutations\":1,\"potencyMutations\":0,\"problems\":").Append(ready ? "[]" : "[\"resting after a breed\"]")
|
||||
.Append(",\"boosters\":").Append(i == 0 ? "[\"Incense +10%\"]" : "[]").Append('}');
|
||||
}
|
||||
sb.Append("],\"pairs\":[{\"stud\":\"Essence 0\",\"dam\":\"Essence 1\",\"chanceBest\":0.13636,\"chanceWorst\":0.05,\"inheritMin\":1,\"inheritMax\":2}],")
|
||||
.Append("\"supplies\":[{\"key\":\"incense1\",\"name\":\"Breeding Incense\",\"effect\":\"+10% mutation chance\",\"count\":2,\"price\":250000,\"apply\":true,\"targets\":[1000,1001]},")
|
||||
.Append("{\"key\":\"neuter\",\"name\":\"Neutering Kit\",\"effect\":\"Permanent\",\"count\":1,\"price\":0,\"apply\":false,\"targets\":[]}],")
|
||||
.Append("\"rules\":[{\"label\":\"Stud charges\",\"value\":\"10/day\",\"source\":\"seen on server\",\"help\":\"Breeds per refill.\"},")
|
||||
.Append("{\"label\":\"Mutation decay\",\"value\":\"0.1\",\"source\":\"ILT profile\",\"help\":\"\"}],")
|
||||
.Append("\"events\":[{\"when\":\"10-15 12:00\",\"kind\":\"birth\",\"text\":\"Congratulations! A baby pet has been born: Pup\"}],")
|
||||
.Append("\"debug\":{\"when\":\"10-15 12:01\",\"enabled\":\"on\",\"location\":\"0x0106 variant 2\",\"match\":\"valid\",\"pet\":\"Essence 0\",\"sex\":\"M\",\"partners\":1}}");
|
||||
return sb.ToString();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// The Pet Breeding tab (Infinite Leaftide only): RynthILT's breeding JSON drawn within the op budget,
|
||||
/// Dance and supply uses asked first, then sent to RynthILT as its verbs.
|
||||
/// </summary>
|
||||
private static void Breeding()
|
||||
{
|
||||
// The tab exists only on Infinite Leaftide.
|
||||
OracleContext c = Context();
|
||||
var view = new OracleView(c);
|
||||
Check(!view.VisibleTabs().Contains(OracleView.TabBreeding), "Aelrynth: no Pet Breeding tab");
|
||||
c.Server.Force("", "Coldeve");
|
||||
Check(!view.VisibleTabs().Contains(OracleView.TabBreeding), "other servers: no Pet Breeding tab");
|
||||
c.Server.Force(ServerTags.InfiniteLeaftide, "InfiniteLeaftide");
|
||||
Check(view.VisibleTabs().Contains(OracleView.TabBreeding), "Infinite Leaftide: the Pet Breeding tab");
|
||||
|
||||
// The parser: fields, lists, the debug block, and bad input.
|
||||
IltBreedingView v = IltBreedingView.Parse(BreedingJson(2));
|
||||
Check(v.Loaded && v.Available && v.Enabled == "on" && v.Room == "landblock 0x0106 variant 2" && v.FreeSlots == 12, "breeding JSON header");
|
||||
Check(v.Essences.Count == 2 && v.Essences[0].Male && !v.Essences[1].Male && v.Essences[0].Ready && v.Essences[0].Boosters.Count == 1,
|
||||
"breeding essences with sex, readiness and boosters");
|
||||
Check(v.Pairs.Count == 1 && Math.Abs(v.Pairs[0].ChanceBest - 0.13636) < 1e-9 && v.Pairs[0].InheritMax == 2, "breeding pair odds");
|
||||
Check(v.Supplies.Count == 2 && v.Supplies[0].Targets.Count == 2 && !v.Supplies[1].Apply, "breeding supplies and their targets");
|
||||
Check(v.Debug is { Match: "valid", Partners: 1 }, "breeding diagnostics");
|
||||
Check(!IltBreedingView.Parse("not json").Loaded && !IltBreedingView.Parse("").Loaded && !IltBreedingView.Parse("[1]").Loaded,
|
||||
"bad breeding JSON is not loaded");
|
||||
Check(IltBreedingView.ApplyVerb(" incense1 ", 1000) == "apply incense1 1000" && IltBreedingView.DanceVerb() == "dance",
|
||||
"breeding verbs");
|
||||
|
||||
// Nothing from RynthILT yet: the tab says to load it.
|
||||
var host = new UiHost();
|
||||
UiWindow main = host.Add(new UiWindow("RynthOracle/Oracle", "Oracle") { Visible = true });
|
||||
c.Settings.TabName = OracleView.TabBreeding;
|
||||
main.Begin(); view.Draw(main); main.End();
|
||||
Check(Encoding.UTF8.GetString(main.Body).Contains("Load RynthILT (0.2.7 or later)"), "without RynthILT: says to load it");
|
||||
main.MarkSubmitted(true);
|
||||
|
||||
// 50 essences with every section open: rows cut at 40, the page still fits.
|
||||
var sent = new List<string>();
|
||||
string ran = "";
|
||||
c.BreedingCommand = verb => { sent.Add(verb); return true; };
|
||||
c.RunCommand = cmd => { ran = cmd; return true; };
|
||||
c.Breeding = IltBreedingView.Parse(BreedingJson(50));
|
||||
main.Begin(); view.Draw(main); main.End();
|
||||
uint seq = 200;
|
||||
foreach (string header in new[] { "br.sup", "br.rules", "br.events" })
|
||||
Apply(host, Event(6, seq++, main.Hash, main.KeyOf(header), new byte[] { 1 }));
|
||||
main.Begin(); view.Draw(main); main.End();
|
||||
ParseAll(host, "Pet Breeding with 50 essences", out int ops);
|
||||
string body = Encoding.UTF8.GetString(main.Body);
|
||||
Check(ops > 5 && ops < 1400, $"Pet Breeding with 50 essences: {ops} ops");
|
||||
Console.WriteLine($" InfiniteLeaftide/Pet Breeding (50 essences, all open): {ops} ops, {main.Body.Length} bytes");
|
||||
Check(body.Contains("Essences (2 ready of 50)") && body.Contains("... and 10 more"), "essence rows cut at 40 with a count");
|
||||
Check(body.Contains("Essence 0 x Essence 1") && body.Contains("5%-13.6%"), "the ready pair with its odds");
|
||||
Check(body.Contains("Supplies (3 carried)") && body.Contains("250,000 pyreals"), "supplies with Ivo's price");
|
||||
Check(body.Contains("Stud charges") && body.Contains("seen on server") && body.Contains("In the breeding room"), "rules and diagnostics");
|
||||
Check(body.Contains("A baby pet has been born"), "recent events");
|
||||
|
||||
// Dance asks first; No drops it, Yes sends it.
|
||||
Apply(host, Event(1, seq++, main.Hash, main.KeyOf("br.dance"), new byte[] { 1, 0, 0 }));
|
||||
Check(sent.Count == 0, "Dance asks before sending");
|
||||
main.Begin(); view.Draw(main); main.End();
|
||||
Apply(host, Event(1, seq++, main.Hash, main.KeyOf("br.no"), new byte[] { 1, 0, 0 }));
|
||||
main.Begin(); view.Draw(main); main.End();
|
||||
Check(sent.Count == 0 && !Encoding.UTF8.GetString(main.Body).Contains("###br.yes"), "No drops the question");
|
||||
Apply(host, Event(1, seq++, main.Hash, main.KeyOf("br.dance"), new byte[] { 1, 0, 0 }));
|
||||
main.Begin(); view.Draw(main); main.End();
|
||||
Apply(host, Event(1, seq++, main.Hash, main.KeyOf("br.yes"), new byte[] { 1, 0, 0 }));
|
||||
Check(sent.Count == 1 && sent[0] == "dance", "Yes sends the dance verb");
|
||||
|
||||
// A supply use on the selected essence (the first) goes the same way.
|
||||
main.Begin(); view.Draw(main); main.End();
|
||||
Check(Encoding.UTF8.GetString(main.Body).Contains("###br.use.0") && !Encoding.UTF8.GetString(main.Body).Contains("###br.use.1"),
|
||||
"only a usable, carried supply has Use");
|
||||
Apply(host, Event(1, seq++, main.Hash, main.KeyOf("br.use.0"), new byte[] { 1, 0, 0 }));
|
||||
main.Begin(); view.Draw(main); main.End();
|
||||
Apply(host, Event(1, seq++, main.Hash, main.KeyOf("br.yes"), new byte[] { 1, 0, 0 }));
|
||||
Check(sent.Count == 2 && sent[1] == "apply incense1 1000", "Use then Yes sends apply with the essence id: " + string.Join("|", sent));
|
||||
|
||||
Apply(host, Event(1, seq++, main.Hash, main.KeyOf("br.refresh"), new byte[] { 1, 0, 0 }));
|
||||
Check(sent.Count == 3 && sent[2] == "refresh", "Refresh is sent straight away");
|
||||
Apply(host, Event(1, seq++, main.Hash, main.KeyOf("br.remote"), new byte[] { 1, 0, 0 }));
|
||||
Check(ran == "/ra hub open breeding", "Mini Remote opens Pets > Breeding: " + ran);
|
||||
main.MarkSubmitted(true);
|
||||
|
||||
// Breeding switched off on the server: said in red, page still drawn.
|
||||
c.Breeding = IltBreedingView.Parse("{\"available\":true,\"enabled\":\"off\",\"essences\":[]}");
|
||||
main.Begin(); view.Draw(main); main.End();
|
||||
Check(Encoding.UTF8.GetString(main.Body).Contains("Pet breeding is off on this server."), "breeding off is shown");
|
||||
}
|
||||
|
||||
/// <summary>RynthILT's Temple guardian JSON ("RynthILT.Data" version 3) as the Quests tab reads it.</summary>
|
||||
private const string GuardianJson = "{\"available\":true,\"world\":\"InfiniteLeaftide\",\"chat\":true,\"auto\":false,\"buy\":true,"
|
||||
+ "\"cooldownHours\":20,\"answer\":\"Pyreal\",\"npc\":\"Guardian of Attribute Enlightenment\",\"answerAgeSec\":30,"
|
||||
+ "\"heard\":\"What is the coin of the realm?\",\"running\":false,\"status\":\"idle\",\"synced\":\"2026-10-18T19:05:00Z\","
|
||||
+ "\"rows\":[{\"attribute\":\"Strength\",\"npc\":\"Fiun Strongarm\",\"count\":3,\"status\":\"Ready\",\"eta\":\"\",\"ready\":true,\"exact\":true},"
|
||||
+ "{\"attribute\":\"Focus\",\"npc\":\"Fiun Thinker\",\"count\":1,\"status\":\"Cooldown\",\"eta\":\"in 5h 2m\",\"ready\":false,\"exact\":false}]}";
|
||||
|
||||
/// <summary>
|
||||
/// The Quests tab's merged trackers (2026-10-18): Legendary quests, markers, and on Infinite
|
||||
/// Leaftide Dynamic Stamps and the Temple guardians, as rows of the one list; Trackers only;
|
||||
/// opening a tracker (RynthNav Go to); the guardian controls; the ops budget.
|
||||
/// </summary>
|
||||
private static void Trackers()
|
||||
{
|
||||
// The guardian JSON and its verbs.
|
||||
var g = RynthCore.Plugin.Shared.IltGuardianView.Parse(GuardianJson);
|
||||
Check(g.Loaded && g.Chat && !g.Auto && g.Buy && g.Answer == "Pyreal" && g.AnswerAgeSec == 30 && g.SyncedUtc.Year == 2026,
|
||||
"guardian JSON header");
|
||||
Check(g.Rows.Count == 2 && g.Rows[0].Ready && g.Rows[0].Exact && g.Rows[1].Eta == "in 5h 2m" && !g.Rows[1].Exact, "guardian rows");
|
||||
Check(!RynthCore.Plugin.Shared.IltGuardianView.Parse("nope").Loaded && !RynthCore.Plugin.Shared.IltGuardianView.Parse("").Loaded,
|
||||
"bad guardian JSON is not loaded");
|
||||
Check(RynthCore.Plugin.Shared.IltGuardianView.SwitchVerb(" Auto ", true) == "auto on"
|
||||
&& RynthCore.Plugin.Shared.IltGuardianView.SwitchVerb("buy", false) == "buy off"
|
||||
&& RynthCore.Plugin.Shared.IltGuardianView.HandInVerb() == "handin", "guardian verbs");
|
||||
|
||||
// Any server: Trackers only lists the Legendary quests and markers with their status, no ILT kinds.
|
||||
OracleContext c = Context();
|
||||
c.Server.Force("", "Coldeve");
|
||||
var view = new OracleView(c);
|
||||
var host = new UiHost();
|
||||
UiWindow main = host.Add(new UiWindow("RynthOracle/Oracle", "Oracle") { Visible = true });
|
||||
view.ShowTrackers(null);
|
||||
main.Begin(); view.Draw(main); main.End();
|
||||
string body = Encoding.UTF8.GetString(main.Body);
|
||||
int trackerRows = LegendaryList.All.Count + MarkerList.All.Count;
|
||||
Check(body.Contains($"{trackerRows} shown") && body.Contains("LEG") && body.Contains("toward John") && body.Contains("markers found"),
|
||||
"Trackers only: every Legendary quest and marker, with their status above");
|
||||
Check(!body.Contains("###q.r.dy:") && !body.Contains("###q.r.gd:") && !body.Contains("###q.r.30minattributes")
|
||||
&& !body.Contains("###gd.auto"),
|
||||
"no stamps, guardians or quests off Infinite Leaftide in Trackers only");
|
||||
main.MarkSubmitted(true);
|
||||
|
||||
// Everything: quests and trackers in one list (the quests first in the default order).
|
||||
view.ShowTrackers(QuestKind.Quest);
|
||||
c.Settings.TabName = OracleView.TabQuests;
|
||||
main.Begin(); view.Draw(main); main.End();
|
||||
body = Encoding.UTF8.GetString(main.Body);
|
||||
Check(body.Contains("Attribute and Skill Redistribution") && !body.Contains("###q.r.lg:") && !body.Contains("###q.r.mk:"),
|
||||
"Show: Quests lists only quests");
|
||||
main.MarkSubmitted(true);
|
||||
|
||||
// A Legendary quest with coordinates in its notes opens with RynthNav's Go to.
|
||||
LegendaryQuest? withCoords = LegendaryList.All.FirstOrDefault(q => NavTargets.Stops(q.Note).Count > 0);
|
||||
view.ShowTrackers(QuestKind.Legendary);
|
||||
main.Begin(); view.Draw(main); main.End();
|
||||
LegendaryQuest pick = withCoords ?? LegendaryList.All[0];
|
||||
Apply(host, Event(1, 700, main.Hash, main.KeyOf("q.r.lg:" + pick.Name), new byte[] { 1, 0, 0 }));
|
||||
main.Begin(); view.Draw(main); main.End();
|
||||
body = Encoding.UTF8.GetString(main.Body);
|
||||
Check(body.Contains("###lg.sel.print") && body.Contains("###lg.sel.close"), "a clicked Legendary quest opens below the list");
|
||||
if (withCoords != null) Check(body.Contains("###q.nav.go") && body.Contains("###q.nav.route"), "its coordinates offer RynthNav Go / Route / Arrow");
|
||||
main.MarkSubmitted(true);
|
||||
|
||||
// A marker always has somewhere to go: its directions' coordinates or its location's name.
|
||||
view.ShowTrackers(QuestKind.Marker);
|
||||
main.Begin(); view.Draw(main); main.End();
|
||||
Marker m0 = MarkerList.All[0];
|
||||
Apply(host, Event(1, 701, main.Hash, main.KeyOf("q.r.mk:" + m0.Number), new byte[] { 1, 0, 0 }));
|
||||
main.Begin(); view.Draw(main); main.End();
|
||||
body = Encoding.UTF8.GetString(main.Body);
|
||||
Check(body.Contains("Marker " + m0.Number) && body.Contains("###q.nav.go") && body.Contains("###m.sel.close"),
|
||||
"a clicked marker opens with Go to");
|
||||
main.MarkSubmitted(true);
|
||||
|
||||
// Infinite Leaftide without RynthILT's guardian data: the guardians say so.
|
||||
c.Server.Force(ServerTags.InfiniteLeaftide, "InfiniteLeaftide");
|
||||
view.ShowTrackers(QuestKind.Guardian);
|
||||
main.Begin(); view.Draw(main); main.End();
|
||||
Check(Encoding.UTF8.GetString(main.Body).Contains("RynthILT isn't loaded"), "guardians without RynthILT: says to load it");
|
||||
main.MarkSubmitted(true);
|
||||
|
||||
// With it: the switches, the answer with Hand in, and a row per attribute; each control sends its verb.
|
||||
var sent = new List<string>();
|
||||
c.GuardianCommand = verb => { sent.Add(verb); return true; };
|
||||
c.Guardian = g;
|
||||
c.GuardianRevision++;
|
||||
main.Begin(); view.Draw(main); main.End();
|
||||
body = Encoding.UTF8.GetString(main.Body);
|
||||
Check(body.Contains("Temple guardians") && body.Contains("1 of 2 attribute turn-ins ready") && body.Contains("Pyreal")
|
||||
&& body.Contains("###gd.handin") && body.Contains("GRD") && body.Contains("Strength (Fiun Strongarm)") && body.Contains("in 5h 2m"),
|
||||
"guardian controls, answer and rows");
|
||||
Apply(host, Event(1, 702, main.Hash, main.KeyOf("gd.handin"), new byte[] { 1, 0, 0 }));
|
||||
Apply(host, Event(2, 703, main.Hash, main.KeyOf("gd.auto"), new byte[] { 1 }));
|
||||
Apply(host, Event(2, 704, main.Hash, main.KeyOf("gd.buy"), new byte[] { 0 }));
|
||||
Apply(host, Event(1, 705, main.Hash, main.KeyOf("gd.refresh"), new byte[] { 1, 0, 0 }));
|
||||
Check(string.Join("|", sent) == "handin|auto on|buy off|refresh", "guardian controls send their verbs: " + string.Join("|", sent));
|
||||
main.MarkSubmitted(true);
|
||||
|
||||
// Every kind at once on Infinite Leaftide (trackers' status, a guardian opened): under the ops limit.
|
||||
// The guardian is opened while Show lists guardians (they sort last), then Show goes back to everything.
|
||||
Apply(host, Event(1, 706, main.Hash, main.KeyOf("q.r.gd:Strength"), new byte[] { 1, 0, 0 }));
|
||||
view.ShowTrackers(null);
|
||||
main.Begin(); view.Draw(main); main.End();
|
||||
ParseAll(host, "ILT Quests, every tracker", out int ops);
|
||||
body = Encoding.UTF8.GetString(main.Body);
|
||||
int iltRows = trackerRows + DynamicStampList.All.Count + 2;
|
||||
Check(body.Contains($"{iltRows} shown") && body.Contains("Temple guardian: Strength") && body.Contains("###gd.sel.close"),
|
||||
"every ILT tracker listed, a guardian opened below");
|
||||
Check(ops > 40 && ops < 1400, $"ILT Quests with every tracker and a guardian opened: {ops} ops");
|
||||
Console.WriteLine($" InfiniteLeaftide/Quests, trackers only ({iltRows} rows, guardian opened): {ops} ops, {main.Body.Length} bytes");
|
||||
}
|
||||
|
||||
private static void Events()
|
||||
|
|
|
|||
|
|
@ -28,12 +28,17 @@
|
|||
<ItemGroup>
|
||||
<Compile Include="..\..\Plugins\RynthCore.Plugin.RynthOracle\**\*.cs" Exclude="..\..\Plugins\RynthCore.Plugin.RynthOracle\obj\**;..\..\Plugins\RynthCore.Plugin.RynthOracle\bin\**" Link="RynthOracle\%(RecursiveDir)%(Filename)%(Extension)" />
|
||||
<Compile Include="..\..\Plugins\RynthCore.Plugin.RynthAi\Combat\FellowshipTracker.cs" Link="RynthOracle\Shared\FellowshipTracker.cs" />
|
||||
<Compile Include="..\..\Plugins\Shared\RynthIltServerApi.cs" Link="RynthOracle\Shared\RynthIltServerApi.cs" />
|
||||
<Compile Include="..\..\Plugins\Shared\RynthIltDataApi.cs" Link="RynthOracle\Shared\RynthIltDataApi.cs" />
|
||||
<Compile Include="..\..\Plugins\Shared\RynthAiHubApi.cs" Link="RynthOracle\Shared\RynthAiHubApi.cs" />
|
||||
<Compile Include="..\..\Plugins\Shared\RynthAiSessionClient.cs" Link="RynthOracle\Shared\RynthAiSessionClient.cs" />
|
||||
<!-- RynthCore's server list and the owner plugin's profile (as in the plugin's csproj). -->
|
||||
<Compile Include="..\..\Plugins\Shared\RynthServerProfileApi.cs" Link="RynthOracle\Shared\RynthServerProfileApi.cs" />
|
||||
<Compile Include="..\..\Plugins\Shared\EngineServerState.cs" Link="RynthOracle\Shared\EngineServerState.cs" />
|
||||
<Compile Include="..\..\Plugins\Shared\ServerStateClient.cs" Link="RynthOracle\Shared\ServerStateClient.cs" />
|
||||
<!-- The Fellowship tab's /fship buttons (as in the plugin's csproj). -->
|
||||
<Compile Include="..\..\Plugins\Shared\ServerCommandShare.cs" Link="RynthOracle\Shared\ServerCommandShare.cs" />
|
||||
<Compile Include="..\..\Plugins\RynthCore.Plugin.RynthILT\IltFellowship\IltFellowshipCommands.cs" Link="RynthOracle\Shared\IltFellowshipCommands.cs" />
|
||||
<Compile Include="..\..\..\RynthCore\src\RynthCore.Engine\UI\ScriptWindows\DisplayListParser.cs" Link="Engine\DisplayListParser.cs" />
|
||||
</ItemGroup>
|
||||
|
||||
|
|
@ -47,6 +52,8 @@
|
|||
<EmbeddedResource Include="..\..\Plugins\RynthCore.Plugin.RynthOracle\Resources\society.csv" LogicalName="RynthOracle.society.csv" />
|
||||
<EmbeddedResource Include="..\..\Plugins\RynthCore.Plugin.RynthOracle\Resources\titles.csv" LogicalName="RynthOracle.titles.csv" />
|
||||
<EmbeddedResource Include="..\..\Plugins\RynthCore.Plugin.RynthOracle\Resources\markers.csv" LogicalName="RynthOracle.markers.csv" />
|
||||
<EmbeddedResource Include="..\..\Plugins\RynthCore.Plugin.RynthOracle\Resources\legendary.csv" LogicalName="RynthOracle.legendary.csv" />
|
||||
<EmbeddedResource Include="..\..\Plugins\RynthCore.Plugin.RynthOracle\Resources\dynstamps.csv" LogicalName="RynthOracle.dynstamps.csv" />
|
||||
<EmbeddedResource Include="..\..\Plugins\RynthCore.Plugin.RynthOracle\Resources\customquests.csv" LogicalName="RynthOracle.customquests.csv" />
|
||||
<EmbeddedResource Include="..\..\Plugins\RynthCore.Plugin.RynthAi\Combat\SpellData.txt" LogicalName="RynthOracle.SpellData.txt" />
|
||||
</ItemGroup>
|
||||
|
|
|
|||
|
|
@ -29,6 +29,7 @@
|
|||
<Compile Include="..\..\..\RynthCore\src\RynthCore.PluginSdk\Manifest\RynthPluginManifest.cs" Link="Sdk\RynthPluginManifest.cs" />
|
||||
<!-- The launcher's known-server picker, checked against the plugins it names. -->
|
||||
<Compile Include="..\..\..\RynthCore\src\RynthCore.App\LaunchServerProfile.cs" Link="Launcher\LaunchServerProfile.cs" />
|
||||
<Compile Include="..\..\..\RynthCore\src\RynthCore.App\KnownServerCatalog.cs" Link="Launcher\KnownServerCatalog.cs" />
|
||||
<!-- The RynthAi test tools' check/runner harness (no plugin code in it). -->
|
||||
<Compile Include="..\RynthCore.RynthAiTests\Harness\Check.cs" Link="Harness\Check.cs" />
|
||||
<Compile Include="..\RynthCore.RynthAiTests\Harness\Runner.cs" Link="Harness\Runner.cs" />
|
||||
|
|
|
|||
|
|
@ -1,5 +1,4 @@
|
|||
using System;
|
||||
using System.Linq;
|
||||
using System.Text.Json;
|
||||
using RynthCore.Plugin.ServerPack;
|
||||
using RynthCore.RynthAiTests.Harness;
|
||||
|
|
@ -79,38 +78,7 @@ internal static class ServerPackModelTests
|
|||
Check.Eq(salvage[1].Bench, "armor", "bench lower-cased");
|
||||
Check.Eq(salvage[1].Kind, "tink", "default kind");
|
||||
Check.True(salvage[1].UsesTinkSlot, "slot by default");
|
||||
Check.Eq(RynthCore.Plugin.Shared.ServerSalvageView.ParseList("{\"id\":\"x\"}").Count, 0, "a profile without the list (older plugins)");
|
||||
|
||||
// The optional row fields: absent = off / the default, and the writer leaves them out then.
|
||||
Check.True(salvage.All(v => v.AppliedInt == 0 && !v.Prepared && v.Order == 0 && !v.AfterCap
|
||||
&& v.StackGroup.Length == 0 && v.StackCap == 0), "optional fields default when absent");
|
||||
string plain = ServerPackProfile.BuildJson(withSalvage, "RynthX", "1", true, "X");
|
||||
Check.True(!plain.Contains("\"applied\"") && !plain.Contains("\"prepared\"") && !plain.Contains("\"order\"")
|
||||
&& !plain.Contains("\"afterCap\"") && !plain.Contains("\"stackGroup\""), "unset fields are not written");
|
||||
|
||||
ServerPackInfo withRules = new("x", "X", new[] { "x.example" }, new[] { "X" })
|
||||
{
|
||||
Salvage = new[]
|
||||
{
|
||||
new ServerSalvage("melee", 52, "post-cap", "once", UsesTinkSlot: false, Order: 995, AfterCap: true),
|
||||
new ServerSalvage("jewelry", 71, "stack", UsesTinkSlot: false, Order: 50, StackGroup: "jewelry-stack", StackCap: 10),
|
||||
new ServerSalvage("trinkets", 20, "tier", "once", UsesTinkSlot: false, AppliedInt: 384, Prepared: true, Order: 10),
|
||||
},
|
||||
};
|
||||
var rules = RynthCore.Plugin.Shared.ServerSalvageView.ParseList(
|
||||
ServerPackProfile.BuildJson(withRules, "RynthX", "1", true, "X"));
|
||||
Check.Eq(rules.Count, 3, "rows with rules");
|
||||
Check.True(rules[0].AfterCap && rules[0].Order == 995 && !rules[0].Prepared && rules[0].StackGroup.Length == 0, "after cap + order");
|
||||
Check.Eq(rules[1].StackGroup, "jewelry-stack", "stack group");
|
||||
Check.Eq(rules[1].StackCap, 10, "stack cap");
|
||||
Check.True(rules[2].Prepared && rules[2].AppliedInt == 384 && rules[2].Order == 10 && !rules[2].AfterCap, "prepared + applied + order");
|
||||
Check.Eq(RynthCore.Plugin.Shared.ServerSalvageView.ParseList(
|
||||
"{\"salvage\":[{\"bench\":\"jewelry\",\"material\":64,\"stackGroup\":\"g\"},{\"bench\":\"jewelry\",\"material\":71,\"stackGroup\":\"g\",\"stackCap\":0}]}")
|
||||
.Count(v => v.StackGroup.Length > 0), 0, "a stack group without a positive cap is no group");
|
||||
var odd = RynthCore.Plugin.Shared.ServerSalvageView.ParseList(
|
||||
"{\"salvage\":[{\"bench\":\"melee\",\"material\":52,\"applied\":\"x\",\"prepared\":1,\"order\":null,\"afterCap\":\"yes\"}]}");
|
||||
Check.True(odd.Count == 1 && odd[0].AppliedInt == 0 && !odd[0].Prepared && odd[0].Order == 0 && !odd[0].AfterCap,
|
||||
"fields of the wrong type read as absent");
|
||||
Check.Eq(RynthCore.Plugin.Shared.ServerSalvageView.ParseList("{\"id\":\"ilt\"}").Count, 0, "a profile without the list (RynthILT, older plugins)");
|
||||
|
||||
string idle = ServerPackProfile.BuildJson(info, "RynthColdeve", "0.1.2", false, null);
|
||||
using JsonDocument idleDoc = JsonDocument.Parse(idle);
|
||||
|
|
@ -234,9 +202,9 @@ internal static class ServerPackModelTests
|
|||
Check.Eq(c.Address, "play.coldeve.ac:9000", "address");
|
||||
Check.True(c.BottingText.StartsWith("Not published"), "unknown policy says so");
|
||||
Check.True(c.BottingText.Contains("Discord"), "and points at the Discord");
|
||||
var lev = new ServerPackInfo("example", "Example", new[] { "play.example.test" }, new[] { "Example" })
|
||||
{ Botting = BottingPolicy.Forbidden, BottingNote = "no automation" };
|
||||
Check.Eq(lev.BottingText, "Forbidden - no automation", "forbidden");
|
||||
var lev = new ServerPackInfo("levistras", "Levistras", new[] { "levistras.acportalstorm.com" }, new[] { "Levistras" })
|
||||
{ Botting = BottingPolicy.Forbidden, BottingNote = "100% Botting-Free" };
|
||||
Check.Eq(lev.BottingText, "Forbidden - 100% Botting-Free", "forbidden");
|
||||
Check.Eq(new ServerPackInfo("x", "", Array.Empty<string>(), Array.Empty<string>()).Address, "", "no host, no address");
|
||||
Check.True(ServerPackModel.LauncherSteps(c)[0].Contains("play.coldeve.ac:9000"), "setup names the address");
|
||||
}
|
||||
|
|
|
|||
|
|
@ -19,6 +19,7 @@ internal static class ServerProjectsTests
|
|||
r.Add("server projects: ids, plugin names and hosts are unique", Unique);
|
||||
r.Add("server projects: no server's host is claimed by another server's list", NoHostOverlap);
|
||||
r.Add("server projects: each new server plugin has ServerData.cs and imports the shared props", Layout);
|
||||
r.Add("server projects: the launcher's known servers match the plugins RynthCore loads for them", LauncherCatalog);
|
||||
}
|
||||
|
||||
private sealed record Project(string Dir, string PluginName, string Id, string Name, string[] Hosts, string[] Worlds, bool Shared);
|
||||
|
|
@ -27,7 +28,7 @@ internal static class ServerProjectsTests
|
|||
private static readonly string[] Expected =
|
||||
{
|
||||
"coldeve", "ilt", "frostace", "reefcull", "conquest", "dreamweave", "portalstorm", "sundering",
|
||||
"achard", "leafdawn", "derptide", "frostcull", "thistlecrown", "eversong", "leafdawning", "aelrynth",
|
||||
"achard", "leafdawn", "levistras", "derptide", "frostcull", "thistlecrown", "eversong", "leafdawning", "aelrynth",
|
||||
};
|
||||
|
||||
private static string PluginsDir()
|
||||
|
|
@ -104,4 +105,42 @@ internal static class ServerProjectsTests
|
|||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// A profile made from the launcher's picker connects to the catalog's host; RynthCore's load
|
||||
/// gate then picks the plugin whose hosts claim it. So each entry must name a real server plugin
|
||||
/// with the same id, that plugin (and no other) must claim the host, and the port and emulator
|
||||
/// must agree with the plugin's ServerData.cs (the card shows those).
|
||||
/// </summary>
|
||||
private static void LauncherCatalog()
|
||||
{
|
||||
List<Project> projects = Load();
|
||||
var catalog = RynthCore.App.KnownServerCatalog.All;
|
||||
Check.Eq(catalog.Count, projects.Count, "one known server per server plugin");
|
||||
foreach (RynthCore.App.KnownServer known in catalog)
|
||||
{
|
||||
Project? p = projects.FirstOrDefault(x => string.Equals(x.PluginName, known.PluginName, StringComparison.Ordinal));
|
||||
Check.True(p != null, $"{known.Name}: plugin {known.PluginName} exists");
|
||||
if (p == null) continue;
|
||||
Check.Eq(p.Id, known.Id, known.PluginName + " server id");
|
||||
|
||||
foreach (Project candidate in projects)
|
||||
{
|
||||
var server = new RynthPluginServer { Id = candidate.Id, Hosts = candidate.Hosts.ToList() };
|
||||
bool claims = server.MatchesHost(known.Host, out _);
|
||||
if (candidate == p)
|
||||
Check.True(claims, $"{p.PluginName} claims the launcher's host {known.Host}");
|
||||
else
|
||||
Check.False(claims, $"{candidate.PluginName} does not claim {known.Name}'s host {known.Host}");
|
||||
}
|
||||
|
||||
if (p.Id == "ilt") continue; // RynthILT has no ServerData.cs
|
||||
string data = File.ReadAllText(Path.Combine(p.Dir, "ServerData.cs"));
|
||||
var port = System.Text.RegularExpressions.Regex.Match(data, @"\bPort\s*=\s*(\d+)");
|
||||
int dataPort = port.Success ? int.Parse(port.Groups[1].Value) : 9000;
|
||||
Check.Eq(known.Port, dataPort, known.PluginName + " port matches ServerData.cs");
|
||||
var emu = System.Text.RegularExpressions.Regex.Match(data, @"\bEmulator\s*=\s*""([^""]+)""");
|
||||
string dataEmu = emu.Success ? emu.Groups[1].Value : "ACE";
|
||||
Check.Eq(known.Emulator.ToString().ToUpperInvariant(), dataEmu.ToUpperInvariant(), known.PluginName + " emulator matches ServerData.cs");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in a new issue