diff --git a/Plugins/RynthCore.Plugin.RynthAelrynth/AelrynthPlugin.cs b/Plugins/RynthCore.Plugin.RynthAelrynth/AelrynthPlugin.cs index c824cd3..cbf9d83 100644 --- a/Plugins/RynthCore.Plugin.RynthAelrynth/AelrynthPlugin.cs +++ b/Plugins/RynthCore.Plugin.RynthAelrynth/AelrynthPlugin.cs @@ -119,7 +119,7 @@ public sealed partial class ServerPackPlugin if (parts.Length < 2 || !parts[1].Equals("vault", StringComparison.OrdinalIgnoreCase)) return; handled = true; string tag = $"[{RynthPluginInfo.Name}] "; - if (!Active) { ChatLine(tag + "The account vault is Aelrynth's; RynthCore doesn't see this world as Aelrynth."); return; } + if (!Active) { ChatFail(tag + "The account vault is Aelrynth's; RynthCore doesn't see this world as Aelrynth."); return; } bool asked; string state; lock (_aelrynth.Gate) diff --git a/Plugins/RynthCore.Plugin.RynthILT/Hub/IltAttributeRaiser.cs b/Plugins/RynthCore.Plugin.RynthILT/Hub/IltAttributeRaiser.cs index 23ac250..b2fb0bc 100644 --- a/Plugins/RynthCore.Plugin.RynthILT/Hub/IltAttributeRaiser.cs +++ b/Plugins/RynthCore.Plugin.RynthILT/Hub/IltAttributeRaiser.cs @@ -108,6 +108,9 @@ internal sealed class IltAttributeRaiser public bool Running => _phase != Phase.Idle; + /// What the raiser is doing or why it can't (the Progression tab's status line; "/ra hub attr" says it). + public string Status => _status; + // ── Order / selection helpers (also used by IltHubStore.Normalize) ───────── public static Stat? Find(string keyOrName) diff --git a/Plugins/RynthCore.Plugin.RynthILT/Hub/IltBanking.cs b/Plugins/RynthCore.Plugin.RynthILT/Hub/IltBanking.cs index 04ec369..75de08b 100644 --- a/Plugins/RynthCore.Plugin.RynthILT/Hub/IltBanking.cs +++ b/Plugins/RynthCore.Plugin.RynthILT/Hub/IltBanking.cs @@ -144,13 +144,17 @@ internal sealed class IltBanking : IIltFeature // ── Commands ──────────────────────────────────────────────────────────── - /// Queues a /bank balance refresh (eaten when ). - public void RequestRefresh(bool quiet) + /// + /// Queues a /bank balance refresh (eaten when ). Null when it went out, else + /// why not (for "/ra hub bank" to say; the buttons ignore it). + /// + public string? RequestRefresh(bool quiet) { RynthLog.Trace(LogCat.IltBanking, $"RequestRefresh(quiet={quiet})"); - if (_ctx.Capture.IsPending("/bank")) return; + if (_ctx.Capture.IsPending("/bank")) return "a /bank read is already waiting for the server's reply."; long now = IltHubContext.NowMs; - if (now - _lastBalanceAt < BalanceSpacingMs) return; + if (now - _lastBalanceAt < BalanceSpacingMs) + return $"the balance was read moments ago; try again in {Math.Max(1, (BalanceSpacingMs - (now - _lastBalanceAt) + 999) / 1000)}s."; _lastBalanceAt = now; _quietBalanceUntil = quiet ? now + QuietBalanceWindowMs : 0; _ctx.Capture.Enqueue(new IltChatRequest @@ -166,6 +170,7 @@ internal sealed class IltBanking : IIltFeature else if (r.Lines.Count > 0) _ctx.Options.Set(IltFeature.Bank, IltTri.On); }, }); + return null; } /// diff --git a/Plugins/RynthCore.Plugin.RynthILT/Hub/IltChunkClap.cs b/Plugins/RynthCore.Plugin.RynthILT/Hub/IltChunkClap.cs index c3190ca..b7c17b2 100644 --- a/Plugins/RynthCore.Plugin.RynthILT/Hub/IltChunkClap.cs +++ b/Plugins/RynthCore.Plugin.RynthILT/Hub/IltChunkClap.cs @@ -472,13 +472,16 @@ internal sealed class IltChunkClap : IIltFeature .Select(wo => ClapPartOf(inv.Wcid(wo), wo.Name, inv.Int(wo, IltInventory.IntItemMaxLevel)))); } - /// Sends "/clap all" through the capture queue (reply stays visible). - public void ClapNow(bool manual) + /// + /// Sends "/clap all" through the capture queue (reply stays visible). Null when it went out, else + /// why not (for "/ra hub clap" to say; the button and the auto clap ignore it). + /// + public string? ClapNow(bool manual) { RynthLog.Trace(LogCat.IltGear, $"ClapNow(manual={manual})"); - if (_ctx.Options.IsOff(IltFeature.Clap)) { _clapStatus = "/clap is not available (server or AutoCraftingEnabled stamp)"; return; } - if (_ctx.Capture.IsPending("/clap all")) return; - if (!manual && !HasClapMaterials()) { _clapStatus = "no aetheria and trinket pair carried (red + Empyrean, blue + Falatacot)"; return; } + if (_ctx.Options.IsOff(IltFeature.Clap)) { _clapStatus = "/clap is not available (server or AutoCraftingEnabled stamp)"; return _clapStatus + "."; } + if (_ctx.Capture.IsPending("/clap all")) return "one is already waiting for the server's reply."; + if (!manual && !HasClapMaterials()) { _clapStatus = "no aetheria and trinket pair carried (red + Empyrean, blue + Falatacot)"; return _clapStatus + "."; } _clapStatus = "sending /clap all..."; _ctx.Capture.Enqueue(new IltChatRequest { @@ -497,6 +500,7 @@ internal sealed class IltChunkClap : IIltFeature if (r.Lines.Any(l => l.StartsWith("Deposited ", StringComparison.Ordinal))) _ctx.Options.Set(IltFeature.Clap, IltTri.On); }, }); + return null; } private void TickClap(long now) diff --git a/Plugins/RynthCore.Plugin.RynthILT/Hub/IltHubContext.cs b/Plugins/RynthCore.Plugin.RynthILT/Hub/IltHubContext.cs index ced863c..876f3da 100644 --- a/Plugins/RynthCore.Plugin.RynthILT/Hub/IltHubContext.cs +++ b/Plugins/RynthCore.Plugin.RynthILT/Hub/IltHubContext.cs @@ -9,6 +9,7 @@ // player first (the confirmed action is then posted). using System; using System.Collections.Concurrent; +using RynthCore.Plugin.Shared; using RynthCore.PluginSdk; namespace RynthCore.Plugin.RynthILT.Hub; @@ -29,9 +30,13 @@ internal sealed class IltHubContext private readonly ConcurrentQueue _confirms = new(); public IltHubContext(RynthCoreHost host, IltHubState state, IltHubStore store, IltChatCapture capture, - IltServerOptions options, IltInventory inventory, IltSettings settings, RynthAiClient ai) + IltServerOptions options, IltInventory inventory, IltSettings settings, RynthAiClient ai, + CommandReply? reply = null) { Host = host; + // The plugin's queue (it writes the waiting lines on its tick); a Hub on its own (the tests) keeps one. + OwnsReply = reply == null; + Reply = reply ?? NewReply(host); State = state; Store = store; Capture = capture; @@ -69,11 +74,26 @@ internal sealed class IltHubContext /// public Action? ShowTab; + /// + /// Where the Hub's chat lines go: RynthSuite's shared reply queue (Plugins/Shared/CommandReply.cs). + /// The host drops a line within 100 ms of another plugin's, so the second and later lines of an + /// answer (the help, /ra hub status) used to go missing; a refused line waits and is offered again. + /// No tag of its own: every Hub line brings its own ("[Mini Remote]", "[ILT Guardian]", ...). + /// + public CommandReply Reply { get; } + + /// True when this Hub made itself (no plugin around it): its tick flushes it. + public bool OwnsReply { get; } + + /// A reply queue writing to 's chat (the plugin's, and a Hub's own). + public static CommandReply NewReply(RynthCoreHost host) => + new(string.Empty, (t, c) => host.HasWriteToChat && host.WriteToChat(t, c), t => host.Log(t)); + /// Writes a local chat line (never sent to the server). - public void Chat(string text) - { - if (Host.HasWriteToChat) Host.WriteToChat(text, 1); - } + public void Chat(string text) => Reply.Ok(text); + + /// A local chat line saying a command didn't work: why, and the usage (the failure colour). + public void ChatFail(string text) => Reply.Fail(text); /// Queues work for the next pump tick (safe from the render thread). public void Post(Action action) => _posted.Enqueue(action); diff --git a/Plugins/RynthCore.Plugin.RynthILT/Hub/IltHubController.cs b/Plugins/RynthCore.Plugin.RynthILT/Hub/IltHubController.cs index afd4bfe..90c13c1 100644 --- a/Plugins/RynthCore.Plugin.RynthILT/Hub/IltHubController.cs +++ b/Plugins/RynthCore.Plugin.RynthILT/Hub/IltHubController.cs @@ -88,7 +88,8 @@ internal sealed class IltHubController /// True while this character's copy from RynthAi is unfinished (IltHubStore.WritesBlocked). /// The character's RynthAi folder while that copy is unfinished (read-only fallback). public IltHubController(RynthCoreHost host, string charFolder, IltSettings settings, RynthAiClient ai, - Func? writesBlocked = null, string? legacyFolder = null) + Func? writesBlocked = null, string? legacyFolder = null, + RynthCore.Plugin.Shared.CommandReply? reply = null) { var store = new IltHubStore(host, charFolder); if (writesBlocked != null) store.WritesBlocked = writesBlocked; @@ -98,7 +99,7 @@ internal sealed class IltHubController var inventory = new IltInventory(host, new IltObjects(host)); IltHubContext? ctxRef = null; var options = new IltServerOptions(host, capture, state, text => ctxRef?.Chat(text), () => settings); - _ctx = new IltHubContext(host, state, store, capture, options, inventory, settings, ai); + _ctx = new IltHubContext(host, state, store, capture, options, inventory, settings, ai, reply); ctxRef = _ctx; Banking = new IltBanking(_ctx); @@ -373,6 +374,7 @@ internal sealed class IltHubController _forceRequest = -1; _ctx.State.ForceLeaftideFeatures = force == 1; } + if (_ctx.OwnsReply) _ctx.Reply.Flush(); _ctx.DrainPosted(); _ctx.Capture.Tick(); _ctx.Options.Tick(); @@ -594,6 +596,7 @@ internal sealed class IltHubController { // "rates reset": the coin / pyreal session starts over with RynthAi's session stats. Rates.Reset(); + _ctx.Chat("[Mini Remote] ILT session rates reset: coins and pyreals count from now."); return true; } if (IsBountyVerb(verb)) @@ -634,7 +637,7 @@ internal sealed class IltHubController { // Quests and Pets are RynthAi's tabs: not ours to open. if (args.Length >= 2 && IltSections.IsUniversalTabName(args[1])) return false; - _ctx.Chat("[Mini Remote] Usage: /ra hub open pets|banking|gear|charms|games|vaulted|guardian|bounties [show|hide|toggle] (character: /ro character, quests: /ro)"); + _ctx.ChatFail("[Mini Remote] Usage: /ra hub open pets|banking|gear|charms|games|vaulted|guardian|bounties [show|hide|toggle] (character: /ro character, quests: /ro)"); break; } OpenSection(section, args.Length > 2 ? args[2] : "toggle"); @@ -649,7 +652,13 @@ internal sealed class IltHubController return false; // the Remote tab or a RynthAi tab: RynthAi's break; case "refresh": _ctx.Options.Refresh(manual: true); break; - case "bank": Banking.RequestRefresh(quiet: false); break; + case "bank": + { + string? why = Banking.RequestRefresh(quiet: false); + if (why == null) _ctx.Chat("[Mini Remote] Reading the bank balance (/bank); the server's [BANK] lines follow."); + else _ctx.ChatFail("[Mini Remote] " + why); + break; + } // "/ilt qb": reads the /qb list again (the Quests tab's quest bonus section). case "qb": _ctx.Chat("[RynthILT] " + QuestBonus.RefreshQb()); break; case "status": PrintStatus(); break; @@ -663,7 +672,13 @@ internal sealed class IltHubController case "servers": HandleServers(rest); break; case "profile": HandleProfile(args.Skip(1).ToArray()); break; case "suit": HandleSuit(args.Skip(1).ToArray()); break; - case "clap": Gear.ChunkClap.ClapNow(manual: true); break; + case "clap": + { + string? why = Gear.ChunkClap.ClapNow(manual: true); + if (why == null) _ctx.Chat("[Mini Remote] Sending /clap all; the server's reply follows."); + else _ctx.ChatFail("[Mini Remote] /clap all: " + why); + break; + } case "attr": HandleAttr(args.Skip(1).ToArray()); break; case "confirm": RunPending(); break; case "cancel": @@ -705,7 +720,7 @@ internal sealed class IltHubController var list = arg.Equals("default", StringComparison.OrdinalIgnoreCase) ? new List(ServerFeatureGate.DefaultServerNames) : ServerFeatureGate.ParseList(arg); - if (list.Count == 0) { _ctx.Chat("[Mini Remote] Usage: /ra hub servers | default | list"); return; } + if (list.Count == 0) { _ctx.ChatFail("[Mini Remote] Usage: /ra hub servers | default | list"); return; } _ctx.Settings.ServerNames = list; _ctx.SaveSettings(); } @@ -718,15 +733,57 @@ internal sealed class IltHubController { var raiser = Progression.Attributes; string sub = a.Length > 0 ? a[0].ToLowerInvariant() : "status"; + const string usage = "[Mini Remote] Usage: /ra hub attr run|stop|costs|status|auto on|off|every |raise "; switch (sub) { - case "run": raiser.HandleRemote("attrrun", new[] { "attrrun" }); break; - case "stop": raiser.HandleRemote("attrstop", new[] { "attrstop" }); break; - case "costs": raiser.HandleRemote("attrcosts", new[] { "attrcosts" }); break; - case "auto": raiser.HandleRemote("attrauto", new[] { "attrauto", a.Length > 1 ? a[1] : "off" }); break; - case "every": raiser.HandleRemote("attrevery", new[] { "attrevery", a.Length > 1 ? a[1] : "5" }); break; - case "raise" when a.Length > 2: raiser.HandleRemote("attrraise", new[] { "attrraise", a[1], a[2] }); break; + case "run": + raiser.HandleRemote("attrrun", new[] { "attrrun" }); + _ctx.Chat("[Mini Remote] Attribute raiser: " + raiser.Status); + break; + case "stop": + { + bool was = raiser.Running; + raiser.HandleRemote("attrstop", new[] { "attrstop" }); + _ctx.Chat(was ? "[Mini Remote] Attribute raiser: " + raiser.Status : "[Mini Remote] Attribute raiser: nothing was running."); + break; + } + case "costs": + raiser.HandleRemote("attrcosts", new[] { "attrcosts" }); + _ctx.Chat(raiser.Running ? "[Mini Remote] Attribute raiser: a run is reading them already; " + raiser.Status + : "[Mini Remote] Attribute raiser: " + (raiser.Blocker() ?? "reading the XP costs (/xp all)...")); + break; + case "auto": + { + // As before: any word but "on" (or none) turns it off; a word that isn't on/off says so. + string word = a.Length > 1 ? a[1] : "off"; + raiser.HandleRemote("attrauto", new[] { "attrauto", word }); + var ch = _ctx.State.Character; + string now = $"[Mini Remote] Attribute auto-raise {(ch.AttrAutoRaise ? $"on, every {ch.AttrAutoRaiseMinutes} min" : "off")}"; + if (word.ToLowerInvariant() is "on" or "off") _ctx.Chat(now + "."); + else _ctx.ChatFail($"{now} ('{word}' isn't on). {usage}"); + break; + } + case "every": + { + // As before: no number means 5 minutes; a word that isn't a number changes nothing. + string word = a.Length > 1 ? a[1] : "5"; + raiser.HandleRemote("attrevery", new[] { "attrevery", word }); + var ch = _ctx.State.Character; + string now = $"[Mini Remote] Attribute auto-raise every {ch.AttrAutoRaiseMinutes} min ({(ch.AttrAutoRaise ? "on" : "off; /ra hub attr auto on")})"; + if (int.TryParse(word, out _)) _ctx.Chat(now + "."); + else _ctx.ChatFail($"{now}: '{word}' isn't a number of minutes. {usage}"); + break; + } + case "raise" when a.Length > 2: + if (IltAttributeRaiser.Find(a[1]) == null || !int.TryParse(a[2], out int levels) || levels <= 0) { _ctx.ChatFail(usage); break; } + raiser.HandleRemote("attrraise", new[] { "attrraise", a[1], a[2] }); + _ctx.Chat("[Mini Remote] Attribute raiser: " + raiser.Status); + break; + case "raise": + _ctx.ChatFail(usage); + break; default: + if (sub != "status") { _ctx.ChatFail(usage); return; } var c = _ctx.State.Character; string blocked = raiser.Blocker() ?? "ready"; _ctx.Chat($"[Mini Remote] Attribute raiser: {blocked}; auto={(c.AttrAutoRaise ? $"on every {c.AttrAutoRaiseMinutes}m" : "off")} " @@ -752,6 +809,7 @@ internal sealed class IltHubController { // Character left the Mini Remote: open its new home instead. if (!mode.Equals("hide", StringComparison.OrdinalIgnoreCase)) OpenMoved(section, moved); + else _ctx.Chat($"[Mini Remote] {IltSections.Label(section)} isn't a Mini Remote tab any more: it is RynthOracle's ({moved}), nothing to hide here."); return; } if (!IltSections.IsTab(section)) @@ -798,8 +856,12 @@ internal sealed class IltHubController _ => "toggle", }; if (_ctx.Host.HasInvokeChatParser && _ctx.Host.InvokeChatParser($"/rc {rcVerb} {m}")) + { + // RynthCore opens or closes it, and says why when it can't (not ILT, no ImGui). + _ctx.Chat($"[Mini Remote] {label} panel: asked RynthCore to {m} it (/rc {rcVerb} {m})."); return; - _ctx.Chat($"[Mini Remote] {label} is a RynthCore ILT panel: the bar's ILT button, or /rc {rcVerb}."); + } + _ctx.ChatFail($"[Mini Remote] {label} is a RynthCore ILT panel: the bar's ILT button, or /rc {rcVerb}."); } /// "show"/"on" → true, "hide"/"off" → false, anything else flips . @@ -831,7 +893,7 @@ internal sealed class IltHubController _ctx.Chat("[Mini Remote] Profiles: " + (names.Count > 0 ? string.Join(", ", names) : "(none)")); return; } - if (a.Length < 2) { _ctx.Chat("[Mini Remote] Usage: /ra hub profile save [shared] | load "); return; } + if (a.Length < 2 || sub is not ("save" or "load")) { _ctx.ChatFail("[Mini Remote] Usage: /ra hub profile list | save [shared] | load "); return; } if (sub == "save") { bool shared = a.Length > 2 && a[2].Equals("shared", StringComparison.OrdinalIgnoreCase); @@ -874,7 +936,7 @@ internal sealed class IltHubController string? label = _pendingLabel; bool fresh = action != null && IltHubContext.NowMs - _pendingAt <= ConfirmWindowMs; ClearPending(); - if (!fresh || action == null) { _ctx.Chat("[Mini Remote] Nothing to confirm."); return; } + if (!fresh || action == null) { _ctx.ChatFail("[Mini Remote] Nothing to confirm."); return; } RynthLog.Event(LogEvents.IltConfirmation, $"confirmed: {label}"); try { action(); } @@ -906,7 +968,7 @@ internal sealed class IltHubController RequestConfirm($"equip suit '{name ?? "(auto)"}'", () => _ctx.Chat("[Mini Remote] " + Gear.Suits.Load(name))); break; default: - _ctx.Chat("[Mini Remote] Usage: /ra hub suit list|test [name]|load [name]"); + _ctx.ChatFail("[Mini Remote] Usage: /ra hub suit list|test [name]|load [name]"); break; } } diff --git a/Plugins/RynthCore.Plugin.RynthILT/Hub/IltVaultedDungeons.cs b/Plugins/RynthCore.Plugin.RynthILT/Hub/IltVaultedDungeons.cs index 18d362f..db83533 100644 --- a/Plugins/RynthCore.Plugin.RynthILT/Hub/IltVaultedDungeons.cs +++ b/Plugins/RynthCore.Plugin.RynthILT/Hub/IltVaultedDungeons.cs @@ -535,7 +535,8 @@ internal sealed class IltVaultedDungeons : IIltFeature { case "on": case "start": - SetActive(true); + if (_cfg.Active) _ctx.Chat("[Vaulted Dungeons] Already on."); + else SetActive(true); return true; case "off": case "stop": diff --git a/Plugins/RynthCore.Plugin.RynthILT/Hub/RynthAiClient.cs b/Plugins/RynthCore.Plugin.RynthILT/Hub/RynthAiClient.cs index 7053f4d..230c419 100644 --- a/Plugins/RynthCore.Plugin.RynthILT/Hub/RynthAiClient.cs +++ b/Plugins/RynthCore.Plugin.RynthILT/Hub/RynthAiClient.cs @@ -123,7 +123,8 @@ internal sealed unsafe class RynthAiClient using var m = new Utf8(mode); int ok = t->MiniRemoteTab(id.P, m.P, reply, 256); string text = Marshal.PtrToStringUTF8((IntPtr)reply) ?? string.Empty; - return ok != 0 ? text : (text.Length > 0 ? text : "The Mini Remote is not available yet."); + // An empty reply from RynthAi still says what was done (every command answers, 2026-10-28). + return ok != 0 ? (text.Length > 0 ? text : $"Mini Remote: {mode} {tabId}.") : (text.Length > 0 ? text : "The Mini Remote is not available yet."); } /// True while the Mini Remote is on screen (any thread). diff --git a/Plugins/RynthCore.Plugin.RynthILT/RynthCore.Plugin.RynthILT.csproj b/Plugins/RynthCore.Plugin.RynthILT/RynthCore.Plugin.RynthILT.csproj index 0268ebd..856b808 100644 --- a/Plugins/RynthCore.Plugin.RynthILT/RynthCore.Plugin.RynthILT.csproj +++ b/Plugins/RynthCore.Plugin.RynthILT/RynthCore.Plugin.RynthILT.csproj @@ -97,6 +97,8 @@ + + diff --git a/Plugins/RynthCore.Plugin.RynthILT/RynthILTPlugin.cs b/Plugins/RynthCore.Plugin.RynthILT/RynthILTPlugin.cs index 22f19a3..2eca621 100644 --- a/Plugins/RynthCore.Plugin.RynthILT/RynthILTPlugin.cs +++ b/Plugins/RynthCore.Plugin.RynthILT/RynthILTPlugin.cs @@ -214,6 +214,7 @@ public sealed class RynthILTPlugin : RynthPluginBase public override void OnTick() { try { RynthLog.Pump(); } catch { } + Reply.Flush(); if (!_loginComplete) return; _ai?.Tick(); PollServerState(force: false); @@ -751,7 +752,7 @@ public sealed class RynthILTPlugin : RynthPluginBase if (!fromRa && (verb == "bounty" || verb == "bounties" || verb == "bountys")) { // "/ilt bounty [list|refresh]": the tracker's own chat commands ("/ra bounty" opens the window). - if (_bounties == null) ChatLine("[RynthILT] Bounties not ready (not logged in yet)."); + if (_bounties == null) ChatFail("[RynthILT] Bounties not ready (not logged in yet)."); else _bounties.HandleChatCommand(parts); return; } @@ -778,15 +779,16 @@ public sealed class RynthILTPlugin : RynthPluginBase // ub-IT's "/ub qblist" and "/ub augs" (RynthAi passes them on): ACECustom's own commands. string sub = args.Length > 0 ? args[0].ToLowerInvariant() : string.Empty; string? server = sub == "qblist" ? "/qb list" : sub == "augs" ? "/aug" : null; - if (server == null) { ChatLine("[RynthILT] /ub qblist or /ub augs"); return; } - if (_hub?.Options.IsIltLikeWorld != true) { ChatLine($"[RynthILT] /ub {sub}: not an Infinite Leaftide world."); return; } - if (!Host.HasInvokeChatParser || !Host.InvokeChatParser(server)) ChatLine("[RynthILT] RynthCore didn't take: " + server); + if (server == null) { ChatFail("[RynthILT] /ub qblist or /ub augs"); return; } + if (_hub?.Options.IsIltLikeWorld != true) { ChatFail($"[RynthILT] /ub {sub}: not an Infinite Leaftide world."); return; } + if (!Host.HasInvokeChatParser || !Host.InvokeChatParser(server)) ChatFail("[RynthILT] RynthCore didn't take: " + server); + else ChatLine($"[RynthILT] /ub {sub}: sent {server}; the server's reply follows."); return; } case "t11": { // "/ilt t11 ..." and RynthAi's "/ra t11 ..." (T11 loot counters; IltT11). - if (_hub == null) { ChatLine("[RynthILT] ILT features not ready (log in first)."); return; } + if (_hub == null) { ChatFail("[RynthILT] ILT features not ready (log in first)."); return; } _hub.T11.HandleCommand(args); return; } @@ -795,7 +797,7 @@ public sealed class RynthILTPlugin : RynthPluginBase { // "/ilt vaulted [on|off|toggle|status]": the Vaulted Dungeons keeper (ILT only; the // module answers "not available" elsewhere, and while the master switch is off). - if (_hub == null) { ChatLine("[RynthILT] ILT features not ready (log in first)."); return; } + if (_hub == null) { ChatFail("[RynthILT] ILT features not ready (log in first)."); return; } _hub.VaultedDungeons.HandleCommand(args); return; } @@ -805,6 +807,7 @@ public sealed class RynthILTPlugin : RynthPluginBase // "/ilt settings [show|hide|toggle]": the ILT settings window. string mode = args.Length >= 1 ? args[0].ToLowerInvariant() : "toggle"; _settingsUi.WindowOpen = mode switch { "show" or "on" => true, "hide" or "off" => false, _ => !_settingsUi.WindowOpen }; + ChatLine(WindowReply("ILT settings", _settingsUi.WindowOpen)); return; } case "stamps": @@ -816,6 +819,7 @@ public sealed class RynthILTPlugin : RynthPluginBase // "/ilt stamps [show|hide|toggle]": the Dynamic Stamps window (RynthOracle's "/ro dynamic" until 2026-10-21). string mode = args.Length >= 1 ? args[0].ToLowerInvariant() : "toggle"; _stampsWindowOpen = IltSections.Resolve(mode, _stampsWindowOpen); + ChatLine(WindowReply("Dynamic Stamps", _stampsWindowOpen)); if (_stampsWindowOpen && _hub?.Options.IsIltLikeWorld == false) ChatLine("[RynthILT] Dynamic Stamps are an Infinite Leaftide quest line; this world isn't treated as ILT."); return; @@ -827,6 +831,7 @@ public sealed class RynthILTPlugin : RynthPluginBase // RynthAi's Mini Remote shows the same tracker as Pets > Breeding). string mode = args.Length >= 1 ? args[0].ToLowerInvariant() : "toggle"; _breedingWindowOpen = IltSections.Resolve(mode, _breedingWindowOpen); + ChatLine(WindowReply("Pet Breeding", _breedingWindowOpen)); return; } case "fellow": @@ -836,6 +841,7 @@ public sealed class RynthILTPlugin : RynthPluginBase // "/ilt fellow [show|hide|toggle]": the ILT fellowship commands window. string mode = args.Length >= 1 ? args[0].ToLowerInvariant() : "toggle"; _fellowshipUi.WindowOpen = mode switch { "show" or "on" => true, "hide" or "off" => false, _ => !_fellowshipUi.WindowOpen }; + ChatLine(WindowReply("ILT fellowship", _fellowshipUi.WindowOpen)); return; } case "help": @@ -856,17 +862,24 @@ public sealed class RynthILTPlugin : RynthPluginBase } if (_hub == null) { - ChatLine("[RynthILT] ILT features not ready (log in first)."); + ChatFail("[RynthILT] ILT features not ready (log in first)."); return; } try { if (!_hub.HandleCommand(verb, args)) - ChatLine($"[RynthILT] Unknown command: {string.Join(" ", parts)}. /ilt help"); + ChatFail($"[RynthILT] Unknown command: {string.Join(" ", parts)}. /ilt help"); + } + catch (Exception ex) + { + RynthLog.Exception(LogCat.IltHub, ex, "command"); + ChatFail($"[RynthILT] {string.Join(" ", parts)} failed: {ex.Message}"); } - catch (Exception ex) { RynthLog.Exception(LogCat.IltHub, ex, "command"); } } + /// "/ilt settings|stamps|breeding|fellow [show|hide|toggle]": the window after it (every command answers, 2026-10-28). + internal static string WindowReply(string window, bool open) => $"[RynthILT] {window} window {(open ? "shown" : "hidden")}."; + private static string[] Prepend(string first, string[] rest) { var a = new string[rest.Length + 1]; @@ -893,7 +906,7 @@ public sealed class RynthILTPlugin : RynthPluginBase } if (!RynthLog.TryParseCategory(target, out LogCat cat)) { - ChatLine($"[RynthILT] Unknown trace category '{target}'. /ilt trace list"); + ChatFail($"[RynthILT] Unknown trace category '{target}'. /ilt trace list"); return; } RynthLog.SetTracing(cat, on); @@ -907,7 +920,7 @@ public sealed class RynthILTPlugin : RynthPluginBase if (words.Length == 0) return; if (words[0].Equals("prog", StringComparison.OrdinalIgnoreCase)) { - if (_hub == null) { ChatLine("[RynthILT] ILT features not ready (log in first)."); return; } + if (_hub == null) { ChatFail("[RynthILT] ILT features not ready (log in first)."); return; } try { _hub.Progression.HandleRemote(words[1..]); } catch (Exception ex) { RynthLog.Exception(LogCat.IltProgression, ex, "prog command"); } return; @@ -921,10 +934,16 @@ public sealed class RynthILTPlugin : RynthPluginBase if (_engineCommands.Count < 64) _engineCommands.Enqueue((action + " " + value).Trim()); } - private void ChatLine(string text) - { - if (Host.HasWriteToChat) Host.WriteToChat(text, 1); - } + // RynthILT's chat lines (the Hub's too) go through RynthSuite's shared reply queue + // (Plugins/Shared/CommandReply.cs): the host drops a line within 100 ms of another plugin's, so the + // help's later lines used to go missing. Every line brings its own tag ("[RynthILT]", "[Mini Remote]"). + private RynthCore.Plugin.Shared.CommandReply? _reply; + private RynthCore.Plugin.Shared.CommandReply Reply => _reply ??= IltHubContext.NewReply(Host); + + private void ChatLine(string text) => Reply.Ok(text); + + /// A command that didn't work: why, and the usage (the failure colour). + private void ChatFail(string text) => Reply.Fail(text); // ── The ILT Hub ────────────────────────────────────────────────────────── @@ -970,7 +989,7 @@ public sealed class RynthILTPlugin : RynthPluginBase try { _hub = new IltHubController(Host, folder, _settings, _ai, () => _hubWritesBlocked, - pending ? IltMigration.FindLegacyCharFolder(world, charName) : null); + pending ? IltMigration.FindLegacyCharFolder(world, charName) : null, Reply); // Once per character: the RynthAi settings that moved here on 2026-10-20. var imported = IltMigration.ImportRynthAiSettings(_hub.State, world, charName); if (imported.Count > 0) diff --git a/Plugins/RynthCore.Plugin.RynthThreads/RynthCore.Plugin.RynthThreads.csproj b/Plugins/RynthCore.Plugin.RynthThreads/RynthCore.Plugin.RynthThreads.csproj index 27c9213..e614bc1 100644 --- a/Plugins/RynthCore.Plugin.RynthThreads/RynthCore.Plugin.RynthThreads.csproj +++ b/Plugins/RynthCore.Plugin.RynthThreads/RynthCore.Plugin.RynthThreads.csproj @@ -32,6 +32,11 @@ DreamWeave only: records Fragment Press results and shows the odds of each modifier per component. + + + + + diff --git a/Plugins/RynthCore.Plugin.RynthThreads/RynthThreadsPlugin.cs b/Plugins/RynthCore.Plugin.RynthThreads/RynthThreadsPlugin.cs index 12ae818..bcdbe5c 100644 --- a/Plugins/RynthCore.Plugin.RynthThreads/RynthThreadsPlugin.cs +++ b/Plugins/RynthCore.Plugin.RynthThreads/RynthThreadsPlugin.cs @@ -18,6 +18,7 @@ using System.Text; using RynthCore.Plugin.RynthThreads.Threads; using RynthCore.Plugin.RynthThreads.Ui; using RynthCore.Plugin.RynthThreads.Views; +using RynthCore.Plugin.Shared; using RynthCore.PluginCore; namespace RynthCore.Plugin.RynthThreads; @@ -50,10 +51,10 @@ public sealed class RynthThreadsPlugin : RynthPluginBase private long _nextPollMs; private string _world = string.Empty; private string _character = string.Empty; - private bool _noUiLogged; public override int Initialize() { + _ = Reply; _ui.Log = msg => Host.Log(msg); _panel = new ThreadsPanel { @@ -127,6 +128,7 @@ public sealed class RynthThreadsPlugin : RynthPluginBase { long now = Environment.TickCount64; while (_commands.TryDequeue(out string? cmd)) RunCommand(cmd); + Reply.Flush(); if (_inWorld && !_checked && now >= _nextIdentityTryMs) TryIdentify(now); if (!_active || _store == null) return; @@ -224,7 +226,7 @@ public sealed class RynthThreadsPlugin : RynthPluginBase } catch (Exception ex) { - Print($"Export failed: {ex.Message}"); + PrintFail($"Export failed: {ex.Message}"); } } @@ -232,39 +234,37 @@ public sealed class RynthThreadsPlugin : RynthPluginBase private void RunCommand(string arg) { - string word = arg.Split(' ', StringSplitOptions.RemoveEmptyEntries) is { Length: > 0 } w ? w[0].ToLowerInvariant() : string.Empty; - if (word is "help" or "?") + // Every /rthreads answers in chat (2026-10-28, ThreadsCommands.cs). + ThreadsVerb verb = ThreadsCommands.Parse(arg, out string word); + if (verb == ThreadsVerb.Help) { - Print($"DreamWeave only: records Fragment Press results and shows the odds of each modifier per component. {Command} shows or hides the window; {Command} stats; {Command} export."); + Print(ThreadsCommands.Help); return; } - if (!_inWorld) { Print("Log in first."); return; } - if (!_checked) { Print("Still finding out which server this is; try again in a moment."); return; } + if (!_inWorld) { PrintFail("Log in first."); return; } + if (!_checked) { PrintFail("Still finding out which server this is; try again in a moment."); return; } if (!_active) { - Print($"RynthThreads is for DreamWeave only (this is {_world})."); + PrintFail($"RynthThreads is for DreamWeave only (this is {_world})."); return; } - switch (word) + switch (verb) { - case "": - if (_window == null) return; + case ThreadsVerb.Window: + if (_window == null) { PrintFail("The Threads window isn't ready yet; try again in a moment."); return; } _window.Visible = !_window.Visible; _window.NeedsPass = true; - if (_window.Visible && !Host.HasUi && !_noUiLogged) - { - _noUiLogged = true; - Print($"This RynthCore engine can't show plugin windows (it needs script windows, API v71, with ImGui on). Presses are still recorded: {Command} stats."); - } + if (Host.HasUi) Print(ThreadsCommands.Window(_window.Visible)); + else PrintFail(ThreadsCommands.NoWindows); break; - case "stats": + case ThreadsVerb.Stats: foreach (string line in StatsLines(CurrentReport(), _store!.FilePath)) Print(line); break; - case "export": + case ThreadsVerb.Export: Export(); break; default: - Print($"{Command} [stats | export | help]"); + PrintFail(ThreadsCommands.Unknown(word)); break; } } @@ -306,11 +306,15 @@ public sealed class RynthThreadsPlugin : RynthPluginBase return lines; } - private void Print(string text) - { - if (!Host.HasWriteToChat || !Host.WriteToChat("[RynthThreads] " + text, 1)) - Host.Log("[RynthThreads] " + text); - } + // Chat lines wait in the shared reply queue (RynthSuite's Plugins/Shared/CommandReply.cs): the host + // drops a line within 100 ms of another plugin's, so /rthreads stats lost all but its first line. + private CommandReply? _reply; + private CommandReply Reply => _reply ??= new CommandReply("[RynthThreads]", + (t, c) => Host.HasWriteToChat && Host.WriteToChat(t, c), t => Host.Log(t)); + + private void Print(string text) => Reply.Ok(text); + + private void PrintFail(string text) => Reply.Fail(text); /// A pass when one is wanted, or now and then while visible. private void Record(UiWindow w, long now) diff --git a/Plugins/RynthCore.Plugin.RynthThreads/ThreadsCommands.cs b/Plugins/RynthCore.Plugin.RynthThreads/ThreadsCommands.cs new file mode 100644 index 0000000..b32b723 --- /dev/null +++ b/Plugins/RynthCore.Plugin.RynthThreads/ThreadsCommands.cs @@ -0,0 +1,39 @@ +// ThreadsCommands.cs - "/rthreads ..." words and what each answers (2026-10-28: every command answers in +// chat, RynthSuite's Plugins/Shared/CommandReply.cs). RynthThreads can't tell a typed /rthreads from a +// meta's, so each one answers. Pure: RynthThreads.Tests covers it. +using RynthCore.Plugin.Shared; + +namespace RynthCore.Plugin.RynthThreads; + +internal enum ThreadsVerb { Window, Stats, Export, Help, Unknown } + +internal static class ThreadsCommands +{ + public const string Command = "/rthreads"; + + public const string Usage = Command + " [stats | export | help]"; + + public static ThreadsVerb Parse(string? arg, out string word) + { + string[] words = (arg ?? string.Empty).Split(' ', System.StringSplitOptions.RemoveEmptyEntries); + word = words.Length > 0 ? words[0].ToLowerInvariant() : string.Empty; + return word switch + { + "" => ThreadsVerb.Window, + "stats" => ThreadsVerb.Stats, + "export" => ThreadsVerb.Export, + "help" or "?" => ThreadsVerb.Help, + _ => ThreadsVerb.Unknown, + }; + } + + public static string Help => + $"DreamWeave only: records Fragment Press results and shows the odds of each modifier per component. {Command} shows or hides the window; {Command} stats; {Command} export."; + + public static string Window(bool shown) => CommandReply.Shown("The Threads window", shown); + + public static string NoWindows => + $"This RynthCore engine can't show plugin windows (it needs script windows, API v71, with ImGui on). Presses are still recorded: {Command} stats."; + + public static string Unknown(string word) => $"Unknown '{Command} {word}'. Usage: {Usage}"; +} diff --git a/Plugins/Shared/ServerPack/ServerPackCommands.cs b/Plugins/Shared/ServerPack/ServerPackCommands.cs new file mode 100644 index 0000000..8cdd6c0 --- /dev/null +++ b/Plugins/Shared/ServerPack/ServerPackCommands.cs @@ -0,0 +1,57 @@ +// ServerPackCommands.cs - "/rserver ..." for every server plugin: which words are its verbs and what each +// answers (2026-10-28: every command answers in chat, RynthSuite's Plugins/Shared/CommandReply.cs). +// The plugin can't tell a typed /rserver from a meta's, so each one answers. The window verbs say the +// window's state; auto/on/off are answered by RynthCore's "/rc server" (the override it saved); info +// lists what is known; help and an unknown word give the usage (the unknown word named first). +// Pure: RynthServerPack.Tests covers it. +using System; +using System.Collections.Generic; +using RynthCore.Plugin.Shared; + +namespace RynthCore.Plugin.ServerPack; + +internal enum ServerVerb { Show, Hide, Toggle, Info, Help, Auto, On, Off, Server, Unknown } + +internal static class ServerPackCommands +{ + /// The verbs every server plugin answers (the server's own come from ServerCommandVerbs). + public static readonly string[] SharedVerbs = { "show", "hide", "toggle", "info", "help", "on", "off", "auto" }; + + /// Whether is a verb here (else it may be a server id: "/rserver coldeve info"). + public static bool IsVerb(string word, ICollection serverVerbs) + { + string w = (word ?? string.Empty).ToLowerInvariant(); + return Array.IndexOf(SharedVerbs, w) >= 0 || serverVerbs.Contains(w); + } + + /// The verb of "/rserver [verb ...]" (parts[0] is "/rserver"; none = toggle). + public static ServerVerb Verb(string[] parts, ICollection serverVerbs) + { + if (parts.Length < 2) return ServerVerb.Toggle; + string w = parts[1].ToLowerInvariant(); + return w switch + { + "show" => ServerVerb.Show, + "hide" => ServerVerb.Hide, + "toggle" => ServerVerb.Toggle, + "info" => ServerVerb.Info, + "help" => ServerVerb.Help, + "auto" => ServerVerb.Auto, + "on" => ServerVerb.On, + "off" => ServerVerb.Off, + _ => serverVerbs.Contains(w) ? ServerVerb.Server : ServerVerb.Unknown, + }; + } + + /// "/rserver [show|hide|toggle]": the window after it. + public static string Window(string serverName, bool shown) => CommandReply.Shown($"The {serverName} window", shown); + + /// The usage, two lines. + public static string[] Usage(string serverName) => new[] + { + $"/rserver [show|hide|toggle] - the {serverName} server card (also in the Mini Remote's Char section).", + $"/rserver info - what is known about {serverName}; /rserver auto|on|off - this character's override.", + }; + + public static string Unknown(string word) => $"Unknown '/rserver {word}'."; +} diff --git a/Plugins/Shared/ServerPack/ServerPackPlugin.cs b/Plugins/Shared/ServerPack/ServerPackPlugin.cs index 1507311..37eb77e 100644 --- a/Plugins/Shared/ServerPack/ServerPackPlugin.cs +++ b/Plugins/Shared/ServerPack/ServerPackPlugin.cs @@ -46,6 +46,7 @@ using System.Collections.Concurrent; using System.Collections.Generic; using System.Runtime.InteropServices; using ImGuiNET; +using RynthCore.Plugin.Shared; using RynthCore.PluginCore; using RynthCore.PluginSdk; @@ -169,6 +170,7 @@ public sealed partial class ServerPackPlugin : RynthPluginBase public override int Initialize() { + _ = Reply; Host.Log($"[{RynthPluginInfo.Name}] Plugin initialized for {Info.Name} ({Info.Id})."); // The server card draws through the engine's cimgui (and so in its current context, a popped-out // Mini Remote's included), never a second copy of ImGui (ImGuiNativeBinding.cs). Found and fixed @@ -206,13 +208,14 @@ public sealed partial class ServerPackPlugin : RynthPluginBase public override void OnTick() { + Reply.Flush(); if (!_loginComplete) return; if (_world == null) RefreshWorld(); while (_commands.TryDequeue(out string[]? parts)) RunCommand(parts); while (_engineCommands.TryDequeue(out string? command)) { if (!Host.HasInvokeChatParser || !Host.InvokeChatParser(command)) - ChatLine($"[{RynthPluginInfo.Name}] RynthCore didn't take: " + command); + ChatFail($"[{RynthPluginInfo.Name}] RynthCore didn't take: " + command); } while (_tickActions.TryDequeue(out Action? action)) { @@ -280,16 +283,17 @@ public sealed partial class ServerPackPlugin : RynthPluginBase /// /rserver show|hide|toggle: the server's window on RynthCore's bar when the engine hosts it (plugin /// windows, v89), else the standalone window this plugin draws itself (older engines). /// - private void SetWindow(RynthPanelOpen mode) + /// Whether the window shows now. + private bool SetWindow(RynthPanelOpen mode) { string title = ServerPackModel.WindowTitle(Info); if (Host.HasSetPanelOpen && Host.SetPanelOpen(title, RynthPanelOpen.Ask) >= 0) { _ui.WindowOpen = false; - Host.SetPanelOpen(title, mode); - return; + return Host.SetPanelOpen(title, mode) == 1; } _ui.WindowOpen = mode switch { RynthPanelOpen.Open => true, RynthPanelOpen.Close => false, _ => !_ui.WindowOpen }; + return _ui.WindowOpen; } /// @@ -358,9 +362,7 @@ public sealed partial class ServerPackPlugin : RynthPluginBase _commands.Enqueue(parts); } - private bool IsVerb(string word) => - word.ToLowerInvariant() is "show" or "hide" or "toggle" or "info" or "help" or "on" or "off" or "auto" - || _serverVerbs.Contains(word); + private bool IsVerb(string word) => ServerPackCommands.IsVerb(word, _serverVerbs); /// Drops the server id: "/rserver coldeve info" -> "/rserver info". private static string[] Shift(string[] parts) @@ -373,24 +375,26 @@ public sealed partial class ServerPackPlugin : RynthPluginBase private void RunCommand(string[] parts) { - string verb = parts.Length >= 2 ? parts[1].ToLowerInvariant() : "toggle"; + // Every /rserver answers in chat (2026-10-28, ServerPackCommands.cs). The window verbs say its + // state; auto/on/off are answered by RynthCore's "/rc server" (or "RynthCore didn't take"). + ServerVerb verb = ServerPackCommands.Verb(parts, _serverVerbs); switch (verb) { - case "show": - SetWindow(RynthPanelOpen.Open); + case ServerVerb.Show: + Reply.Ok(ServerPackCommands.Window(Info.Name, SetWindow(RynthPanelOpen.Open))); return; - case "hide": - SetWindow(RynthPanelOpen.Close); + case ServerVerb.Hide: + Reply.Ok(ServerPackCommands.Window(Info.Name, SetWindow(RynthPanelOpen.Close))); return; - case "toggle": - SetWindow(RynthPanelOpen.Toggle); + case ServerVerb.Toggle: + Reply.Ok(ServerPackCommands.Window(Info.Name, SetWindow(RynthPanelOpen.Toggle))); return; - case "auto": - case "on": - case "off": - _engineCommands.Enqueue(ServerPackModel.ForceCommand(Info.Id, verb)); + case ServerVerb.Auto: + case ServerVerb.On: + case ServerVerb.Off: + _engineCommands.Enqueue(ServerPackModel.ForceCommand(Info.Id, parts[1].ToLowerInvariant())); return; - case "info": + case ServerVerb.Info: PrintInfo(); return; } @@ -398,8 +402,9 @@ public sealed partial class ServerPackPlugin : RynthPluginBase bool handled = false; ServerChatCommand(parts, ref handled); if (handled) return; - ChatLine($"[{RynthPluginInfo.Name}] {ChatCommand} [show|hide|toggle] - the {Info.Name} server card (also in the Mini Remote's Char section)."); - ChatLine($"[{RynthPluginInfo.Name}] {ChatCommand} info - what is known about {Info.Name}; {ChatCommand} auto|on|off - this character's override."); + if (verb == ServerVerb.Unknown) Reply.Fail(ServerPackCommands.Unknown(parts[1]) + " " + ServerPackCommands.Usage(Info.Name)[0]); + else ChatLine(ServerPackCommands.Usage(Info.Name)[0]); + ChatLine(ServerPackCommands.Usage(Info.Name)[1]); } private void PrintInfo() @@ -416,8 +421,15 @@ public sealed partial class ServerPackPlugin : RynthPluginBase ServerInfoLines(line => ChatLine(tag + line)); } - internal void ChatLine(string text) - { - if (Host.HasWriteToChat) Host.WriteToChat(text, 1); - } + // Chat lines wait in the shared reply queue (RynthSuite's Plugins/Shared/CommandReply.cs): the host drops + // a line within 100 ms of another plugin's, so /rserver info's later lines used to go missing. A line + // with its own "[...]" tag keeps it; one without gets "[]". + private CommandReply? _reply; + internal CommandReply Reply => _reply ??= new CommandReply($"[{RynthPluginInfo.Name}]", + (t, c) => Host.HasWriteToChat && Host.WriteToChat(t, c), t => Host.Log(t)); + + internal void ChatLine(string text) => Reply.Ok(text); + + /// A command that didn't work: why, and the usage (the failure colour). + internal void ChatFail(string text) => Reply.Fail(text); } diff --git a/Plugins/Shared/ServerPack/ServerPlugin.props b/Plugins/Shared/ServerPack/ServerPlugin.props index 8d5adb2..bc3452e 100644 --- a/Plugins/Shared/ServerPack/ServerPlugin.props +++ b/Plugins/Shared/ServerPack/ServerPlugin.props @@ -55,6 +55,9 @@ + + + diff --git a/Tools/RynthILT.Tests/Program.cs b/Tools/RynthILT.Tests/Program.cs index d351cc8..94764c6 100644 --- a/Tools/RynthILT.Tests/Program.cs +++ b/Tools/RynthILT.Tests/Program.cs @@ -53,6 +53,7 @@ internal static class Program RingEvadeTests.Register(runner); VaultedSwitchTests.Register(runner); T11Tests.Register(runner); + ReplyTests.Register(runner); RemoteTabTests.Register(runner); StampTests.Register(runner); BankRosterTests.Register(runner); diff --git a/Tools/RynthILT.Tests/ReplyTests.cs b/Tools/RynthILT.Tests/ReplyTests.cs new file mode 100644 index 0000000..a93d76e --- /dev/null +++ b/Tools/RynthILT.Tests/ReplyTests.cs @@ -0,0 +1,130 @@ +using System; +using System.IO; +using System.Linq; +using RynthCore.Plugin.RynthILT; +using RynthCore.Plugin.RynthILT.Hub; +using RynthCore.RynthAiHostTests.Fakes; +using RynthCore.RynthAiTests.Harness; + +namespace RynthILT.Tests; + +// Every ILT command answers in chat (2026-10-28). The Hub's verbs ("/ilt hub ...", "/ra hub|guardian| +// bounty|rates ...") run here on the fake engine host, each typed right and typed wrong, and must each +// write a line of their own. The plugin-level window verbs (settings, stamps, breeding, fellow) need the +// plugin's %APPDATA% folder, so their line (WindowReply) is checked on its own. +internal static class ReplyTests +{ + private const uint Player = 0x50000001; + + public static void Register(Runner r) + { + r.Add("replies: every Hub verb answers in chat, typed right and wrong", HubVerbs); + r.Add("replies: the plugin's window verbs say the window's state", WindowVerbs); + } + + private static IltHubController NewHub(string folder) + { + FakeHost.Reset(); + FakeAiHub.Reset(); + FakeHost.WorldName = "InfiniteLeaftide"; + var host = FakeHost.Create(Player); + var ai = new RynthAiClient(host); + ai.UseTableForTests(FakeAiHub.Table); + string dir = Path.Combine(Program.TempRoot, "replies-" + folder); + if (Directory.Exists(dir)) Directory.Delete(dir, recursive: true); + Directory.CreateDirectory(dir); + var hub = new IltHubController(host, dir, new IltSettings(), ai); + hub.OnLoginComplete("Replier", forceFromMigration: false); + return hub; + } + + /// Runs one Hub command; the lines it wrote (it must write one). + private static string[] Answer(IltHubController hub, string verb, params string[] args) + { + FakeHost.Chat.Clear(); + bool handled = hub.HandleCommand(verb, args); + string typed = ("/ra " + verb + " " + string.Join(" ", args)).Trim(); + Check.True(handled, typed + ": handled"); + Check.True(FakeHost.Chat.Count > 0, typed + ": answers in chat"); + return FakeHost.Chat.ToArray(); + } + + private static void Says(IltHubController hub, string needle, string verb, params string[] args) + { + string[] lines = Answer(hub, verb, args); + Check.True(lines.Any(l => l.Contains(needle, StringComparison.OrdinalIgnoreCase)), + $"/ra {verb} {string.Join(" ", args)}: says '{needle}' (got: {string.Join(" / ", lines)})"); + } + + private static void HubVerbs() + { + var hub = NewHub("hub"); + + // right forms + Says(hub, "rates reset", "rates", "reset"); + Says(hub, "asked RynthCore to toggle", "bounty"); + Says(hub, "asked RynthCore to show", "guardian", "window", "show"); + Says(hub, "Mini Remote", "hub", "show"); + Says(hub, "Mini Remote", "hub", "open", "gear"); + Says(hub, "nothing to hide", "hub", "open", "character", "hide"); + Says(hub, "World 'InfiniteLeaftide'", "hub", "status"); + Says(hub, "Leaftide features", "hub", "features"); + Says(hub, "Force ILT world: on", "hub", "force", "on"); + Says(hub, "ILT world names", "hub", "servers"); + Says(hub, "Profiles:", "hub", "profile", "list"); + Says(hub, "Suits:", "hub", "suit", "list"); + Says(hub, "Reading the bank balance", "hub", "bank"); + Says(hub, "Sending /clap all", "hub", "clap"); + Says(hub, "Attribute raiser", "hub", "attr"); + Says(hub, "Attribute raiser", "hub", "attr", "run"); + Says(hub, "Attribute raiser", "hub", "attr", "stop"); + Says(hub, "Attribute raiser", "hub", "attr", "costs"); + Says(hub, "auto-raise on", "hub", "attr", "auto", "on"); + Says(hub, "every 10 min", "hub", "attr", "every", "10"); + Says(hub, "Attribute raiser", "hub", "attr", "raise", "str", "1"); + Says(hub, "Nothing to cancel", "hub", "cancel"); + Says(hub, "/ra hub [show|hide|toggle]", "hub", "help"); + + // "/ra hub open character" opens RynthOracle's tab: RynthOracle answers ("/ro character"). + FakeHost.ChatCommands.Clear(); + Check.True(hub.HandleCommand("hub", new[] { "open", "character" }) && FakeHost.ChatCommands.Contains("/ro character"), + "/ra hub open character: runs /ro character (RynthOracle answers it)"); + + // wrong forms: why, and how it's typed + Says(hub, "already waiting", "hub", "bank"); // the one sent above is still out + Says(hub, "already waiting", "hub", "clap"); + Says(hub, "Usage: /ra hub open", "hub", "open", "wobble"); + Says(hub, "Usage: /ra hub profile", "hub", "profile", "wobble", "x"); + Says(hub, "Usage: /ra hub profile", "hub", "profile", "save"); + Says(hub, "Usage: /ra hub suit", "hub", "suit", "wobble"); + Says(hub, "Usage: /ra hub attr", "hub", "attr", "auto", "maybe"); + Says(hub, "Usage: /ra hub attr", "hub", "attr", "every", "soon"); + Says(hub, "Usage: /ra hub attr", "hub", "attr", "raise", "luck", "1"); + Says(hub, "Usage: /ra hub attr", "hub", "attr", "raise"); + Says(hub, "Usage: /ra hub attr", "hub", "attr", "wobble"); + Says(hub, "Usage: /ra hub servers", "hub", "servers", ","); + Says(hub, "Nothing to confirm", "hub", "confirm"); + Says(hub, "/ra hub [show|hide|toggle]", "hub", "wobble"); + Says(hub, "/ra guardian", "guardian", "wobble"); + + // Vaulted Dungeons answers every word (off here: its master switch is off by default). + foreach (string w in new[] { "on", "off", "toggle", "status", "wobble" }) + { + FakeHost.Chat.Clear(); + hub.VaultedDungeons.HandleCommand(new[] { w }); + Check.True(FakeHost.Chat.Count > 0, $"/ilt vaulted {w}: answers"); + } + + // The Hub's verbs as RynthILT takes them from RynthAi's /ra. + foreach (string line in new[] { "hub bank", "hub attr run", "guardian status", "bounty", "rates reset", "t11", "ub qblist" }) + Check.True(RynthILTPlugin.IsIltVerb(line.Split(' ')), $"/ra {line} is RynthILT's"); + } + + private static void WindowVerbs() + { + Check.Eq(RynthILTPlugin.WindowReply("ILT settings", true), "[RynthILT] ILT settings window shown.", "/ilt settings: shown"); + Check.Eq(RynthILTPlugin.WindowReply("Dynamic Stamps", false), "[RynthILT] Dynamic Stamps window hidden.", "/ilt stamps: hidden"); + foreach (string w in new[] { "ILT settings", "Dynamic Stamps", "Pet Breeding", "ILT fellowship" }) + Check.True(RynthILTPlugin.WindowReply(w, true).StartsWith("[RynthILT] " + w, StringComparison.Ordinal), $"{w}: its own line"); + } +} diff --git a/Tools/RynthServerPack.Tests/Program.cs b/Tools/RynthServerPack.Tests/Program.cs index 60fae99..939ffbc 100644 --- a/Tools/RynthServerPack.Tests/Program.cs +++ b/Tools/RynthServerPack.Tests/Program.cs @@ -19,6 +19,7 @@ internal static class Program VaultTests.Register(runner); QuestPackTests.Register(runner); LevistrasTests.Register(runner); + ServerPackCommandsTests.Register(runner); return runner.Run("RynthServerPack tests", args.Length > 0 ? args[0] : null); } } diff --git a/Tools/RynthServerPack.Tests/RynthServerPack.Tests.csproj b/Tools/RynthServerPack.Tests/RynthServerPack.Tests.csproj index e8aca60..8ddde72 100644 --- a/Tools/RynthServerPack.Tests/RynthServerPack.Tests.csproj +++ b/Tools/RynthServerPack.Tests/RynthServerPack.Tests.csproj @@ -29,6 +29,9 @@ + + + diff --git a/Tools/RynthServerPack.Tests/ServerPackCommandsTests.cs b/Tools/RynthServerPack.Tests/ServerPackCommandsTests.cs new file mode 100644 index 0000000..7ab9644 --- /dev/null +++ b/Tools/RynthServerPack.Tests/ServerPackCommandsTests.cs @@ -0,0 +1,67 @@ +using System; +using System.Collections.Generic; +using RynthCore.Plugin.ServerPack; +using RynthCore.Plugin.Shared; +using RynthCore.RynthAiTests.Harness; + +namespace RynthServerPack.Tests; + +// Every "/rserver" command answers in chat (2026-10-28). RunCommand needs the plugin's host, so the words +// (shared and a server's own, as RynthAelrynth's "vault"), the verb each one is, and the lines are checked +// here, plus the shared reply queue the server plugins write through. +internal static class ServerPackCommandsTests +{ + public static void Register(Runner r) + { + r.Add("rserver: every word is a verb or a server id, typed right and wrong", Words); + r.Add("rserver: the window, usage and unknown-word lines", Lines); + r.Add("rserver: replies go through the shared queue, tagged with the plugin's name", Queue); + } + + private static readonly HashSet Vault = new(StringComparer.OrdinalIgnoreCase) { "vault" }; + + private static void Words() + { + var table = new (string Line, ServerVerb Verb)[] + { + ("/rserver", ServerVerb.Toggle), ("/rserver show", ServerVerb.Show), ("/rserver HIDE", ServerVerb.Hide), + ("/rserver toggle", ServerVerb.Toggle), ("/rserver info", ServerVerb.Info), ("/rserver help", ServerVerb.Help), + ("/rserver auto", ServerVerb.Auto), ("/rserver on", ServerVerb.On), ("/rserver off", ServerVerb.Off), + ("/rserver vault", ServerVerb.Server), ("/rserver wobble", ServerVerb.Unknown), + }; + var seen = new HashSet(); + foreach (var (line, verb) in table) + { + ServerVerb got = ServerPackCommands.Verb(line.Split(' ', StringSplitOptions.RemoveEmptyEntries), Vault); + Check.Eq(got, verb, $"'{line}'"); + seen.Add(got); + } + foreach (ServerVerb v in Enum.GetValues()) Check.True(seen.Contains(v), $"the table covers /rserver's {v}"); + Check.True(ServerPackCommands.IsVerb("Info", Vault) && ServerPackCommands.IsVerb("vault", Vault), "shared and own verbs"); + Check.False(ServerPackCommands.IsVerb("coldeve", Vault), "a server id isn't a verb (\"/rserver coldeve info\")"); + Check.Eq(ServerPackCommands.Verb(new[] { "/rserver", "vault" }, new HashSet()), ServerVerb.Unknown, "another server's own verb is unknown here"); + } + + private static void Lines() + { + Check.Eq(ServerPackCommands.Window("Coldeve", true), "The Coldeve window shown.", "show"); + Check.Eq(ServerPackCommands.Window("Coldeve", false), "The Coldeve window hidden.", "hide"); + string[] usage = ServerPackCommands.Usage("Coldeve"); + Check.Eq(usage.Length, 2, "two usage lines"); + Check.True(usage[0].Contains("/rserver [show|hide|toggle]") && usage[1].Contains("/rserver auto|on|off"), "the usage names every verb"); + Check.Eq(ServerPackCommands.Unknown("wobble"), "Unknown '/rserver wobble'.", "an unknown word"); + } + + private static void Queue() + { + var chat = new List<(string, int)>(); + var r = new CommandReply("[RynthColdeve]", (t, c) => { chat.Add((t, c)); return true; }); + r.Ok(ServerPackCommands.Window("Coldeve", true)); + r.Fail("[RynthAelrynth] The account vault is Aelrynth's; RynthCore doesn't see this world as Aelrynth."); + while (r.Flush()) { } + Check.Eq(chat.Count, 2, "both lines written"); + Check.Eq(chat[0], ("[RynthColdeve] The Coldeve window shown.", CommandReply.OkChatType), "untagged: the plugin's tag, the ok colour"); + Check.Eq(chat[1].Item2, CommandReply.FailChatType, "a refusal: the failure colour"); + Check.True(chat[1].Item1.StartsWith("[RynthAelrynth] ", StringComparison.Ordinal), "a line with its own tag keeps it"); + } +} diff --git a/Tools/RynthThreads.Tests/Program.cs b/Tools/RynthThreads.Tests/Program.cs index 4723f05..0a4f6d0 100644 --- a/Tools/RynthThreads.Tests/Program.cs +++ b/Tools/RynthThreads.Tests/Program.cs @@ -35,6 +35,7 @@ namespace RynthThreads.Tests InferenceTests.Register(runner); StoreTests.Register(runner); WindowTests.Register(runner); + ReplyTests.Register(runner); int rc = runner.Run("RynthThreads tests", args.Length > 0 ? args[0] : null); try { Directory.Delete(TempRoot, recursive: true); } catch { } return rc; diff --git a/Tools/RynthThreads.Tests/ReplyTests.cs b/Tools/RynthThreads.Tests/ReplyTests.cs new file mode 100644 index 0000000..5d0dbf5 --- /dev/null +++ b/Tools/RynthThreads.Tests/ReplyTests.cs @@ -0,0 +1,44 @@ +using System; +using System.Collections.Generic; +using RynthCore.Plugin.RynthThreads; +using RynthCore.RynthAiTests.Harness; + +namespace RynthThreads.Tests; + +// Every /rthreads command answers in chat (2026-10-28). RunCommand needs the plugin's host, so the words, +// the verb each one is, and the lines are checked here. +internal static class ReplyTests +{ + public static void Register(Runner r) + { + r.Add("replies: every /rthreads word, typed right and wrong", Words); + r.Add("replies: the window, help and unknown-word lines", Lines); + } + + private static void Words() + { + var table = new (string Typed, ThreadsVerb Verb)[] + { + ("", ThreadsVerb.Window), ("stats", ThreadsVerb.Stats), ("STATS now", ThreadsVerb.Stats), ("export", ThreadsVerb.Export), + ("help", ThreadsVerb.Help), ("?", ThreadsVerb.Help), ("odds", ThreadsVerb.Unknown), + }; + var seen = new HashSet(); + foreach (var (typed, verb) in table) + { + Check.Eq(ThreadsCommands.Parse(typed, out _), verb, $"'/rthreads {typed}'"); + seen.Add(verb); + } + foreach (ThreadsVerb v in Enum.GetValues()) Check.True(seen.Contains(v), $"the table covers /rthreads' {v}"); + ThreadsCommands.Parse("Odds please", out string word); + Check.Eq(word, "odds", "the unknown word, for its line"); + } + + private static void Lines() + { + Check.Eq(ThreadsCommands.Window(true), "The Threads window shown.", "toggle: shown"); + Check.Eq(ThreadsCommands.Window(false), "The Threads window hidden.", "toggle: hidden"); + Check.True(ThreadsCommands.Help.Contains("/rthreads stats") && ThreadsCommands.Help.Contains("/rthreads export"), "help names the verbs"); + Check.Eq(ThreadsCommands.Unknown("odds"), "Unknown '/rthreads odds'. Usage: /rthreads [stats | export | help]", "an unknown word"); + Check.True(ThreadsCommands.NoWindows.Contains("can't show plugin windows"), "no plugin windows: why"); + } +} diff --git a/Tools/RynthThreads.Tests/RynthThreads.Tests.csproj b/Tools/RynthThreads.Tests/RynthThreads.Tests.csproj index 746a661..369e2de 100644 --- a/Tools/RynthThreads.Tests/RynthThreads.Tests.csproj +++ b/Tools/RynthThreads.Tests/RynthThreads.Tests.csproj @@ -31,6 +31,7 @@ +