Snapshot for release 2026.10.11.1 (internal d20160b)

This commit is contained in:
Tom Bohar 2026-10-11 15:00:56 -04:00
commit 504a6f080a
66 changed files with 7865 additions and 310 deletions

View file

@ -0,0 +1,252 @@
using System;
using System.Collections.Generic;
using System.Linq;
using RynthCore.Plugin.RynthILT.Bounty;
using RynthCore.RynthAiTests.Harness;
namespace RynthILT.Tests;
// The RynthILT review of SilentKelpie's tracker (2026-10-09). Two promises, checked here on a
// fake clock:
// * rate: at most one "/bounty list" per MinRefreshSeconds (5 s floor, whatever asks: kills,
// award lines every kill, Refresh spam, opening and closing the window), and none while the
// window is closed;
// * hidden chat: only the reply to the tracker's own read is eaten. A /bounty the player types
// is shown, also when it overlaps a read of ours, and our own command coming back through the
// engine's chat bar dispatcher is not mistaken for the player's.
internal static class BountyReviewTests
{
public static void Register(Runner r)
{
r.Add("review: awards on every kill never read more than once per MinRefreshSeconds", AwardsEveryKill);
r.Add("review: Refresh spam and window open/close keep the 5 s floor", RefreshSpamAndToggling);
r.Add("review: a long mixed session: every read 5 s apart and only while the window is open", MixedSession);
r.Add("review: a /bounty list the player types is shown and stands in for the next read", TypedListShown);
r.Add("review: a /bounty the player types during our read: the rest of that read is shown", TypedDuringCapture);
r.Add("review: our own /bounty list coming back through the chat bar is not the player's", OwnEcho);
r.Add("review: command matching and long lines", Matching);
}
private const string Header = "Bounties:";
private const string Line = " Lugian Mines: 1 Ascension Coin every 1 kill - you: 0 of 1 kills.";
private const string Footer = "Bounty: type /bounty to see the bounties where you stand.";
private sealed class Rig
{
public long Ms = 1_000_000;
public readonly List<long> SentAt = new();
public readonly List<bool> SentWhileOpen = new();
public BountyTracker T = null!;
public bool Open;
private long _lastPollMs;
public void Step(long ms)
{
for (long e = 0; e < ms; e += 250)
{
Ms += 250;
if (Open && Ms - _lastPollMs >= 1000) { T.BuildJson(); _lastPollMs = Ms; }
T.Tick();
}
}
/// <summary>The server answers our read at once (header, a line, footer).</summary>
public void Reply()
{
T.OnChat(Header);
T.OnChat(Line);
T.OnChat(Footer);
}
}
private static Rig New(int minRefreshSeconds = 5)
{
var rig = new Rig();
rig.T = new BountyTracker(cmd =>
{
if (cmd != BountyTracker.ListCommand) return;
rig.SentAt.Add(rig.Ms);
rig.SentWhileOpen.Add(rig.T.WindowOpen);
}, _ => { }, _ => { }, string.Empty, () => rig.Ms);
rig.T.Command($"set minrefreshseconds {minRefreshSeconds}");
return rig;
}
private static long MinGap(List<long> at)
{
long min = long.MaxValue;
for (int i = 1; i < at.Count; i++) min = Math.Min(min, at[i] - at[i - 1]);
return min;
}
private static void AwardsEveryKill()
{
var rig = New(minRefreshSeconds: 10);
rig.Open = true;
// A 1-kill bounty with no cooldown: every kill prints an award, for two minutes.
for (int s = 0; s < 120; s++)
{
rig.T.OnKill();
rig.T.OnChat("Bounty complete! +1 Ascension Coin gained.");
rig.T.OnChat("Next bounty requires 1 kill.");
rig.Step(1000);
if (rig.T.Reading) rig.Reply();
}
Check.True(rig.SentAt.Count >= 2, $"it still reads ({rig.SentAt.Count} reads)");
Check.True(rig.SentAt.Count <= 13, $"at most one read per 10 s over 120 s ({rig.SentAt.Count} reads)");
Check.True(MinGap(rig.SentAt) >= 10_000, $"reads at least MinRefreshSeconds apart (min gap {MinGap(rig.SentAt)} ms)");
}
private static void RefreshSpamAndToggling()
{
var rig = New(minRefreshSeconds: 30);
rig.Open = true;
rig.Step(500);
rig.Reply();
Check.Eq(rig.SentAt.Count, 1, "opening reads once");
// Refresh clicked every half second for 20 s: manual reads keep the 5 s floor.
for (int i = 0; i < 40; i++)
{
rig.T.Command("refresh");
rig.Step(500);
if (rig.T.Reading) rig.Reply();
}
Check.True(rig.SentAt.Count <= 5, $"20 s of Refresh spam: at most 4 more reads ({rig.SentAt.Count} in all)");
Check.True(MinGap(rig.SentAt) >= 5_000, $"manual reads at least 5 s apart (min gap {MinGap(rig.SentAt)} ms)");
// Kills while closed, then the window toggled open and shut every 4 s for a minute.
int before = rig.SentAt.Count;
for (int i = 0; i < 15; i++)
{
rig.Open = false;
rig.T.OnKill();
rig.Step(4000);
rig.Open = true;
rig.Step(1000);
if (rig.T.Reading) rig.Reply();
}
Check.True(rig.SentAt.Count - before <= 3, $"open/close every 5 s for 75 s with MinRefreshSeconds 30: at most 3 reads ({rig.SentAt.Count - before})");
Check.True(MinGap(rig.SentAt) >= 5_000, "and never two within 5 s");
Check.True(rig.SentWhileOpen.All(o => o), "every read went out with the window open");
}
private static void MixedSession()
{
var rig = New(minRefreshSeconds: 5);
var rnd = new Random(20261009);
for (int s = 0; s < 1800; s++) // 30 minutes
{
if (s % 120 == 0) rig.Open = !rig.Open;
int roll = rnd.Next(100);
if (roll < 30) rig.T.OnKill();
else if (roll < 35) rig.T.OnChat("Bounty complete! +1 Ascension Coin gained.");
else if (roll < 37) rig.T.Command("refresh");
else if (roll < 38) rig.T.OnChat("Bounty unlocked: Ascension Coin - 1 kill required.");
rig.Step(1000);
if (rig.T.Reading && rnd.Next(4) != 0) rig.Reply(); // now and then the server says nothing
}
Check.True(rig.SentAt.Count > 10, $"reads happened ({rig.SentAt.Count})");
Check.True(MinGap(rig.SentAt) >= 5_000, $"every read at least 5 s after the last (min gap {MinGap(rig.SentAt)} ms)");
Check.True(rig.SentWhileOpen.All(o => o), "every read went out with the window open");
}
private static void TypedListShown()
{
var rig = New(minRefreshSeconds: 5);
rig.Open = true;
rig.Step(500);
rig.Reply();
Check.Eq(rig.SentAt.Count, 1, "first read");
rig.Step(10_000);
// The player types /bounty list: the reply is shown (nothing eaten) and still applied.
rig.T.NoteTypedCommand("/bounty list");
Check.True(rig.T.Reading, "the typed list is captured (shown)");
Check.False(rig.T.OnChat(Header), "typed reply: the header stays in chat");
Check.False(rig.T.OnChat(" Lugian Mines: 1 Ascension Coin every 1 kill - you: 0 of 1 kills."), "typed reply: the lines stay in chat");
Check.False(rig.T.OnChat(Footer), "typed reply: the footer stays in chat");
Check.False(rig.T.Reading, "and the footer ends it");
Check.Eq(rig.T.State.Entries.Count, 1, "the typed reply fills the list");
// It counts as the latest read: a kill right after waits the full interval.
rig.T.OnKill();
rig.Step(4000);
Check.Eq(rig.SentAt.Count, 1, "no read of ours on top of the player's");
rig.Step(2000);
Check.Eq(rig.SentAt.Count, 2, "the kill's read comes MinRefreshSeconds after the typed one");
Check.True(rig.T.OnChat(Header) && rig.T.OnChat(Line) && rig.T.OnChat(Footer), "our own read is eaten again");
// "/bounty" (where you stand) output is never eaten.
rig.T.NoteTypedCommand("/bounty");
Check.False(rig.T.OnChat("Bounty: 1 Ascension Coin - 0 of 1 kills."), "a /bounty line stays in chat");
Check.False(rig.T.OnChat("Bounty: there is no bounty here."), "'no bounty here' stays in chat");
}
private static void TypedDuringCapture()
{
var rig = New(minRefreshSeconds: 5);
rig.Open = true;
rig.Step(500);
Check.Eq(rig.SentAt.Count, 1, "our read went out");
rig.T.NoteTypedCommand(BountyTracker.ListCommand); // our own echo first (consumed)
Check.True(rig.T.OnChat(Header), "our reply's header is eaten");
// The player types /bounty list while our reply is still coming in.
rig.Step(250);
rig.T.NoteTypedCommand("/bounty list");
Check.False(rig.T.OnChat(Line), "after the player asked, reward lines are shown");
Check.False(rig.T.OnChat(Footer), "and so is the footer");
Check.False(rig.T.OnChat(Header), "the player's own reply: header shown");
Check.False(rig.T.OnChat(Line), "the player's own reply: line shown");
Check.False(rig.T.OnChat(Footer), "the player's own reply: footer shown");
Check.False(rig.T.OnChat("Bounty complete! +1 Ascension Coin gained."), "award lines are never eaten");
// On a server without /bounty, the player's typed /bounty during our read: the refusal shows.
var rig2 = New();
rig2.Open = true;
rig2.Step(500);
rig2.T.NoteTypedCommand("/bounty");
Check.False(rig2.T.OnChat("Unknown command: bounty"), "the refusal of the player's own /bounty stays in chat");
}
private static void OwnEcho()
{
var rig = New(minRefreshSeconds: 5);
rig.Open = true;
rig.Step(500);
Check.Eq(rig.SentAt.Count, 1, "our read went out");
rig.Step(250);
rig.T.NoteTypedCommand("/bounty list"); // the engine's dispatcher passing our own line back
Check.True(rig.T.OnChat(Header), "our echo is recognised: the reply is still eaten");
Check.True(rig.T.OnChat(Line), "reward lines eaten");
Check.True(rig.T.OnChat(Footer), "footer eaten");
// An echo that comes too late is taken for the player's: that read is shown, never eaten wrongly.
rig.Step(10_000);
Check.Eq(rig.SentAt.Count, 1, "no new read yet (nothing asked)");
rig.T.Command("refresh");
rig.Step(500);
Check.Eq(rig.SentAt.Count, 2, "refresh reads");
rig.Step(3000);
rig.T.NoteTypedCommand("/bounty list");
Check.False(rig.T.OnChat(Header), "a late echo errs on the shown side");
}
private static void Matching()
{
Check.True(BountyTracker.IsBountyCommand("/bounty"), "/bounty");
Check.True(BountyTracker.IsBountyCommand("/bounty list"), "/bounty list");
Check.True(BountyTracker.IsBountyCommand("@Bounty all"), "@bounty all");
Check.False(BountyTracker.IsBountyCommand("/bountyhunter"), "a longer command is not /bounty");
Check.False(BountyTracker.IsBountyCommand("/b hello"), "chat");
Check.True(BountyTracker.IsListCommand("/bounty list") && BountyTracker.IsListCommand("/BOUNTY ALL"), "list commands");
Check.False(BountyTracker.IsListCommand("/bounty") || BountyTracker.IsListCommand("/bounty list now"), "not list commands");
var rig = New();
rig.Open = true;
rig.Step(500);
string longLine = " Lugian Mines: 1 Ascension Coin every 1 kill - you: 0 of 1 kills." + new string(' ', 600) + "x";
Check.False(rig.T.OnChat(longLine), "a line over 512 characters is never eaten or parsed");
}
}

View file

@ -0,0 +1,388 @@
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Text.Json;
using RynthCore.Plugin.RynthILT.Bounty;
using RynthCore.RynthAiTests.Harness;
namespace RynthILT.Tests;
// ACECustom bounty tracker (2026-10-09). The server keeps the kill counts (BountyProgress is a
// server-only property), so the engine's Bounties window has RynthILT read "/bounty list" quietly
// and parse it. The line formats below are copied from ACECustom BountyManager (ShowAllBounties /
// ShowBounty / Award / NextBountyLine). The tracker runs on a fake clock; the engine's 1 s poll
// of RynthPluginGetBountiesJson is simulated by calling BuildJson.
internal static class BountyTests
{
public static void Register(Runner r)
{
r.Add("bounty: /bounty list lines (counting, cooldown, QB, layers, commas)", ListLines);
r.Add("bounty: /bounty lines, waits and chat events", HereLinesAndEvents);
r.Add("bounty: a full read replaces the list, a partial one updates it", ApplyListRules);
r.Add("bounty: kills and awards stamp the row; an ended cooldown shows 0 kills; state survives a relog", ChangesAndCooldown);
r.Add("bounty: /bounty updates only the one reward it can mean", HereMatching);
r.Add("bounty: an open window reads the list quietly, kills and awards re-read it", WindowReadsAndKills);
r.Add("bounty: closed window sends nothing; unknown command stops reads; no reply times out", ClosedAndUnsupported);
r.Add("bounty: the window's JSON (options, QB filter, closest first) parses in the engine", BridgeJson);
}
// ── Parsing ────────────────────────────────────────────────────────────────
private static void ListLines()
{
Check.True(BountyParse.TryParseListLine(" Lugian Mines: 1 Ascension Coin every 100 kills (at most every 5 min) - you: 34 of 100 kills.", out var a),
"counting line parses (leading indentation)");
Check.Eq(a.Where, "Lugian Mines", "area");
Check.Eq(a.Amount, 1L, "amount");
Check.Eq(a.Item, "Ascension Coin", "item");
Check.Eq(a.KillsRequired, 100, "kills per award");
Check.Eq(a.CooldownSeconds, 300, "cooldown");
Check.Eq(a.Status.Status, BountyStatus.Counting, "status");
Check.Eq(a.Status.Kills, 34, "kills so far");
Check.True(BountyParse.TryParseListLine("All zones: 3 Pyreal Nugget every 1,000 kills (at most every 2 min 30 sec) - you: unlocks in 1 hr 15 sec, then 1,000 kills required.", out var b),
"cooldown line parses");
Check.Eq(b.Where, "All zones", "all-zones area");
Check.Eq(b.KillsRequired, 1000, "N0 kills");
Check.Eq(b.CooldownSeconds, 150, "2 min 30 sec");
Check.Eq(b.Status.Status, BountyStatus.Cooldown, "cooldown status");
Check.Eq(b.Status.WaitSeconds, 3615, "1 hr 15 sec");
Check.Eq(b.Status.KillsRequired, 1000, "kills after the cooldown");
Check.True(BountyParse.TryParseListLine("Valley of Death: 1,500 Trade Note - Large every 1 kill - you: needs 5,000 QB (you have 3,210).", out var c),
"QB line with no cooldown and a hyphenated item parses");
Check.Eq(c.Amount, 1500L, "N0 amount");
Check.Eq(c.Item, "Trade Note - Large", "item keeps its own ' - '");
Check.Eq(c.KillsRequired, 1, "one kill");
Check.Eq(c.CooldownSeconds, 0, "no cooldown");
Check.Eq(c.Status.Status, BountyStatus.NeedsQb, "QB status");
Check.Eq(c.Status.QbRequired, 5000L, "QB needed");
Check.Eq(c.Status.QbHave, 3210L, "QB had");
Check.True(BountyParse.TryParseListLine("Halls of Metos: Lower (layer 2): 2 Ascension Coin every 50 kills - you: 0 of 50 kills.", out var d),
"an area with ': ' and a layer parses");
Check.Eq(d.Where, "Halls of Metos: Lower (layer 2)", "area keeps its colon and layer");
Check.False(BountyParse.TryParseListLine("Bounties:", out _), "the header is not a reward");
Check.False(BountyParse.TryParseListLine("Bounty: type /bounty to see the bounties where you stand.", out _), "the footer is not a reward");
Check.False(BountyParse.TryParseListLine("Bob says, \"Lugian Mines: 1 coin every 100 kills\"", out _), "chat talk is not a reward");
Check.True(BountyParse.IsListTerminator("Bounty: type /bounty to see the bounties where you stand."), "footer ends the reply");
Check.True(BountyParse.IsListTerminator("Bounty: there are no bounties anywhere right now."), "'none anywhere' ends the reply");
Check.True(BountyParse.IsNoBountiesAnywhere("Bounty: there are no bounties anywhere right now."), "'none anywhere' is recognised");
Check.False(BountyParse.IsListTerminator("Bounty: there is no bounty here."), "/bounty's 'none here' is not the list's end");
Check.True(BountyParse.IsUnknownCommand("Unknown command: bounty"), "ACE's unknown-command reply is recognised");
Check.False(BountyParse.IsUnknownCommand("Unknown command: bank"), "another command's reply is not ours");
}
private static void HereLinesAndEvents()
{
Check.True(BountyParse.TryParseHereLine("Bounty: 1 Ascension Coin - 12 of 100 kills.", out var h1), "plain /bounty line");
Check.Eq(h1.Scope, "", "no scope");
Check.Eq(h1.Status.Kills, 12, "kills");
Check.True(BountyParse.TryParseHereLine("Bounty (all zones): 3 Pyreal Nugget - unlocks in 45 sec, then 1 kill required.", out var h2), "all-zones /bounty line");
Check.Eq(h2.Scope, "all zones", "all-zones scope");
Check.Eq(h2.Status.WaitSeconds, 45, "45 sec");
Check.True(BountyParse.TryParseHereLine("Bounty (Thaelaryn Island): 1 Ascension Coin - needs 500 QB (you have 20).", out var h3), "region /bounty line");
Check.Eq(h3.Scope, "Thaelaryn Island", "region scope");
Check.False(BountyParse.TryParseHereLine("Bounty: there is no bounty here.", out _), "'none here' is not a reward");
Check.False(BountyParse.TryParseHereLine("Bounty: +1 Ascension Coin will follow in a moment.", out _), "held notice is not a reward");
Check.Eq(BountyParse.ParseWaitSeconds("5 min"), 300, "5 min");
Check.Eq(BountyParse.ParseWaitSeconds("2 hr 3 min 4 sec"), 7384, "hr min sec");
Check.Eq(BountyParse.ParseWaitSeconds("soon"), 0, "unparseable wait");
Check.True(BountyParse.TryParseEvent("Bounty unlocked: Ascension Coin - 100 kills required.", out var k1, out string item1, out int n1, out _)
&& k1 == BountyEventKind.Unlocked && item1 == "Ascension Coin" && n1 == 100, "unlock event");
Check.True(BountyParse.TryParseEvent("Bounty complete! +3 Pyreal Nuggets gained.", out var k2, out string item2, out _, out _)
&& k2 == BountyEventKind.Complete && item2 == "Pyreal Nuggets", "award event");
Check.True(BountyParse.TryParseEvent("Next bounty unlocks in 2 min 30 sec - 1 kill required.", out var k3, out _, out int n3, out int w3)
&& k3 == BountyEventKind.NextCooldown && n3 == 1 && w3 == 150, "next-cooldown event");
Check.True(BountyParse.TryParseEvent("Next bounty requires 1,000 kills.", out var k4, out _, out int n4, out _)
&& k4 == BountyEventKind.NextReady && n4 == 1000, "next-ready event");
Check.True(BountyParse.TryParseEvent("Bounty: Your inventory is full. +1 Ascension Coin gained (3 total). They're safe until you make room.", out var k5, out _, out _, out _)
&& k5 == BountyEventKind.Held, "held event");
Check.False(BountyParse.TryParseEvent("Bounty: there is no bounty here.", out _, out _, out _, out _), "'none here' is not an event");
Check.False(BountyParse.TryParseEvent("Bounty: 1 Ascension Coin - 12 of 100 kills.", out _, out _, out _, out _), "a status line is not an event");
Check.False(BountyParse.TryParseEvent("Bounty: type /bounty to see the bounties where you stand.", out _, out _, out _, out _), "the footer is not an event");
}
// ── Applying reads ─────────────────────────────────────────────────────────
private static BountyListLine L(string line)
{
Check.True(BountyParse.TryParseListLine(line, out var l), "fixture parses: " + line);
return l;
}
private static void ApplyListRules()
{
var t = New(out _, out _, out _);
var t0 = new DateTime(2026, 10, 8, 12, 0, 0, DateTimeKind.Utc);
t.ApplyList(new[]
{
L("Lugian Mines: 1 Ascension Coin every 100 kills - you: 10 of 100 kills."),
L("All zones: 3 Pyreal Nugget every 50 kills - you: 0 of 50 kills."),
}, complete: true, noneAnywhere: false, t0);
Check.Eq(t.State.Entries.Count, 2, "full read: two rewards");
Check.Eq(t.State.ListedUtc, t0, "read time stamped");
// A partial reply (no footer) only updates what it names; the other rows stay.
t.ApplyList(new[] { L("Lugian Mines: 1 Ascension Coin every 100 kills - you: 11 of 100 kills.") },
complete: false, noneAnywhere: false, t0.AddSeconds(5));
Check.Eq(t.State.Entries.Count, 2, "partial read keeps the other row");
Check.Eq(t.State.Entries[0].Kills, 11, "partial read updates the named row in place");
// A full read drops areas that are gone and keeps the server's order.
t.ApplyList(new[]
{
L("Thaelaryn Island: 1 Ascension Coin every 20 kills - you: 4 of 20 kills."),
L("Lugian Mines: 1 Ascension Coin every 100 kills - you: 12 of 100 kills."),
}, complete: true, noneAnywhere: false, t0.AddSeconds(10));
Check.Eq(string.Join(",", t.State.Entries.Select(e => e.Where)), "Thaelaryn Island,Lugian Mines", "server order, removed area gone");
t.ApplyList(Array.Empty<BountyListLine>(), complete: true, noneAnywhere: true, t0.AddSeconds(20));
Check.Eq(t.State.Entries.Count, 0, "'none anywhere' empties the list");
Check.True(t.State.NoneAnywhere, "and says so");
}
private static void ChangesAndCooldown()
{
string file = Path.Combine(Program.TempRoot, "bounty-changes", BountyTracker.FileName);
var t = New(out _, out _, out _, file);
var t0 = new DateTime(2026, 10, 8, 12, 0, 0, DateTimeKind.Utc);
const string Head = "Lugian Mines: 1 Ascension Coin every 3 kills (at most every 5 min) - you: ";
t.ApplyList(new[] { L(Head + "1 of 3 kills.") }, true, false, t0);
Check.Eq(t.State.Entries[0].ChangedUtc, default(DateTime), "first sighting is not a change");
t.ApplyList(new[] { L(Head + "2 of 3 kills.") }, true, false, t0.AddSeconds(10));
Check.Eq(t.State.Entries[0].ChangedUtc, t0.AddSeconds(10), "a new kill stamps the row");
t.ApplyList(new[] { L(Head + "unlocks in 5 min, then 3 kills required.") }, true, false, t0.AddSeconds(20));
var e = t.State.Entries[0];
Check.Eq(e.ChangedUtc, t0.AddSeconds(20), "the award stamps the row");
Check.Eq(e.UnlockAtUtc, t0.AddSeconds(320), "unlock time = read time + wait");
Check.Eq(BountyTracker.Effective(e, t0.AddSeconds(100)).Status, BountyStatus.Cooldown, "still cooling down");
var after = BountyTracker.Effective(e, t0.AddSeconds(321));
Check.True(after.Status == BountyStatus.Counting && after.Kills == 0, "after the cooldown: 0 of N kills");
Check.True(BountyTracker.Describe(e, t0.AddSeconds(100)).Contains("unlocks in 3 min 40 sec"), "chat text counts the cooldown down");
// The state survives a relog (the window fills right after login).
t.Command("set hideqblocked 1");
t.Save();
var loaded = New(out _, out _, out _, file);
Check.Eq(loaded.State.Entries.Count, 1, "entries saved per character");
Check.Eq(loaded.State.Entries[0].UnlockAtUtc, t0.AddSeconds(320), "unlock time saved");
Check.True(loaded.State.HideQbLocked, "options saved");
}
private static void HereMatching()
{
var t = New(out _, out _, out _);
var t0 = new DateTime(2026, 10, 8, 12, 0, 0, DateTimeKind.Utc);
t.ApplyList(new[]
{
L("Lugian Mines: 1 Ascension Coin every 100 kills - you: 10 of 100 kills."),
L("Halls of Metos: 1 Ascension Coin every 100 kills - you: 50 of 100 kills."),
L("Thaelaryn Island: 2 Ascension Coin every 20 kills - you: 4 of 20 kills."),
L("All zones: 1 Ascension Coin every 100 kills - you: 0 of 100 kills."),
}, true, false, t0);
Check.True(BountyParse.TryParseHereLine("Bounty (Thaelaryn Island): 2 Ascension Coin - 5 of 20 kills.", out var region), "fixture");
Check.True(t.ApplyHere(region, t0.AddSeconds(5)), "a region line names its area");
Check.Eq(t.State.Entries[2].Kills, 5, "region row updated");
Check.True(BountyParse.TryParseHereLine("Bounty (all zones): 1 Ascension Coin - 1 of 100 kills.", out var zones), "fixture");
Check.True(t.ApplyHere(zones, t0.AddSeconds(6)), "an all-zones line names its area");
Check.Eq(t.State.Entries[3].Kills, 1, "all-zones row updated");
Check.True(BountyParse.TryParseHereLine("Bounty: 1 Ascension Coin - 11 of 100 kills.", out var plain), "fixture");
Check.False(t.ApplyHere(plain, t0.AddSeconds(7)), "two dungeons pay the same reward: left alone");
Check.Eq(t.State.Entries[0].Kills, 10, "first dungeon untouched");
Check.Eq(t.State.Entries[1].Kills, 50, "second dungeon untouched");
}
// ── The read loop ──────────────────────────────────────────────────────────
private const string ListReplyCounting = " Lugian Mines: 1 Ascension Coin every 100 kills - you: 34 of 100 kills.";
private const string Footer = "Bounty: type /bounty to see the bounties where you stand.";
private static void WindowReadsAndKills()
{
var t = New(out var clock, out var sent, out _);
t.Command("set minrefreshseconds 5");
Run(t, clock, 500, windowOpen: true);
Check.Eq(Reads(sent), 1, "opening the window reads /bounty list");
Check.True(t.Reading, "a read is in progress");
Check.True(t.OnChat("Bounties:"), "the header is hidden from chat");
Check.True(t.OnChat(ListReplyCounting), "reward lines are hidden from chat");
Check.True(t.OnChat(Footer), "the footer is hidden and ends the read");
Check.False(t.Reading, "the read is over");
Check.Eq(t.State.Entries.Count, 1, "the read fills the list");
Check.Eq(t.State.Entries[0].Kills, 34, "with the player's kills");
// A kill re-reads after the debounce, but not sooner than MinRefreshSeconds after the last read.
t.OnKill();
Run(t, clock, 3000, windowOpen: true);
Check.Eq(Reads(sent), 1, "no re-read inside MinRefreshSeconds");
Run(t, clock, 3000, windowOpen: true);
Check.Eq(Reads(sent), 2, "a kill re-reads the list");
t.OnChat("Bounties:");
t.OnChat(" Lugian Mines: 1 Ascension Coin every 100 kills - you: 35 of 100 kills.");
t.OnChat(Footer);
Check.Eq(t.State.Entries[0].Kills, 35, "the kill shows up");
Check.True(t.State.Entries[0].ChangedUtc != default, "and the row is highlighted");
// Award lines are shown to the player and also trigger a read, once MinRefreshSeconds
// have passed since the last one (review 2026-10-09: awards used to skip the interval).
Check.False(t.OnChat("Bounty complete! +1 Ascension Coin gained."), "award lines stay in chat");
Check.Eq(t.State.LastEvent, "Bounty complete! +1 Ascension Coin gained.", "the window shows the last event");
Run(t, clock, 2000, windowOpen: true);
Check.Eq(Reads(sent), 2, "the award's re-read waits for MinRefreshSeconds");
Run(t, clock, 3000, windowOpen: true);
Check.Eq(Reads(sent), 3, "an award re-reads the list");
// A reply whose footer never comes ends after a quiet moment, as a partial update.
t.OnChat("Bounties:");
t.OnChat(" Lugian Mines: 1 Ascension Coin every 100 kills (at most every 5 min) - you: unlocks in 5 min, then 100 kills required.");
Run(t, clock, 2000, windowOpen: true);
Check.False(t.Reading, "a reply without its footer still ends");
Check.Eq(t.State.Entries[0].Status, (int)BountyStatus.Cooldown, "and is applied");
// Lines the player asks for themselves are not hidden but still update the list.
Check.False(t.OnChat(" Lugian Mines: 1 Ascension Coin every 100 kills - you: 0 of 100 kills."), "a typed /bounty list line stays in chat");
Check.Eq(t.State.Entries[0].Status, (int)BountyStatus.Counting, "and updates the row");
// Closing the window (the engine stops polling; 3 s grace) stops the reads.
Run(t, clock, 5000, windowOpen: false);
int before = Reads(sent);
t.OnKill();
Run(t, clock, 20000, windowOpen: false);
Check.Eq(Reads(sent), before, "no reads once the window is closed");
}
private static void ClosedAndUnsupported()
{
var t = New(out var clock, out var sent, out var chat);
t.Command("set minrefreshseconds 5");
t.OnKill();
Run(t, clock, 10000, windowOpen: false);
Check.Eq(Reads(sent), 0, "closed window: kills send nothing");
Run(t, clock, 500, windowOpen: true);
Check.Eq(Reads(sent), 1, "opening the window reads the list");
Check.True(t.OnChat("Unknown command: bounty"), "the unknown-command reply to our read is hidden");
Check.True(t.Unsupported, "'Unknown command: bounty' marks the server unsupported");
t.OnKill();
Run(t, clock, 10 * 60_000, windowOpen: true);
Check.Eq(Reads(sent), 1, "no automatic reads on an unsupported server, periodic included");
t.HandleChatCommand(new[] { "/ilt", "bountys", "refresh" });
Check.False(t.Unsupported, "a manual refresh tries again");
Run(t, clock, 500, windowOpen: true);
Check.Eq(Reads(sent), 2, "and reads the list");
Check.True(chat.Any(c => c.Contains("Reading /bounty list")), "the command answers in chat");
Run(t, clock, 11000, windowOpen: true);
Check.False(t.Reading, "no reply: the read is abandoned");
Check.True(t.BuildJson().Contains("no reply to /bounty list"), "and the window says so");
// With the window closed a manual refresh sends nothing (review 2026-10-09: reads only
// while the window is open); the next open reads.
Run(t, clock, 5000, windowOpen: false);
Check.True(t.Command("refresh").Contains("window is open"), "a closed-window refresh says why it waits");
Check.Eq(Reads(sent), 2, "a closed-window refresh sends nothing");
Run(t, clock, 500, windowOpen: true);
Check.Eq(Reads(sent), 3, "the next open reads");
chat.Clear();
t.HandleChatCommand(new[] { "/ilt", "bounty" });
Check.True(chat.Any(c => c.Contains("/rc bounties")), "'/ilt bounty' points at the window");
}
private static void BridgeJson()
{
var t = New(out _, out _, out _);
var now = DateTime.UtcNow;
t.ApplyList(new[]
{
L("Valley of Death: 1,500 Trade Note - Large every 1 kill - you: needs 5,000 QB (you have 3,210)."),
L("Lugian Mines: 1 Ascension Coin every 100 kills - you: 10 of 100 kills."),
L("Thaelaryn Island: 2 Ascension Coin every 20 kills (at most every 5 min) - you: unlocks in 2 min, then 20 kills required."),
L("Halls of Metos: 1 Ascension Coin every 10 kills - you: 9 of 10 kills."),
}, true, false, now);
Check.Eq(t.Command("set minrefreshseconds 1"), "", "option accepted");
Check.Eq(t.State.MinRefreshSeconds, BountyTracker.MinRefreshFloorSeconds, "MinRefreshSeconds is clamped to the floor");
t.Command("set periodicminutes 999");
Check.Eq(t.State.PeriodicRefreshMinutes, BountyTracker.PeriodicCeilingMinutes, "PeriodicRefreshMinutes is clamped");
Check.True(t.Command("set nonsense 1").Contains("unknown"), "unknown option is reported");
using (var doc = JsonDocument.Parse(t.BuildJson()))
{
var root = doc.RootElement;
Check.Eq(root.GetProperty("rows").GetArrayLength(), 4, "all rows by default");
Check.Eq(root.GetProperty("rows")[0].GetProperty("where").GetString(), "Valley of Death", "server order by default");
Check.Eq(root.GetProperty("minRefreshSeconds").GetInt32(), 5, "camelCase option names");
}
t.Command("set hideqblocked 1");
t.Command("set sortbyprogress on");
string json = t.BuildJson();
using (var doc = JsonDocument.Parse(json))
{
var rows = doc.RootElement.GetProperty("rows");
Check.Eq(rows.GetArrayLength(), 3, "QB-locked row hidden");
Check.Eq(doc.RootElement.GetProperty("hiddenCount").GetInt32(), 1, "and counted");
Check.Eq(rows[0].GetProperty("where").GetString(), "Halls of Metos", "closest first: 9 of 10");
Check.Eq(rows[2].GetProperty("where").GetString(), "Thaelaryn Island", "cooldowns after counting rows");
}
#if ENGINE_BOUNTIES
var snap = RynthCore.Engine.UI.Data.BountiesSnapshot.Parse(json);
Check.NotNull(snap, "the engine parses the plugin's JSON");
Check.True(snap!.HideQbLocked && snap.SortByProgress, "engine sees the options");
Check.Eq(snap.MinRefreshSeconds, 5, "engine sees MinRefreshSeconds");
Check.Eq(snap.HiddenCount, 1, "engine sees the hidden count");
Check.Eq(snap.Rows.Count, 3, "engine sees the rows");
var cd = snap.Rows.Single(r => r.Where == "Thaelaryn Island");
Check.Eq(cd.Status, (int)RynthCore.Engine.UI.Data.BountyRowStatus.Cooldown, "engine status enum matches the plugin's");
Check.True(cd.UnlockInSec > 100 && cd.UnlockInSec <= 120, $"cooldown seconds left ({cd.UnlockInSec})");
Check.Eq(cd.CooldownSeconds, 300, "cooldown length");
var halls = snap.Rows[0];
Check.True(halls.Kills == 9 && halls.KillsRequired == 10 && halls.Amount == 1 && halls.Item == "Ascension Coin", "row fields");
#endif
}
// ── Helpers ────────────────────────────────────────────────────────────────
private sealed class Clock { public long Ms = 1_000_000; }
private static BountyTracker New(out Clock clock, out List<string> sent, out List<string> chat, string file = "")
{
var c = new Clock();
var s = new List<string>();
var ch = new List<string>();
if (file.Length > 0) Directory.CreateDirectory(Path.GetDirectoryName(file)!);
var t = new BountyTracker(s.Add, ch.Add, _ => { }, file, () => c.Ms);
clock = c;
sent = s;
chat = ch;
return t;
}
private static int Reads(List<string> sent) => sent.Count(x => x == BountyTracker.ListCommand);
/// <summary>Advances the clock in 250 ms steps, ticking; with the window open the engine polls every second.</summary>
private static void Run(BountyTracker t, Clock clock, long ms, bool windowOpen)
{
for (long elapsed = 0; elapsed < ms; elapsed += 250)
{
clock.Ms += 250;
if (windowOpen && elapsed % 1000 == 0) t.BuildJson();
t.Tick();
}
}
}

View file

@ -0,0 +1,28 @@
using System;
using System.IO;
using RynthCore.RynthAiTests.Harness;
namespace RynthILT.Tests;
// Offline tests for the RynthILT plugin: the ACECustom bounty tracker (parsing, merging, the
// quiet /bounty list read loop on a fake clock, persistence, the bridge JSON). Each test prints
// PASS / FAIL.
//
// Run: dotnet run -c Release (all tests)
// dotnet run -c Release -- window (tests whose name contains "window")
internal static class Program
{
/// <summary>Scratch folder next to the exe for files tests write. Emptied at start.</summary>
public static string TempRoot { get; } = Path.Combine(AppContext.BaseDirectory, "scratch");
private static int Main(string[] args)
{
if (Directory.Exists(TempRoot)) Directory.Delete(TempRoot, recursive: true);
Directory.CreateDirectory(TempRoot);
var runner = new Runner();
BountyTests.Register(runner);
BountyReviewTests.Register(runner);
return runner.Run("RynthILT tests", args.Length > 0 ? args[0] : null);
}
}

View file

@ -0,0 +1,38 @@
<Project Sdk="Microsoft.NET.Sdk">
<!--
Tests for the RynthILT plugin's ACECustom bounty tracker (Bounty/BountyParse.cs and
Bounty/BountyTracker.cs, ported from SilentKelpie's rynth/RynthSuite PR #11 with his
BountyTests). The plugin is a NativeAOT x86 library, so its host-agnostic sources are
compiled in here directly instead of referencing the project. File tests use a scratch
folder next to the exe, never %APPDATA%\RynthCore.
Run: dotnet run -c Release (exit 0 = pass, 1 = fail; an argument filters by test name)
-->
<PropertyGroup>
<OutputType>Exe</OutputType>
<TargetFramework>net10.0</TargetFramework>
<Nullable>enable</Nullable>
<InvariantGlobalization>true</InvariantGlobalization>
<RootNamespace>RynthILT.Tests</RootNamespace>
</PropertyGroup>
<ItemGroup>
<Compile Include="..\..\Plugins\RynthCore.Plugin.RynthILT\Bounty\BountyParse.cs" Link="Plugin\BountyParse.cs" />
<Compile Include="..\..\Plugins\RynthCore.Plugin.RynthILT\Bounty\BountyTracker.cs" Link="Plugin\BountyTracker.cs" />
<Compile Include="..\..\Plugins\RynthCore.Plugin.RynthILT\RynthILTJsonContext.cs" Link="Plugin\RynthILTJsonContext.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" />
</ItemGroup>
<!-- The engine's Bounties snapshot reader (self-contained DTOs), so BountyTests checks the plugin's
JSON against the engine's own reader. Optional, so this builds before the engine side is
merged: without the file the round-trip check is compiled out (ENGINE_BOUNTIES). -->
<PropertyGroup Condition="Exists('..\..\..\RynthCore\src\RynthCore.Engine\UI\Data\BountiesSnapshotJson.cs')">
<DefineConstants>$(DefineConstants);ENGINE_BOUNTIES</DefineConstants>
</PropertyGroup>
<ItemGroup Condition="Exists('..\..\..\RynthCore\src\RynthCore.Engine\UI\Data\BountiesSnapshotJson.cs')">
<Compile Include="..\..\..\RynthCore\src\RynthCore.Engine\UI\Data\BountiesSnapshotJson.cs" Link="Engine\BountiesSnapshotJson.cs" />
</ItemGroup>
</Project>