RynthDreamWeave: web links in the bar icon's dropdown; card buttons only on older engines

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
Daniel Wallace 2026-11-07 20:12:39 -08:00
commit 1d7605db23
3 changed files with 97 additions and 0 deletions

View file

@ -3,6 +3,7 @@ using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Xml.Linq;
using RynthCore.Engine.UI.Sections;
using RynthCore.Plugin.RynthDreamWeave;
using RynthCore.Plugin.ServerPack;
using RynthCore.RynthAiTests.Harness;
@ -33,6 +34,61 @@ internal static class DreamWeaveWebTests
r.Add("dreamweave web: a malformed launch-code line never reaches chat", MalformedSuccess);
r.Add("dreamweave web: the source scan's helpers read code, not comments or strings", ScanHelpers);
r.Add("dreamweave web: the plugin's shared hooks hand off to the web tools first", HooksHandOff);
r.Add("dreamweave web: the bar icon's menu lists the destinations, in the engine's own terms", BarMenuItems);
r.Add("dreamweave web: the engine draws the bar menu from API 94", EngineDrawsMenu);
r.Add("dreamweave web: the card hides its buttons only when the engine's version says it draws the menu", CardHidesButtonsOnNewEngines);
}
private static void BarMenuItems()
{
List<ServerBarMenuItem> items = DreamWeaveWeb.BarMenu();
string[][] want =
{
new[] { "market", "Market", ((char)0xE470).ToString(), "/rserver market" },
new[] { "suit", "Suit Builder", ((char)0xE40A).ToString(), "/rserver suit" },
new[] { "abilities", "Ability Planner", ((char)0xE6A2).ToString(), "/rserver abilities" },
};
Check.Eq(items.Count, want.Length, "one item per destination");
for (int i = 0; i < want.Length && i < items.Count; i++)
{
Check.Eq(items[i].Id, want[i][0], "id " + i);
Check.Eq(items[i].Tooltip, want[i][1], "tooltip " + i);
Check.Eq(items[i].Icon, want[i][2], "icon " + i);
Check.Eq(items[i].Command, want[i][3], "command " + i);
Check.Eq(SectionManifestParser.Command(items[i].Command), items[i].Command, "the engine keeps the command " + i);
Check.Eq(SectionManifestParser.Icon(items[i].Icon), items[i].Icon, "the engine keeps the icon " + i);
Check.True(DreamWeaveWeb.ById(items[i].Id) != null, "the command's verb is a destination: " + items[i].Id);
}
Check.True(items.Count <= SectionManifestParser.MaxBarMenuItems, "within the engine's cap");
// And through the manifest, as the engine reads it.
var info = new ServerPackInfo("dreamweave", "DreamWeave", new[] { "play.acdreamweave.com" }, Array.Empty<string>());
SectionManifest m = SectionManifestParser.Parse("RynthDreamWeave", ServerPackModel.BuildSectionsJson(info, "RynthDreamWeave", null, barMenu: items), out string error);
Check.Eq(error, string.Empty, "parses clean: " + error);
Check.Eq(m.Windows.Single().Menu.Length, 3, "the engine reads three items");
}
private static void EngineDrawsMenu()
{
Check.Eq(DreamWeaveWeb.BarMenuEngineApi, 94u, "the engine API that draws the bar menu");
Check.False(DreamWeaveWeb.EngineDrawsBarMenu(93), "93: the card keeps its buttons");
Check.True(DreamWeaveWeb.EngineDrawsBarMenu(94), "94: the engine draws the menu");
Check.True(DreamWeaveWeb.EngineDrawsBarMenu(95), "95: the engine draws the menu");
Check.False(DreamWeaveWeb.EngineDrawsBarMenu(0), "0: unknown version keeps the buttons");
}
private static void CardHidesButtonsOnNewEngines()
{
string hostPath = Path.Combine(ServerProjectsTests.PluginsDir(), "RynthCore.Plugin.RynthDreamWeave", "DreamWeaveWebTools.cs");
Check.True(File.Exists(hostPath), "DreamWeaveWebTools.cs exists");
if (!File.Exists(hostPath)) return;
string host = StripComments(File.ReadAllText(hostPath));
List<string> card = StatementsAfter(host, "partial void ServerCardActions()");
Check.Eq(card.Count, 1, "ServerCardActions implemented once");
Check.True(card.Count == 1 && card[0].Contains("EngineDrawsBarMenu(Host.Version)", StringComparison.Ordinal),
"ServerCardActions asks the running engine's version (Host.Version)");
Check.False(host.Contains("CurrentApiVersion", StringComparison.Ordinal), "the plugin never reads the compile-time CurrentApiVersion");
Check.True(host.Contains("DreamWeaveWeb.BarMenu()", StringComparison.Ordinal), "ServerBarMenu supplies DreamWeaveWeb.BarMenu()");
}
// -- Host wiring (source scan: the plugin is NativeAOT, so its host code can't run here) --