RynthServers as of 2026-11-17 (internal 2bf93a4): release 2026.11.17.1

This commit is contained in:
Tom Bohar 2026-11-17 10:32:01 -05:00
commit 4b09478f12
24 changed files with 3676 additions and 261 deletions

View file

@ -0,0 +1,394 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using RynthCore.Plugin.RynthDreamWeave;
using RynthCore.RynthAiTests.Harness;
namespace RynthServerPack.Tests;
// RynthDreamWeave's leaderboards (Plugins\RynthCore.Plugin.RynthDreamWeave\DreamWeave\DreamWeaveBoards.cs,
// 2026-11-15): DreamWeave's /top replies read into boards, its own replies marked for hiding while a typed
// /top shows, the automatic refresh's timing, the boards kept on disk, and where you stand.
// The replies are shaped as a live client got them on 2026-11-15 (one chat message per board, lines split by
// '\n'); every name is made up.
internal static class DreamWeaveBoardsTests
{
private const int System = 0x05, Broadcast = 0x00, Tell = 0x03;
private static readonly DateTime Utc = new(2026, 11, 15, 17, 0, 0, DateTimeKind.Utc);
private static readonly string[] Names =
{
"Aldric Venn", "Brisa", "Corvo Hale", "Dunmere", "Elsk", "Fenwick Ash", "Gorran", "Hessa Pell", "Ivo", "Jarrow Kett",
"Kaelith", "Lunet", "Morrow Stane", "Nyssa", "Orrin Dale", "Pellam", "Quill", "Rhoswen", "Sable Mott", "Tamsin",
};
private static string LevelBoard()
{
var sb = new StringBuilder("=== Level Leaderboard (Top 20) ===\n");
for (int i = 0; i < 20; i++) sb.Append($"{i + 1}. {Names[i]} - Level {498 - i * 5}\n");
return sb.ToString();
}
private static string CapBoard() =>
"=== Class Ability Points Leaderboard (Top 20) ===\n"
+ string.Concat(Enumerable.Range(0, 20).Select(i => $"{i + 1}. {Names[i]} - {45 - i / 2} earned\n"))
+ "...\n34. Wynfor (you) - 33 earned\n";
public static void Register(Runner r)
{
r.Add("dw boards: a /top board is read (header, 20 rows, your row below the list)", ReadBoard);
r.Add("dw boards: every board shape (bank account row, speed season, winners, arena, knot, empty, refusals)", Shapes);
r.Add("dw boards: only the reply to its own request is hidden; a typed /top shows and still updates", OursAndTyped);
r.Add("dw boards: player chat, a quote mid-message and a late split line are not read", NotRead);
r.Add("dw boards: a board longer than RynthCore hands a plugin is read to its last whole line and marked cut", Cut);
r.Add("dw boards: lines split over messages are read within a few seconds of the header", SplitLines);
r.Add("dw boards: automatic refresh: off by default, one board every 35 s, one at a time, gives up after 6 s", AutoTiming);
r.Add("dw boards: automatic refresh skips cut boards, recent boards, portal space and a typed /top's reply", AutoSkips);
r.Add("dw boards: Read all boards asks for every board, one every 6 s", Sweep);
r.Add("dw boards: the boards are saved and read back (broken or unknown data left out)", Saved);
r.Add("dw boards: where you stand, and the command and board names", Standing);
}
private static DreamWeaveBoards Logged(out long t)
{
var b = new DreamWeaveBoards();
t = 1_000_000;
b.Login(t);
return b;
}
private static void ReadBoard()
{
DreamWeaveBoards b = Logged(out long t);
Check.Eq(b.Request("level", t), "/top level", "the level board's command");
Check.True(b.Pending, "the request waits");
Check.True(b.OnChatText(LevelBoard(), System, t + 300, Utc), "our reply: hidden");
Check.False(b.Pending, "answered");
BoardResult? r = b.Result("level");
Check.NotNull(r, "read");
Check.Eq(r!.Rows.Count, 20, "20 rows");
Check.Eq(r.Rows[0].Rank, 1, "rank 1");
Check.Eq(r.Rows[0].Name, "Aldric Venn", "a name with a space");
Check.Eq(r.Rows[19].Value, "Level 403", "the last value");
Check.Null(r.Below, "nothing below the list");
Check.Eq(r.UpdatedUtc, Utc, "when");
Check.False(r.Cut, "whole");
b.Request("cap", t + 10_000);
Check.True(b.OnChatText(CapBoard(), System, t + 10_200, Utc), "cap: hidden");
r = b.Result("cap")!;
Check.Eq(r.Rows.Count, 20, "cap: 20 rows, the '...' and your row aren't rows");
Check.NotNull(r.Below, "your row below the list");
Check.Eq(r.Below!.Rank, 34, "your rank");
Check.Eq(r.Below.Name, "Wynfor", "your name without '(you)'");
Check.Eq(r.Below.Value, "33 earned", "your value");
Check.True(r.Below.Marked && !r.Below.Account, "marked as you");
}
private static void Shapes()
{
DreamWeaveBoards b = Logged(out long t);
b.OnChatText("=== Banked Pyreals Leaderboard (Top 20) ===\n1. Brisa - 12,007,997,013 pyreals\n2. Gorran - 9,123,456 pyreals\n...\n27. Lunet (your account) - 747,436,009 pyreals\n", System, t, Utc);
BoardResult bank = b.Result("bank")!;
Check.Eq(bank.Rows[0].Value, "12,007,997,013 pyreals", "bank value");
Check.True(bank.Below!.Account && bank.Below.Marked, "the account row");
Check.Eq(b.StandingText("bank"), "#27 (below the list) (your account)", "the account standing");
b.Request("speed", t + 1_000);
Check.True(b.OnChatText("=== The Black Book - Cells of the Black Book Leaderboard (Top 20) ===\n1. Corvo Hale - 3:55.55\n2. Elsk - 4:11.89\n", System, t + 1_200, Utc),
"speed: any title, when /top speed was asked");
Check.Eq(b.Result("speed")!.Title, "The Black Book - Cells of the Black Book", "the season title");
Check.Eq(b.Result("speed")!.Rows[1].Value, "4:11.89", "a time");
Check.False(b.OnChatText("=== Mystery Board Leaderboard (Top 20) ===\n1. Ivo - 3\n", System, t + 60_000, Utc), "an unknown title without /top speed isn't read");
Check.Eq(b.Result("speed")!.Rows.Count, 2, "and changes nothing");
b.Request("speed", t + 70_000);
b.OnChatText("=== Season 4 - Crypt Leaderboard (Top 20) ===\nThat season has ended. No speed trial season is currently running.\nNo scores have been recorded yet.\n", System, t + 70_100, Utc);
Check.Eq(b.Result("speed")!.Rows.Count, 0, "an ended season with no runs");
Check.True(b.Result("speed")!.Note.Contains("That season has ended") && b.Result("speed")!.Note.Contains("No scores"), "both notes");
b.Request("winners", t + 80_000);
Check.True(b.OnChatText("=== Speed Trial Winners (Last 20 Seasons) ===\n1. The Black Book - Cells of the Black Book - Kaelith - 3:55.55\n2. The Unsung Choir - Lost Coastal Archive - unclaimed\n3. Test Season - The Orange Room - unclaimed\n", System, t + 80_100, Utc), "winners: hidden");
BoardResult w = b.Result("winners")!;
Check.Eq(w.Rows.Count, 3, "three seasons");
Check.Eq(w.Rows[0].Detail, "The Black Book - Cells of the Black Book", "the season");
Check.Eq(w.Rows[0].Name, "Kaelith", "its winner");
Check.Eq(w.Rows[0].Value, "3:55.55", "the time");
Check.Eq(w.Rows[1].Name, "unclaimed", "an unclaimed season");
Check.Eq(w.Rows[1].Detail, "The Unsung Choir - Lost Coastal Archive", "its season");
b.Request("2v2", t + 90_000);
Check.True(b.OnChatText("[Arena] Top 10 - 2v2:\r\n1. Dunmere (War Mage) 1540 (2-0)\r\n2. Fenwick Ash (Heavy Weapon) 1500 (1-1)\r\n3. Pellam 1460 (0-2)", Broadcast, t + 90_100, Utc), "arena: hidden");
BoardResult a = b.Result("2v2")!;
Check.Eq(a.Rows.Count, 3, "arena rows");
Check.Eq(a.Rows[1].Name, "Fenwick Ash", "arena name");
Check.Eq(a.Rows[1].Value, "1500", "rating");
Check.Eq(a.Rows[1].Detail, "Heavy Weapon, 1-1", "template and record");
Check.Eq(a.Rows[2].Detail, "0-2", "no template");
b.OnChatText("[Arena] Top 10 - Tugak Brawl:\n1. Nyssa (Finesse Weapon) 1500 (1-0)", Broadcast, t + 95_000, Utc);
Check.Eq(b.Result("tugak")!.Rows.Count, 1, "tugak by its label");
b.Request("bg", t + 100_000);
Check.True(b.OnChatText("[Arena] No one is ranked in Battleground yet.", Broadcast, t + 100_100, Utc), "an empty ladder: ours");
Check.Eq(b.Result("bg")!.Note, "No one is ranked yet.", "empty ladder note");
b.Request("knot", t + 110_000);
b.OnChatText("=== Knot Clears Leaderboard (Top 20) ===\n1. Quill - Level 436 - Drift Olthoi Matron - 2:40.91\n2. Tamsin - Level 297\n", System, t + 110_100, Utc);
Check.Eq(b.Result("knot")!.Rows[0].Value, "Level 436 - Drift Olthoi Matron - 2:40.91", "knot: the whole value");
Check.Eq(b.Result("knot")!.Rows[1].Value, "Level 297", "a clear without a time");
b.Request("thread", t + 120_000);
b.OnChatText("=== Thread-Guide Leaderboard (Top 20) ===\n1. Rhoswen - rung 375 (1,132 clears)\n2. Ivo - no rung (4 clears)\n", System, t + 120_100, Utc);
Check.Eq(b.Result("thread")!.Rows[1].Value, "no rung (4 clears)", "thread values");
b.Request("stamp", t + 130_000);
Check.True(b.OnChatText("Quest stamps are not currently enabled on this server.", System, t + 130_100, Utc), "a refusal answers our request");
Check.Eq(b.Result("stamp")!.Note, "Quest stamps are not currently enabled on this server.", "kept as the board's note");
b.Request("1v1", t + 140_000);
Check.True(b.OnChatText("[Arena] Arena ratings are unavailable right now.", Broadcast, t + 140_100, Utc), "arena refusal");
Check.False(b.OnChatText("Bank balances are unavailable right now, try again shortly.", System, t + 400_000, Utc), "a refusal with no /top out isn't read");
b.Request("deaths", t + 150_000);
b.OnChatText("=== Deaths Leaderboard (Top 20) ===\nNo scores have been recorded yet.\nYou are exempt from the leaderboards, so your own scores are not listed.\n", System, t + 150_100, Utc);
Check.True(b.Result("deaths")!.Note.StartsWith("No scores") && b.Result("deaths")!.Note.Contains("exempt"), "empty and exempt");
foreach (BoardDef d in DreamWeaveBoards.Defs) Check.NotNull(DreamWeaveBoards.Def(d.Key), "def " + d.Key);
Check.Eq(DreamWeaveBoards.Defs.Length, 17, "17 boards");
}
private static void OursAndTyped()
{
DreamWeaveBoards b = Logged(out long t);
// Typed by the player: shows, and updates.
b.NoteTyped("/top level", t);
Check.False(b.OnChatText(LevelBoard(), System, t + 300, Utc), "typed: shown");
Check.Eq(b.Result("level")!.Rows.Count, 20, "typed: read");
// Ours for level, the player types /top level too: theirs, shown.
b.Request("level", t + 10_000);
b.NoteTyped("/top level", t + 10_050);
Check.False(b.Pending, "the typed one takes it over");
Check.False(b.OnChatText(LevelBoard(), System, t + 10_300, Utc), "both asked: shown");
// Ours for cap, the player types /top deaths: the cap reply is still ours, deaths shows.
b.Request("cap", t + 20_000);
b.NoteTyped("/top deaths", t + 20_010);
Check.False(b.OnChatText("=== Deaths Leaderboard (Top 20) ===\n1. Ivo - 3 deaths\n", System, t + 20_200, Utc), "their board shows");
Check.True(b.Pending, "ours still waits");
Check.True(b.OnChatText(CapBoard(), System, t + 20_300, Utc), "ours hidden");
// Late: not ours any more.
b.Request("title", t + 30_000);
Check.False(b.OnChatText("=== Titles Leaderboard (Top 20) ===\n1. Brisa - 203 titles\n", System, t + 30_000 + DreamWeaveBoards.ReplyTimeoutMs + 1, Utc), "a late reply shows");
Check.Eq(b.Result("title")!.Rows[0].Value, "203 titles", "and is read");
Check.True(b.LastMiss.Length > 0, "the miss is noted");
// A failed send leaves nothing waiting.
b.Request("level", t + 40_000);
b.NotSent();
Check.False(b.Pending, "not sent: nothing waits");
Check.False(b.OnChatText(LevelBoard(), System, t + 40_100, Utc), "and the reply isn't ours");
}
private static void NotRead()
{
DreamWeaveBoards b = Logged(out long t);
b.Request("level", t);
Check.False(b.OnChatText(LevelBoard(), Tell, t + 100, Utc), "a tell isn't read");
Check.Null(b.Result("level"), "nothing read");
Check.False(b.OnChatText("Ivo says, \"=== Level Leaderboard (Top 20) ===\"\n1. Ivo - Level 999\n", System, t + 200, Utc), "a quote isn't a header");
Check.Null(b.Result("level"), "still nothing");
Check.False(b.OnChatText("1. Ivo - Level 999", System, t + 300, Utc), "a row with no header isn't read");
b.OnChatText(LevelBoard(), System, t + 400, Utc);
Check.False(b.OnChatText("21. Ivo - Level 1", System, t + 400 + DreamWeaveBoards.BlockMs + 1, Utc), "a row long after the header isn't read");
Check.Eq(b.Result("level")!.Rows.Count, 20, "rows unchanged");
Check.False(b.OnChatText("", System, t, Utc) || b.OnChatText(null, System, t, Utc), "empty");
}
private static string LongKnot()
{
var sb = new StringBuilder("=== Knot Clears Leaderboard (Top 20) ===\n");
for (int i = 0; i < 20; i++) sb.Append($"{i + 1}. {Names[i]} - Level {436 - i * 7} - Drift Olthoi Matron - {2 + i % 7}:{10 + i * 2}.{50 + i}\n");
sb.Append("...\n41. Wynfor (you) - Level 120 - Drift Olthoi Matron - 9:00.00\n");
return sb.ToString();
}
private static void Cut()
{
DreamWeaveBoards b = Logged(out long t);
string full = LongKnot();
Check.True(full.Length > DreamWeaveBoards.EngineMaxChars, "the fixture is longer than the engine hands over");
string seen = full[..DreamWeaveBoards.EngineMaxChars];
b.Request("knot", t);
Check.True(b.OnChatText(seen, System, t + 200, Utc), "ours (the engine prints it anyway)");
BoardResult r = b.Result("knot")!;
Check.True(r.Cut, "marked cut");
int whole = seen.Split('\n').Length - 1; // complete lines, the header included
Check.Eq(r.Rows.Count, whole - 1, "every whole row, not the cut one");
foreach (BoardRow row in r.Rows) Check.True(row.Value.Contains(':') && row.Value.Split(" - ").Length == 3, "a whole row: " + row.Value);
Check.Null(r.Below, "your row was past the cut");
Check.True(r.Note.Contains("cut short"), "the note says so");
Check.Eq(b.StandingText("knot"), "not in the part read", "standing on a cut board");
}
private static void SplitLines()
{
DreamWeaveBoards b = Logged(out long t);
b.Request("level", t);
Check.True(b.OnChatText("=== Level Leaderboard (Top 20) ===", System, t + 100, Utc), "header alone: ours");
Check.True(b.OnChatText("1. Brisa - Level 498", System, t + 150, Utc), "a row in its own message: ours");
Check.True(b.OnChatText("2. Ivo - Level 490", System, t + 3_000, Utc), "within a few seconds of the last line");
Check.True(b.OnChatText("...", System, t + 3_100, Utc), "the dots");
Check.True(b.OnChatText("40. Wynfor (you) - Level 300", System, t + 3_200, Utc), "your row");
Check.Eq(b.Result("level")!.Rows.Count, 2, "two rows");
Check.Eq(b.Result("level")!.Below!.Rank, 40, "and yours");
Check.False(b.OnChatText("3. Ivo - Level 1", System, t + 3_200 + DreamWeaveBoards.BlockMs + 1, Utc), "too late");
}
private static void AutoTiming()
{
var b = new DreamWeaveBoards();
b.LoadSettings((_, fallback) => fallback);
Check.False(b.AutoRefresh, "off by default");
long t = 1_000_000;
b.Login(t);
Check.Null(b.Due(t + DreamWeaveBoards.FirstAutoDelayMs + 1, true), "off: nothing");
b.AutoRefresh = true;
Check.Null(b.Due(t + 1_000, true), "not right after login");
string? first = b.Due(t + DreamWeaveBoards.FirstAutoDelayMs, true);
Check.Eq(first, "/top level", "the first board after the delay");
long now = t + DreamWeaveBoards.FirstAutoDelayMs;
Check.True(b.Pending, "it waits for its reply");
b.OnChatText(LevelBoard(), System, now + 300, Utc);
Check.Null(b.Due(now + 1_000, true), "not before the interval");
Check.Eq(b.Due(now + DreamWeaveBoards.AutoIntervalMs, true), "/top bank", "the next board in turn");
now += DreamWeaveBoards.AutoIntervalMs;
// No reply: given up after 6 s, the next one goes at its time.
b.Expire(now + DreamWeaveBoards.ReplyTimeoutMs);
Check.False(b.Pending, "given up");
Check.Eq(b.LastMiss, "No reply to /top bank.", "the miss");
Check.Eq(b.Due(now + DreamWeaveBoards.AutoIntervalMs, true), "/top cap", "the next");
// Every board once per round: 17 x 35 s is about ten minutes.
Check.True(DreamWeaveBoards.Defs.Length * DreamWeaveBoards.AutoIntervalMs is >= 9 * 60_000 and <= 11 * 60_000, "a round is about ten minutes");
b.Logout();
Check.Null(b.Due(now + 10 * 60_000, true), "nothing after logout");
// Turned on later: the first board soon.
var c = new DreamWeaveBoards();
c.Login(t);
c.SetAutoRefresh(true, t + 1_000);
Check.Eq(c.Due(t + 6_000, true), "/top level", "on: a board within seconds");
}
private static void AutoSkips()
{
DreamWeaveBoards b = Logged(out long t);
b.AutoRefresh = true;
long now = t + DreamWeaveBoards.FirstAutoDelayMs;
Check.Null(b.Due(now, false), "not outside the world or in portal space");
// The player just typed /top bank: wait for its reply first.
b.NoteTyped("/top bank", now);
Check.Null(b.Due(now + 100, true), "a typed /top's reply may still come");
// A cut board (knot) and one read just now (bank, the typed one) are skipped.
b.OnChatText("=== Banked Pyreals Leaderboard (Top 20) ===\n1. Brisa - 5 pyreals\n", System, now + 200, Utc);
b.Request("knot", now + 300);
b.OnChatText(LongKnot()[..DreamWeaveBoards.EngineMaxChars], System, now + 400, Utc);
var asked = new List<string>();
long at = now + 1_000;
for (int i = 0; i < 40 && asked.Count < 15; i++, at += DreamWeaveBoards.AutoIntervalMs)
{
string? cmd = b.Due(at, true);
if (cmd == null) continue;
asked.Add(cmd);
b.NotSent(); // nothing waits
}
Check.False(asked.Contains("/top knot"), "the cut board is left out");
Check.False(asked.Take(10).Contains("/top bank"), "a board read just now waits for the next round");
Check.True(asked.Contains("/top level") && asked.Contains("/top bg"), "the others go");
}
private static void Sweep()
{
DreamWeaveBoards b = Logged(out long t);
b.Request("level", t);
b.SweepAll();
Check.Eq(b.SweepLeft, 17, "every board queued");
Check.Null(b.Due(t + 100, true), "one request at a time: not while one waits");
b.OnChatText(LevelBoard(), System, t + 200, Utc);
var sent = new List<string>();
long now = t;
for (int i = 0; i < 200 && b.SweepLeft > 0; i++, now += 1_000)
{
string? cmd = b.Due(now, true);
if (cmd == null) continue;
sent.Add(cmd);
b.OnChatText("Quest stamps are not currently enabled on this server.", System, now + 100, Utc); // any answer
}
Check.Eq(sent.Count, 17, "17 sent");
Check.Eq(sent.Distinct().Count(), 17, "each once");
Check.True(now - t >= 16 * DreamWeaveBoards.SweepIntervalMs, "paced");
Check.True(sent.Contains("/top speed winners"), "speed winners");
}
private static void Saved()
{
DreamWeaveBoards b = Logged(out long t);
b.OnChatText(CapBoard(), System, t, Utc);
b.OnChatText("[Arena] Top 10 - 1v1:\n1. Dunmere (War Mage) 1600 (11-0)", Broadcast, t + 10, Utc);
b.Request("knot", t + 20);
b.OnChatText(LongKnot()[..DreamWeaveBoards.EngineMaxChars], System, t + 30, Utc);
Check.True(b.Dirty, "read: to save");
string json = b.SaveJson();
Check.False(b.Dirty, "saved");
var c = new DreamWeaveBoards();
c.LoadSaved(json);
Check.Eq(c.ReadCount, 3, "three boards back");
BoardResult cap = c.Result("cap")!;
Check.Eq(cap.Rows.Count, 20, "rows back");
Check.Eq(cap.Rows[3].Name, Names[3], "a name");
Check.Eq(cap.Below!.Rank, 34, "your row back");
Check.True(cap.Below.Marked, "still yours");
Check.Eq(cap.UpdatedUtc, Utc, "when");
Check.Eq(cap.UpdatedMs, 0L, "from disk: due for the automatic refresh");
Check.Eq(c.Result("1v1")!.Rows[0].Detail, "War Mage, 11-0", "arena detail");
Check.True(c.Result("knot")!.Cut, "cut kept, so it stays out of the automatic refresh");
Check.Eq(DreamWeaveBoards.FromJson("{ broken").Count, 0, "broken: nothing");
Check.Eq(DreamWeaveBoards.FromJson(null).Count, 0, "missing: nothing");
Check.Eq(DreamWeaveBoards.FromJson("{\"v\":1,\"boards\":[{\"key\":\"fishing\",\"rows\":[]},{\"key\":\"level\",\"rows\":[{\"r\":1,\"n\":\"Ivo\",\"v\":\"Level 9\"}]}]}").Count, 1,
"an unknown board is left out");
string path = DreamWeaveBoards.SavePath(@"C:\x\RynthCore\rynthdreamweave.json", 0x50000180);
Check.Eq(path, @"C:\x\RynthCore\rynthdreamweave.boards.50000180.json", "beside the settings, per character");
}
private static void Standing()
{
DreamWeaveBoards b = Logged(out long t);
Check.Eq(b.StandingText("level"), "not read yet", "not read");
b.OnChatText(LevelBoard(), System, t, Utc);
Check.Eq(b.StandingText("level"), "not on it", "not on it");
b.YourName = "hessa pell";
Check.Eq(b.StandingText("level"), "#8", "by your name in the list (any case)");
Check.Eq(b.Standing("level").Value, "Level 463", "your value");
b.OnChatText(CapBoard(), System, t + 10, Utc);
Check.Eq(b.StandingText("cap"), "#8", "in the list beats the server's below row only when listed");
b.YourName = "Wynfor";
Check.Eq(b.StandingText("cap"), "#34 (below the list)", "below the list");
b.OnChatText("[Arena] Top 10 - 1v1:\n1. Wynfor (War Mage) 1600 (11-0)", Broadcast, t + 20, Utc);
Check.Eq(b.Standing("1v1").Value, "rating 1600 (War Mage, 11-0)", "arena standing");
Check.Eq(DreamWeaveBoards.KeyOfCommand("/top"), "", "the list");
Check.Eq(DreamWeaveBoards.KeyOfCommand(" /TOP Speed Winners "), "winners", "speed winners");
Check.Eq(DreamWeaveBoards.KeyOfCommand("/top speed"), "speed", "speed");
Check.Eq(DreamWeaveBoards.KeyOfCommand("/top stamps"), "stamp", "stamps");
Check.Eq(DreamWeaveBoards.KeyOfCommand("/top 2v2 20"), "2v2", "a count after an arena board");
Check.Null(DreamWeaveBoards.KeyOfCommand("/top fishing"), "unknown");
Check.Null(DreamWeaveBoards.KeyOfCommand("/topple"), "not /top");
Check.Null(DreamWeaveBoards.KeyOfCommand("/b"), "not /top");
Check.Eq(DreamWeaveBoards.KeyOfName("speed winners"), "winners", "name: speed winners");
Check.Eq(DreamWeaveBoards.KeyOfName("Class ability points"), "cap", "name: a label");
Check.Null(DreamWeaveBoards.KeyOfName(""), "name: empty");
Check.Eq(DreamWeaveBoards.Age(Utc, Utc.AddSeconds(30)), "updated just now", "age now");
Check.Eq(DreamWeaveBoards.Age(Utc, Utc.AddMinutes(9.5)), "updated 9 min ago", "age min");
Check.Eq(DreamWeaveBoards.Age(Utc, Utc.AddHours(3)), "updated 3 h ago", "age h");
Check.Eq(DreamWeaveBoards.Age(DateTime.MinValue, Utc), "not read yet", "age never");
}
}

View file

@ -31,6 +31,8 @@ internal static class DreamWeaveSkillsTests
r.Add("dreamweave skills: the Titles page (the server's list, updates, saving)", Titles);
r.Add("dreamweave skills: one main panel at a time, as retail", OnePanel);
r.Add("dreamweave skills: +10 presses made while a raise is on its way wait for its answer", HeldPresses);
r.Add("dreamweave skills: +10 buys the last ranks when fewer than ten are left, as retail", TenToTheTop);
r.Add("dreamweave skills: a read dropped at logout doesn't freeze the panel (R-20261114-190620-f744)", ReadGateLostRead);
}
private static void Attributes()
@ -315,6 +317,51 @@ internal static class DreamWeaveSkillsTests
Check.Eq(rule.Next(true, Map), default(OnePanelRule.Step), "after a reset the first frame only learns again");
}
// 2026-11-14, report R-20261114-190620-f744: a level-497 character's panel still read level 495 and that
// level's XP for next level. The panel's one-read-in-flight flag was set when a read was queued for the
// tick and cleared when it ran; the shared plugin drops the tick's queue at logout, so a read queued in
// the last frames before a logout left the flag set and no read was ever queued again.
private static void ReadGateLostRead()
{
var gate = new ReadGate();
Check.True(gate.Due(10_000, everyFrame: false), "the first frame reads");
Check.True(gate.Waiting, "one queued");
Check.False(gate.Due(10_000 + ReadGate.EveryMs, everyFrame: false), "not a second while the first waits");
Check.False(gate.Due(10_001, everyFrame: true), "not even every-frame while one waits");
gate.Done();
Check.False(gate.Due(10_100, everyFrame: false), "four a second");
Check.True(gate.Due(10_000 + ReadGate.EveryMs, everyFrame: false), "the next after 250 ms");
gate.Done();
Check.True(gate.Due(10_251, everyFrame: true), "a raise on its way: the very next frame");
gate.Done();
// The reported freeze: a read queued, then its queue dropped (logout), so Done never comes.
Check.True(gate.Due(20_000, everyFrame: false), "queued just before the logout");
for (long t = 20_000; t < 20_000 + ReadGate.LostAfterMs; t += 16)
Check.False(gate.Due(t, everyFrame: false), "still waiting for it at " + t);
Check.True(gate.Due(20_000 + ReadGate.LostAfterMs, everyFrame: false), "taken as lost and queued again");
gate.Done();
Check.True(gate.Due(20_000 + ReadGate.LostAfterMs + ReadGate.EveryMs, everyFrame: false), "and reading on after it");
// Logout resets it (SkillsReader.Clear): the next login's first frame reads, whatever was waiting.
Check.True(gate.Waiting, "a read waiting at logout");
gate.Reset();
Check.False(gate.Waiting, "forgotten");
Check.True(gate.Due(30_000, everyFrame: false), "the next login reads at once");
gate.Done();
// After a raise or a title the panel asks for a read at once.
Check.True(gate.Due(40_000, everyFrame: false), "a read");
gate.Done();
gate.AskNow();
Check.True(gate.Due(40_001, everyFrame: false), "AskNow: the next frame, not 250 ms later");
gate.Done();
// A clock reading of 0 still marks a read as waiting.
var zero = new ReadGate();
Check.True(zero.Due(0, everyFrame: false), "read at clock 0");
Check.True(zero.Waiting, "and it waits");
}
private static void HeldPresses()
{
var held = new HeldRaises();
@ -366,4 +413,69 @@ internal static class DreamWeaveSkillsTests
Check.Eq(held.Count, 3, "vital +10 spam is held too");
held.Drop();
}
// A #rynth-issues report, 2026-11-11 ("Can't max skills"): a trained skill untrained and trained again
// came back at rank 0; twenty +10s took it to 200 of 208 and +10 went dark (the engine prices +10 only
// with ten ranks left), so it could no longer be maxed by tens. Retail's +10 (GetCostToRaise10) buys
// the ranks left when fewer than ten are. The report's footer read "Experience To Raise: 180,507,736",
// which is the trained chart's step from 200 to 201.
private static void TenToTheTop()
{
uint[] tr = RetailData.TrainedSkillXp, sp = RetailData.SpecializedSkillXp;
Check.Eq(tr.Length - 1, 208, "trained skills top out at 208 ranks");
Check.Eq(sp.Length - 1, 226, "specialized at 226");
Check.Eq(tr[208], 4_203_819_496u, "the trained top is portal.dat's (the engine prices from the same table)");
Check.Eq(sp[226], 4_100_490_438u, "the specialized top too");
Check.Eq((long)tr[201] - tr[200], 180_507_736L, "the report's cost to raise: trained rank 200");
// The reported skill: trained, rank 200, the engine's +10 is -1.
var rich = SkillsSheet.Empty with { UnassignedXp = 194_045_060_050 };
SkillLine at200 = Skill(18, SkillClass.Trained, b: 277, buffed: 353, one: 180_507_736, ten: -1) with { Ranks = 200, XpSpent = tr[200] };
Check.Eq(SkillsLayout.Ten(at200), (8u, (long)tr[208] - tr[200]), "+10 at 200 of 208 buys the last 8");
Check.True(SkillsLayout.CanRaiseTen(rich, at200), "and is lit with the XP for them");
Check.False(SkillsLayout.CanRaiseTen(rich with { UnassignedXp = (long)tr[208] - tr[200] - 1 }, at200), "dark one XP short");
// XP from use part way into the rank counts, as the engine's own price does.
SkillLine partWay = at200 with { XpSpent = tr[200] + 1000 };
Check.Eq(SkillsLayout.Ten(partWay).Cost, (long)tr[208] - tr[200] - 1000, "XP already in the rank is not paid twice");
// At the top: nothing.
SkillLine top = at200 with { Ranks = 208, XpSpent = tr[208], CostOne = -1, Raisable = false, AtTop = true };
Check.Eq(SkillsLayout.Ten(top), (0u, -1L), "at the top +10 buys nothing");
Check.False(SkillsLayout.CanRaiseTen(rich, top), "and is dark");
// Ten or more left: the engine's price, as before.
SkillLine low = Skill(18, SkillClass.Trained, ten: 12_000) with { Ranks = 50, XpSpent = tr[50] };
Check.Eq(SkillsLayout.Ten(low), (10u, 12_000L), "ten left: the engine's +10");
Check.Eq(SkillsLayout.TenStep(tr, 50, tr[50], -1), (0u, -1L), "ten left but no engine price: don't guess");
Check.Eq(SkillsLayout.Ten(Skill(23, SkillClass.Untrained, ten: -1, credits: 6, trainable: true) with { Ranks = 200 }), (0u, -1L), "untrained: no chart, no +10");
// From rank 0 by tens to the very top, trained and specialized (the engine's +10 is -1 under ten left).
foreach ((uint[] chart, SkillClass c, int presses) in new[] { (tr, SkillClass.Trained, 21), (sp, SkillClass.Specialized, 23) })
{
SkillLine s = Skill(18, c) with { Ranks = 0, XpSpent = 0 };
int n = 0;
long paid = 0;
while (n < 100)
{
long engineTen = s.Ranks + 10 < chart.Length ? (long)chart[s.Ranks + 10] - s.XpSpent : -1;
(uint ranks, long cost) = SkillsLayout.Ten(s with { CostTen = engineTen });
if (ranks == 0) break;
n++;
paid += cost;
s = s with { Ranks = s.Ranks + ranks, XpSpent = chart[s.Ranks + ranks] };
}
Check.Eq((int)s.Ranks, chart.Length - 1, c + ": +10 reaches the top");
Check.Eq(n, presses, c + ": in " + presses + " presses");
Check.Eq(paid, (long)chart[^1], c + ": for exactly the chart's total");
}
// Attributes and vitals: retail's gmAttributeUI does the same.
uint[] at = RetailData.AttributeXp, vt = RetailData.VitalXp;
int atTop = at.Length - 1, vtTop = vt.Length - 1;
var str = new AttributeLine(1, 1, "Strength", 0, 280, 280, (long)at[atTop - 4] - at[atTop - 5], -1, true, false, (uint)(atTop - 5), at[atTop - 5]);
Check.Eq(AttributesPage.Ten(str), (5u, (long)at[atTop] - at[atTop - 5]), "an attribute 5 from the top: +10 buys 5");
Check.True(AttributesPage.CanRaiseTen(rich, str), "lit");
var mana = new AttributeLine(2, 5, "Mana", 0, 400, 400, (long)vt[vtTop] - vt[vtTop - 1], -1, true, false, (uint)(vtTop - 1), vt[vtTop - 1]);
Check.Eq(AttributesPage.Ten(mana), (1u, (long)vt[vtTop] - vt[vtTop - 1]), "a vital one from the top: +10 buys 1");
var maxed = mana with { Ranks = (uint)vtTop, XpSpent = vt[vtTop], CostOne = -1, Raisable = false, AtTop = true };
Check.False(AttributesPage.CanRaiseTen(rich, maxed), "a vital at the top: dark");
}
}

View file

@ -0,0 +1,428 @@
using System;
using RynthCore.Plugin.RynthDreamWeave;
using RynthCore.RynthAiTests.Harness;
namespace RynthServerPack.Tests;
// RynthDreamWeave's offline bonus tracker (Plugins\RynthCore.Plugin.RynthDreamWeave\DreamWeave\DreamWeaveXpBonus.cs,
// 2026-11-15): every line the server sends about it (worded as ACE-DreamWeave's source of 2026-11-02 writes them),
// every duration format, its own /offlinebonus's reply hidden while a typed one shows, the automatic read's timing,
// the local clock between readings, and the reading kept on disk.
internal static class DreamWeaveXpBonusTests
{
private const int Broadcast = 0x00, System = 0x05, Tell = 0x03;
private static readonly DateTime Utc = new(2026, 11, 15, 17, 0, 0, DateTimeKind.Utc);
private const string Spent = "Offline experience bonus: +100% to your combat experience and Luminance for the next 48m 31s, currently being SPENT (draining while you fight).";
private const string Banking = "Offline experience bonus: +100% to your combat experience and Luminance for the next 3h 10m, currently BANKING (idle for longer than the 5m 0s timeout, so it's growing again instead of draining).";
private const string NoneBanked = "You have no offline experience bonus banked. Log this character out to bank bonus time while you play others.";
private const string Disabled = "The offline experience bonus is not enabled on this server.";
public static void Register(Runner r)
{
r.Add("dw xpbonus: every duration format is read, and written as the server writes it", Durations);
r.Add("dw xpbonus: the /offlinebonus replies (spent, banking, active, other percent, none banked, not enabled)", StatusReplies);
r.Add("dw xpbonus: the pushes (now active, banking again, exhausted, welcome back)", Pushes);
r.Add("dw xpbonus: the [BANK] line and /bonus lines keep the state; two a minute apart can set it", RemainingOnly);
r.Add("dw xpbonus: player chat and a quoted copy are not read", NotRead);
r.Add("dw xpbonus: only the reply to its own request is hidden; typed and pushed lines show", OursAndTyped);
r.Add("dw xpbonus: automatic read: off by default, 35 s after login, every 10 min, only when quiet", AutoTiming);
r.Add("dw xpbonus: Check now goes at the next quiet moment, the automatic read on or off", CheckNow);
r.Add("dw xpbonus: the clock counts down while active, up while banking (to the cap), stops at 0", Clock);
r.Add("dw xpbonus: the tracker's line and how old the reading is", Lines);
r.Add("dw xpbonus: the reading is saved and read back (a newer live one kept, broken data left out)", Saved);
r.Add("dw xpbonus: the bank's and the boards' next command times, for the gap", NextTimes);
}
private static DreamWeaveXpBonus Logged(out long t)
{
var x = new DreamWeaveXpBonus();
t = 1_000_000;
x.Login(t);
return x;
}
private static void Durations()
{
void Is(string text, double seconds, double res)
{
Check.True(DreamWeaveXpBonus.TryDuration(text, out double s, out double r), $"'{text}' is read");
Check.Eq(s, seconds, $"'{text}' = {seconds} s");
Check.Eq(r, res, $"'{text}' is shown to {res} s");
}
Is("3h 10m", 3 * 3600 + 600, 60);
Is("37h 5m", 37 * 3600 + 300, 60); // a long absence: total hours
Is("24h 0m", 86_400, 60);
Is("48m 31s", 48 * 60 + 31, 1);
Is("1m 0s", 60, 1);
Is("12s", 12, 1);
Is("0s", 0, 1);
Is("5m", 300, 60);
Is("2h", 7200, 3600);
foreach (string bad in new[] { "", "abc", "3h10m", "48m31s", "-5s", "3 h", "1d 2h", "3h 10m 5s" })
Check.False(DreamWeaveXpBonus.TryDuration(bad, out _, out _), $"'{bad}' is not a duration");
Check.Eq(DreamWeaveXpBonus.Format(2911), "48m 31s", "minutes and seconds");
Check.Eq(DreamWeaveXpBonus.Format(11_400), "3h 10m", "hours and minutes");
Check.Eq(DreamWeaveXpBonus.Format(11_459.9), "3h 10m", "seconds are dropped past an hour");
Check.Eq(DreamWeaveXpBonus.Format(133_500), "37h 5m", "total hours");
Check.Eq(DreamWeaveXpBonus.Format(12.7), "12s", "seconds, rounded down");
Check.Eq(DreamWeaveXpBonus.Format(-3), "0s", "never negative");
Check.Eq(DreamWeaveXpBonus.Format(60), "1m 0s", "a minute");
}
private static void StatusReplies()
{
DreamWeaveXpBonus x = Logged(out long t);
x.OnChatText(Spent, Broadcast, t, Utc);
Check.Eq(x.State, XpBonusState.Active, "SPENT = active");
Check.Eq(x.Seconds, 2911.0, "48m 31s");
Check.Eq(x.Percent, 100, "+100%");
Check.Eq(x.LastLine, XpBonusLine.Status, "a status line");
x.OnChatText(Banking, Broadcast, t + 1000, Utc);
Check.Eq(x.State, XpBonusState.Banking, "BANKING = idle");
Check.Eq(x.Seconds, 11_400.0, "3h 10m");
x.OnChatText("Offline experience bonus: +100% to your combat experience and Luminance for the next 20m 0s, ACTIVE (draining).", Broadcast, t + 2000, Utc);
Check.Eq(x.State, XpBonusState.Active, "an ACTIVE wording is active too");
Check.Eq(x.Seconds, 1200.0, "20m 0s");
x.OnChatText("Offline experience bonus: +50% to your combat experience and Luminance for the next 5m, currently BANKING.", Broadcast, t + 3000, Utc);
Check.Eq(x.Percent, 50, "another percent");
Check.Eq(x.Seconds, 300.0, "a bare minutes duration");
Check.Eq(x.Title, "XP bonus +50%", "titled with its percent");
x.OnChatText("Offline experience bonus: +100% to your combat experience and Luminance for the next 9s, doing something new.", Broadcast, t + 4000, Utc);
Check.Eq(x.State, XpBonusState.Banking, "an unknown state wording keeps the state");
Check.Eq(x.Seconds, 9.0, "and still reads the time");
x.OnChatText(NoneBanked, Broadcast, t + 5000, Utc);
Check.Eq(x.State, XpBonusState.Empty, "none banked");
Check.Eq(x.Seconds, 0.0, "0 s");
Check.Eq(x.Percent, 100, "the percent stays");
x.OnChatText(Disabled, Broadcast, t + 6000, Utc);
Check.Eq(x.State, XpBonusState.Disabled, "not enabled");
Check.Eq(x.Line(t + 6000), "Offline XP bonus: not enabled on this server", "the not-enabled line");
// With a chat timestamp in front (as RynthCore's chat timestamps put it).
x.OnChatText("[17:01:05] " + Spent, Broadcast, t + 7000, Utc);
Check.Eq(x.State, XpBonusState.Active, "read after a timestamp");
}
private static void Pushes()
{
DreamWeaveXpBonus x = Logged(out long t);
x.OnChatText("Welcome back - you were away for 37h 5m. Your offline experience bonus bank has been increased to 24h 0m.", Broadcast, t, Utc);
Check.Eq(x.LastLine, XpBonusLine.Welcome, "welcome back");
Check.Eq(x.State, XpBonusState.Banking, "a fresh login is idle");
Check.Eq(x.Seconds, 86_400.0, "the bank, not the time away");
x.OnChatText("Your offline experience bonus is now active - 23h 59m remaining.", Broadcast, t + 60_000, Utc);
Check.Eq(x.LastLine, XpBonusLine.Activated, "now active");
Check.Eq(x.State, XpBonusState.Active, "active");
Check.Eq(x.Seconds, 86_340.0, "23h 59m");
x.OnChatText("Your offline experience bonus is now idle and banking again - 48m 31s stored.", Broadcast, t + 120_000, Utc);
Check.Eq(x.LastLine, XpBonusLine.Banking, "banking again");
Check.Eq(x.State, XpBonusState.Banking, "idle");
Check.Eq(x.Seconds, 2911.0, "48m 31s");
x.OnChatText("Your offline experience bonus is now idle and banking again - 0s stored.", Broadcast, t + 130_000, Utc);
Check.Eq(x.State, XpBonusState.Banking, "banking from an empty bank");
Check.Eq(x.Seconds, 0.0, "0s stored");
Check.Eq(x.Remaining(t + 140_000), 10.0, "and it counts up from 0");
x.OnChatText("Your offline experience bonus is now active - 12s remaining.", Broadcast, t + 150_000, Utc);
x.OnChatText("Your offline experience bonus is exhausted.", Broadcast, t + 162_000, Utc);
Check.Eq(x.LastLine, XpBonusLine.Exhausted, "exhausted");
Check.Eq(x.State, XpBonusState.Empty, "nothing left");
Check.Eq(x.Seconds, 0.0, "0 s");
}
private static void RemainingOnly()
{
DreamWeaveXpBonus x = Logged(out long t);
x.OnChatText("[BANK] Offline Bonus Time: 48m 31s", System, t, Utc);
Check.Eq(x.LastLine, XpBonusLine.Bank, "the [BANK] line");
Check.Eq(x.State, XpBonusState.Unknown, "no state from one /b");
Check.Eq(x.Seconds, 2911.0, "its time");
Check.False(x.Running, "the clock doesn't run without a state");
Check.Eq(x.Line(t + 30_000), "Double XP: 48m 31s banked", "the time, no state");
// A minute later, a minute less: being spent.
x.OnChatText("[BANK] Offline Bonus Time: 47m 31s", System, t + 60_000, Utc);
Check.Eq(x.State, XpBonusState.Active, "two readings going down = active");
x.OnChatText("[BANK] Offline Bonus Time: 48m 31s", System, t + 120_000, Utc);
Check.Eq(x.State, XpBonusState.Banking, "going up = banking");
Check.Eq(x.Seconds, 2911.0, "48m 31s");
// A push in between starts the comparison again: the next /b doesn't undo it.
x.OnChatText("Your offline experience bonus is now active - 48m 11s remaining.", Broadcast, t + 140_000, Utc);
x.OnChatText("[BANK] Offline Bonus Time: 47m 31s", System, t + 180_000, Utc);
Check.Eq(x.State, XpBonusState.Active, "the push's state holds");
x.OnChatText("[BANK] Offline Bonus Time: 47m 21s", System, t + 190_000, Utc);
Check.Eq(x.State, XpBonusState.Active, "readings 10 s apart don't set a state");
x.OnChatText("[BANK] Offline Bonus Time: none", System, t + 200_000, Utc);
Check.Eq(x.State, XpBonusState.Empty, "none = empty");
x.OnChatText("[BANK] Offline Bonus Time: 15s", System, t + 215_000, Utc);
Check.Eq(x.State, XpBonusState.Banking, "an empty bank that grows is banking");
// /bonus: the percent and the time.
DreamWeaveXpBonus y = Logged(out t);
y.OnChatText("Your offline experience bonus is now active - 3h 10m remaining.", Broadcast, t, Utc);
y.OnChatText(" Offline bonus: +100% (3h 9m remaining)", Broadcast, t + 30_000, Utc);
Check.Eq(y.LastLine, XpBonusLine.Summary, "the /bonus line");
Check.Eq(y.Percent, 100, "its percent");
Check.Eq(y.State, XpBonusState.Active, "the state stays");
Check.Near(y.Seconds, 11_370, 0.01, "3h 9m read inside the running clock keeps the clock's seconds (11400 - 30)");
y.OnChatText(" Offline bonus: +0% (none banked)", Broadcast, t + 40_000, Utc);
Check.Eq(y.State, XpBonusState.Empty, "none banked");
Check.Eq(y.Percent, 100, "+0% doesn't replace the percent");
y.OnChatText(" Offline bonus: +50.5% (12s remaining)", Broadcast, t + 50_000, Utc);
Check.Eq(y.Percent, 51, "a decimal percent, rounded");
// Another [BANK] line is not ours.
y.OnChatText("[BANK] Luminance: 8,904,758", System, t + 60_000, Utc);
Check.Eq(y.LastLine, XpBonusLine.Summary, "the luminance line is the bank's, not ours");
}
private static void NotRead()
{
DreamWeaveXpBonus x = Logged(out long t);
Check.False(x.OnChatText(Spent, Tell, t, Utc), "a tell isn't read");
Check.False(x.HasReading, "nothing read from a tell");
x.OnChatText("Brisa says, \"" + Spent + "\"", Broadcast, t, Utc);
Check.False(x.HasReading, "a quoted copy isn't read (anchored)");
x.OnChatText("I think: [BANK] Offline Bonus Time: 24h 0m", Broadcast, t, Utc);
Check.False(x.HasReading, "a [BANK] line mid-text isn't read");
x.OnChatText("Your offline experience bonus is now active - soon remaining.", Broadcast, t, Utc);
Check.False(x.HasReading, "a line without a duration isn't read");
Check.False(x.OnChatText(null, Broadcast, t, Utc) || x.OnChatText("", Broadcast, t, Utc), "empty text");
}
private static void OursAndTyped()
{
DreamWeaveXpBonus x = Logged(out long t);
Check.Eq(x.Request(t), "/offlinebonus", "the command");
x.NoteChatBar(); // our own send through the chat bar
Check.True(x.Waiting(t + 100), "waiting for the reply");
Check.False(x.OnChatText("Your offline experience bonus is now active - 48m 31s remaining.", Broadcast, t + 200, Utc), "a push in the window still shows");
Check.True(x.OnChatText(Spent, Broadcast, t + 300, Utc), "our reply: hidden");
Check.False(x.Waiting(t + 400), "answered");
Check.False(x.OnChatText(Spent, Broadcast, t + 500, Utc), "the same line again (the server's own, or typed): shows");
// The player types /offlinebonus while ours waits: the reply is theirs.
x.Request(t + 10_000);
x.NoteChatBar(); // ours
x.NoteChatBar(); // theirs
Check.False(x.OnChatText(Banking, Broadcast, t + 10_300, Utc), "a typed /offlinebonus's reply shows");
Check.Eq(x.State, XpBonusState.Banking, "and still updates the row");
// None banked and not enabled are replies too.
x.Request(t + 20_000);
x.NoteChatBar();
Check.True(x.OnChatText(NoneBanked, Broadcast, t + 20_200, Utc), "none banked: hidden");
x.Request(t + 30_000);
x.NoteChatBar();
Check.True(x.OnChatText(Disabled, Broadcast, t + 30_200, Utc), "not enabled: hidden");
// No reply in time: given up once, and a late reply shows.
x.Request(t + 40_000);
x.NoteChatBar();
Check.False(x.Tick(t + 41_000), "still within the window");
Check.True(x.Tick(t + 46_000), "given up");
Check.False(x.Tick(t + 47_000), "given up once");
Check.Eq(x.LastMiss, "No reply to /offlinebonus.", "said why");
Check.False(x.OnChatText(Spent, Broadcast, t + 47_500, Utc), "a late reply shows");
Check.Eq(x.LastMiss, "", "a reading clears the miss");
// A typed /offlinebonus with no own request is just typed.
x.NoteChatBar();
Check.False(x.OnChatText(Spent, Broadcast, t + 50_000, Utc), "shows");
// Not sent: nothing waits.
x.Request(t + 60_000);
x.NotSent();
Check.False(x.Waiting(t + 60_100), "not sent: not waiting");
Check.False(x.OnChatText(Spent, Broadcast, t + 60_200, Utc), "and a reply shows");
Check.True(DreamWeaveXpBonus.IsCommand("/offlinebonus") && DreamWeaveXpBonus.IsCommand(" /OfflineBonus ") && DreamWeaveXpBonus.IsCommand("/offlinebonus now"), "the command, any case, words after it");
Check.False(DreamWeaveXpBonus.IsCommand("/offlinebonusx") || DreamWeaveXpBonus.IsCommand("/bonus") || DreamWeaveXpBonus.IsCommand("offlinebonus") || DreamWeaveXpBonus.IsCommand(null), "not the command");
}
private static void AutoTiming()
{
var x = new DreamWeaveXpBonus();
x.LoadSettings((_, def) => def);
Check.False(x.AutoRead, "off by default");
x.LoadSettings((key, def) => key == DreamWeaveXpBonus.SettingAutoRead ? true : def);
Check.True(x.AutoRead, "the setting turns it on");
long t = 1_000_000;
x.Login(t);
Check.Eq(x.NextReadMs, t + 35_000, "the first read 35 s after login");
Check.Null(x.Due(t + 34_000, true, true), "not before");
Check.Null(x.Due(t + 35_000, true, false), "not while another command is near");
Check.Null(x.Due(t + 35_500, false, true), "not in portal space");
Check.Eq(x.Due(t + 36_000, true, true), "/offlinebonus", "then it goes");
Check.Eq(x.NextReadMs, t + 36_000 + 600_000, "the next in ten minutes");
Check.Null(x.Due(t + 37_000, true, true), "one at a time");
// A full reading of any kind (the login line, a typed one) starts the ten minutes again.
x.OnChatText(Spent, Broadcast, t + 300_000, Utc);
Check.Eq(x.NextReadMs, t + 300_000 + 600_000, "a reading pushes the next read out");
x.OnChatText("[BANK] Offline Bonus Time: 48m 0s", System, t + 310_000, Utc);
Check.Eq(x.NextReadMs, t + 300_000 + 600_000, "a /b reading (no state) doesn't");
x.SetAutoRead(false, t + 320_000);
Check.Eq(x.NextReadMs, long.MaxValue, "off: nothing coming");
Check.Null(x.Due(t + 2_000_000, true, true), "off: nothing sent");
x.SetAutoRead(true, t + 400_000);
Check.Eq(x.NextReadMs, t + 400_000 + DreamWeaveXpBonus.GapMs, "turned on: soon");
x.Logout();
Check.Eq(x.NextReadMs, long.MaxValue, "logged out: nothing coming");
Check.False(x.HasReading, "logged out: the reading is gone");
}
private static void CheckNow()
{
DreamWeaveXpBonus x = Logged(out long t);
Check.False(x.AutoRead, "automatic read off");
x.CheckSoon(t);
Check.True(x.Waiting(t), "a Check now waits to go");
Check.Eq(x.NextReadMs, t, "now");
Check.Null(x.Due(t, true, false), "not while another command is near");
Check.Eq(x.Due(t + 2_000, true, true), "/offlinebonus", "at the next quiet moment");
Check.True(x.Waiting(t + 2_100), "then waits for the reply");
Check.Eq(x.NextReadMs, long.MaxValue, "and nothing more comes with the automatic read off");
x.NoteChatBar();
Check.True(x.OnChatText(Spent, Broadcast, t + 2_300, Utc), "its reply is hidden");
}
private static void Clock()
{
DreamWeaveXpBonus x = Logged(out long t);
x.OnChatText(Spent, Broadcast, t, Utc);
Check.True(x.Running, "active: running");
Check.Eq(x.Remaining(t + 31_000), 2880.0, "31 s less");
Check.Eq(x.Remaining(t + 2_911_000), 0.0, "to 0");
Check.Eq(x.Remaining(t + 9_000_000), 0.0, "and no further");
Check.False(x.IsActive(t + 2_911_000), "spent: not active any more");
Check.Eq(x.Line(t + 3_000_000), "Double XP +100%: None banked", "and none banked");
x.OnChatText(Banking, Broadcast, t, Utc);
Check.Eq(x.Remaining(t + 600_000), 12_000.0, "banking: ten minutes more");
Check.Eq(x.Remaining(t + 100_000_000), 86_400.0, "up to the 24 h cap");
Check.Eq(x.Line(t + 100_000_000), "Double XP +100%: 24h 0m banked (idle, full)", "full");
x.OnChatText("Welcome back - you were away for 30h 0m. Your offline experience bonus bank has been increased to 30h 0m.", Broadcast, t, Utc);
Check.Eq(x.CapSeconds, 108_000.0, "a bank above 24 h raises the cap (the server's is set higher)");
x.OnChatText(NoneBanked, Broadcast, t, Utc);
Check.False(x.Running, "empty: not running");
Check.Eq(x.Remaining(t + 600_000), 0.0, "stays 0");
// A reading shown to the minute replaces the clock only when the clock is outside it.
DreamWeaveXpBonus y = Logged(out t);
y.OnChatText(Banking, Broadcast, t, Utc); // 3h 10m 0s, banking
y.OnChatText("[BANK] Offline Bonus Time: 3h 10m", System, t + 45_000, Utc);
Check.Near(y.Seconds, 11_445, 0.01, "3h 10m 45s is inside '3h 10m': the clock's seconds kept");
y.OnChatText("[BANK] Offline Bonus Time: 3h 0m", System, t + 50_000, Utc);
Check.Eq(y.Seconds, 10_800.0, "outside it: the server's value");
}
private static void Lines()
{
DreamWeaveXpBonus x = Logged(out long t);
Check.Eq(x.Line(t), "Double XP: not read yet", "before a reading");
Check.Eq(x.Detail(t, Utc), "Not read yet: press Check now.", "what to do");
x.OnChatText(Spent, Broadcast, t, Utc);
Check.Eq(x.Line(t), "Double XP +100%: 48m 31s left (active)", "active");
Check.True(x.IsActive(t), "coloured");
Check.Eq(x.Detail(t, Utc), "Server read just now; counting down", "fresh, counting down");
Check.Eq(x.Detail(t + 180_000, Utc.AddMinutes(3)), "Server read 3 min ago; counting down", "three minutes old");
Check.Eq(x.Line(t + 31_000), "Double XP +100%: 48m 0s left (active)", "counted down");
x.OnChatText(Banking, Broadcast, t, Utc);
Check.Eq(x.Line(t), "Double XP +100%: 3h 10m banked (idle)", "banking");
Check.False(x.IsActive(t), "not coloured");
Check.Eq(x.Detail(t, Utc.AddHours(2)), "Server read 2 h ago; counting up", "counting up");
DreamWeaveXpBonus y = Logged(out t);
y.OnChatText("Your offline experience bonus is now active - 1m 0s remaining.", Broadcast, t, Utc);
Check.Eq(y.Line(t), "Double XP: 1m 0s left (active)", "no percent known yet");
y.OnChatText("[BANK] Offline Bonus Time: none", System, t, Utc);
Check.Eq(y.Line(t), "Double XP: None banked", "none banked");
Check.Eq(DreamWeaveXpBonus.Age(Utc, Utc.AddSeconds(59)), "just now", "under a minute");
Check.Eq(DreamWeaveXpBonus.Age(Utc, Utc.AddMinutes(59)), "59 min ago", "minutes");
Check.Eq(DreamWeaveXpBonus.Age(Utc, Utc.AddHours(5)), "5 h ago", "hours");
Check.Eq(DreamWeaveXpBonus.Age(Utc, Utc.AddDays(3)), "3 d ago", "days");
}
private static void Saved()
{
DreamWeaveXpBonus x = Logged(out long t);
x.OnChatText(Spent, Broadcast, t, Utc);
Check.True(x.Dirty, "a reading is to be saved");
string json = x.SaveJson();
Check.False(x.Dirty, "saved");
DreamWeaveXpBonus y = Logged(out t);
y.LoadSaved(json);
Check.Eq(y.State, XpBonusState.Active, "the state");
Check.Eq(y.Seconds, 2911.0, "the time");
Check.Eq(y.Percent, 100, "the percent");
Check.Eq(y.ReadUtc, Utc, "when");
Check.Eq(y.ReadMs, 0L, "loaded from disk");
Check.False(y.Running, "the clock doesn't run on a saved reading");
Check.Eq(y.Remaining(t + 600_000), 2911.0, "it stays as read");
Check.Eq(y.Line(t), "Double XP +100%: 48m 31s left (active)", "shown as read");
Check.Eq(y.Detail(t, Utc.AddHours(3)), "Saved reading, 3 h ago; not counting until the next one.", "and said to be old");
Check.False(y.Dirty, "nothing new to save");
// The login lines can come before the character is known: a newer live reading stays.
DreamWeaveXpBonus z = Logged(out t);
z.OnChatText("Welcome back - you were away for 9h 2m. Your offline experience bonus bank has been increased to 9h 2m.", Broadcast, t, Utc.AddHours(9));
z.LoadSaved(json);
Check.Eq(z.Seconds, 9.0 * 3600 + 120, "the live reading stays");
Check.Eq(z.State, XpBonusState.Banking, "and its state");
Check.Eq(z.Percent, 100, "the saved percent fills in the one the push didn't say");
DreamWeaveXpBonus w = Logged(out t);
foreach (string bad in new[] { "", "{", "[]", "{\"v\":1}", "{\"state\":\"active\",\"seconds\":5,\"updated\":\"never\"}" })
{
w.LoadSaved(bad);
Check.False(w.HasReading, $"broken '{bad}': left out");
}
w.LoadSaved("{\"v\":1,\"state\":\"sideways\",\"seconds\":60,\"updated\":\"2026-11-15T17:00:00.0000000Z\"}");
Check.Eq(w.State, XpBonusState.Unknown, "an unknown state reads as unknown");
Check.Eq(w.Seconds, 60.0, "with its time");
Check.True(DreamWeaveXpBonus.SavePath(@"C:\x\RynthCore\rynthdreamweave.json", 0x5000ABCD)
.EndsWith(@"RynthCore\rynthdreamweave.xpbonus.5000ABCD.json", StringComparison.Ordinal), "saved beside the settings, per character");
}
private static void NextTimes()
{
var bank = new DreamWeaveBank();
long t = 1_000_000;
bank.Login(t);
Check.Eq(bank.NextCheckMs, t + DreamWeaveBank.FirstCheckDelayMs, "the bank's first /b");
bank.CheckEveryMinute = false;
Check.Eq(bank.NextCheckMs, long.MaxValue, "bank check off: none");
var boards = new DreamWeaveBoards();
boards.Login(t);
Check.Eq(boards.NextAutoMs, long.MaxValue, "boards' automatic refresh off: none");
boards.SetAutoRefresh(true, t);
Check.Eq(boards.NextAutoMs, t + 5_000, "on: its next /top");
Check.True(DreamWeaveXpBonus.FirstReadDelayMs - DreamWeaveBank.FirstCheckDelayMs >= DreamWeaveXpBonus.GapMs
&& DreamWeaveBoards.FirstAutoDelayMs - DreamWeaveXpBonus.FirstReadDelayMs >= DreamWeaveXpBonus.GapMs,
"the first read after login sits between the bank's first /b and the boards' first /top");
}
}

View file

@ -22,6 +22,8 @@ internal static class Program
ServerPackCommandsTests.Register(runner);
DreamWeaveSkillsTests.Register(runner);
DreamWeaveTests.Register(runner);
DreamWeaveBoardsTests.Register(runner);
DreamWeaveXpBonusTests.Register(runner);
ServerWebOpenTests.Register(runner);
ServerWebPanelTests.Register(runner);
DreamWeaveWebTests.Register(runner);

View file

@ -55,6 +55,10 @@
<Compile Include="..\..\Plugins\RynthCore.Plugin.RynthAelrynth\Aelrynth\VaultFeed.cs" Link="Aelrynth\VaultFeed.cs" />
<!-- RynthDreamWeave's bank check for Lum/hr (pure part). -->
<Compile Include="..\..\Plugins\RynthCore.Plugin.RynthDreamWeave\DreamWeave\DreamWeaveBank.cs" Link="DreamWeave\DreamWeaveBank.cs" />
<!-- RynthDreamWeave's leaderboards: the /top reader, the automatic refresh and the saved boards (pure part). -->
<Compile Include="..\..\Plugins\RynthCore.Plugin.RynthDreamWeave\DreamWeave\DreamWeaveBoards.cs" Link="DreamWeave\DreamWeaveBoards.cs" />
<!-- RynthDreamWeave's offline bonus tracker: the server's lines, the read's timing, the clock, the saved reading (pure part). -->
<Compile Include="..\..\Plugins\RynthCore.Plugin.RynthDreamWeave\DreamWeave\DreamWeaveXpBonus.cs" Link="DreamWeave\DreamWeaveXpBonus.cs" />
<!-- The difficulty tier RynthAelrynth publishes for RynthAi (and the value names, RynthServerProfileApi.cs). -->
<Compile Include="..\..\Plugins\RynthCore.Plugin.RynthAelrynth\Aelrynth\AelrynthDifficulty.cs" Link="Aelrynth\AelrynthDifficulty.cs" />
<Compile Include="$(RynthSuiteRoot)Plugins\Shared\RynthServerProfileApi.cs" Link="Shared\RynthServerProfileApi.cs" />
@ -84,6 +88,7 @@
<Compile Include="..\..\Plugins\RynthCore.Plugin.RynthDreamWeave\DreamWeave\AttributesTitles.cs" Link="DreamWeave\AttributesTitles.cs" />
<Compile Include="..\..\Plugins\RynthCore.Plugin.RynthDreamWeave\DreamWeave\OnePanelRule.cs" Link="DreamWeave\OnePanelRule.cs" />
<Compile Include="..\..\Plugins\RynthCore.Plugin.RynthDreamWeave\DreamWeave\HeldRaises.cs" Link="DreamWeave\HeldRaises.cs" />
<Compile Include="..\..\Plugins\RynthCore.Plugin.RynthDreamWeave\DreamWeave\ReadGate.cs" Link="DreamWeave\ReadGate.cs" />
<!-- The RynthAi test tools' check/runner harness (no plugin code in it). -->
<Compile Include="$(RynthSuiteRoot)Tools\RynthCore.RynthAiTests\Harness\Check.cs" Link="Harness\Check.cs" />
<Compile Include="$(RynthSuiteRoot)Tools\RynthCore.RynthAiTests\Harness\Runner.cs" Link="Harness\Runner.cs" />