RynthSuite as of 2026-11-29 (internal 46bae49): release 2026.11.28.1
This commit is contained in:
parent
25552fa794
commit
598f49c899
131 changed files with 11825 additions and 329 deletions
155
Tools/RynthOracle.Tests/GuideTabTests.cs
Normal file
155
Tools/RynthOracle.Tests/GuideTabTests.cs
Normal 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");
|
||||
}
|
||||
}
|
||||
}
|
||||
Loading…
Reference in a new issue