Sections manifest: an absent globalRoomFallback means Roleplay
The Dereth Network README names Roleplay as the room a world usually borrows for the Global room, so an entry that leaves the fallback out matches Roleplay until chat shows another room. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
parent
a92b282fd6
commit
01f432d745
2 changed files with 5 additions and 2 deletions
|
|
@ -68,7 +68,8 @@
|
||||||
// "pattern": "...", "globalRoom": false } ] } ].
|
// "pattern": "...", "globalRoom": false } ] } ].
|
||||||
// "server" and "id" are ids (the owner key is "server/id"); "action" is copy
|
// "server" and "id" are ids (the owner key is "server/id"); "action" is copy
|
||||||
// or move; "globalRoomFallback" is General, Trade, LFG or Roleplay (the
|
// or move; "globalRoomFallback" is General, Trade, LFG or Roleplay (the
|
||||||
// room a "globalRoom": true rule matches until chat shows another). An
|
// room a "globalRoom": true rule matches until chat shows another; absent:
|
||||||
|
// Roleplay, the room the Dereth Network README names as usual). An
|
||||||
// entry with a bad field is dropped and reported in the parse error (the
|
// entry with a bad field is dropped and reported in the parse error (the
|
||||||
// other keys still parse); at most MaxChatTabs entries of MaxChatRules
|
// other keys still parse); at most MaxChatTabs entries of MaxChatRules
|
||||||
// rules each. Engines before this ignore the key.
|
// rules each. Engines before this ignore the key.
|
||||||
|
|
@ -341,7 +342,7 @@ internal static class SectionManifestParser
|
||||||
string name = Text(Str(e, "name"), MaxLabelLength);
|
string name = Text(Str(e, "name"), MaxLabelLength);
|
||||||
if (name.Length == 0) { why = "missing name"; return null; }
|
if (name.Length == 0) { why = "missing name"; return null; }
|
||||||
string fallback = Str(e, "globalRoomFallback").Trim();
|
string fallback = Str(e, "globalRoomFallback").Trim();
|
||||||
string room = fallback.Length == 0 ? "General" : GlobalRooms.FirstOrDefault(r => r.Equals(fallback, StringComparison.OrdinalIgnoreCase)) ?? string.Empty;
|
string room = fallback.Length == 0 ? "Roleplay" : GlobalRooms.FirstOrDefault(r => r.Equals(fallback, StringComparison.OrdinalIgnoreCase)) ?? string.Empty;
|
||||||
if (room.Length == 0) { why = "globalRoomFallback is not General, Trade, LFG or Roleplay"; return null; }
|
if (room.Length == 0) { why = "globalRoomFallback is not General, Trade, LFG or Roleplay"; return null; }
|
||||||
var rules = new List<SectionChatRuleDecl>();
|
var rules = new List<SectionChatRuleDecl>();
|
||||||
foreach (JsonElement r in Array(e, "rules"))
|
foreach (JsonElement r in Array(e, "rules"))
|
||||||
|
|
|
||||||
|
|
@ -613,6 +613,8 @@ internal static class Program
|
||||||
Check(t.Rules[0].Action == "copy" && t.Rules[0].When == "type:3" && t.Rules[0].Pattern == "^x" && !t.Rules[0].GlobalRoom, "rule 0 fields");
|
Check(t.Rules[0].Action == "copy" && t.Rules[0].When == "type:3" && t.Rules[0].Pattern == "^x" && !t.Rules[0].GlobalRoom, "rule 0 fields");
|
||||||
|
|
||||||
Check(SectionManifestParser.Parse("DW", """{ "contributions": [] }""", out _).ChatTabs.Length == 0, "no chatTabs key = empty array");
|
Check(SectionManifestParser.Parse("DW", """{ "contributions": [] }""", out _).ChatTabs.Length == 0, "no chatTabs key = empty array");
|
||||||
|
var noFallback = SectionManifestParser.Parse("DW", """{ "chatTabs": [ { "server": "dw", "id": "a", "name": "A", "rules": [] } ] }""", out _);
|
||||||
|
Check(noFallback.ChatTabs.Length == 1 && noFallback.ChatTabs[0].GlobalRoomFallback == "Roleplay", "absent globalRoomFallback = Roleplay");
|
||||||
|
|
||||||
// Each reject drops the entry, reports it in error, and still parses the other keys.
|
// Each reject drops the entry, reports it in error, and still parses the other keys.
|
||||||
string section = """ "sections": [ { "id": "quests", "label": "Quests", "order": 150 } ] """;
|
string section = """ "sections": [ { "id": "quests", "label": "Quests", "order": 150 } ] """;
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue