RynthServers as of 2026-11-29 (internal 461c3c2): release 2026.11.28.1
This commit is contained in:
parent
5e34af11bf
commit
7bd21f5932
25 changed files with 4298 additions and 15 deletions
|
|
@ -31,6 +31,8 @@ internal static class Program
|
|||
RynthCore.Plugin.RynthILT.Hub.IltMigration.LegacySharedRoot = Path.Combine(TempRoot, "RynthAi");
|
||||
RynthCore.Plugin.RynthILT.RynthLog.Init(default, Path.Combine(TempRoot, "Logs"));
|
||||
RynthCore.Plugin.Shared.DataWriteGuard.PluginName = "RynthILT"; // as RynthILTPlugin.Initialize sets it
|
||||
// The wiki quest guide's sealed login, settings and saved guide (each wiki test points it at its own folder).
|
||||
RynthCore.Plugin.RynthILT.IltWiki.WikiLoginStore.FolderOverride = Path.Combine(TempRoot, "Wiki");
|
||||
|
||||
var runner = new Runner();
|
||||
BountyTests.Register(runner);
|
||||
|
|
@ -56,6 +58,7 @@ internal static class Program
|
|||
ReplyTests.Register(runner);
|
||||
RemoteTabTests.Register(runner);
|
||||
StampTests.Register(runner);
|
||||
WikiGuideTests.Register(runner);
|
||||
BankRosterTests.Register(runner);
|
||||
// Before DataApiTests: its last test releases the RynthILT.Data table, which the breeding version test queries.
|
||||
BreedingTests.Register(runner);
|
||||
|
|
|
|||
|
|
@ -39,6 +39,8 @@
|
|||
<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" />
|
||||
<Compile Include="$(RynthSuiteRoot)Tools\RynthCore.RynthAiHostTests\Fakes\FakeHost.cs" Link="Fakes\FakeHost.cs" />
|
||||
<!-- RynthOracle's reader of "RynthServer.QuestGuide" (WikiGuideTests read RynthILT's published guide as RynthOracle does). -->
|
||||
<Compile Include="$(RynthSuiteRoot)Plugins\Shared\ServerQuestGuideClient.cs" Link="Shared\ServerQuestGuideClient.cs" />
|
||||
<!-- The shared reader RynthAi's Crafting tab uses on RynthILT's RynthServer.Profile JSON (ProfileTests),
|
||||
Plugins\Shared\EngineServerState.cs, comes with the plugin now (it reads RynthCore's server list). -->
|
||||
</ItemGroup>
|
||||
|
|
|
|||
616
Tools/RynthILT.Tests/WikiGuideTests.cs
Normal file
616
Tools/RynthILT.Tests/WikiGuideTests.cs
Normal file
|
|
@ -0,0 +1,616 @@
|
|||
using System;
|
||||
using System.Collections.Concurrent;
|
||||
using System.Collections.Generic;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
using System.Net;
|
||||
using System.Net.Http;
|
||||
using System.Text;
|
||||
using System.Threading;
|
||||
using System.Threading.Tasks;
|
||||
using RynthCore.Plugin.RynthILT.IltWiki;
|
||||
using RynthCore.Plugin.Shared;
|
||||
using RynthCore.RynthAiTests.Harness;
|
||||
|
||||
namespace RynthILT.Tests;
|
||||
|
||||
// The Leaftide wiki quest guide (IltWiki/, 2026-11-27): the address, the sealed login, the MediaWiki
|
||||
// sign-in and the read, against a FAKE wiki (FakeWiki below; nothing here touches the network), and the
|
||||
// controller's opt-in, commands and the guide it hands RynthOracle. Every page below is made up for the
|
||||
// tests: invented quests, people and places, written in the wiki's page layout. No real wiki text.
|
||||
internal static class WikiGuideTests
|
||||
{
|
||||
private const string Api = "https://wiki.test/api.php";
|
||||
private const string User = "Tester@probe";
|
||||
private const string Password = "pw-Fake-7f3k-q9zz-Bot";
|
||||
|
||||
public static void Register(Runner r)
|
||||
{
|
||||
r.Add("wiki: the address the player types becomes the API address (https only)", Address);
|
||||
r.Add("wiki: robots.txt's Crawl-delay sets the gap between requests", Robots);
|
||||
r.Add("wiki: the login is sealed with DPAPI, opens again, and Sign out deletes it", Sealed);
|
||||
r.Add("wiki: sign-in against a fake wiki (token, POST, cookie, assert=user, User-Agent, gaps)", SignIn);
|
||||
r.Add("wiki: a failed sign-in says why in plain words, without the password", SignInFails);
|
||||
r.Add("wiki: off by default: nothing fetched or saved, RynthOracle sees only the way to sign in", OffByDefault);
|
||||
r.Add("wiki: signing in reads the guide, saves it and hands it to RynthOracle", ReadsGuide);
|
||||
r.Add("wiki: a second read fetches only edited pages; Refresh waits 5 minutes", OnlyEdited);
|
||||
r.Add("wiki: a lost session signs in again once; a refused sign-in ends the read plainly", LostSession);
|
||||
r.Add("wiki: Sign out deletes the login and the guide; RynthOracle's guide goes", SignOut);
|
||||
r.Add("wiki: /ilt wiki commands each answer, and never take a login in chat", Commands);
|
||||
r.Add("wiki: a login saved for another address is never used", OtherAddress);
|
||||
r.Add("wiki: the invented pages read into steps, stamps, loot, kill tasks and contracts", Parsing);
|
||||
}
|
||||
|
||||
// ── The invented pages ──────────────────────────────────────────────────
|
||||
|
||||
private const string MothErrand = @"{{Leaftide Content}}
|
||||
{{Quest Summary
|
||||
| Level = 120+
|
||||
| Recommended Level = 150+
|
||||
| Quest Type = Solo
|
||||
| Starts With = [[Warden Pellis]]
|
||||
| Starts At = [[Hollow Reach]]
|
||||
| Repeat Timer = 20 Hours
|
||||
}}
|
||||
== Overview ==
|
||||
Warden Pellis wants the glow sacs of the lantern moths that swarm the old quarry.
|
||||
== Walkthrough & Notes ==
|
||||
# Talk to [[Warden Pellis]] at 12.3N, 45.6E.
|
||||
#* {{stamped|LanternMothErrandStarted}}
|
||||
# Kill lantern moths in the quarry (14.0N 47.2E) and loot a {{Itemlink|Moth Glow Sac}}.
|
||||
# Return the {{Itemlink|Moth Glow Sac}} to Warden Pellis.
|
||||
#* {{stamped|LanternMothErrandDone}}
|
||||
== Rewards ==
|
||||
{{Rewards Table
|
||||
| Quest Task = Hand in a glow sac
|
||||
| XP Reward = 5,000,000
|
||||
| Item Reward = * {{Icon Link|Pellis Lantern}}
|
||||
}}
|
||||
[[Category:Invented Quests]]";
|
||||
|
||||
private const string GlimmerBeetles = @"{{Quest Summary
|
||||
| Level = 80+
|
||||
| Quest Type = Solo/Fellowship
|
||||
| Starts With = [[Huntmaster Orlo]]
|
||||
| Repeat Timer = 7 days
|
||||
| Kill Task = Yes
|
||||
}}
|
||||
== Discord Description ==
|
||||
Thin out the glimmer beetles near the salt flats.
|
||||
== Walkthrough & Notes ==
|
||||
Speak to Huntmaster Orlo at 3.1s,70.2w to take the task.
|
||||
|
||||
Kill 50 Glimmer Beetles anywhere on the salt flats.
|
||||
|
||||
Return to Huntmaster Orlo for the reward.
|
||||
== QB Stamps ==
|
||||
{{stamped|GlimmerBeetleTaskTaken}} {{stamped|GlimmerBeetleKills on first completion}}
|
||||
[[Category:Kill Tasks]]";
|
||||
|
||||
private const string ThornboundInitiate = @"{{Quest Summary
|
||||
| Level = 50+
|
||||
| Starts With = [[Sister Wren]]
|
||||
}}
|
||||
== Walkthrough ==
|
||||
# Bring Sister Wren three bramble cuttings.
|
||||
[[Category:Society Quests: Initiate Rank]]";
|
||||
|
||||
private const string BrambleContract = @"{{Item
|
||||
| Name = Contract for the Bramble Wardens
|
||||
| Description = Starts the Bramble Wardens' errand again.
|
||||
| Recommended Level = 60
|
||||
}}
|
||||
{{Intro | Related Quests = [[Thornbound Initiate Tasks]]}}
|
||||
== Notes ==
|
||||
* Purchased from [[Quartermaster Ivo]] in [[Hollow Reach]].
|
||||
[[Category:Contracts]]";
|
||||
|
||||
private const string MothItem = @"{{Item | Name = Moth Glow Sac}}
|
||||
A pale sac that glows faintly. Not a quest page.";
|
||||
|
||||
// ── A fake MediaWiki ────────────────────────────────────────────────────
|
||||
|
||||
private sealed class FakeWiki : HttpMessageHandler
|
||||
{
|
||||
public readonly Dictionary<string, (long Rev, string Text)> Pages = new(StringComparer.Ordinal)
|
||||
{
|
||||
["The Lantern Moth Errand"] = (101, MothErrand),
|
||||
["Glimmer Beetle Kill Task"] = (102, GlimmerBeetles),
|
||||
["Thornbound Initiate Tasks"] = (103, ThornboundInitiate),
|
||||
["Contract for the Bramble Wardens"] = (104, BrambleContract),
|
||||
["Moth Glow Sac"] = (105, MothItem),
|
||||
};
|
||||
|
||||
/// <summary>Category -> members (title, ns).</summary>
|
||||
public readonly Dictionary<string, List<(string Title, int Ns)>> Categories = new(StringComparer.Ordinal)
|
||||
{
|
||||
["Category:Kill_Tasks"] = new() { ("Glimmer Beetle Kill Task", 0), ("Category:Kill Tasks by Level", 14) },
|
||||
["Category:Kill Tasks by Level"] = new() { ("Glimmer Beetle Kill Task", 0) },
|
||||
["Category:Society_Quests"] = new() { ("Category:Society Quests: Initiate Rank", 14), ("Category:Society Items", 14) },
|
||||
["Category:Society Quests: Initiate Rank"] = new() { ("Thornbound Initiate Tasks", 0) },
|
||||
["Category:Society Items"] = new() { ("Moth Glow Sac", 0) },
|
||||
["Category:Contracts"] = new() { ("Contract for the Bramble Wardens", 0) },
|
||||
};
|
||||
|
||||
public string User = WikiGuideTests.User;
|
||||
public string Password = WikiGuideTests.Password;
|
||||
public string? Robots = "User-agent: *\nCrawl-Delay: 12\n";
|
||||
public string? LoginResultOverride; // "Aborted" etc.
|
||||
public string? HtmlInstead; // every API answer is this HTML page
|
||||
public bool Redirect;
|
||||
/// <summary>After this many signed-in queries the wiki forgets the session, once (0 = never).</summary>
|
||||
public int DropSessionAfter;
|
||||
/// <summary>The wiki takes the password once only (it was revoked mid-read).</summary>
|
||||
public bool RevokeAfterFirstLogin;
|
||||
|
||||
public readonly ConcurrentQueue<(string Method, string Url, string Body, string Agent, string Cookie)> Log = new();
|
||||
public readonly List<string> ContentTitles = new();
|
||||
public int Logins;
|
||||
private int _sessionNo;
|
||||
private string _session = "";
|
||||
private string _signedSession = "";
|
||||
private int _queries;
|
||||
private const string LoginToken = "tok+\\";
|
||||
|
||||
private static Dictionary<string, string> Parse(string query)
|
||||
{
|
||||
var map = new Dictionary<string, string>(StringComparer.Ordinal);
|
||||
foreach (string part in query.TrimStart('?').Split('&', StringSplitOptions.RemoveEmptyEntries))
|
||||
{
|
||||
int eq = part.IndexOf('=');
|
||||
string k = Uri.UnescapeDataString((eq < 0 ? part : part[..eq]).Replace('+', ' '));
|
||||
string v = eq < 0 ? "" : Uri.UnescapeDataString(part[(eq + 1)..].Replace('+', ' '));
|
||||
map[k] = v;
|
||||
}
|
||||
return map;
|
||||
}
|
||||
|
||||
private static HttpResponseMessage Json(string json, string? cookie = null)
|
||||
{
|
||||
var r = new HttpResponseMessage(HttpStatusCode.OK) { Content = new StringContent(json, Encoding.UTF8, "application/json") };
|
||||
if (cookie != null) r.Headers.TryAddWithoutValidation("Set-Cookie", cookie);
|
||||
return r;
|
||||
}
|
||||
|
||||
private static string Esc(string s) => System.Text.Json.JsonEncodedText.Encode(s).ToString();
|
||||
|
||||
protected override async Task<HttpResponseMessage> SendAsync(HttpRequestMessage request, CancellationToken cancellationToken)
|
||||
{
|
||||
string body = request.Content == null ? "" : await request.Content.ReadAsStringAsync(cancellationToken);
|
||||
string agent = request.Headers.UserAgent.ToString();
|
||||
string cookie = request.Headers.TryGetValues("Cookie", out var cs) ? string.Join("; ", cs) : "";
|
||||
Log.Enqueue((request.Method.Method, request.RequestUri!.ToString(), body, agent, cookie));
|
||||
Uri u = request.RequestUri!;
|
||||
if (u.AbsolutePath == "/robots.txt")
|
||||
return Robots == null ? new HttpResponseMessage(HttpStatusCode.NotFound) : new HttpResponseMessage(HttpStatusCode.OK) { Content = new StringContent(Robots) };
|
||||
if (Redirect)
|
||||
{
|
||||
var r = new HttpResponseMessage(HttpStatusCode.Found);
|
||||
r.Headers.Location = new Uri("https://elsewhere.test/");
|
||||
return r;
|
||||
}
|
||||
if (HtmlInstead != null) return new HttpResponseMessage(HttpStatusCode.OK) { Content = new StringContent(HtmlInstead, Encoding.UTF8, "text/html") };
|
||||
Dictionary<string, string> q = Parse(request.Method == HttpMethod.Post ? body : u.Query);
|
||||
bool hasSession = _session.Length > 0 && cookie.Contains("wikisession=" + _session, StringComparison.Ordinal);
|
||||
|
||||
if (q.GetValueOrDefault("meta") == "tokens")
|
||||
{
|
||||
_session = "s" + (++_sessionNo);
|
||||
return Json("{\"batchcomplete\":true,\"query\":{\"tokens\":{\"logintoken\":\"" + Esc(LoginToken) + "\"}}}", "wikisession=" + _session + "; path=/; secure; HttpOnly");
|
||||
}
|
||||
if (q.GetValueOrDefault("action") == "login")
|
||||
{
|
||||
Logins++;
|
||||
if (!hasSession || q.GetValueOrDefault("lgtoken") != LoginToken) return Json("{\"login\":{\"result\":\"WrongToken\"}}");
|
||||
if (LoginResultOverride != null) return Json("{\"login\":{\"result\":\"" + LoginResultOverride + "\",\"reason\":\"Main-password logins are switched off here.\"}}");
|
||||
bool revoked = RevokeAfterFirstLogin && Logins > 1;
|
||||
if (q.GetValueOrDefault("lgname") != User || q.GetValueOrDefault("lgpassword") != Password || revoked)
|
||||
return Json("{\"login\":{\"result\":\"Failed\",\"reason\":\"That login name or password is wrong (fake wiki).\"}}");
|
||||
_signedSession = _session;
|
||||
_queries = 0;
|
||||
return Json("{\"login\":{\"result\":\"Success\",\"lguserid\":7,\"lgusername\":\"Tester\"}}");
|
||||
}
|
||||
if (q.GetValueOrDefault("action") != "query") return Json("{\"error\":{\"code\":\"badvalue\",\"info\":\"unknown action\"}}");
|
||||
bool signed = hasSession && _session == _signedSession && _signedSession.Length > 0;
|
||||
if (signed && DropSessionAfter > 0 && ++_queries > DropSessionAfter)
|
||||
{
|
||||
_signedSession = "";
|
||||
signed = false;
|
||||
DropSessionAfter = 0; // once: the session lapsed
|
||||
}
|
||||
if (q.GetValueOrDefault("assert") == "user" && !signed)
|
||||
return Json("{\"error\":{\"code\":\"assertuserfailed\",\"info\":\"You are no longer logged in.\"}}");
|
||||
|
||||
if (q.GetValueOrDefault("meta") == "userinfo|siteinfo")
|
||||
return Json("{\"query\":{\"userinfo\":{\"id\":7,\"name\":\"Tester\"},\"general\":{\"server\":\"https://wiki.test\",\"articlepath\":\"/$1\"}}}");
|
||||
if (q.GetValueOrDefault("generator") == "embeddedin")
|
||||
{
|
||||
// Two pages per answer, with a continuation (as a big wiki answers).
|
||||
var quests = Pages.Where(p => p.Value.Text.Contains("{{Quest Summary")).Select(p => p.Key).OrderBy(t => t, StringComparer.Ordinal).ToList();
|
||||
int from = int.TryParse(q.GetValueOrDefault("geicontinue"), out int f) ? f : 0;
|
||||
var part = quests.Skip(from).Take(2).ToList();
|
||||
string cont = from + 2 < quests.Count ? ",\"continue\":{\"geicontinue\":\"" + (from + 2) + "\",\"continue\":\"gei||\"}" : "";
|
||||
return Json("{\"query\":{\"pages\":[" + string.Join(",", part.Select(t => PageInfo(t, 0))) + "]}" + cont + "}");
|
||||
}
|
||||
if (q.GetValueOrDefault("generator") == "categorymembers")
|
||||
{
|
||||
string cat = q.GetValueOrDefault("gcmtitle") ?? "";
|
||||
var members = Categories.TryGetValue(cat, out var m) ? m : new List<(string, int)>();
|
||||
return Json("{\"query\":{\"pages\":[" + string.Join(",", members.Select(x => PageInfo(x.Item1, x.Item2))) + "]}}");
|
||||
}
|
||||
if (q.GetValueOrDefault("prop") == "revisions")
|
||||
{
|
||||
var titles = (q.GetValueOrDefault("titles") ?? "").Split('|');
|
||||
lock (ContentTitles) ContentTitles.AddRange(titles);
|
||||
var parts = titles.Where(Pages.ContainsKey).Select(t =>
|
||||
"{\"ns\":0,\"title\":\"" + Esc(t) + "\",\"revisions\":[{\"revid\":" + Pages[t].Rev + ",\"slots\":{\"main\":{\"content\":\"" + Esc(Pages[t].Text) + "\"}}}]}");
|
||||
return Json("{\"query\":{\"pages\":[" + string.Join(",", parts) + "]}}");
|
||||
}
|
||||
return Json("{\"error\":{\"code\":\"badvalue\",\"info\":\"not faked\"}}");
|
||||
}
|
||||
|
||||
private string PageInfo(string title, int ns) =>
|
||||
"{\"ns\":" + ns + ",\"title\":\"" + Esc(title) + "\"" + (ns == 0 && Pages.TryGetValue(title, out var p) ? ",\"lastrevid\":" + p.Rev : "") + "}";
|
||||
}
|
||||
|
||||
// ── Helpers ─────────────────────────────────────────────────────────────
|
||||
|
||||
private sealed class Harness
|
||||
{
|
||||
public readonly FakeWiki Wiki = new();
|
||||
public readonly List<(string Text, bool Ok)> Said = new();
|
||||
public readonly ConcurrentQueue<TimeSpan> Waits = new();
|
||||
public DateTime Now = new(2026, 11, 27, 12, 0, 0, DateTimeKind.Utc);
|
||||
public int Handlers;
|
||||
public int SettingsOpened;
|
||||
public readonly IltWikiGuide Guide;
|
||||
|
||||
public Harness(string name, bool fresh = true)
|
||||
{
|
||||
string dir = Path.Combine(Program.TempRoot, "wiki-" + name);
|
||||
if (fresh && Directory.Exists(dir)) Directory.Delete(dir, recursive: true);
|
||||
WikiLoginStore.FolderOverride = dir;
|
||||
ServerQuestGuideHost.ResetForTests();
|
||||
Guide = new IltWikiGuide((t, ok) => Said.Add((t, ok)), null, () => { Handlers++; return Wiki; },
|
||||
(gap, _) => { Waits.Enqueue(gap); return Task.CompletedTask; }, () => Now)
|
||||
{
|
||||
OpenSettings = () => SettingsOpened++,
|
||||
};
|
||||
Guide.Load();
|
||||
}
|
||||
|
||||
public void Settle()
|
||||
{
|
||||
Check.True(Guide.WaitForTests(), "the background work ended");
|
||||
Guide.Tick();
|
||||
}
|
||||
|
||||
public string AllSaid => string.Join(" / ", Said.Select(s => s.Text));
|
||||
}
|
||||
|
||||
private static unsafe ServerQuestGuideClient ReadPublished()
|
||||
{
|
||||
var client = new ServerQuestGuideClient();
|
||||
client.Use((RynthServerQuestGuideApiV1*)ServerQuestGuideHost.Query(1), "RynthILT");
|
||||
return client;
|
||||
}
|
||||
|
||||
/// <summary>No file under the wiki folder holds the password (or the login name) in readable form, except none may.</summary>
|
||||
private static void NoSecretOnDisk(string what)
|
||||
{
|
||||
string dir = WikiLoginStore.Folder;
|
||||
if (!Directory.Exists(dir)) { Check.True(true, what + ": no files"); return; }
|
||||
foreach (string f in Directory.GetFiles(dir, "*", SearchOption.AllDirectories))
|
||||
{
|
||||
byte[] bytes = File.ReadAllBytes(f);
|
||||
string utf8 = Encoding.UTF8.GetString(bytes), utf16 = Encoding.Unicode.GetString(bytes);
|
||||
Check.False(utf8.Contains(Password) || utf16.Contains(Password), $"{what}: {Path.GetFileName(f)} doesn't hold the password");
|
||||
}
|
||||
string logs = Path.Combine(Program.TempRoot, "Logs");
|
||||
if (Directory.Exists(logs))
|
||||
foreach (string f in Directory.GetFiles(logs, "*", SearchOption.AllDirectories))
|
||||
{
|
||||
string text;
|
||||
try
|
||||
{
|
||||
using var fs = new FileStream(f, FileMode.Open, FileAccess.Read, FileShare.ReadWrite | FileShare.Delete);
|
||||
using var sr = new StreamReader(fs);
|
||||
text = sr.ReadToEnd();
|
||||
}
|
||||
catch (IOException) { continue; }
|
||||
Check.False(text.Contains(Password), $"{what}: the log {Path.GetFileName(f)} doesn't hold the password");
|
||||
}
|
||||
}
|
||||
|
||||
// ── Tests ───────────────────────────────────────────────────────────────
|
||||
|
||||
private static void Address()
|
||||
{
|
||||
Check.True(WikiAddress.TryNormalize("https://wiki.test/", out string a, out _) && a == Api, "a site becomes its api.php");
|
||||
Check.True(WikiAddress.TryNormalize("wiki.test", out a, out _) && a == Api, "no scheme: https is assumed");
|
||||
Check.True(WikiAddress.TryNormalize("https://wiki.test/index.php?title=Main_Page#x", out a, out _) && a == Api, "index.php becomes api.php, query dropped");
|
||||
Check.True(WikiAddress.TryNormalize("https://wiki.test/w/api.php", out a, out _) && a == "https://wiki.test/w/api.php", "an api.php stays");
|
||||
Check.False(WikiAddress.TryNormalize("http://wiki.test/", out _, out string e) , "plain http is refused");
|
||||
Check.True(e.Contains("https"), "and says https");
|
||||
Check.False(WikiAddress.TryNormalize("https://me:pw@wiki.test/", out _, out _), "a login in the address is refused");
|
||||
Check.False(WikiAddress.TryNormalize("", out _, out _) || WikiAddress.TryNormalize("ht!tp:/", out _, out _), "empty or junk is refused");
|
||||
Check.True(WikiAddress.Same("https://WIKI.test/api.php", Api) && !WikiAddress.Same("https://other.test/api.php", Api), "same address, any case");
|
||||
Check.Eq(WikiAddress.FileKey(Api), "wiki.test", "the cache file key is the host");
|
||||
Check.Eq(WikiAddress.RobotsOf(Api), "https://wiki.test/robots.txt", "robots.txt beside it");
|
||||
}
|
||||
|
||||
private static void Robots()
|
||||
{
|
||||
Check.Eq(WikiClient.CrawlDelay("User-agent: *\nCrawl-Delay: 10\n"), 10.0, "Crawl-Delay for every robot");
|
||||
Check.Eq(WikiClient.CrawlDelay("User-agent: OtherBot\nCrawl-delay: 99\n\nUser-agent: *\nDisallow: /x\n"), (double?)null, "another robot's delay isn't ours");
|
||||
Check.Eq(WikiClient.CrawlDelay("User-agent: OtherBot\nUser-agent: *\nCrawl-delay: 3 # comment\n"), 3.0, "a group naming several robots");
|
||||
Check.Eq(WikiClient.CrawlDelay("<html>login</html>"), (double?)null, "a login page instead: none");
|
||||
}
|
||||
|
||||
private static void Sealed()
|
||||
{
|
||||
WikiLoginStore.FolderOverride = Path.Combine(Program.TempRoot, "wiki-sealed");
|
||||
Check.True(WikiLoginStore.Save(new WikiLogin(Api, User, Password), out string err), "saved: " + err);
|
||||
byte[] raw = File.ReadAllBytes(WikiLoginStore.FilePath);
|
||||
string u8 = Encoding.UTF8.GetString(raw), u16 = Encoding.Unicode.GetString(raw);
|
||||
Check.False(u8.Contains(Password) || u16.Contains(Password) || u8.Contains("Tester") || u8.Contains("wiki.test"), "the file is sealed: no password, name or address readable");
|
||||
WikiLogin? back = WikiLoginStore.Load(out err);
|
||||
Check.True(back != null && back.Api == Api && back.User == User && back.Password == Password, "it opens again for this Windows user");
|
||||
Check.False(back!.ToString().Contains(Password), "a login written out never shows the password");
|
||||
raw[raw.Length / 2] ^= 0x5a;
|
||||
File.WriteAllBytes(WikiLoginStore.FilePath, raw);
|
||||
Check.True(WikiLoginStore.Load(out err) == null && err.Contains("sign in again"), "a damaged file is no login, said plainly");
|
||||
Check.True(WikiLoginStore.Delete(out _) && !File.Exists(WikiLoginStore.FilePath) && !WikiLoginStore.Exists, "Delete removes it");
|
||||
}
|
||||
|
||||
private static void SignIn()
|
||||
{
|
||||
var wiki = new FakeWiki();
|
||||
var waits = new List<TimeSpan>();
|
||||
using var client = new WikiClient(Api, wiki, (g, _) => { waits.Add(g); return Task.CompletedTask; });
|
||||
WikiSignIn s = client.SignInAsync(User, Password, CancellationToken.None).GetAwaiter().GetResult();
|
||||
Check.True(s.Ok && s.UserName == "Tester" && s.ArticleBase == "https://wiki.test/", "signed in: " + s.Message);
|
||||
var log = wiki.Log.ToArray();
|
||||
Check.Eq(log.Length, 4, "robots, token, login, user check");
|
||||
Check.True(log[0].Url.EndsWith("/robots.txt") && log[1].Url.Contains("meta=tokens") && log[2].Method == "POST" && log[3].Url.Contains("assert=user"),
|
||||
"in that order");
|
||||
Check.True(log[2].Body.Contains("lgname=Tester%40probe") && log[2].Body.Contains("lgtoken="), "the login POST carries the name and the token");
|
||||
Check.True(log.All(l => !l.Url.Contains(Password) && !l.Url.Contains("lgpassword")), "the password is never in an address");
|
||||
Check.True(log.Count(l => l.Body.Contains(Uri.EscapeDataString(Password)) || l.Body.Contains(Password)) == 1, "only the login POST carries the password");
|
||||
Check.True(log[2].Cookie.Contains("wikisession=") && log[3].Cookie.Contains("wikisession="), "the session cookie goes back");
|
||||
Check.True(log.All(l => l.Agent == WikiClient.UserAgent), "every request names only the plugin: " + log[0].Agent);
|
||||
Check.True(client.Gap == TimeSpan.FromSeconds(12) && waits.Count == 3 && waits.All(w => w == TimeSpan.FromSeconds(12)),
|
||||
$"robots.txt's 12 s kept between every request ({string.Join(",", waits)})");
|
||||
|
||||
var slow = new FakeWiki { Robots = "User-agent: *\nCrawl-delay: 1\n" };
|
||||
using var c2 = new WikiClient(Api, slow, (_, _) => Task.CompletedTask);
|
||||
c2.SignInAsync(User, Password, CancellationToken.None).GetAwaiter().GetResult();
|
||||
Check.Eq(c2.Gap, WikiClient.MinGap, "never closer than 5 s");
|
||||
var none = new FakeWiki { Robots = null };
|
||||
using var c3 = new WikiClient(Api, none, (_, _) => Task.CompletedTask);
|
||||
c3.SignInAsync(User, Password, CancellationToken.None).GetAwaiter().GetResult();
|
||||
Check.Eq(c3.Gap, WikiClient.DefaultGap, "no robots.txt: 10 s");
|
||||
}
|
||||
|
||||
private static WikiSignIn Try(FakeWiki wiki, string user, string password)
|
||||
{
|
||||
using var client = new WikiClient(Api, wiki, (_, _) => Task.CompletedTask);
|
||||
return client.SignInAsync(user, password, CancellationToken.None).GetAwaiter().GetResult();
|
||||
}
|
||||
|
||||
private static void SignInFails()
|
||||
{
|
||||
WikiSignIn s = Try(new FakeWiki(), User, "not-the-password");
|
||||
Check.True(!s.Ok && s.Message.Contains("turned the sign-in down") && s.Message.Contains("fake wiki"), "wrong password: " + s.Message);
|
||||
Check.False(s.Message.Contains("not-the-password"), "the message never holds the password");
|
||||
s = Try(new FakeWiki(), "Tester", "not-the-password");
|
||||
Check.True(s.Message.Contains("YourName@botname"), "a name without @: the bot password hint");
|
||||
s = Try(new FakeWiki { LoginResultOverride = "Aborted" }, User, Password);
|
||||
Check.True(!s.Ok && s.Message.Contains("Special:BotPasswords"), "a main-password sign-in turned away: " + s.Message);
|
||||
s = Try(new FakeWiki { HtmlInstead = "<!DOCTYPE html><html>Login required</html>" }, User, Password);
|
||||
Check.True(!s.Ok && s.Message.Contains("api.php"), "not an API: " + s.Message);
|
||||
s = Try(new FakeWiki { Redirect = true }, User, Password);
|
||||
Check.True(!s.Ok && s.Message.Contains("somewhere else"), "a redirect isn't followed: " + s.Message);
|
||||
}
|
||||
|
||||
private static void OffByDefault()
|
||||
{
|
||||
var h = new Harness("off");
|
||||
h.Guide.Tick();
|
||||
Check.False(h.Guide.SignedIn, "not signed in");
|
||||
Check.False(h.Guide.OnLogin(iltActive: true), "login on ILT: no read");
|
||||
h.Guide.Tick();
|
||||
Check.Eq(h.Handlers, 0, "no connection was made");
|
||||
Check.False(Directory.Exists(WikiLoginStore.Folder) && Directory.GetFiles(WikiLoginStore.Folder).Length > 0, "nothing saved");
|
||||
Check.Eq(h.Guide.Address, "", "no wiki address built in");
|
||||
ServerQuestGuideClient c = ReadPublished();
|
||||
Check.True(c.Available && c.Guide.IsEmpty && c.Tag == "Leaftide", "RynthOracle sees the Leaftide guide, empty");
|
||||
Check.True(c.Info!.Takes("settings") && !c.Info.Takes("refresh") && c.Info.Status.Contains("Sign in"), "only the way to sign in: " + c.Info.Status);
|
||||
Check.True(c.Command("settings"), "RynthOracle's Its settings is taken");
|
||||
h.Guide.Tick();
|
||||
Check.Eq(h.SettingsOpened, 1, "and opens the ILT settings");
|
||||
}
|
||||
|
||||
private static Harness SignedIn(string name)
|
||||
{
|
||||
var h = new Harness(name);
|
||||
Check.True(h.Guide.SignIn("https://wiki.test/", User, Password, fromChat: false), "sign-in started: " + h.Guide.Status);
|
||||
h.Settle();
|
||||
return h;
|
||||
}
|
||||
|
||||
private static void ReadsGuide()
|
||||
{
|
||||
var h = SignedIn("reads");
|
||||
Check.True(h.Guide.SignedIn && h.Guide.User == User, "signed in: " + h.Guide.Status);
|
||||
QuestGuide g = h.Guide.Guide;
|
||||
Check.Eq(g.Quests.Count, 3, "three quest pages (the item page isn't one)");
|
||||
Check.True(g.Contracts.Count == 1 && g.Contracts[0].Npc == "Quartermaster Ivo", "the contract and who sells it");
|
||||
Check.True(g.KillTasks.SequenceEqual(new[] { "Glimmer Beetle Kill Task" }), "the kill task list");
|
||||
Check.True(g.Society.TryGetValue("Thornbound Initiate Tasks", out string? rank) && rank == "Initiate", "the society quest's rank");
|
||||
Check.False(g.Society.ContainsKey("Moth Glow Sac"), "an items sub-category isn't followed");
|
||||
Check.Eq(g.Source, "wiki.test", "the source is the wiki's host");
|
||||
Check.Eq(g.Find("The Lantern Moth Errand")?.Url, "https://wiki.test/The_Lantern_Moth_Errand", "page addresses from the site's article path");
|
||||
Check.True(File.Exists(IltWikiGuide.GuidePath(Api)) && WikiLoginStore.Exists, "the guide and the sealed login are saved");
|
||||
Check.True(h.Said.Any(s => s.Ok && s.Text.Contains("signed in as Tester")) && h.Said.Any(s => s.Ok && s.Text.Contains("3 quests")),
|
||||
"the sign-in and the read answered in chat: " + h.AllSaid);
|
||||
Check.False(h.AllSaid.Contains(Password) || h.Guide.Status.Contains(Password) || string.Join(" ", h.Guide.StatusLines()).Contains(Password),
|
||||
"no chat or status line holds the password");
|
||||
NoSecretOnDisk("after the read");
|
||||
|
||||
ServerQuestGuideClient c = ReadPublished();
|
||||
Check.True(c.Available && c.Guide.Quests.Count == 3 && c.Info!.Takes("refresh") && c.Info.Takes("settings"), "RynthOracle gets the guide, with Refresh");
|
||||
Check.False(c.Info.Status.Contains(Password), "the published status holds no secret");
|
||||
|
||||
// A fresh plugin start reads the saved guide without a request.
|
||||
var again = new Harness("reads", fresh: false);
|
||||
Check.True(again.Guide.SignedIn && again.Guide.Guide.Quests.Count == 3 && again.Handlers == 0, "a restart: signed in, the saved guide, no request");
|
||||
Check.False(again.Guide.OnLogin(true), "a fresh guide isn't read again at login");
|
||||
var later = new Harness("reads", fresh: false);
|
||||
later.Now = later.Now.AddHours(25);
|
||||
Check.True(later.Guide.OnLogin(true), "a day old: read again at login");
|
||||
later.Settle();
|
||||
Check.True(later.Guide.Status.Contains("3 quests"), "and read: " + later.Guide.Status);
|
||||
Check.False(later.Said.Any(), "the login read is quiet when it works");
|
||||
var off = new Harness("reads", fresh: false);
|
||||
off.Now = later.Now.AddHours(30);
|
||||
off.Guide.SetDaily(false);
|
||||
Check.False(off.Guide.OnLogin(true), "the switch off: no login read");
|
||||
off.Guide.SetDaily(true);
|
||||
Check.False(off.Guide.OnLogin(false), "not ILT: no login read");
|
||||
}
|
||||
|
||||
private static void OnlyEdited()
|
||||
{
|
||||
var h = SignedIn("edited");
|
||||
int firstContent = h.Wiki.ContentTitles.Count;
|
||||
Check.True(firstContent == 4, "the first read fetched every listed page (3 quests, 1 contract): " + firstContent);
|
||||
Check.False(h.Guide.Refresh(fromChat: true), "Refresh right after a read waits");
|
||||
Check.True(h.Said.Last().Text.Contains("again in") && !h.Said.Last().Ok, "and says when: " + h.Said.Last().Text);
|
||||
h.Wiki.Pages["The Lantern Moth Errand"] = (201, MothErrand.Replace("20 Hours", "18 Hours"));
|
||||
h.Now = h.Now.AddMinutes(6);
|
||||
h.Wiki.ContentTitles.Clear();
|
||||
Check.True(h.Guide.Refresh(fromChat: true), "Refresh after 5 minutes reads");
|
||||
h.Settle();
|
||||
// The edited quest, plus the pages that aren't quests (they are checked again each time).
|
||||
Check.True(h.Wiki.ContentTitles.Contains("The Lantern Moth Errand") && !h.Wiki.ContentTitles.Contains("Glimmer Beetle Kill Task")
|
||||
&& !h.Wiki.ContentTitles.Contains("Thornbound Initiate Tasks") && !h.Wiki.ContentTitles.Contains("Contract for the Bramble Wardens"),
|
||||
"only the edited page (and non-quest pages) fetched: " + string.Join(", ", h.Wiki.ContentTitles));
|
||||
Check.Eq(h.Guide.Guide.Find("The Lantern Moth Errand")?.Repeat, "18 Hours", "the edit is in the guide");
|
||||
Check.Eq(h.Guide.Guide.Find("Glimmer Beetle Kill Task")?.Rev, 102L, "an unchanged page kept from the saved guide");
|
||||
}
|
||||
|
||||
private static void LostSession()
|
||||
{
|
||||
var h = new Harness("lost");
|
||||
h.Wiki.DropSessionAfter = 3;
|
||||
h.Guide.SignIn(Api, User, Password, fromChat: false);
|
||||
h.Settle();
|
||||
Check.True(h.Guide.Guide.Quests.Count == 3 && h.Wiki.Logins == 2, $"the session ended mid-read; signed in again and finished ({h.Wiki.Logins} sign-ins, {h.Guide.Status})");
|
||||
|
||||
var r = new Harness("revoked");
|
||||
r.Wiki.DropSessionAfter = 3;
|
||||
r.Wiki.RevokeAfterFirstLogin = true;
|
||||
r.Guide.SignIn(Api, User, Password, fromChat: false);
|
||||
r.Settle();
|
||||
Check.True(r.Guide.Status.Contains("signing in again didn't work") && r.Guide.Status.Contains("fake wiki"), "a revoked bot password ends the read plainly: " + r.Guide.Status);
|
||||
Check.True(r.Guide.Guide.IsEmpty && r.Said.Any(s => !s.Ok), "no guide from it, and chat says so");
|
||||
Check.False(r.AllSaid.Contains(Password) || r.Guide.Status.Contains(Password), "without the password");
|
||||
}
|
||||
|
||||
private static void SignOut()
|
||||
{
|
||||
var h = SignedIn("signout");
|
||||
Check.True(h.Guide.SignOut(fromChat: true), "signed out");
|
||||
Check.True(h.Said.Last().Ok && h.Said.Last().Text.Contains("deleted"), "and says so: " + h.Said.Last().Text);
|
||||
Check.False(WikiLoginStore.Exists || File.Exists(IltWikiGuide.GuidePath(Api)), "the sealed login and the saved guide are gone");
|
||||
Check.True(!h.Guide.SignedIn && h.Guide.Guide.IsEmpty, "nothing in memory either");
|
||||
h.Guide.Tick();
|
||||
ServerQuestGuideClient c = ReadPublished();
|
||||
Check.True(c.Guide.IsEmpty && !c.Info!.Takes("refresh"), "RynthOracle's copy goes");
|
||||
Check.Eq(h.Guide.Address, Api, "the address stays (it is no secret)");
|
||||
Check.True(h.Guide.SignOut(fromChat: false), "signing out again is fine");
|
||||
var restart = new Harness("signout", fresh: false);
|
||||
Check.False(restart.Guide.SignedIn, "a restart stays signed out");
|
||||
}
|
||||
|
||||
private static void Commands()
|
||||
{
|
||||
var h = new Harness("commands");
|
||||
void Run(string line, bool ok, string needle)
|
||||
{
|
||||
h.Said.Clear();
|
||||
h.Guide.HandleCommand(line.Split(' ', StringSplitOptions.RemoveEmptyEntries));
|
||||
Check.True(h.Said.Count > 0, $"/ilt wiki {line}: answers");
|
||||
Check.True(h.Said.All(s => s.Ok == ok), $"/ilt wiki {line}: {(ok ? "worked" : "didn't")} ({h.AllSaid})");
|
||||
Check.True(h.AllSaid.Contains(needle, StringComparison.OrdinalIgnoreCase), $"/ilt wiki {line}: says '{needle}' ({h.AllSaid})");
|
||||
}
|
||||
Run("status", true, "Off until you sign in");
|
||||
Run("", true, "address: not set");
|
||||
Run("refresh", false, "not signed in");
|
||||
Run("signin", true, "settings window is open");
|
||||
Check.Eq(h.SettingsOpened, 1, "signin without a login opens the settings");
|
||||
h.Said.Clear();
|
||||
h.Guide.HandleCommand(new[] { "signin", User, Password });
|
||||
Check.True(h.Said.Count == 1 && !h.Said[0].Ok && h.Said[0].Text.Contains("aren't taken in chat"), "a login typed in chat is refused: " + h.AllSaid);
|
||||
Check.False(h.AllSaid.Contains(Password) || h.AllSaid.Contains(User), "and not repeated");
|
||||
Check.Eq(h.Handlers, 0, "nothing was sent");
|
||||
Check.False(WikiLoginStore.Exists, "nothing was saved");
|
||||
Run("signout", true, "not signed in");
|
||||
Run("address http://wiki.test/", false, "https");
|
||||
Run("address wiki.test", true, Api);
|
||||
Run("address", true, Api);
|
||||
Run("auto off", true, "is off");
|
||||
Check.False(h.Guide.Daily, "the switch is off");
|
||||
Run("auto on", true, "is on");
|
||||
Run("help", true, "/ilt wiki signout");
|
||||
Run("frobnicate", false, "unknown");
|
||||
|
||||
var s = SignedIn("commands-signed");
|
||||
s.Said.Clear();
|
||||
s.Guide.HandleCommand(new[] { "status" });
|
||||
Check.True(s.AllSaid.Contains("signed in as " + User) && s.AllSaid.Contains("3 quests"), "status when signed in: " + s.AllSaid);
|
||||
s.Said.Clear();
|
||||
s.Guide.HandleCommand(new[] { "address", "https://other.test/" });
|
||||
Check.True(s.Said.Count == 1 && !s.Said[0].Ok && s.Said[0].Text.Contains("sign out first"), "the address can't change while signed in");
|
||||
s.Now = s.Now.AddMinutes(10);
|
||||
s.Said.Clear();
|
||||
s.Guide.HandleCommand(new[] { "signin" });
|
||||
Check.True(s.Said.Any(x => x.Ok && x.Text.Contains("signing in again")), "signin with a saved login signs in again: " + s.AllSaid);
|
||||
s.Settle();
|
||||
Check.True(s.Guide.Status.Contains("3 quests"), "and reads: " + s.Guide.Status);
|
||||
}
|
||||
|
||||
private static void OtherAddress()
|
||||
{
|
||||
var h = new Harness("other");
|
||||
h.Guide.SetAddress("https://wiki.test/", fromChat: false);
|
||||
Check.True(WikiLoginStore.Save(new WikiLogin("https://other.test/api.php", User, Password), out _), "a login for another wiki is on disk");
|
||||
var again = new Harness("other", fresh: false);
|
||||
Check.False(again.Guide.SignedIn, "it isn't used for this address");
|
||||
Check.True(again.Guide.Status.Contains("another wiki address"), "and the status says why: " + again.Guide.Status);
|
||||
Check.False(again.Guide.OnLogin(true) || again.Guide.Refresh(fromChat: false), "no read with it");
|
||||
Check.Eq(again.Handlers, 0, "nothing was sent anywhere");
|
||||
}
|
||||
|
||||
private static void Parsing()
|
||||
{
|
||||
GuideQuest q = QuestWikiText.ParseQuest("The Lantern Moth Errand", MothErrand, 101, "https://wiki.test/");
|
||||
Check.True(q.Level == "120+" && q.StartsWith == "Warden Pellis" && q.StartsAt == "Hollow Reach" && q.IsDaily, "the summary box");
|
||||
Check.True(q.Overview.StartsWith("Warden Pellis wants"), "the overview");
|
||||
Check.Eq(q.Steps.Count, 3, "three numbered steps");
|
||||
Check.True(q.Steps[0].Coords.SequenceEqual(new[] { "12.3N, 45.6E" }) && q.Steps[0].Stamps.SequenceEqual(new[] { "LanternMothErrandStarted" }), "a step's place and stamp");
|
||||
Check.True(q.Steps[1].Coords.SequenceEqual(new[] { "14.0N, 47.2E" }) && q.Loot.SequenceEqual(new[] { "Moth Glow Sac" }), "the loot is the killed-for item, not the handed-in one");
|
||||
Check.True(q.Rewards.Contains("For Hand in a glow sac:") && q.Rewards.Contains("XP: 5,000,000"), "the rewards table");
|
||||
|
||||
GuideQuest k = QuestWikiText.ParseQuest("Glimmer Beetle Kill Task", GlimmerBeetles, 102, "https://wiki.test/");
|
||||
Check.True(k.IsKillTaskPage && k.IsWeekly && k.KillTarget == 50, "a weekly kill task of 50");
|
||||
Check.True(k.Overview.StartsWith("Thin out") && k.Steps.Count == 3, "the Discord description and the paragraph steps");
|
||||
Check.True(k.Steps[0].Coords.SequenceEqual(new[] { "3.1S, 70.2W" }), "coordinates written '3.1s,70.2w'");
|
||||
Check.True(k.AllStamps().Contains("GlimmerBeetleTaskTaken") && k.AllStamps().Contains("GlimmerBeetleKills"), "the QB Stamps, cut to the flag");
|
||||
|
||||
var (pages, cont) = IltWikiReader.Generated("{\"continue\":{\"gcmcontinue\":\"page|X|9\",\"continue\":\"gcm||\"},\"query\":{\"pages\":[{\"ns\":0,\"title\":\"A\",\"lastrevid\":5},{\"ns\":14,\"title\":\"Category:B\"},{\"ns\":0,\"title\":\"C\",\"missing\":true}]}}");
|
||||
Check.True(pages.Count == 2 && pages[0] == ("A", 0, 5L) && pages[1].Ns == 14 && cont.Count == 2, "a generator answer: pages, sub-categories, the continuation");
|
||||
Check.True(IltWikiReader.RankOf("Category:Society Quests: Knight Rank") == "Knight" && IltWikiReader.SkipCategory("Category:Society Items"), "ranks and skipped sub-categories");
|
||||
}
|
||||
}
|
||||
507
Tools/RynthServerPack.Tests/DreamWeaveAbilitiesTests.cs
Normal file
507
Tools/RynthServerPack.Tests/DreamWeaveAbilitiesTests.cs
Normal file
|
|
@ -0,0 +1,507 @@
|
|||
using System;
|
||||
using RynthCore.Plugin.RynthDreamWeave;
|
||||
using RynthCore.RynthAiTests.Harness;
|
||||
|
||||
namespace RynthServerPack.Tests;
|
||||
|
||||
// RynthDreamWeave's class ability point calculator (Plugins\RynthCore.Plugin.RynthDreamWeave\DreamWeave\AbilityPointPrices.cs
|
||||
// and DreamWeaveAbilityPoints.cs, 2026-11-17): DreamWeave's two price curves as its server computes them
|
||||
// (ACE-DreamWeave ClassAbilityLumCurve.cs with the PropertyManager defaults), what a budget buys, the curve fitted to
|
||||
// the server's quote, the "/abilities points" reply (worded as the source of 2026-11-02 writes it) and the grant
|
||||
// lines, only its own reply hidden, and when its read goes.
|
||||
internal static class DreamWeaveAbilitiesTests
|
||||
{
|
||||
private const int Broadcast = 0x00, Advancement = 0x0D, Tell = 0x03;
|
||||
private static readonly DateTime Utc = new(2026, 11, 17, 22, 0, 0, DateTimeKind.Utc);
|
||||
|
||||
private const string Points = "Points: 12 available, 30 lifetime earned.";
|
||||
private const string Lum = "Luminance purchases: 5 bought so far; the next point costs 3,051,758 Luminance. Exchange it at the reckoning-stone by the Skillmaster in the Drift Network. Prices rise with each point and there is no cap.";
|
||||
private const string Xp = "Experience purchases: 2 bought so far; the next point costs 392,000,000,000 experience and you have 1,234,567 unassigned. Prices rise with each point and there is no cap.";
|
||||
private const string XpLocked = "Experience purchases: unlocked at level 275 (you are 200).";
|
||||
private const string Off = "Class abilities are not currently enabled on this server.";
|
||||
|
||||
public static void Register(Runner r)
|
||||
{
|
||||
r.Add("dw abilities: the luminance curve is the server's (1M, x1.25 to the 10th, x1.5 to the 20th, x1.75 after)", LumCurve);
|
||||
r.Add("dw abilities: the experience curve is the server's (200B, x1.4 each) and stops at long.MaxValue", XpCurve);
|
||||
r.Add("dw abilities: a range is the unrounded prices summed and rounded once", Ranges);
|
||||
r.Add("dw abilities: what a budget buys, its cost and what the next point still needs", Affordable);
|
||||
r.Add("dw abilities: the curve is scaled to a quote it doesn't give, and kept when it does", Fit);
|
||||
r.Add("dw abilities: the /abilities points reply (unlocked, locked, class abilities off)", Replies);
|
||||
r.Add("dw abilities: only the reply to its own request is hidden; a typed one shows and is read", OursAndTyped);
|
||||
r.Add("dw abilities: player chat and a quoted copy are not read", NotRead);
|
||||
r.Add("dw abilities: a purchase moves its lane on and asks for a read; other grants and learning move only the points", Grants);
|
||||
r.Add("dw abilities: the read goes once when the page opens, on Read now, only when quiet and in the world", ReadTiming);
|
||||
r.Add("dw abilities: a request with no reply is given up and said", Missed);
|
||||
r.Add("dw abilities: the command, the numbers in words and ordinals, and the summary lines", Text);
|
||||
r.Add("dw abilities: buying with experience: the command, the grant, the refusals, no answer, no read meanwhile", BuyXp);
|
||||
r.Add("dw abilities: the luminance stone: its answers, what it counted, a purchase through it, one used by hand", Stone);
|
||||
r.Add("dw abilities: the earning rate (purchases added back, a drop starts again) and the time to the next point", Rates);
|
||||
r.Add("dw abilities: how the price grows from a point on, and the live prices of 2026-11-17", StageAndLive);
|
||||
}
|
||||
|
||||
private static void LumCurve()
|
||||
{
|
||||
AbilityCurve c = AbilityCurve.Luminance;
|
||||
Check.Eq(c.Cost(0), 0L, "no 0th point");
|
||||
Check.Eq(c.Cost(1), 1_000_000L, "1st");
|
||||
Check.Eq(c.Cost(2), 1_250_000L, "2nd = x1.25");
|
||||
Check.Eq(c.Cost(3), 1_562_500L, "3rd");
|
||||
Check.Eq(c.Cost(6), 3_051_758L, "6th (3,051,757.8125 rounded)");
|
||||
Check.Eq(c.Cost(10), 7_450_581L, "10th = 1.25^9");
|
||||
Check.Eq(c.Cost(11), 11_175_871L, "11th: x1.5 from the 10th");
|
||||
Check.Eq(c.Cost(20), 429_638_021L, "20th: 1.25^9 * 1.5^10");
|
||||
Check.Eq(c.Cost(21), 751_866_537L, "21st: x1.75 from the 20th");
|
||||
Check.Eq(c.Cost(23), 2_302_591_270L, "23rd");
|
||||
// Seen live on DreamWeave (a client log, 2026-11): "You gain 1 class ability point from spending 16,763,806 Luminance."
|
||||
Check.Eq(c.Cost(12), 16_763_806L, "12th, as the server charged it");
|
||||
}
|
||||
|
||||
private static void XpCurve()
|
||||
{
|
||||
AbilityCurve c = AbilityCurve.Experience;
|
||||
Check.Eq(c.Cost(1), 200_000_000_000L, "1st");
|
||||
Check.Eq(c.Cost(2), 280_000_000_000L, "2nd = x1.4 (seen live: \"from spending 280,000,000,000 experience\")");
|
||||
Check.Eq(c.Cost(3), 392_000_000_000L, "3rd (391,999,999,999.99994 rounded)");
|
||||
Check.Eq(c.Cost(10), 4_132_209_356_800L, "10th = 1.4^9");
|
||||
Check.Eq(c.Cost(54), long.MaxValue, "the 54th is past long.MaxValue: it stays there");
|
||||
Check.Eq(c.CostOfRange(50, 10), long.MaxValue, "a range past it too");
|
||||
Check.Eq(AbilityCurve.ExperienceMinLevel, 275, "the lane opens at 275");
|
||||
}
|
||||
|
||||
private static void Ranges()
|
||||
{
|
||||
AbilityCurve c = AbilityCurve.Luminance;
|
||||
Check.Eq(c.CostOfRange(5, 0), 0L, "no points, no cost");
|
||||
Check.Eq(c.CostOfRange(0, 1), 1_000_000L, "one point");
|
||||
Check.Eq(c.CostOfRange(5, 5), 25_045_872L, "points 6 to 10: 25,045,871.73 rounded once");
|
||||
long each = 0;
|
||||
for (int n = 6; n <= 10; n++) each += c.Cost(n);
|
||||
Check.Eq(each, 25_045_872L, "the same as the rounded prices here");
|
||||
Check.Eq(c.CostOfRange(0, 23), 5_670_039_471L, "the first 23 points");
|
||||
}
|
||||
|
||||
private static void Affordable()
|
||||
{
|
||||
AbilityCurve c = AbilityCurve.Luminance;
|
||||
int k = c.Affordable(0, 3_000_000, out long spent, out long next, out long need);
|
||||
Check.Eq(k, 2, "3M buys the 1st and 2nd");
|
||||
Check.Eq(spent, 2_250_000L, "for 2,250,000");
|
||||
Check.Eq(next, 1_562_500L, "the 3rd's price");
|
||||
Check.Eq(need, 812_500L, "the 3rd needs 812,500 more");
|
||||
|
||||
k = c.Affordable(0, 2_250_000, out spent, out _, out need);
|
||||
Check.Eq(k, 2, "exactly enough buys both");
|
||||
Check.Eq(need, 1_562_500L, "nothing left for the 3rd");
|
||||
|
||||
k = c.Affordable(5, 8_904_758, out spent, out _, out need);
|
||||
Check.Eq(k, 2, "8,904,758 from 5 bought: the 6th and 7th");
|
||||
Check.Eq(spent, 6_866_455L, "3,051,758 + 3,814,697");
|
||||
Check.Eq(need, 2_730_069L, "the 8th (4,768,372) less what is left");
|
||||
|
||||
k = c.Affordable(0, 0, out spent, out _, out need);
|
||||
Check.Eq(k, 0, "nothing buys nothing");
|
||||
Check.Eq(need, 1_000_000L, "the 1st needs all of it");
|
||||
|
||||
k = AbilityCurve.Experience.Affordable(0, long.MaxValue - 1, out spent, out _, out need);
|
||||
Check.True(k > 40 && k < 54, $"the experience lane stops before long.MaxValue ({k})");
|
||||
Check.True(spent > 0 && spent < long.MaxValue, "and what it spent fits");
|
||||
}
|
||||
|
||||
private static void Fit()
|
||||
{
|
||||
AbilityCurve c = AbilityCurve.Luminance;
|
||||
AbilityCurve same = c.Fit(5, 3_051_758, out bool matches);
|
||||
Check.True(matches, "the server's own price matches");
|
||||
Check.Eq(same, c, "and the curve is kept");
|
||||
|
||||
AbilityCurve scaled = c.Fit(5, 6_103_516, out matches);
|
||||
Check.False(matches, "a doubled price doesn't");
|
||||
Check.Eq(scaled.Cost(6), 6_103_516L, "the scaled curve gives the quote");
|
||||
Check.Eq(scaled.Cost(1), 2_000_000L, "and doubles the rest");
|
||||
|
||||
c.Fit(5, 0, out matches);
|
||||
Check.True(matches, "no quote: kept");
|
||||
}
|
||||
|
||||
private static DreamWeaveAbilityPoints Asked(out long t)
|
||||
{
|
||||
var p = new DreamWeaveAbilityPoints();
|
||||
t = 1_000_000;
|
||||
p.Login();
|
||||
p.CheckSoon();
|
||||
Check.Eq(p.Due(t, canSend: true, quiet: true), DreamWeaveAbilityPoints.Command, "the read goes");
|
||||
p.NoteChatBar(); // our own send through the chat bar
|
||||
return p;
|
||||
}
|
||||
|
||||
private static void Replies()
|
||||
{
|
||||
var p = Asked(out long t);
|
||||
Check.True(p.OnChatText(Points, Broadcast, t + 100, Utc), "points line hidden");
|
||||
Check.True(p.OnChatText(Lum, Broadcast, t + 110, Utc), "luminance line hidden");
|
||||
Check.True(p.OnChatText(Xp, Broadcast, t + 120, Utc), "experience line hidden");
|
||||
Check.Eq(p.Available, 12, "available");
|
||||
Check.Eq(p.Earned, 30, "earned");
|
||||
Check.Eq(p.LumBought, 5, "luminance bought");
|
||||
Check.Eq(p.LumNext, 3_051_758L, "its next price");
|
||||
Check.True(p.LumMatches, "the published curve gives it");
|
||||
Check.Eq(p.XpBought, 2, "experience bought");
|
||||
Check.Eq(p.XpNext, 392_000_000_000L, "its next price");
|
||||
Check.True(p.XpMatches, "the published curve gives it");
|
||||
Check.Eq(p.UnassignedXp, 1_234_567L, "unassigned experience from the reply");
|
||||
Check.Null(p.XpUnlockLevel, "the lane is open");
|
||||
Check.True(p.HasReading, "a reading");
|
||||
Check.Eq(p.ReadUtc, Utc, "read now");
|
||||
Check.False(p.Waiting(t + 130), "the reply is complete");
|
||||
|
||||
p = Asked(out t);
|
||||
p.OnChatText(Points, Broadcast, t + 100, Utc);
|
||||
p.OnChatText(Lum, Broadcast, t + 110, Utc);
|
||||
Check.True(p.OnChatText(XpLocked, Broadcast, t + 120, Utc), "the locked line hidden");
|
||||
Check.Eq(p.XpUnlockLevel, 275, "opens at 275");
|
||||
Check.Eq(p.Level, 200, "the level from the line");
|
||||
Check.Eq(p.XpBought, 0, "none bought below it");
|
||||
Check.Null(p.XpNext, "no quote");
|
||||
Check.False(p.Waiting(t + 130), "the reply is complete");
|
||||
|
||||
p = Asked(out t);
|
||||
Check.True(p.OnChatText(Off, Broadcast, t + 100, Utc), "the off line hidden");
|
||||
Check.True(p.Off, "class abilities are off");
|
||||
Check.False(p.Waiting(t + 110), "and that is the whole reply");
|
||||
|
||||
// A timestamped line and one message holding the whole reply.
|
||||
p = Asked(out t);
|
||||
Check.True(p.OnChatText("[22:01:05] " + Points + "\n" + Lum + "\r\n" + Xp, Broadcast, t + 100, Utc), "one message, hidden");
|
||||
Check.Eq(p.LumBought, 5, "read");
|
||||
Check.Eq(p.XpBought, 2, "read");
|
||||
|
||||
// A price the curve doesn't give: scaled to it.
|
||||
p = Asked(out t);
|
||||
p.OnChatText("Luminance purchases: 5 bought so far; the next point costs 6,103,516 Luminance. Exchange it.", Broadcast, t + 100, Utc);
|
||||
Check.False(p.LumMatches, "a changed price is seen");
|
||||
Check.Eq(p.LumCurve.Cost(6), 6_103_516L, "the lane's curve gives the quote");
|
||||
}
|
||||
|
||||
private static void OursAndTyped()
|
||||
{
|
||||
// Typed: the chat bar sees a /abilities points we didn't send.
|
||||
var p = new DreamWeaveAbilityPoints();
|
||||
long t = 1_000_000;
|
||||
p.Login();
|
||||
p.NoteChatBar();
|
||||
Check.False(p.OnChatText(Points, Broadcast, t, Utc), "a typed command's reply shows");
|
||||
Check.False(p.OnChatText(Lum, Broadcast, t + 10, Utc), "all of it");
|
||||
Check.False(p.OnChatText(Xp, Broadcast, t + 20, Utc), "all of it");
|
||||
Check.Eq(p.LumBought, 5, "and is read");
|
||||
|
||||
// Ours, then the player types one while it is on its way: theirs shows.
|
||||
p = Asked(out t);
|
||||
p.NoteChatBar(); // the player's
|
||||
Check.False(p.OnChatText(Points, Broadcast, t + 100, Utc), "the player's reply shows");
|
||||
|
||||
// After our reply, the same lines (a /abilities list ends with Points:) show.
|
||||
p = Asked(out t);
|
||||
p.OnChatText(Points + "\n" + Lum + "\n" + Xp, Broadcast, t + 100, Utc);
|
||||
Check.False(p.OnChatText(Points, Broadcast, t + 500, Utc), "a later Points line shows");
|
||||
Check.Eq(p.Available, 12, "and is read");
|
||||
|
||||
// The window: a reply 5 s late isn't ours.
|
||||
p = Asked(out t);
|
||||
Check.False(p.OnChatText(Lum, Broadcast, t + 6_000, Utc), "too late to be ours");
|
||||
}
|
||||
|
||||
private static void NotRead()
|
||||
{
|
||||
var p = Asked(out long t);
|
||||
Check.False(p.OnChatText(Lum, Tell, t + 100, Utc), "a tell isn't read");
|
||||
Check.Null(p.LumBought, "nothing read");
|
||||
Check.False(p.OnChatText("Someone says, \"" + Lum + "\"", Broadcast, t + 100, Utc), "a quoted copy isn't read");
|
||||
Check.Null(p.LumBought, "nothing read");
|
||||
Check.False(p.OnChatText("You gain 5 class ability points from spending 1 Luminance. Available: 99.", Tell, t + 100, Utc), "a grant in a tell isn't read");
|
||||
Check.Null(p.Available, "nothing read");
|
||||
}
|
||||
|
||||
private static void Grants()
|
||||
{
|
||||
var p = Asked(out long t);
|
||||
p.OnChatText(Points + "\n" + Lum + "\n" + Xp, Broadcast, t + 100, Utc);
|
||||
int rev = p.Revision;
|
||||
Check.False(p.OnChatText("You gain 1 class ability point from spending 3,051,758 Luminance. Available: 13. Use /abilities to spend them.",
|
||||
Advancement, t + 10_000, Utc), "a grant shows");
|
||||
Check.Eq(p.LumBought, 6, "the luminance lane moves on");
|
||||
Check.Null(p.LumNext, "its quote is stale");
|
||||
Check.Eq(p.Available, 13, "available");
|
||||
Check.Eq(p.Earned, 31, "earned");
|
||||
Check.True(p.Wanted, "a read follows");
|
||||
Check.True(p.Revision != rev, "the page refills");
|
||||
|
||||
p = Asked(out t);
|
||||
p.OnChatText(Points + "\n" + Lum + "\n" + Xp, Broadcast, t + 100, Utc);
|
||||
p.OnChatText("You gain 2 class ability points from spending 672,000,000,000 experience. Available: 14. Use /abilities to spend them.",
|
||||
Advancement, t + 10_000, Utc);
|
||||
Check.Eq(p.XpBought, 4, "the experience lane moves on");
|
||||
Check.Eq(p.LumBought, 5, "the luminance lane doesn't");
|
||||
Check.True(p.Wanted, "a read follows");
|
||||
|
||||
p = Asked(out t);
|
||||
p.OnChatText(Points + "\n" + Lum + "\n" + Xp, Broadcast, t + 100, Utc);
|
||||
p.OnChatText("You gain 1 class ability point from reaching level 300. Available: 13. Use /abilities to spend them.",
|
||||
Advancement, t + 10_000, Utc);
|
||||
Check.Eq(p.Available, 13, "a milestone moves the points");
|
||||
Check.Eq(p.LumBought, 5, "not a lane");
|
||||
Check.False(p.Wanted, "no read");
|
||||
|
||||
p.OnChatText("You have learned Arcane Surge rank 2/5. Points: 10 available, 31 lifetime earned.", Broadcast, t + 20_000, Utc);
|
||||
Check.Eq(p.Available, 10, "learning moves the points");
|
||||
Check.Eq(p.Earned, 31, "earned");
|
||||
|
||||
// A purchase before any reading: no lane to move.
|
||||
var q = new DreamWeaveAbilityPoints();
|
||||
q.Login();
|
||||
q.OnChatText("You gain 1 class ability point from spending 1,000,000 Luminance. Available: 1. Use /abilities to spend them.", Advancement, t, Utc);
|
||||
Check.Null(q.LumBought, "unknown stays unknown");
|
||||
Check.Eq(q.Available, 1, "available");
|
||||
Check.False(q.Wanted, "no read without the page");
|
||||
}
|
||||
|
||||
private static void ReadTiming()
|
||||
{
|
||||
var p = new DreamWeaveAbilityPoints();
|
||||
long t = 1_000_000;
|
||||
p.Login();
|
||||
Check.False(p.Wanted, "nothing at login");
|
||||
Check.Null(p.Due(t, true, true), "nothing goes");
|
||||
p.PageOpened();
|
||||
Check.True(p.Wanted, "the page's first draw wants a read");
|
||||
Check.Null(p.Due(t, canSend: false, quiet: true), "not outside the world or in portal space");
|
||||
Check.Null(p.Due(t, canSend: true, quiet: false), "not near another command");
|
||||
Check.Eq(p.Due(t, true, true), DreamWeaveAbilityPoints.Command, "then it goes");
|
||||
Check.Null(p.Due(t + 10, true, true), "once");
|
||||
p.OnChatText(Points + "\n" + Lum + "\n" + Xp, Broadcast, t + 100, Utc);
|
||||
p.PageOpened();
|
||||
Check.False(p.Wanted, "the page again: no second read");
|
||||
|
||||
p.CheckSoon();
|
||||
Check.True(p.Wanted, "Read now");
|
||||
Check.Eq(p.Due(t + 1_000, true, true), DreamWeaveAbilityPoints.Command, "goes");
|
||||
p.CheckSoon();
|
||||
Check.Null(p.Due(t + 1_100, true, true), "not while the last one waits for its reply");
|
||||
|
||||
p.Logout();
|
||||
p.Login();
|
||||
Check.False(p.HasReading, "a new login forgets the reading");
|
||||
p.PageOpened();
|
||||
Check.True(p.Wanted, "and reads again when the page opens");
|
||||
|
||||
p.Login();
|
||||
Check.Eq(p.Due(t, true, true), null, "login drops a wanted read");
|
||||
p.CheckSoon();
|
||||
p.Due(t, true, true);
|
||||
p.NotSent();
|
||||
Check.False(p.Waiting(t), "a send that didn't go isn't waited for");
|
||||
}
|
||||
|
||||
private static void Missed()
|
||||
{
|
||||
var p = Asked(out long t);
|
||||
Check.False(p.Tick(t + 1_000), "still in time");
|
||||
Check.True(p.Tick(t + 6_000), "given up after 5 s");
|
||||
Check.True(p.LastMiss.Contains("No reply", StringComparison.Ordinal), "and said");
|
||||
Check.False(p.Tick(t + 7_000), "once");
|
||||
p.CheckSoon();
|
||||
Check.Eq(p.LastMiss, "", "Read now clears it");
|
||||
}
|
||||
|
||||
private static DreamWeaveAbilityPoints ReadIn(out long t)
|
||||
{
|
||||
var p = Asked(out t);
|
||||
p.OnChatText("Points: 0 available, 35 lifetime earned.\n"
|
||||
+ "Luminance purchases: 16 bought so far; the next point costs 127,300,154 Luminance. Exchange it at the reckoning-stone.\n"
|
||||
+ "Experience purchases: 3 bought so far; the next point costs 548,800,000,000 experience and you have 600,000,000,000 unassigned. Prices rise.",
|
||||
Broadcast, t + 100, Utc);
|
||||
t += 10_000;
|
||||
return p;
|
||||
}
|
||||
|
||||
private static void BuyXp()
|
||||
{
|
||||
var p = ReadIn(out long t);
|
||||
Check.Eq(p.BuyXp(1, t), "/abilities buyxp 1", "the command");
|
||||
Check.True(p.Buying(t + 10), "waits for its answer");
|
||||
Check.Null(p.BuyXp(1, t + 20), "one at a time");
|
||||
p.CheckSoon();
|
||||
Check.Null(p.Due(t + 30, true, true), "no read while a purchase waits");
|
||||
Check.False(p.OnChatText("You gain 1 class ability point from spending 548,800,000,000 experience. Available: 1. Use /abilities to spend them.",
|
||||
Advancement, t + 500, Utc), "the grant shows");
|
||||
Check.Eq(p.XpBought, 4, "the lane moves on");
|
||||
Check.False(p.Buying(t + 600), "answered");
|
||||
Check.False(p.BuyFailed, "bought");
|
||||
Check.True(p.BuyMessage.StartsWith("Bought 1 point with experience (548,800,000,000)", StringComparison.Ordinal), p.BuyMessage);
|
||||
Check.Eq(p.Due(t + 700, true, true), DreamWeaveAbilityPoints.Command, "then the read goes");
|
||||
|
||||
p = ReadIn(out t);
|
||||
Check.Eq(p.BuyXp(5, t), "/abilities buyxp 5", "five at once");
|
||||
p.OnChatText("Buying 5 points costs 5,000,000,000,000 experience; you have 600,000,000,000 unassigned.", Broadcast, t + 300, Utc);
|
||||
Check.True(p.BuyFailed, "refused");
|
||||
Check.True(p.BuyMessage.Contains("Not enough unassigned experience", StringComparison.Ordinal), p.BuyMessage);
|
||||
Check.False(p.Buying(t + 400), "answered");
|
||||
Check.Eq(p.XpBought, 3, "nothing bought");
|
||||
|
||||
p = ReadIn(out t);
|
||||
p.BuyXp(1, t);
|
||||
p.OnChatText("You must be level 275 to exchange experience for class ability points. You are level 200.", Broadcast, t + 300, Utc);
|
||||
Check.True(p.BuyFailed, "refused below the level");
|
||||
Check.Eq(p.XpUnlockLevel, 275, "the lane's level");
|
||||
Check.Eq(p.Level, 200, "yours");
|
||||
|
||||
p = ReadIn(out t);
|
||||
p.BuyXp(1, t);
|
||||
p.Tick(t + 1_000);
|
||||
Check.False(p.BuyFailed, "still in time");
|
||||
p.Tick(t + DreamWeaveAbilityPoints.BuyWindowMs + 1);
|
||||
Check.True(p.BuyFailed, "no answer is said");
|
||||
Check.True(p.BuyMessage.Contains("No answer", StringComparison.Ordinal), p.BuyMessage);
|
||||
Check.False(p.Buying(t + DreamWeaveAbilityPoints.BuyWindowMs + 2), "and given up");
|
||||
|
||||
p = ReadIn(out t);
|
||||
Check.Null(p.BuyXp(0, t), "no points, no command");
|
||||
p.BuyXp(1, t);
|
||||
p.BuyNotSent("Couldn't send it.");
|
||||
Check.False(p.Buying(t + 1), "not waiting for a send that didn't go");
|
||||
Check.True(p.BuyFailed, "and said");
|
||||
|
||||
// A refusal that isn't the answer to the page's purchase (typed by hand) is read but not said.
|
||||
p = ReadIn(out t);
|
||||
p.OnChatText("Buying 1 point costs 548,800,000,000 experience; you have 5 unassigned.", Broadcast, t, Utc);
|
||||
Check.Eq(p.BuyMessage, "", "not said");
|
||||
Check.Eq(p.UnassignedXp, 5L, "but read");
|
||||
}
|
||||
|
||||
private static void Stone()
|
||||
{
|
||||
var p = ReadIn(out long t);
|
||||
p.SetStone(known: false, near: true);
|
||||
Check.False(p.StoneNear, "an unknown stone is never near");
|
||||
p.SetStone(known: true, near: true);
|
||||
Check.True(p.StoneNear, "known and near");
|
||||
|
||||
p.StoneUsed(t);
|
||||
Check.True(p.Buying(t + 30_000), "the walk and AC's Yes/No take a while");
|
||||
Check.False(p.OnChatText("Reckoning-Stone of Radiance: this weighs your Luminance and renders it as a class ability point. Each point costs more than the last; the only limit is the price.",
|
||||
Broadcast, t + 2_000, Utc), "the stone's words show");
|
||||
Check.True(p.Buying(t + 2_100), "still waiting");
|
||||
p.OnChatText("Your next point would cost 127,300,154 Luminance; you have 56,700,791 (0 available + 56,700,791 banked).", Broadcast, t + 2_200, Utc);
|
||||
Check.True(p.BuyFailed, "not enough");
|
||||
Check.True(p.BuyMessage.Contains("Not enough luminance", StringComparison.Ordinal), p.BuyMessage);
|
||||
Check.Eq(p.StoneSpendable, 56_700_791L, "what the stone counted");
|
||||
Check.Eq(p.StoneOnYou, 0L, "on you");
|
||||
Check.Eq(p.LumNext, 127_300_154L, "its price");
|
||||
Check.True(p.LumMatches, "the curve's");
|
||||
|
||||
p = ReadIn(out t);
|
||||
p.StoneUsed(t);
|
||||
p.OnChatText("You gain 1 class ability point from spending 127,300,154 Luminance. Available: 1. Use /abilities to spend them.", Advancement, t + 9_000, Utc);
|
||||
Check.Eq(p.LumBought, 17, "bought through the stone");
|
||||
Check.False(p.BuyFailed, "bought");
|
||||
Check.True(p.BuyMessage.StartsWith("Bought 1 point with luminance (127,300,154)", StringComparison.Ordinal), p.BuyMessage);
|
||||
Check.False(p.Buying(t + 9_100), "answered");
|
||||
|
||||
p = ReadIn(out t);
|
||||
p.StoneUsed(t);
|
||||
p.OnChatText("Buying 1 point costs 127,300,154 Luminance; you have 100 (0 available + 100 banked).", Broadcast, t + 9_000, Utc);
|
||||
Check.True(p.BuyFailed, "a Yes it couldn't honour");
|
||||
Check.Eq(p.StoneSpendable, 100L, "what it counted");
|
||||
|
||||
p = ReadIn(out t);
|
||||
p.OnChatText("Your next point would cost 127,300,154 Luminance; you have 56,700,791 (5 available + 56,700,786 banked).", Broadcast, t, Utc);
|
||||
Check.Eq(p.BuyMessage, "", "a stone used by hand: not said");
|
||||
Check.Eq(p.StoneOnYou, 5L, "but read");
|
||||
|
||||
p = ReadIn(out t);
|
||||
p.StoneUsed(t);
|
||||
p.Tick(t + DreamWeaveAbilityPoints.StoneWindowMs + 1);
|
||||
Check.False(p.Buying(t + DreamWeaveAbilityPoints.StoneWindowMs + 2), "a stone use not answered is let go");
|
||||
Check.False(p.BuyFailed, "quietly: the player may have said No");
|
||||
}
|
||||
|
||||
private static void Rates()
|
||||
{
|
||||
var r = new EarnRate();
|
||||
Check.Null(r.PerHour(1), "nothing yet");
|
||||
r.Add(0, 1_000);
|
||||
Check.Null(r.PerHour(1), "one reading");
|
||||
r.Add(30 * 60_000, 1_600);
|
||||
Check.Null(r.PerHour(60 * 60_000), "not long enough");
|
||||
Check.Near(r.PerHour(10 * 60_000) ?? -1, 1_200, 1e-9, "600 in 30 min");
|
||||
r.Spent(500); // a point bought: the bank drops by 500
|
||||
r.Add(60 * 60_000, 1_700);
|
||||
Check.Near(r.PerHour(1) ?? -1, 1_200, 1e-9, "the purchase is added back");
|
||||
r.Add(70 * 60_000, 100);
|
||||
Check.Null(r.PerHour(1), "a drop nothing explains starts again");
|
||||
r.Add(130 * 60_000, 700);
|
||||
Check.Near(r.PerHour(1) ?? -1, 600, 1e-9, "from there");
|
||||
r.Clear();
|
||||
Check.Null(r.PerHour(1), "cleared");
|
||||
|
||||
Check.Eq(EarnRate.Time(0, 100), "now", "nothing needed");
|
||||
Check.Eq(EarnRate.Time(500, 1_000), "about 30 min", "half an hour");
|
||||
Check.Eq(EarnRate.Time(3_500, 1_000), "about 3.5 h", "hours and a half");
|
||||
Check.Eq(EarnRate.Time(70_599_363, 1_200_000), "about 59 h", "59 hours");
|
||||
Check.Eq(EarnRate.Time(100, 1), "about 4 days", "days");
|
||||
Check.Eq(EarnRate.Time(100, 0), "", "never at nothing an hour");
|
||||
Check.Eq(EarnRate.Time(1, 1e9), "about 1 min", "at least a minute");
|
||||
}
|
||||
|
||||
private static void StageAndLive()
|
||||
{
|
||||
Check.Eq(AbilityText.Stage(AbilityCurve.Luminance, 2), "each point costs x1.25 the last up to the 10th, then x1.5 up to the 20th, then x1.75", "early");
|
||||
Check.Eq(AbilityText.Stage(AbilityCurve.Luminance, 18), "each point costs x1.5 the last up to the 20th, then x1.75", "middle");
|
||||
Check.Eq(AbilityText.Stage(AbilityCurve.Luminance, 21), "each point costs x1.75 the last, with no end", "tail");
|
||||
Check.Eq(AbilityText.Stage(AbilityCurve.Experience, 5), "each point costs x1.4 the last, with no end", "experience");
|
||||
// DreamWeave's own quotes for one character on 2026-11-17 (/abilities points): 16 bought with luminance, 3 with experience.
|
||||
Check.Eq(AbilityCurve.Luminance.Cost(17), 127_300_154L, "the 17th luminance point, as quoted");
|
||||
Check.Eq(AbilityCurve.Experience.Cost(4), 548_800_000_000L, "the 4th experience point, as quoted");
|
||||
}
|
||||
|
||||
private static void Text()
|
||||
{
|
||||
Check.True(DreamWeaveAbilityPoints.IsCommand("/abilities points"), "the command");
|
||||
Check.True(DreamWeaveAbilityPoints.IsCommand(" /Abilities POINTS "), "any case and spacing");
|
||||
Check.False(DreamWeaveAbilityPoints.IsCommand("/abilities"), "not the list");
|
||||
Check.False(DreamWeaveAbilityPoints.IsCommand("/abilities buyxp 1"), "not a purchase");
|
||||
|
||||
Check.Eq(AbilityText.Ordinal(1), "1st", "1st");
|
||||
Check.Eq(AbilityText.Ordinal(2), "2nd", "2nd");
|
||||
Check.Eq(AbilityText.Ordinal(3), "3rd", "3rd");
|
||||
Check.Eq(AbilityText.Ordinal(4), "4th", "4th");
|
||||
Check.Eq(AbilityText.Ordinal(11), "11th", "11th");
|
||||
Check.Eq(AbilityText.Ordinal(12), "12th", "12th");
|
||||
Check.Eq(AbilityText.Ordinal(13), "13th", "13th");
|
||||
Check.Eq(AbilityText.Ordinal(21), "21st", "21st");
|
||||
Check.Eq(AbilityText.Ordinal(112), "112th", "112th");
|
||||
Check.Eq(AbilityText.Num(3_051_758), "3,051,758", "under a billion: exact only");
|
||||
Check.Eq(AbilityText.Num(392_000_000_000), "392,000,000,000 (392 billion)", "with words");
|
||||
Check.Eq(AbilityText.Words(4_132_209_356_800), "4.13 trillion", "two places under ten");
|
||||
Check.Eq(AbilityText.Words(25_045_871_734), "25 billion", "one place under a hundred, dropped when 0");
|
||||
Check.Eq(AbilityText.Num(long.MaxValue), "more than 9.2 quintillion", "past the top");
|
||||
|
||||
Check.Eq(AbilityText.Lane("Luminance", AbilityCurve.Luminance, 5, 8_904_758, "banked"),
|
||||
"Luminance: 5 bought; the 6th costs 3,051,758; your 8,904,758 banked buys 2 more (6,866,455), the 8th needs 2,730,069 more",
|
||||
"the lane's sentence");
|
||||
Check.Eq(AbilityText.Lane("Experience", AbilityCurve.Experience, 0, 1_000, "unassigned"),
|
||||
"Experience: 0 bought; the 1st costs 200,000,000,000 (200 billion); your 1,000 unassigned is 199,999,999,000 (200 billion) short of it",
|
||||
"short of the next");
|
||||
Check.Eq(AbilityText.Range("Luminance", AbilityCurve.Luminance, 5, 5),
|
||||
"Luminance: points 6 to 10 cost 25,045,872 in all (3,051,758, 3,814,697, 4,768,372, 5,960,464, 7,450,581)", "a range");
|
||||
Check.Eq(AbilityText.Range("Luminance", AbilityCurve.Luminance, 0, 1), "Luminance: the 1st point costs 1,000,000", "one point");
|
||||
|
||||
var p = Asked(out long t);
|
||||
Check.Eq(p.Summary(null), "Your class ability points aren't read yet", "before a reading");
|
||||
p.OnChatText(Points + "\n" + Lum + "\n" + XpLocked, Broadcast, t + 100, Utc);
|
||||
Check.Eq(p.Summary(8_904_758),
|
||||
"Class ability points: 12 available, 30 earned. "
|
||||
+ "Luminance: 5 bought; the 6th costs 3,051,758; your 8,904,758 banked buys 2 more (6,866,455), the 8th needs 2,730,069 more. "
|
||||
+ "Experience: opens at level 275 (you are 200)", "the summary");
|
||||
}
|
||||
}
|
||||
|
|
@ -126,13 +126,15 @@ internal static class DreamWeaveTests
|
|||
Check.Eq(b.Published, (long?)150_000, "the deposit isn't earned");
|
||||
b.OnChatLine("[BANK] Luminance: 180,000", t + 130_000);
|
||||
Check.Eq(b.Published, (long?)160_000, "earned after it counts");
|
||||
// R-20261125-230220-95f8: earned luminance goes straight into the bank, so a deposit all is a reading
|
||||
// (a meta's "/b d" counted everything earned since the last reading as moved in: Lum/hr 6.6m vs 71m).
|
||||
b.OnChatLine("[BANK] Deposited all. Pyreals: 1,000 | Luminance: 230,000 | Keys: 1 | Promissory Notes: 0", t + 140_000);
|
||||
Check.Eq(b.MovedIn, 70_000L, "deposit all: what the bank gained since the reading moved in");
|
||||
Check.Eq(b.Published, (long?)160_000, "deposit all isn't earned");
|
||||
Check.Eq(b.MovedIn, 20_000L, "deposit all moves nothing it can name");
|
||||
Check.Eq(b.Published, (long?)210_000, "what the bank gained before it counts as earned");
|
||||
b.OnChatLine("[BANK] Luminance: 30,000", t + 200_000);
|
||||
Check.Eq(b.Published, (long?)0, "spending from the bank is a drop (readers don't count drops), never below 0");
|
||||
Check.Eq(b.Published, (long?)10_000, "spending from the bank is a drop (readers don't count drops), never below 0");
|
||||
b.OnChatLine("[BANK] Luminance: 35,000", t + 260_000);
|
||||
Check.Eq(b.Published, (long?)5_000, "and what comes after it counts");
|
||||
Check.Eq(b.Published, (long?)15_000, "and what comes after it counts");
|
||||
}
|
||||
|
||||
private static void Pasted()
|
||||
|
|
|
|||
|
|
@ -24,6 +24,7 @@ internal static class Program
|
|||
DreamWeaveTests.Register(runner);
|
||||
DreamWeaveBoardsTests.Register(runner);
|
||||
DreamWeaveXpBonusTests.Register(runner);
|
||||
DreamWeaveAbilitiesTests.Register(runner);
|
||||
ServerWebOpenTests.Register(runner);
|
||||
ServerWebPanelTests.Register(runner);
|
||||
DreamWeaveWebTests.Register(runner);
|
||||
|
|
|
|||
|
|
@ -59,6 +59,9 @@
|
|||
<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" />
|
||||
<!-- RynthDreamWeave's class ability point calculator: the price curves, the /abilities points reader (pure part). -->
|
||||
<Compile Include="..\..\Plugins\RynthCore.Plugin.RynthDreamWeave\DreamWeave\AbilityPointPrices.cs" Link="DreamWeave\AbilityPointPrices.cs" />
|
||||
<Compile Include="..\..\Plugins\RynthCore.Plugin.RynthDreamWeave\DreamWeave\DreamWeaveAbilityPoints.cs" Link="DreamWeave\DreamWeaveAbilityPoints.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" />
|
||||
|
|
|
|||
Loading…
Reference in a new issue