WIP: DreamWeave: declare the Dereth Network chat tab #6
4 changed files with 26 additions and 4 deletions
DreamWeave: declare the Dereth network on the Network tab
ServerChatTab gains an optional ServerChatNetwork (kind, command);
BuildSectionsJson writes "network" inside the entry only when set.
DreamWeave sets ("dereth", "derethnetwork").
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
commit
24e0ec3683
|
|
@ -78,7 +78,7 @@ internal static class ServerData
|
||||||
new ServerChatRule("copy", "type:3", "", "^[^\"]+@[a-z0-9-]+( \\(discord\\))? tells you, \""),
|
new ServerChatRule("copy", "type:3", "", "^[^\"]+@[a-z0-9-]+( \\(discord\\))? tells you, \""),
|
||||||
new ServerChatRule("copy", "type:4", "", "^You tell [^\"]+@[a-z0-9-]+( \\(discord\\))?, \""),
|
new ServerChatRule("copy", "type:4", "", "^You tell [^\"]+@[a-z0-9-]+( \\(discord\\))?, \""),
|
||||||
new ServerChatRule("copy", "", "startswith", "", GlobalRoom: true),
|
new ServerChatRule("copy", "", "startswith", "", GlobalRoom: true),
|
||||||
}),
|
}, new ServerChatNetwork("dereth", "derethnetwork")),
|
||||||
},
|
},
|
||||||
Discord = "https://discord.gg/p2h3yca4BD",
|
Discord = "https://discord.gg/p2h3yca4BD",
|
||||||
Wiki = "https://wiki.acdreamweave.com",
|
Wiki = "https://wiki.acdreamweave.com",
|
||||||
|
|
|
||||||
|
|
@ -56,10 +56,15 @@ internal sealed record ServerSalvage(string Bench, int Material, string Effect,
|
||||||
/// <param name="GlobalRoom">The engine discovers which Global room is live and writes its prefix as the pattern.</param>
|
/// <param name="GlobalRoom">The engine discovers which Global room is live and writes its prefix as the pattern.</param>
|
||||||
internal sealed record ServerChatRule(string Action, string When, string Mode, string Pattern, bool GlobalRoom = false);
|
internal sealed record ServerChatRule(string Action, string When, string Mode, string Pattern, bool GlobalRoom = false);
|
||||||
|
|
||||||
|
/// <summary>The cross-world network a chat tab fronts: "dereth" with the server command that joins and sends (without the slash).</summary>
|
||||||
|
internal sealed record ServerChatNetwork(string Kind, string Command);
|
||||||
|
|
||||||
/// <summary>A default chat tab the server declares: a named tab with its rules, optionally pinned.</summary>
|
/// <summary>A default chat tab the server declares: a named tab with its rules, optionally pinned.</summary>
|
||||||
/// <param name="Id">Stable id within this server (lowercase letters, digits, dashes); owns the tab's rules.</param>
|
/// <param name="Id">Stable id within this server (lowercase letters, digits, dashes); owns the tab's rules.</param>
|
||||||
/// <param name="GlobalRoomFallback">The Global room used until one is discovered: "General", "Trade", "LFG" or "Roleplay".</param>
|
/// <param name="GlobalRoomFallback">The Global room used until one is discovered: "General", "Trade", "LFG" or "Roleplay".</param>
|
||||||
internal sealed record ServerChatTab(string Id, string Name, bool Pinned, string GlobalRoomFallback, ServerChatRule[] Rules);
|
/// <param name="Network">The network the tab fronts (join, status and sends go through its command); null = none.</param>
|
||||||
|
internal sealed record ServerChatTab(string Id, string Name, bool Pinned, string GlobalRoomFallback, ServerChatRule[] Rules,
|
||||||
|
ServerChatNetwork? Network = null);
|
||||||
|
|
||||||
internal sealed class ServerPackInfo
|
internal sealed class ServerPackInfo
|
||||||
{
|
{
|
||||||
|
|
|
||||||
|
|
@ -228,7 +228,10 @@ internal sealed class ServerPackModel
|
||||||
sb.Append(",\"pattern\":").Append(Q(rule.Pattern));
|
sb.Append(",\"pattern\":").Append(Q(rule.Pattern));
|
||||||
sb.Append(",\"globalRoom\":").Append(rule.GlobalRoom ? "true" : "false").Append('}');
|
sb.Append(",\"globalRoom\":").Append(rule.GlobalRoom ? "true" : "false").Append('}');
|
||||||
}
|
}
|
||||||
sb.Append("]}");
|
sb.Append(']');
|
||||||
|
if (tab.Network != null)
|
||||||
|
sb.Append(",\"network\":{\"kind\":").Append(Q(tab.Network.Kind)).Append(",\"command\":").Append(Q(tab.Network.Command)).Append('}');
|
||||||
|
sb.Append('}');
|
||||||
}
|
}
|
||||||
sb.Append(']');
|
sb.Append(']');
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -247,7 +247,7 @@ internal static class ServerPackModelTests
|
||||||
new ServerChatRule("copy", "type:3", "", TellIn),
|
new ServerChatRule("copy", "type:3", "", TellIn),
|
||||||
new ServerChatRule("copy", "type:4", "", TellOut),
|
new ServerChatRule("copy", "type:4", "", TellOut),
|
||||||
new ServerChatRule("copy", "", "startswith", "", GlobalRoom: true),
|
new ServerChatRule("copy", "", "startswith", "", GlobalRoom: true),
|
||||||
}),
|
}, new ServerChatNetwork("dereth", "derethnetwork")),
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
string json = ServerPackModel.BuildSectionsJson(info, "RynthDreamWeave");
|
string json = ServerPackModel.BuildSectionsJson(info, "RynthDreamWeave");
|
||||||
|
|
@ -272,6 +272,20 @@ internal static class ServerPackModelTests
|
||||||
Check.Eq(t.Rules[2].Mode, "startswith", "global mode");
|
Check.Eq(t.Rules[2].Mode, "startswith", "global mode");
|
||||||
Check.Eq(t.Rules[2].Pattern, string.Empty, "global pattern empty");
|
Check.Eq(t.Rules[2].Pattern, string.Empty, "global pattern empty");
|
||||||
|
|
||||||
|
Check.True(t.Network != null, "network parsed");
|
||||||
|
Check.Eq(t.Network!.Kind, "dereth", "network kind");
|
||||||
|
Check.Eq(t.Network.Command, "derethnetwork", "network command");
|
||||||
|
Check.True(json.Contains("\"network\":{\"kind\":\"dereth\",\"command\":\"derethnetwork\"}"), "network key written");
|
||||||
|
|
||||||
|
// An entry without a network emits no network key.
|
||||||
|
ServerPackInfo plain = new("dreamweave", "DreamWeave", new[] { "play.example" }, new[] { "DreamWeave" })
|
||||||
|
{
|
||||||
|
ChatTabs = new[] { new ServerChatTab("t", "T", false, "General", new[] { new ServerChatRule("copy", "", "startswith", "x") }) },
|
||||||
|
};
|
||||||
|
string plainJson = ServerPackModel.BuildSectionsJson(plain, "RynthDreamWeave");
|
||||||
|
Check.False(plainJson.Contains("\"network\""), "no network key without a network");
|
||||||
|
Check.True(SectionManifestParser.Parse("RynthDreamWeave", plainJson, out string e2).ChatTabs[0].Network == null && e2 == string.Empty, "no network parsed: " + e2);
|
||||||
|
|
||||||
// A pack without chat tabs emits no key.
|
// A pack without chat tabs emits no key.
|
||||||
Check.False(ServerPackModel.BuildSectionsJson(Coldeve(), "RynthColdeve").Contains("chatTabs"), "no chatTabs key by default");
|
Check.False(ServerPackModel.BuildSectionsJson(Coldeve(), "RynthColdeve").Contains("chatTabs"), "no chatTabs key by default");
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue