RynthSuite as of 2026-11-29 (internal 46bae49): release 2026.11.28.1

This commit is contained in:
Tom Bohar 2026-11-29 00:38:53 -05:00
commit 598f49c899
131 changed files with 11825 additions and 329 deletions

View file

@ -0,0 +1,155 @@
using System;
using System.Text;
using RynthCore.Plugin.RynthOracle;
using RynthCore.Plugin.RynthOracle.Data;
using RynthCore.Plugin.RynthOracle.Ui;
using RynthCore.Plugin.RynthOracle.Views;
using RynthCore.Plugin.Shared;
namespace RynthOracle.Tests
{
/// <summary>
/// The Guide tab (2026-11-27): the lists (All / Story / Dailies / Weekly, Kill Tasks, Society, Contracts), the four
/// states, kill counts from /myquests and chat, "first time / done before", the server plugin's guide over the
/// wiki's, and every page through the engine's parser. The guide is the made-up one of QuestGuideTests.
/// </summary>
internal static partial class Program
{
private static unsafe void GuideTab()
{
OracleContext c = Context();
long now = DateTimeOffset.UtcNow.ToUnixTimeSeconds();
c.Flags.OnChatLine($"TestErrandStarted - 1 solves ({now - 3600})\"Started\" -1 72000", 1000);
c.Flags.OnChatLine($"KillTaskSampleBeasts_0101 - 12 solves ({now - 600})\"Beasts\" 50 0", 1000);
c.Flags.OnChatLine($"KillTaskOtherThings_0202 - 3 solves ({now - 600})\"Others\" 10 0", 1000);
c.Flags.Tick(6000);
c.UtcNow = DateTime.UtcNow;
c.Wiki.Use(SampleGuide());
GuideProgress p = c.Progress;
// ── The four states ──
QuestGuide g = c.Wiki.Guide;
GuideQuest daily = g.Find("Test Daily Errand")!;
GuideProgress.Row r = p.RowOf(daily, c.UtcNow);
Check(r.State == GuideState.PartWaiting && r.Held == 1 && r.All == 3 && r.Status.StartsWith("1/3 wait ") && r.Tip.Contains("2 still to get"),
$"one stamp of three held, its timer running: part done, waiting ({r.Status})");
Check(p.StateOf(daily, "TestErrandStarted", c.UtcNow) == StampState.Done && p.StateOf(daily, "TestErrandFang", c.UtcNow) == StampState.Missing,
"a held stamp inside its timer counts; a missing one doesn't");
Check(p.StateOf(daily, "testerrandstarted", c.UtcNow) == StampState.Done, "a stamp matches its flag by any spelling");
Check(p.StateOf(daily, "TestErrandStarted", c.UtcNow.AddDays(1)) == StampState.Earlier, "after its timer it was done on an earlier run");
Check(p.RowOf(daily, c.UtcNow.AddDays(1)).State == GuideState.PartReady, "the timer up: part done, ready");
Check(c.OnGuideChatLine("You've stamped TestErrandFang!", c.UtcNow) && c.SessionStamps.Contains("testerrandfang"), "a stamp line in chat is held at once");
Check(p.RowOf(daily, c.UtcNow).Held == 2, "two of three held now");
c.OnGuideChatLine("You've stamped TestErrandDone!", c.UtcNow);
GuideProgress.Row full = p.RowOf(daily, c.UtcNow);
Check(full.State == GuideState.Done && full.HideWhenDone && full.Status.StartsWith("Done "), "every stamp held, its timer running: done, hidden by Hide done");
GuideQuest story = g.Find("Test Story Quest")!;
Check(p.RowOf(story, c.UtcNow).Status == "no stamps" && p.RowOf(story, c.UtcNow, flagDone: true).State == GuideState.Done
&& p.RowOf(story, c.UtcNow, flagDone: false).State == GuideState.NotDone, "a quest without stamps: the quest list's flag, else unknown");
Check(GuideProgress.RepeatText(daily).StartsWith("Daily (every 20h") && GuideProgress.RepeatText(story) == "One-time", "the timer text");
// ── Kill tasks ──
GuideQuest kt = g.Find("Sample Beast Kill Task")!;
GuideProgress.Kill k = p.KillOf(kt, c.UtcNow);
Check(k.State == KillState.Counting && k.Kills == 12 && k.Goal == 50 && string.Equals(k.Counter?.Key, "KillTaskSampleBeasts_0101", StringComparison.OrdinalIgnoreCase) && !k.DoneBefore,
$"a kill task counting from its /myquests counter, the first time ({k.Status})");
Check(c.OnGuideChatLine("You have killed 13 Sample Beasts! You must kill 50 to complete your task.", DateTime.UtcNow.AddSeconds(5)), "a kill line is taken");
k = p.KillOf(kt, c.UtcNow);
Check(k.Kills == 13 && k.FromChat && k.Status == "13 / 50", "the kill line moves the count at once");
c.OnGuideChatLine("You have killed 50 Sample Beasts! You must kill 50 to complete your task.", DateTime.UtcNow.AddSeconds(6));
Check(p.KillOf(kt, c.UtcNow).State == KillState.TurnIn, "all kills made: turn in");
Check(GuideProgress.FlagLabel("KillTaskOtherThings_0202") == "Kill Task Other Things 0202", "a counter flag's label");
Check(!c.OnGuideChatLine("You have killed a Sample Beast.", c.UtcNow), "an ordinary kill line isn't a kill task's");
// ── The page ──
var view = new OracleView(c);
var host = new UiHost();
UiWindow main = host.Add(new UiWindow("RynthOracle/Oracle", "Oracle") { Visible = true, DefaultWidth = 760, DefaultHeight = 600 });
string Draw(string what)
{
main.Begin(); view.Draw(main); main.End();
ParseAll(host, what, out int ops);
Check(ops > 5 && ops < 1400, $"{what}: {ops} ops");
string body = Encoding.UTF8.GetString(main.Body);
main.MarkSubmitted(true);
return body;
}
Check(Array.IndexOf(view.VisibleTabs(), OracleView.TabGuide) == 1, "the Guide tab is the second tab");
view.ShowGuide(GuideList.All);
string all = Draw("Guide: All");
Check(all.Contains("Test Daily Errand") && all.Contains("Test Story Quest") && all.Contains("AC Community Wiki feed: off"),
"All lists the guide's quests and says the feed is off");
view.ShowGuide(GuideList.Dailies, "w:Test Daily Errand");
string opened = Draw("Guide: a quest opened");
Check(opened.Contains("Daily (every 20h") && opened.Contains("Go 12.3N, 45.6E") && opened.Contains("[x] stamped TestErrandStarted")
&& opened.Contains("Sample Fang") && opened.Contains("Wiki page") && !opened.Contains("Run this quest"),
"the opened quest: timer, Go buttons, ticked stamps, loot; no run controls in this version");
view.ShowGuide(GuideList.Story, "");
string storyPage = Draw("Guide: Story");
Check(storyPage.Contains("Test Story Quest") && !storyPage.Contains("Test Daily Errand"), "Story holds the one-time quests only");
view.ShowGuide(GuideList.KillTasks);
Check(view.KillTasksShowing, "the Kill Tasks list is on screen");
string kills = Draw("Guide: Kill Tasks");
Check(kills.Contains("Sample Beast Kill Task") && kills.Contains("Turn in") && kills.Contains("1st"), "a wiki kill task: turn in, first time");
Check(kills.Contains("Others") && kills.Contains("3 / 10"), "a counter no wiki task names is listed too");
Check(kills.Contains("Kill tasks: 0 counting, 1 to turn in"), "the summary line");
view.ShowGuide(GuideList.Society, "w:Test Story Quest");
string society = Draw("Guide: Society");
Check(society.Contains("Initiate: Test Story Quest") && society.Contains("Society: Initiate"), "society quests by rank");
view.ShowGuide(GuideList.Contracts, "c:Contract for Test Daily Errand");
string contracts = Draw("Guide: Contracts");
Check(contracts.Contains("Contract for Test Daily Errand") && contracts.Contains("Go to Sample Barkeep") && contracts.Contains("Open"),
"a contract: where it comes from (Go) and its quest (Open)");
// Open goes to the quest in All.
main.Begin(); view.Draw(main); main.End();
Apply(host, Event(1, 300, main.Hash, main.KeyOf("g.c.q.0"), new byte[] { 1, 0, 0 }));
string afterOpen = Draw("Guide: Open from a contract");
Check(afterOpen.Contains("Daily (every 20h") && afterOpen.Contains("[x] stamped"), "Open shows the contract's quest");
// Hide done leaves the finished daily out (every stamp held, its timer running).
c.Settings.GuideHideDone = true;
view.ShowGuide(GuideList.All, "");
string hidden = Draw("Guide: hide done");
Check(!hidden.Contains("Test Daily Errand") && hidden.Contains("Test Story Quest"), "Hide done leaves out the done daily");
c.Settings.GuideHideDone = false;
// ── A server plugin's guide comes first, over the wiki's quest of the same name ──
var serverGuide = new QuestGuide();
serverGuide.Quests.Add(new GuideQuest { Title = "Test Story Quest", Steps = { new GuideStep { Text = "The server's own way", Stamps = { "ServerStoryStamp" } } } });
serverGuide.Quests.Add(new GuideQuest { Title = "Server Only Quest", RepeatSec = 7 * 86400 });
ServerQuestGuideHost.ResetForTests();
var table = (RynthServerQuestGuideApiV1*)ServerQuestGuideHost.Query(1);
ServerQuestGuideHost.Publish("Test Server", "RynthTestServer", serverGuide, "2 quests", running: false, RynthServerQuestGuide.CommandRefresh);
c.ServerGuide.Use(table, "RynthTestServer");
GuideSet set = view.GuideSources();
Check(set.Quests.Count == 4 && set.Find("Test Story Quest")!.Steps.Count == 1 && set.FromServer(set.Find("Server Only Quest")!)
&& !set.FromServer(set.Find("Test Daily Errand")!), "merged: the server's quests first and over the wiki's of the same name");
Check(set.SocietyRankOf(set.Find("Test Story Quest")!) == "Initiate", "the wiki's society rank still applies");
view.ShowGuide(GuideList.Weekly, "w:Server Only Quest");
string weekly = Draw("Guide: a server quest");
Check(weekly.Contains("Test Server Wiki (RynthTestServer)") && weekly.Contains("Read it again") && weekly.Contains("From Test Server's guide"),
"the server guide's line, its command button and the quest's source");
ServerQuestGuideHost.Release();
c.ServerGuide.Use(table, "RynthTestServer");
Check(view.GuideSources().Quests.Count == 3, "the server's guide gone: the wiki's alone");
ServerQuestGuideHost.ResetForTests();
// ── No guide at all: the feed's controls, saying what it reads ──
OracleContext empty = Context();
var emptyView = new OracleView(empty);
UiWindow ew = new UiHost().Add(new UiWindow("RynthOracle/Oracle", "Oracle") { Visible = true });
empty.Settings.TabName = OracleView.TabGuide;
ew.Begin(); emptyView.Draw(ew); ew.End();
string none = Encoding.UTF8.GetString(ew.Body);
Check(none.Contains("No quest guide yet") && none.Contains("Turn the feed on and read it") && none.Contains("asheron.fandom.com/api.php"),
"no guide: the feed's button, and what it reads and from where");
// ── /ro guide ──
Check(OracleCommand.Parse("guide") is { Verb: OracleVerb.Tab, Tab: OracleView.TabGuide, Word: "" }
&& OracleCommand.Parse("killtasks") is { Tab: OracleView.TabGuide, Word: "killtasks" }
&& OracleCommand.Parse("guide society").Word == "society" && OracleCommand.Parse("contracts").Word == "contracts", "/ro guide words");
}
}
}

View file

@ -41,6 +41,8 @@ namespace RynthOracle.Tests
{
// Tab clicks save the settings: into a scratch file, never the player's %APPDATA% copy.
OracleSettings.PathOverride = System.IO.Path.Combine(System.IO.Path.GetTempPath(), "RynthOracleTests-" + Guid.NewGuid().ToString("N") + "-settings.json");
// The wiki feed's saved guide: a scratch path too (none there, so the feed starts empty).
CommunityWikiFeed.PathOverride = System.IO.Path.Combine(System.IO.Path.GetTempPath(), "RynthOracleTests-" + Guid.NewGuid().ToString("N") + "-guide.json");
Lists();
QuestLines();
Catalog();
@ -68,6 +70,10 @@ namespace RynthOracle.Tests
ServerMove();
Replies();
ReadyEarly();
QuestListDaily();
QuestGuideInterface();
WikiFeed();
GuideTab();
Console.WriteLine($"{_pass} passed, {_fail} failed");
return _fail == 0 ? 0 : 1;
}

View file

@ -0,0 +1,101 @@
using System;
using System.Collections.Generic;
using System.Text;
using RynthCore.Plugin.Shared;
namespace RynthOracle.Tests
{
/// <summary>
/// The quest guide (2026-11-27; SilentKelpie's PR 12 idea, re-implemented): the "RynthServer.QuestGuide"
/// interface a server plugin serves its guide through, the guide's JSON, and RynthOracle's reader of it.
/// The server side runs in-process (ServerQuestGuideHost's table, as a server plugin would hand it out).
/// </summary>
internal static partial class Program
{
/// <summary>A small guide in the shared format: two quests (one with steps and stamps), a kill task, a contract.</summary>
internal static QuestGuide SampleGuide()
{
var g = new QuestGuide { Source = "test wiki", UpdatedUtc = new DateTime(2026, 11, 27, 12, 0, 0, DateTimeKind.Utc) };
g.Quests.Add(new GuideQuest
{
Title = "Test Daily Errand", Url = "https://wiki.example/Test_Daily_Errand", Rev = 11, Level = "50+", Repeat = "20 Hours",
RepeatSec = 20 * 3600, StartsWith = "Sample Questgiver", StartsAt = "Sampletown",
Steps =
{
new GuideStep { Text = "Talk to Sample Questgiver", Coords = { "12.3N, 45.6E" }, Stamps = { "TestErrandStarted" } },
new GuideStep { Text = "Kill the Sample Beast and loot its Sample Fang", Items = { "Sample Fang" }, Stamps = { "TestErrandFang" } },
new GuideStep { Text = "Hand the fang in", Stamps = { "TestErrandDone" } },
},
Loot = { "Sample Fang" }, Rewards = { "Luminance: 1,000" },
});
g.Quests.Add(new GuideQuest { Title = "Test Story Quest", Overview = "A one-time quest." });
g.Quests.Add(new GuideQuest
{
Title = "Sample Beast Kill Task", KillTask = "Yes", RepeatSec = 20 * 3600, Repeat = "20 hours",
Steps = { new GuideStep { Text = "Kill 50 Sample Beasts", Stamps = { "KillTaskSampleBeasts_0101 on first completion" } } },
});
g.KillTasks.Add("Sample Beast Kill Task");
g.Society["Test Story Quest"] = "Initiate";
g.Contracts.Add(new GuideContract { Title = "Contract for Test Daily Errand", Name = "Contract for Test Daily Errand", Npc = "Sample Barkeep", Quests = { "Test Daily Errand" } });
return g;
}
private static unsafe void QuestGuideInterface()
{
// The guide's JSON round trip, stamps cut to their flags on the way in.
QuestGuide g = SampleGuide();
QuestGuide back = QuestGuide.Parse(g.ToJson());
Check(back.Quests.Count == 3 && back.Contracts.Count == 1 && back.KillTasks.Count == 1, "the guide reads back: quests, kill tasks, contracts");
GuideQuest? daily = back.Find("test daily errand");
Check(daily != null && daily.Steps.Count == 3 && daily.Steps[0].Coords[0] == "12.3N, 45.6E" && daily.RepeatSec == 72000 && daily.IsDaily,
"a quest's steps, coordinates and timer read back");
Check(back.Find("Sample Beast Kill Task")!.Steps[0].Stamps[0] == "KillTaskSampleBeasts_0101", "a stamp with words after it is cut to the flag");
Check(back.IsKillTask(back.Find("Sample Beast Kill Task")!) && !back.IsKillTask(daily!), "kill tasks by the summary box and the list");
Check(back.SocietyRankOf(back.Find("Test Story Quest")!) == "Initiate", "society rank from the guide's society list");
Check(QuestGuide.Parse("not json").IsEmpty && QuestGuide.Parse("{\"schema\":9,\"quests\":[{\"title\":\"x\"}]}").IsEmpty,
"junk or another schema is an empty guide");
Check(GuideStamp.Clean("You've stamped TestErrandFang!") == "TestErrandFang" && GuideStamp.Clean("Shiny Red Stone") == "Shiny Red Stone",
"a chat line's stamp, and a stamp of plain words left whole");
Check(GuideStamp.Key("Shiny_Red_Stone") == GuideStamp.Key("shiny red stone"), "stamp names compare alike");
// A server plugin serves it; the reader takes it through the table.
ServerQuestGuideHost.ResetForTests();
var table = (RynthServerQuestGuideApiV1*)ServerQuestGuideHost.Query(1);
Check(table != null && table->Version == 1 && ServerQuestGuideHost.Query(2) == IntPtr.Zero, "the table answers version 1 only");
var client = new ServerQuestGuideClient();
client.Use(table, "RynthTestServer");
Check(!client.Available && client.Guide.IsEmpty, "nothing published: no guide");
ServerQuestGuideHost.Publish("Test Server", "RynthTestServer", null, "reading the wiki...", running: true, RynthServerQuestGuide.CommandRefresh);
client.Use(table, "RynthTestServer");
Check(client.Available && client.Guide.IsEmpty && client.Info!.Running && client.Info.Status == "reading the wiki...",
"a guide still being read: its status, no quests");
ServerQuestGuideHost.Publish("Test Server", "RynthTestServer", g, "3 quests", running: false, RynthServerQuestGuide.CommandRefresh, RynthServerQuestGuide.CommandSettings);
int rev = client.Revision;
client.Use(table, "RynthTestServer");
Check(client.Guide.Quests.Count == 3 && client.Tag == "Test Server" && client.Revision != rev, "the published guide is read");
rev = client.Revision;
client.Use(table, "RynthTestServer");
Check(client.Revision == rev, "unchanged info: nothing read again");
Check(client.Command("refresh") && ServerQuestGuideHost.TryTakeCommand(out string word) && word == "refresh", "a command goes to the plugin's queue");
Check(!client.Command("delete-everything") && !ServerQuestGuideHost.TryTakeCommand(out _), "a word the plugin doesn't list isn't sent");
// A name outside ASCII survives the info JSON's escaping.
ServerQuestGuideHost.Publish("Café \"Q\"", "RynthTestServer", g, "ok", running: false);
client.Use(table, "RynthTestServer");
Check(client.Tag == "Café \"Q\"" && !client.Info!.Takes("refresh"), "the tag's escaping, and no commands listed");
ServerQuestGuideHost.Release();
Check(table->Version == 0, "shutdown: the table says so");
client.Use(table, "RynthTestServer");
Check(!client.Available && client.Guide.IsEmpty, "a shut-down plugin's guide goes away");
ServerQuestGuideHost.ResetForTests();
Check(ServerQuestGuideInfo.Parse("{\"schema\":1,\"bytes\":-5,\"commands\":[\"Refresh\",3]}") is { Bytes: 0 } i && i.Takes("refresh"),
"the info is read leniently");
Check(ServerQuestGuideInfo.Parse("{\"schema\":2}") == null && ServerQuestGuideInfo.Parse("[]") == null, "another schema, or junk, is no info");
}
}
}

View file

@ -0,0 +1,20 @@
using System;
using RynthCore.Plugin.RynthOracle.Data;
namespace RynthOracle.Tests
{
// "Check once a day for a newer quest list" ran once per login: a client that stayed logged in for
// days never checked again. It is due a day after the last check started, however long the session.
internal static partial class Program
{
private static void QuestListDaily()
{
DateTime last = new DateTime(2026, 11, 20, 9, 0, 0, DateTimeKind.Utc);
Check(QuestCatalogUpdater.Due(last.AddDays(1), last), "quest list: due a day after the last check");
Check(!QuestCatalogUpdater.Due(last.AddHours(23), last), "quest list: not due within the day");
Check(QuestCatalogUpdater.Due(last.AddDays(3), last), "quest list: still due days later in the same session");
Check(QuestCatalogUpdater.Due(last, DateTime.MinValue), "quest list: never checked: due");
Check(!new QuestCatalogUpdater().Running, "quest list: a new updater isn't running");
}
}
}

View file

@ -25,6 +25,10 @@ namespace RynthOracle.Tests
("progress", OracleVerb.Tab, OracleView.TabProgress), ("progression", OracleVerb.Tab, OracleView.TabProgress),
("status", OracleVerb.Status, ""), ("about", OracleVerb.About, OracleView.TabAbout), ("help", OracleVerb.Help, ""), ("?", OracleVerb.Help, ""),
("STATUS", OracleVerb.Status, ""), ("questz", OracleVerb.Unknown, ""), ("dynamic", OracleVerb.Unknown, ""),
("wiki", OracleVerb.Wiki, ""), ("wiki on", OracleVerb.Wiki, ""), ("wiki off", OracleVerb.Wiki, ""), ("wiki read", OracleVerb.Wiki, ""),
("wiki status", OracleVerb.Wiki, ""), ("wiki delete", OracleVerb.Unknown, ""),
("guide", OracleVerb.Tab, OracleView.TabGuide), ("killtasks", OracleVerb.Tab, OracleView.TabGuide), ("kill tasks", OracleVerb.Tab, OracleView.TabGuide),
("guide society", OracleVerb.Tab, OracleView.TabGuide), ("contracts", OracleVerb.Tab, OracleView.TabGuide),
};
var seen = new HashSet<OracleVerb>();
foreach (var (typed, verb, tab) in words)

View file

@ -38,6 +38,12 @@
<!-- "RynthServer.QuestPack": the active server plugin's quest pack (as in the plugin's csproj). -->
<Compile Include="..\..\Plugins\Shared\RynthServerQuestPackApi.cs" Link="RynthOracle\Shared\RynthServerQuestPackApi.cs" />
<Compile Include="..\..\Plugins\Shared\ServerQuestPackClient.cs" Link="RynthOracle\Shared\ServerQuestPackClient.cs" />
<!-- "RynthServer.QuestGuide": the reader (as in the plugin's csproj) and a server plugin's side (the tests serve a guide). -->
<Compile Include="..\..\Plugins\Shared\RynthServerQuestGuideApi.cs" Link="RynthOracle\Shared\RynthServerQuestGuideApi.cs" />
<Compile Include="..\..\Plugins\Shared\QuestGuideData.cs" Link="RynthOracle\Shared\QuestGuideData.cs" />
<Compile Include="..\..\Plugins\Shared\ServerQuestGuideClient.cs" Link="RynthOracle\Shared\ServerQuestGuideClient.cs" />
<Compile Include="..\..\Plugins\Shared\ServerQuestGuideHost.cs" Link="RynthOracle\Shared\ServerQuestGuideHost.cs" />
<Compile Include="..\..\Plugins\Shared\QuestWikiText.cs" Link="RynthOracle\Shared\QuestWikiText.cs" />
<Compile Include="..\..\Plugins\Shared\CommandReply.cs" Link="RynthOracle\Shared\CommandReply.cs" />
<Compile Include="..\..\..\RynthCore\src\RynthCore.Engine\UI\ScriptWindows\DisplayListParser.cs" Link="Engine\DisplayListParser.cs" />
</ItemGroup>

View file

@ -46,7 +46,7 @@ namespace RynthOracle.Tests
{
c.Server.Force(tag, world);
string[] tabs = view.VisibleTabs();
Check(Array.IndexOf(tabs, "Pet Breeding") < 0 && tabs.Length == 11, $"ilt: {world}: the same eleven tabs: " + string.Join(",", tabs));
Check(Array.IndexOf(tabs, "Pet Breeding") < 0 && tabs.Length == 12, $"ilt: {world}: the same twelve tabs: " + string.Join(",", tabs));
}
}

View file

@ -0,0 +1,153 @@
using System;
using System.Collections.Generic;
using RynthCore.Plugin.RynthOracle;
using RynthCore.Plugin.RynthOracle.Data;
using RynthCore.Plugin.Shared;
namespace RynthOracle.Tests
{
/// <summary>
/// The wiki page reader (Plugins/Shared/QuestWikiText.cs) and the AC Community Wiki feed's pure parts
/// (2026-11-27). The pages here are made up in the wiki's template style; no wiki text is copied in.
/// The feed is off by default and never fetches in these tests.
/// </summary>
internal static partial class Program
{
private const string TestWiki = "https://wiki.example/wiki/";
/// <summary>A made-up quest page: summary box, overview, numbered steps with stamps and items, a stamp listed apart, rewards.</summary>
internal const string SampleQuestPage = @"{{Quest Summary
| Level = 50+
| Recommended Level = 80+
| Quest Type = Solo
| Starts With = [[Sample Questgiver]]
| Starts At = [[Sampletown]]
| Repeat Timer = 20 Hours
}}
<!-- an editor's note that isn't shown -->
== Overview ==
Sample Questgiver wants a '''fang''' from the [[Sample Beast|beast]] in the hills.<ref>a footnote</ref>
== Walkthrough ==
# Talk to [[Sample Questgiver]] in Sampletown (12.3N, 45.6E).
#* {{stamped|TestErrandStarted}}
# Travel to the hills at 20.1s 30.2w and kill the Sample Beast to loot a {{Itemlink|Sample Fang}}.
#* It hits hard.
# Hand the {{Itemlink|Sample Fang}} to [[Sample Questgiver]].
== QB Stamps ==
{{stamped|TestErrandFang}} {{stamped|TestErrandDone on first completion}}
== Rewards ==
{{Rewards Table
| Quest Task = Hand in the fang
| Item Reward = * {{Itemlink|Sample Trinket}} (x2)
| XP Reward = 1,000,000
}}
[[Category:Quests]]
[[Category:Sample Quests]]";
private const string SampleKillPage = @"{{Quest Summary | Level = 30+ | Kill Task = Yes | Repeat Timer = Non Repeatable | Starts With = [[Sample Hunter]] }}
== Walkthrough ==
* Kill 50 [[Sample Beast]]s for the hunter. {{stamped|KillTaskSampleBeasts_0101 on first completion}}
* Return to the hunter.";
private const string SampleContractPage = @"{{Intro | Related Quests = [[Test Daily Errand]], [[Test Story Quest|the story]] }}
{{Item | Name = Contract for Test Daily Errand | Description = Starts the errand again. | Recommended Level = 50 }}
== Notes ==
* Purchased from [[Sample Barkeep]] in the Sampletown inn.
[[Category:Contracts]]";
private static void WikiFeed()
{
// ── The page reader ──
Check(QuestWikiText.IsQuestPage(SampleQuestPage) && !QuestWikiText.IsQuestPage("just text"), "a quest page has the summary box");
GuideQuest q = QuestWikiText.ParseQuest("Test Daily Errand", SampleQuestPage, 77, TestWiki);
Check(q.Url == "https://wiki.example/wiki/Test_Daily_Errand" && q.Rev == 77, "the page's address and revision: " + q.Url);
Check(q.Level == "50+" && q.RecommendedLevel == "80+" && q.Type == "Solo" && q.StartsWith == "Sample Questgiver" && q.StartsAt == "Sampletown",
"the summary box: level, type, where it starts");
Check(q.RepeatSec == 20 * 3600 && q.IsDaily && !q.IsOneTime, "a 20 hour timer is a daily");
Check(q.Overview == "Sample Questgiver wants a fang from the beast in the hills.", "the overview, links and markup cleaned: " + q.Overview);
Check(q.Steps.Count == 3, $"three numbered steps ({q.Steps.Count})");
Check(q.Steps[0].Coords.Count == 1 && q.Steps[0].Coords[0] == "12.3N, 45.6E" && q.Steps[0].Stamps[0] == "TestErrandStarted",
"step 1: its coordinates and stamp");
Check(q.Steps[1].Coords[0] == "20.1S, 30.2W" && q.Steps[1].Notes.Count == 1 && q.Steps[1].Items[0] == "Sample Fang",
"step 2: lower-case coordinates, its tip and its item");
Check(q.Steps[1].Stamps.Contains("TestErrandFang"), "a stamp listed apart goes with the step that names it");
Check(q.Steps[2].Stamps.Contains("TestErrandDone"), "the last stamp left goes to the last stampless step, cut to its flag");
Check(q.ExtraStamps.Count == 0 && q.AllStamps().Count == 3, "every stamp tied to a step");
Check(q.Loot.Count == 1 && q.Loot[0] == "Sample Fang", "loot: the item a kill step names, not the hand-in");
Check(q.Rewards.Count == 3 && q.Rewards[0] == "For Hand in the fang:" && q.Rewards[1] == "Sample Trinket (x2)" && q.Rewards[2] == "XP: 1,000,000",
"the rewards table: " + string.Join(" | ", q.Rewards));
Check(q.Categories.Contains("Sample Quests"), "the categories");
GuideQuest k = QuestWikiText.ParseQuest("Sample Beast Kill Task", SampleKillPage, 5, TestWiki);
Check(k.IsKillTaskPage && k.KillTarget == 50 && k.KillCreatureKey == "samplebeast", "a kill task: the box, the count, the creature");
Check(k.RepeatSec == 0 && k.IsOneTime, "\"Non Repeatable\" is one-time");
Check(k.Steps.Count == 2 && k.Steps[0].Stamps[0] == "KillTaskSampleBeasts_0101", "bullet steps, the counter stamp cut to its flag");
Check(QuestWikiText.IsContractPage("Contract for Test Daily Errand", SampleContractPage), "a contract page");
GuideContract c = QuestWikiText.ParseContract("Contract for Test Daily Errand", SampleContractPage, 9, TestWiki);
Check(c.Name == "Contract for Test Daily Errand" && c.Level == "50" && c.Description == "Starts the errand again.", "the contract's item box");
Check(c.Quests.Count == 2 && c.Quests[0] == "Test Daily Errand" && c.Quests[1] == "Test Story Quest", "the quests it is for");
Check(c.Npc == "Sample Barkeep" && c.Where.StartsWith("Purchased from Sample Barkeep"), "where it comes from: " + c.Where);
// Paragraph walkthroughs, repeat timers.
GuideQuest para = QuestWikiText.ParseQuest("P", "{{Quest Summary}}\n== Walkthrough ==\nFirst go here.\nStill the first.\n\nThen go there 1.0N 2.0E.", 0, TestWiki);
Check(para.Steps.Count == 2 && para.Steps[1].Coords[0] == "1.0N, 2.0E", "paragraphs are steps");
Check(QuestWikiText.RepeatSeconds("7 days") == 7 * 86400 && QuestWikiText.RepeatSeconds("3d 12h") == 3 * 86400 + 12 * 3600
&& QuestWikiText.RepeatSeconds("Weekly") == 7 * 86400 && QuestWikiText.RepeatSeconds("None") == 0
&& QuestWikiText.RepeatSeconds("whenever") == -1, "repeat timers");
Check(QuestWikiText.Clean("[[File:x.png|thumb|a [[link]]]] [[Foo|bar]] {{Itemlink|Baz}} &amp; <br/>end") == "bar Baz & end", "markup cleaned");
// ── The API's answers ──
var members = QuestWikiText.Members(
"{\"continue\":{\"cmcontinue\":\"page|X\",\"continue\":\"-||\"},\"query\":{\"categorymembers\":[{\"ns\":0,\"title\":\"A\"},{\"ns\":14,\"title\":\"Category:B\"},{\"ns\":6,\"title\":\"File:C\"}]}}",
"categorymembers");
Check(members.Pages.Count == 1 && members.Pages[0] == "A" && members.SubCats.Count == 1 && members.Continue.Count == 2,
"category members: pages, sub-categories, continue");
Dictionary<string, long> revs = QuestWikiText.LastRevisions("{\"query\":{\"pages\":[{\"title\":\"A\",\"lastrevid\":12},{\"title\":\"Gone\",\"missing\":true}]}}");
Check(revs.Count == 1 && revs["A"] == 12, "page revisions, missing pages left out");
var contents = QuestWikiText.Contents("{\"query\":{\"pages\":[{\"title\":\"A\",\"revisions\":[{\"revid\":12,\"slots\":{\"main\":{\"content\":\"hello\"}}}]}]}}");
Check(contents.Count == 1 && contents[0].Rev == 12 && contents[0].Text == "hello", "page contents");
Check(QuestWikiText.Members("not json", "x").Pages.Count == 0 && QuestWikiText.LastRevisions("[").Count == 0, "junk answers are empty");
var titles = new List<string>();
for (int i = 0; i < 120; i++) titles.Add("T" + i);
Check(QuestWikiText.Batches(titles).Count == 3, "titles in batches of 50");
string url = QuestWikiText.ApiUrl(CommunityWikiFeed.Api, ("action", "query"), ("titles", "A B|C&D"));
Check(url.StartsWith("https://asheron.fandom.com/api.php?format=json&formatversion=2&action=query&titles=A%20B%7CC%26D"), "the API address, values escaped: " + url);
// ── The feed's pure parts ──
Check(CommunityWikiFeed.RankOf("Category:Society Quests: Knight Rank") == "Knight" && CommunityWikiFeed.RankOf("Category:Joining a Society Quests") == "Joining"
&& CommunityWikiFeed.RankOf("Category:Other") == "", "society ranks from category names");
Check(CommunityWikiFeed.SkipCategory("Category:Quest Items") && CommunityWikiFeed.SkipCategory("Category:Quest NPCs")
&& !CommunityWikiFeed.SkipCategory("Category:Society Quests"), "item and NPC lists aren't followed");
var old = new QuestGuide { Reader = QuestWikiText.ReaderVersion, UpdatedUtc = DateTime.UtcNow.AddHours(-1) };
old.Quests.Add(new GuideQuest { Title = "Same", Rev = 1 });
old.Quests.Add(new GuideQuest { Title = "Edited", Rev = 1 });
old.Quests.Add(new GuideQuest { Title = "Dropped", Rev = 1 });
var listed = new Dictionary<string, long> { ["Same"] = 1, ["Edited"] = 2, ["New"] = 3 };
List<string> toRead = CommunityWikiFeed.PagesToRead(old, listed);
Check(toRead.Count == 2 && toRead.Contains("Edited") && toRead.Contains("New"), "only new and edited pages are read");
Check(CommunityWikiFeed.PagesToRead(new QuestGuide { Reader = 0, Quests = { new GuideQuest { Title = "Same", Rev = 1 } } }, new Dictionary<string, long> { ["Same"] = 1 }).Count == 1,
"a guide from an older reader is read again whole");
var fresh = new Dictionary<string, GuideQuest> { ["Edited"] = new GuideQuest { Title = "Edited", Rev = 2 }, ["New"] = new GuideQuest { Title = "New", Rev = 3 } };
QuestGuide merged = CommunityWikiFeed.Merge(old, listed, fresh, new Dictionary<string, GuideContract>(), DateTime.UtcNow);
Check(merged.Quests.Count == 3 && merged.Find("Edited")!.Rev == 2 && merged.Find("Same") != null && merged.Find("Dropped") == null
&& merged.Source == CommunityWikiFeed.Host, "the merge: fresh pages, kept pages, dropped pages gone");
Check(!CommunityWikiFeed.Due(old, DateTime.UtcNow) && CommunityWikiFeed.Due(old, DateTime.UtcNow.AddDays(1)) && CommunityWikiFeed.Due(new QuestGuide(), DateTime.UtcNow),
"read again once a day old (or when there is none)");
// ── Off by default; it says what it reads and from where ──
Check(!new OracleSettings().WikiFeedOn, "the feed is off by default");
var feed = new CommunityWikiFeed(System.IO.Path.Combine(System.IO.Path.GetTempPath(), "RynthOracleTests-" + Guid.NewGuid().ToString("N") + "-feed.json"));
Check(!feed.Start(on: false) && !feed.Running && !feed.LoginRead(on: false, daily: true, DateTime.UtcNow), "off: no read starts");
Check(CommunityWikiFeed.WhatItReads.Contains("https://asheron.fandom.com/api.php") && CommunityWikiFeed.WhatItReads.Contains("no login"),
"the disclosure names the address");
OracleContext ctx = Context();
ctx.Settings.WikiFeedOn = false;
var (readOk, readText) = ctx.ReadWikiNow();
Check(!readOk && readText.Contains("off") && readText.Contains("asheron.fandom.com/api.php") && !ctx.Wiki.Running, "Read now with the feed off fetches nothing and says why");
Check(ctx.SetWikiFeed(false).Text.Contains("already off"), "turning it off when off says so");
Check(OracleCommand.Parse("wiki on") is { Verb: OracleVerb.Wiki, Word: "on" } && OracleCommand.Parse("wiki") is { Verb: OracleVerb.Wiki, Word: "status" }
&& OracleCommand.Parse("wiki read") is { Verb: OracleVerb.Wiki, Word: "read" }, "/ro wiki words");
}
}
}