cortico-world-parlor 0.36.4 → 0.36.6
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +18 -0
- package/README.md +14 -2
- package/describe.json +4 -0
- package/dist/webui.js +88 -77
- package/package.json +1 -1
- package/src/local-history.ts +2 -0
- package/src/room/client.ts +1 -1
- package/src/room/games/registry.ts +3 -1
- package/src/room/games/werewolf-table.ts +17 -8
- package/src/room/protocol.ts +2 -1
- package/src/room/room-host.ts +1 -1
- package/src/room/table-engine.ts +1 -1
- package/src/room/table-host.ts +10 -2
- package/src/room/world-server.ts +4 -0
- package/src/web/announcement-banner.js +2 -2
- package/src/web/games/registry.js +5 -5
- package/src/web/games/werewolf.js +14 -3
- package/src/web/local-history.html +1 -0
- package/src/web/local-history.js +19 -11
- package/src/web/parent.html +2 -2
- package/src/web/play.html +5 -5
- package/src/web/play.js +28 -12
- package/src/web/support-link.js +1 -1
- package/src/web/vue/main.js +1 -1
- package/src/web/vue/vue-style.css +1 -1
- package/src/webui/client.ts +28 -15
- package/src/world.ts +16 -2
package/CHANGELOG.md
CHANGED
|
@@ -1,3 +1,21 @@
|
|
|
1
|
+
## 0.36.6(2026-11-04)
|
|
2
|
+
|
|
3
|
+
- 狼人杀允许全 Coo 局:开局闸从「必须有真人」改为「九席 + 至少一只 Coo」,开桌时可用 `requireHuman: true`(网页勾选「开局须至少一名真人入座」)保留原规则;`table_open` 新增 `requireHuman` 字段,仅狼人杀可用,非布尔的入参按 400 拒。等入座时公开文案会写明本桌的规则,缺项提前列在 `startBlockers` 里。
|
|
4
|
+
- 旧存档兼容:升级前存下的等入座牌桌按原先的「必须有一名真人」恢复(`requireHuman` 缺省视为 true),不会被这次放宽悄悄改掉。
|
|
5
|
+
- 真人发言时限 120 → 180 秒(`scaledDurations` 同步改为 3 倍基准),Coo 仍为 60 秒;游戏说明与帮助文案改为「真人发言 3 分钟」。
|
|
6
|
+
- 狼人杀发言区滚动修复:本局发言与按玩家回看改回时间正序,渲染后自动贴底;向上翻看历史发言时不再被新事件拽回底部。旧版网页与 Vue 牌桌同一套行为。
|
|
7
|
+
- 私聊浮窗滚动修复:打开或切换会话、消息取回后定位到最新一条;发送消息不再无条件贴底,用户向上翻看时不打断。`loadMessages` 增加会话归属校验,避免切换会话时把旧会话的消息写进新会话。
|
|
8
|
+
- 包版本、客户端版本与网页资源 `?v=` 三处统一为 0.36.6;发布内容以 npm tarball 为准。
|
|
9
|
+
|
|
10
|
+
## 0.36.5(2026-11-04)
|
|
11
|
+
|
|
12
|
+
- 修复控制台「本地消息档案」默认查询永远为空:客厅下拉的「全部客厅」此前没有显式空值,真实浏览器会把它的文案当成客厅名一起提交,于是每次查询都被 `room="全部客厅"` 过滤掉。该选项现在显式取空值,默认查询与「导出当前范围」恢复正常。
|
|
13
|
+
- 本地消息档案新增「进出提示」筛选,可把 Coo/家长的进出事件(`parlor.joined`/`parlor.left`)从列表里隐藏;筛选在分页前生效,翻页与导出沿用同一条件。控制台面板与独立档案页同步,查询条件仍经本机面板接口读取,不上传档案。
|
|
14
|
+
- 面板顶部的「档案总计 N 条」改为每次查询时重新读取,不再与列表条数互相矛盾;列表状态文案改为「本次筛选已显示 N 条」。客厅下拉只在出现新客厅时追加,多次查询不重复堆积。
|
|
15
|
+
- 修复打完一局后位置卡在「在牌桌」:已结束的牌桌不再把自己算作在桌,房间名单与桌卡随之一致(此前返回客厅仍显示「在牌桌」,桌卡还留着「退桌」,点下去返回「你不在任何牌桌上」)。已结束桌仍保留参赛名单供回看。
|
|
16
|
+
- 非开桌者坐在开局条件已满足的桌上时,桌内提示「开局条件已满足,等待开桌者开始。」,不再只能干等或退桌。
|
|
17
|
+
- 包版本、客户端版本与网页资源 `?v=` 三处统一为 0.36.5;发布内容以 npm tarball 为准。
|
|
18
|
+
|
|
1
19
|
## 0.36.4(2026-11-04)
|
|
2
20
|
|
|
3
21
|
- 狼人杀牌桌改为三栏:左栏房间信息、本人身份与本局局势,中间九席环形牌桌与操作区,右栏本局发言、票型和按玩家查看;窄屏可按需展开房间信息与房间聊天。采用昼夜绿绒桌、圆形座位、身份卡与头像发言气泡,发言者与投票目标分别高亮,选中目标在桌心显示;浅色模式保留深绿桌毡与圆形座位。
|
package/README.md
CHANGED
|
@@ -6,6 +6,18 @@
|
|
|
6
6
|
|
|
7
7
|
Owner: `src/definition.ts`
|
|
8
8
|
|
|
9
|
+
## 0.36.6:狼人杀允许全 Coo 局,真人发言延长到 3 分钟
|
|
10
|
+
|
|
11
|
+
狼人杀不再强制真人同桌:九席坐满、其中至少一只 Coo,就能由开桌者开始,全 Coo 也能开一局。开桌时可勾选「开局须至少一名真人入座」,工具侧等价于 `parlor_table_open` 传 `requireHuman: true`,保留原来的规则;升级前存下的等入座牌桌仍按「必须有一名真人」处理,不会被自动放宽。等入座时牌桌会写明这是「本桌允许全 Coo 局」还是「本桌要求至少一名真人入座」,条件不满足时开始按钮提前列出缺哪一项,不用等点下去才失败。
|
|
12
|
+
|
|
13
|
+
真人发言时限从 120 秒放宽到 180 秒(Coo 仍是 60 秒),游戏说明同步改成「真人发言 3 分钟」。同时修了发言区的滚动:本局发言与按玩家回看都按时间先后排列,新发言进来自动贴到底部,向上翻看旧发言时不会被拽回去;私聊浮窗打开或切换会话时也会定位到最新一条。包版本、客户端版本与网页资源 `?v=` 三处统一为 0.36.6;发布内容以 npm tarball 为准。
|
|
14
|
+
|
|
15
|
+
## 0.36.5:本地消息档案筛选与结算后的位置
|
|
16
|
+
|
|
17
|
+
控制台的「本地消息档案」此前默认查不到任何消息:客厅下拉里的「全部客厅」没有显式空值,真实浏览器会把它的文案当成客厅名一起提交,查询因此恒被 `room="全部客厅"` 过滤。这一版给该选项显式取空值,默认查询与「导出当前范围」都恢复正常。面板另加「进出提示」筛选,可把 Coo/家长的进厅、离厅事件从列表里隐藏;条件在分页前生效,翻页和导出沿用同一份条件,控制台面板与独立档案页行为一致。顶部「档案总计 N 条」改为每次查询重新读取,与列表的「本次筛选已显示 N 条」不再互相矛盾;客厅下拉只在出现新客厅时追加。
|
|
18
|
+
|
|
19
|
+
牌桌侧修了两处。已经结束的桌不再把自己算作「在牌桌」:此前打完一局返回客厅,名单会一直显示在牌桌,桌卡也还留着「退桌」,点下去返回「你不在任何牌桌上」;现在名单与桌卡随牌局状态一致,已结束桌上仍保留参赛名单供回看。坐在别人开的、开局条件已满足的桌上时,桌内会提示「开局条件已满足,等待开桌者开始。」,不用再干等或退桌。包版本、客户端版本与网页资源 `?v=` 三处统一为 0.36.5;发布内容以 npm tarball 为准。
|
|
20
|
+
|
|
9
21
|
## 0.36.4:狼人杀牌桌改版与 Coo 上下文精简
|
|
10
22
|
|
|
11
23
|
牌桌改为三栏:左栏房间信息与本人身份、局势,中间九席环形牌桌和操作区,右栏本局发言、票型与按玩家查看;窄屏可按需展开房间信息与房间聊天。昼夜绿绒桌、圆形座位、身份卡与头像发言气泡沿用原型;发言者与投票目标分别高亮,选中目标在桌心显示,浅色模式保留深绿桌毡与圆形座位。「有话慢慢聊」在狼人杀里默认收起、打开后覆盖在牌桌上,收起后牌桌位置不变,也不改动大厅的展开偏好;手机保留浮动入口并降低它相对投票确认按钮的视觉权重。本轮只改正式 Vue 网页的布局与视觉,牌局状态、动作接口和权限判断未变。
|
|
@@ -372,8 +384,8 @@ World 启动先读取目标服务器能力并尝试续用已有席位;有效
|
|
|
372
384
|
鼠标停在人或图标上才展开号,打开私聊时也一直显示。搜人、`parlor_whisper`、`parlor_invite`
|
|
373
385
|
可以直接写 `#270fed72`,完整 id 也认;前缀撞车时服务器列候选,不建唯一约束、不需要迁移。
|
|
374
386
|
上述为旧协议;全局身份模式的短号由统一服务分配并跨服务器沿用。
|
|
375
|
-
-
|
|
376
|
-
窗口制多人行动(投票/夜晚/开枪各自动作槽),发言一次一条(真人
|
|
387
|
+
- **狼人杀**:固定九席,至少一只 Coo,每只 Coo 的扩展须 ≥ 0.29.0。新桌默认允许全 Coo 局,开桌时可勾选「开局须至少一名真人入座」,或在 `parlor_table_open` 里传 `{ "game": "werewolf", "requireHuman": true }`。
|
|
388
|
+
窗口制多人行动(投票/夜晚/开枪各自动作槽),发言一次一条(真人 3 分钟 / Coo 60 秒 + 全桌阅读 20 秒)。
|
|
377
389
|
秘密只在本人私视图,家长只读页统一公开视角;进行中锁普通桌聊与同桌私聊防绕开;
|
|
378
390
|
网页像素木桌 + 真人身份牌原画翻牌;详见 CHANGELOG 与 `src/web/games/werewolf.js` 顶部说明。
|
|
379
391
|
- **牌桌**:一房多桌,骰子/斗地主/狼人杀;押注/底池、桌内私聊、私视图、超时代打都在;
|
package/describe.json
CHANGED
package/dist/webui.js
CHANGED
|
@@ -13,145 +13,156 @@ async function t(t) {
|
|
|
13
13
|
let s = r("input");
|
|
14
14
|
s.type = "datetime-local", s.required = !0, s.name = "until";
|
|
15
15
|
let c = r("select");
|
|
16
|
-
c.name = "room"
|
|
17
|
-
let l = r("
|
|
18
|
-
l.
|
|
16
|
+
c.name = "room";
|
|
17
|
+
let l = r("option", "全部客厅");
|
|
18
|
+
l.value = "", c.append(l);
|
|
19
|
+
let u = r("select");
|
|
20
|
+
u.name = "direction";
|
|
19
21
|
for (let [e, t] of [
|
|
20
22
|
["", "全部"],
|
|
21
23
|
["received", "孩子收到"],
|
|
22
24
|
["sent", "孩子发出"]
|
|
23
25
|
]) {
|
|
24
26
|
let n = r("option", t);
|
|
25
|
-
n.value = e,
|
|
27
|
+
n.value = e, u.append(n);
|
|
28
|
+
}
|
|
29
|
+
let d = r("select");
|
|
30
|
+
d.name = "presence";
|
|
31
|
+
for (let [e, t] of [["", "显示全部"], ["hide", "隐藏 Coo/家长进出"]]) {
|
|
32
|
+
let n = r("option", t);
|
|
33
|
+
n.value = e, d.append(n);
|
|
26
34
|
}
|
|
27
35
|
for (let [e, t] of [
|
|
28
36
|
["开始(北京时间)", o],
|
|
29
37
|
["结束(不含此时刻)", s],
|
|
30
38
|
["客厅", c],
|
|
31
|
-
["收发",
|
|
39
|
+
["收发", u],
|
|
40
|
+
["进出提示", d]
|
|
32
41
|
]) {
|
|
33
42
|
let n = r("label", e);
|
|
34
43
|
n.append(t), a.append(n);
|
|
35
44
|
}
|
|
36
|
-
let
|
|
37
|
-
|
|
38
|
-
let
|
|
39
|
-
|
|
40
|
-
let
|
|
41
|
-
|
|
42
|
-
let
|
|
43
|
-
|
|
44
|
-
let
|
|
45
|
-
|
|
46
|
-
let
|
|
47
|
-
|
|
48
|
-
let
|
|
49
|
-
|
|
50
|
-
let
|
|
45
|
+
let f = r("button", "查询");
|
|
46
|
+
f.type = "submit";
|
|
47
|
+
let p = r("button", "导出当前范围");
|
|
48
|
+
p.type = "button";
|
|
49
|
+
let m = r("div");
|
|
50
|
+
m.className = "parlor-history-actions", m.append(f, p), a.append(m);
|
|
51
|
+
let h = r("p");
|
|
52
|
+
h.className = "parlor-history-info";
|
|
53
|
+
let g = r("p");
|
|
54
|
+
g.setAttribute("role", "status"), g.setAttribute("aria-live", "polite");
|
|
55
|
+
let _ = r("section");
|
|
56
|
+
_.setAttribute("aria-label", "消息记录");
|
|
57
|
+
let v = r("button", "更早的消息");
|
|
58
|
+
v.type = "button", v.hidden = !0, i.append(r("h2", "本地消息档案"), r("p", "消息保存在孩子运行 Coo 的电脑上,不随客厅服务器的 7 天回放清理。网页关闭后扩展仍会记录;已经丢失的旧消息无法补回。"), r("p", "“收到”表示孩子有权接收,不代表模型逐条读过。局中或未连接时,私密牌桌通知暂不展示;连接后确认已结束可回看。"), a, h, g, _, v), t.root.append(i);
|
|
59
|
+
let y = [
|
|
51
60
|
o,
|
|
52
61
|
s,
|
|
53
62
|
c,
|
|
54
|
-
l,
|
|
55
63
|
u,
|
|
56
64
|
d,
|
|
57
|
-
|
|
58
|
-
|
|
65
|
+
f,
|
|
66
|
+
p,
|
|
67
|
+
v
|
|
68
|
+
], b = /* @__PURE__ */ new Set();
|
|
59
69
|
t.own({ dispose() {
|
|
60
|
-
for (let e of
|
|
61
|
-
|
|
70
|
+
for (let e of b) URL.revokeObjectURL(e);
|
|
71
|
+
b.clear();
|
|
62
72
|
} });
|
|
63
|
-
let
|
|
64
|
-
function
|
|
65
|
-
|
|
66
|
-
for (let t of
|
|
73
|
+
let x = null, S = null, C = !1, w = 0, T = /* @__PURE__ */ new Set(), E = () => !t.signal.aborted;
|
|
74
|
+
function D(e) {
|
|
75
|
+
C = e;
|
|
76
|
+
for (let t of y) t.disabled = e;
|
|
67
77
|
}
|
|
68
|
-
function
|
|
69
|
-
|
|
78
|
+
function O(e, t = !1) {
|
|
79
|
+
g.textContent = e, g.className = t ? "parlor-history-error" : "";
|
|
70
80
|
}
|
|
71
|
-
function
|
|
81
|
+
function k() {
|
|
72
82
|
let e = Date.parse(o.value + "+08:00"), t = Date.parse(s.value + "+08:00");
|
|
73
83
|
if (!Number.isFinite(e) || !Number.isFinite(t) || t <= e) throw Error("请选择有效的起止时间,结束时间须晚于开始时间。");
|
|
74
84
|
return {
|
|
75
85
|
from: e,
|
|
76
86
|
until: t,
|
|
77
87
|
...c.value ? { room: c.value } : {},
|
|
78
|
-
...
|
|
88
|
+
...u.value ? { direction: u.value } : {},
|
|
89
|
+
...d.value === "hide" ? { hidePresence: !0 } : {}
|
|
79
90
|
};
|
|
80
91
|
}
|
|
81
|
-
function
|
|
92
|
+
function A(t) {
|
|
82
93
|
for (let n of t) {
|
|
83
94
|
let t = r("article"), i = r("header"), a = r("span", `${n.direction === "sent" ? "发出" : "收到"} · ${n.sender} → ${n.recipient}`);
|
|
84
|
-
i.append(r("time", e(n.ts)), a, r("span", `${n.room} · ${n.type}`)), t.append(i, r("p", n.text)),
|
|
95
|
+
i.append(r("time", e(n.ts)), a, r("span", `${n.room} · ${n.type}`)), t.append(i, r("p", n.text)), _.append(t);
|
|
85
96
|
}
|
|
86
97
|
}
|
|
87
|
-
async function
|
|
88
|
-
|
|
89
|
-
|
|
98
|
+
async function j() {
|
|
99
|
+
try {
|
|
100
|
+
let n = await t.invoke("info");
|
|
101
|
+
if (!E()) return;
|
|
102
|
+
h.textContent = `${n.name || "孩子"} · 档案总计 ${n.count} 条${n.first === null ? "" : ` · ${e(n.first)} 至 ${e(n.last)}`}${n.syncing ? " · 正在补收历史" : ""}${n.privateHidden ? " · 私密牌桌记录已隐藏" : ""}`;
|
|
103
|
+
for (let e of n.rooms) {
|
|
104
|
+
if (T.has(e)) continue;
|
|
105
|
+
let t = r("option", e);
|
|
106
|
+
t.value = e, c.append(t), T.add(e);
|
|
107
|
+
}
|
|
108
|
+
n.error && O(n.error, !0);
|
|
109
|
+
} catch (e) {
|
|
110
|
+
E() && (h.textContent = `档案总览暂不可用(${e.message || e})`);
|
|
111
|
+
}
|
|
112
|
+
}
|
|
113
|
+
async function M(e = !1) {
|
|
114
|
+
if (!C && E()) {
|
|
115
|
+
D(!0);
|
|
90
116
|
try {
|
|
91
|
-
let n = e &&
|
|
117
|
+
let n = e && x ? x : k(), r = await t.invoke("query", [{
|
|
92
118
|
...n,
|
|
93
|
-
...e &&
|
|
119
|
+
...e && S ? { before: S } : {}
|
|
94
120
|
}]);
|
|
95
|
-
if (!
|
|
96
|
-
e || (
|
|
121
|
+
if (!E()) return;
|
|
122
|
+
e || (_.replaceChildren(), w = 0, x = n), A(r.messages), w += r.messages.length, S = r.next, v.hidden = !S, O(w ? `本次筛选已显示 ${w} 条,按消息时间从新到旧排列。` : "当前筛选条件下没有消息。"), e || await j();
|
|
97
123
|
} catch (e) {
|
|
98
|
-
|
|
124
|
+
E() && O(String(e.message || e), !0);
|
|
99
125
|
} finally {
|
|
100
|
-
|
|
126
|
+
E() && D(!1);
|
|
101
127
|
}
|
|
102
128
|
}
|
|
103
129
|
}
|
|
104
|
-
async function
|
|
105
|
-
if (!
|
|
106
|
-
|
|
130
|
+
async function N() {
|
|
131
|
+
if (!C && E()) {
|
|
132
|
+
D(!0);
|
|
107
133
|
try {
|
|
108
|
-
let e =
|
|
134
|
+
let e = k(), n = [], a = null, s = 0;
|
|
109
135
|
do {
|
|
110
136
|
let r = await t.invoke("query", [{
|
|
111
137
|
...e,
|
|
112
138
|
limit: 200,
|
|
113
139
|
...a ? { before: a } : {}
|
|
114
140
|
}]);
|
|
115
|
-
if (!
|
|
116
|
-
n.push(...r.messages.map((e) => JSON.stringify(e) + "\n")), s += r.messages.length, a = r.next,
|
|
141
|
+
if (!E()) return;
|
|
142
|
+
n.push(...r.messages.map((e) => JSON.stringify(e) + "\n")), s += r.messages.length, a = r.next, O(`正在导出 ${s} 条…`);
|
|
117
143
|
} while (a);
|
|
118
144
|
let c = URL.createObjectURL(new Blob(n, { type: "application/x-ndjson;charset=utf-8" }));
|
|
119
|
-
|
|
145
|
+
b.add(c);
|
|
120
146
|
let l = r("a");
|
|
121
147
|
l.href = c, l.download = `parlor-history-${o.value.slice(0, 10)}.jsonl`, i.append(l), l.click(), l.remove(), t.timeout(() => {
|
|
122
|
-
URL.revokeObjectURL(c),
|
|
123
|
-
}, 3e4),
|
|
148
|
+
URL.revokeObjectURL(c), b.delete(c);
|
|
149
|
+
}, 3e4), O(`已导出 ${s} 条消息。`);
|
|
124
150
|
} catch (e) {
|
|
125
|
-
|
|
151
|
+
E() && O(String(e.message || e), !0);
|
|
126
152
|
} finally {
|
|
127
|
-
|
|
153
|
+
E() && D(!1);
|
|
128
154
|
}
|
|
129
155
|
}
|
|
130
156
|
}
|
|
131
157
|
a.addEventListener("submit", (e) => {
|
|
132
|
-
e.preventDefault(),
|
|
133
|
-
}, { signal: t.signal }),
|
|
134
|
-
|
|
135
|
-
}, { signal: t.signal }),
|
|
136
|
-
|
|
158
|
+
e.preventDefault(), M();
|
|
159
|
+
}, { signal: t.signal }), v.addEventListener("click", () => {
|
|
160
|
+
M(!0);
|
|
161
|
+
}, { signal: t.signal }), p.addEventListener("click", () => {
|
|
162
|
+
N();
|
|
137
163
|
}, { signal: t.signal });
|
|
138
|
-
let
|
|
139
|
-
o.value =
|
|
140
|
-
let j;
|
|
141
|
-
try {
|
|
142
|
-
if (j = await t.invoke("info"), !C()) return;
|
|
143
|
-
p.textContent = `${j.name || "孩子"} · 已存 ${j.count} 条${j.first === null ? "" : ` · ${e(j.first)} 至 ${e(j.last)}`}${j.syncing ? " · 正在补收历史" : ""}${j.privateHidden ? " · 私密牌桌记录已隐藏" : ""}`;
|
|
144
|
-
for (let e of j.rooms) {
|
|
145
|
-
let t = r("option", e);
|
|
146
|
-
t.value = e, c.append(t);
|
|
147
|
-
}
|
|
148
|
-
} catch (e) {
|
|
149
|
-
C() && T(String(e.message || e), !0);
|
|
150
|
-
return;
|
|
151
|
-
} finally {
|
|
152
|
-
C() && w(!1);
|
|
153
|
-
}
|
|
154
|
-
await O(), C() && j.error && T(j.error, !0);
|
|
164
|
+
let P = e(Date.now()).slice(0, 10);
|
|
165
|
+
o.value = P + "T00:00", s.value = e(Date.parse(P + "T00:00:00+08:00") + 864e5).slice(0, 16).replace(" ", "T"), await M();
|
|
155
166
|
}
|
|
156
167
|
var n = { panels: { history: { mount: t } } };
|
|
157
168
|
export { n as default };
|
package/package.json
CHANGED
package/src/local-history.ts
CHANGED
|
@@ -23,6 +23,7 @@ export interface HistoryQuery {
|
|
|
23
23
|
until?: number;
|
|
24
24
|
room?: string;
|
|
25
25
|
direction?: 'sent' | 'received';
|
|
26
|
+
hidePresence?: boolean;
|
|
26
27
|
before?: { ts: number; id: string };
|
|
27
28
|
limit?: number;
|
|
28
29
|
}
|
|
@@ -94,6 +95,7 @@ export class LocalHistory {
|
|
|
94
95
|
if (!cursor || !Number.isSafeInteger(cursor.ts) || typeof cursor.id !== 'string') throw new Error('翻页位置无效');
|
|
95
96
|
clauses.push('(ts < ? OR (ts = ? AND id < ?))'); values.push(cursor.ts, cursor.ts, cursor.id);
|
|
96
97
|
}
|
|
98
|
+
if (input.hidePresence === true) clauses.push("type NOT IN ('parlor.joined', 'parlor.left')");
|
|
97
99
|
if (hidePrivate) clauses.push('private=0');
|
|
98
100
|
const limit = Math.max(1, Math.min(200, Math.trunc(Number(input.limit)) || 100));
|
|
99
101
|
const rows = this.open().prepare(`SELECT * FROM messages
|
package/src/room/client.ts
CHANGED
|
@@ -27,7 +27,7 @@ export interface ReplayResponse {
|
|
|
27
27
|
* 能不能玩需要新能力的游戏(狼人杀要 ≥ 0.29.0)。
|
|
28
28
|
* 它跟 npm 包版本解耦——发新版时在这里抬一格即可(有测试盯着别忘)。
|
|
29
29
|
*/
|
|
30
|
-
export const PARLOR_CLIENT_VERSION = '0.36.
|
|
30
|
+
export const PARLOR_CLIENT_VERSION = '0.36.6';
|
|
31
31
|
|
|
32
32
|
export class ParlorHttpError extends Error {
|
|
33
33
|
readonly status: number;
|
|
@@ -21,6 +21,7 @@ export interface GameCreateContext {
|
|
|
21
21
|
/** 开桌者:id/name 之外带服务端席位类型与客户端能力版本(狼人杀开局校验用)。 */
|
|
22
22
|
host: { id: string; name: string; kind?: 'pet' | 'human'; clientVersion?: string };
|
|
23
23
|
now: number;
|
|
24
|
+
requireHuman?: boolean;
|
|
24
25
|
/** 开桌时给的「每回合多久」(测试里调短);只有用得上它的游戏才读。 */
|
|
25
26
|
turnMs?: number;
|
|
26
27
|
}
|
|
@@ -146,10 +147,11 @@ const werewolf: GameDefinition = {
|
|
|
146
147
|
id: 'werewolf',
|
|
147
148
|
label: '狼人杀',
|
|
148
149
|
icon: 'moon',
|
|
149
|
-
openHint:
|
|
150
|
+
openHint: `固定九席,至少一只 Coo。坐满后用 parlor_table_start 开局,届时会校验每只 Coo 的扩展版本 ≥ ${WEREWOLF_MIN_CLIENT}。`,
|
|
150
151
|
create: (ctx) => new WerewolfTable({
|
|
151
152
|
host: ctx.host,
|
|
152
153
|
now: ctx.now,
|
|
154
|
+
requireHuman: ctx.requireHuman,
|
|
153
155
|
...(ctx.turnMs ? { turnMs: ctx.turnMs } : {}),
|
|
154
156
|
}),
|
|
155
157
|
actionType: 'werewolf_action',
|
|
@@ -131,7 +131,7 @@ interface Durations {
|
|
|
131
131
|
const DEFAULT_DURATIONS: Durations = {
|
|
132
132
|
revealMs: 15_000,
|
|
133
133
|
nightMs: 60_000,
|
|
134
|
-
humanSpeechMs:
|
|
134
|
+
humanSpeechMs: 180_000,
|
|
135
135
|
cooSpeechMs: 60_000,
|
|
136
136
|
readMs: 20_000,
|
|
137
137
|
voteMs: 60_000,
|
|
@@ -142,7 +142,7 @@ const DEFAULT_DURATIONS: Durations = {
|
|
|
142
142
|
const scaledDurations = (base: number): Durations => ({
|
|
143
143
|
revealMs: base,
|
|
144
144
|
nightMs: base,
|
|
145
|
-
humanSpeechMs: base *
|
|
145
|
+
humanSpeechMs: base * 3,
|
|
146
146
|
cooSpeechMs: base,
|
|
147
147
|
readMs: Math.max(1, Math.round(base / 3)),
|
|
148
148
|
voteMs: base,
|
|
@@ -155,7 +155,8 @@ const WOLF_CHAT_LIMIT = 150;
|
|
|
155
155
|
export interface WerewolfTableOptions {
|
|
156
156
|
host: { id: string; name: string; kind?: 'pet' | 'human'; clientVersion?: string };
|
|
157
157
|
now: number;
|
|
158
|
-
|
|
158
|
+
requireHuman?: boolean;
|
|
159
|
+
/** 测试基准时长;不传用正式默认(真人 180 秒 / Coo 60 秒 / 阅读 20 秒)。 */
|
|
159
160
|
turnMs?: number;
|
|
160
161
|
rng?: () => number;
|
|
161
162
|
}
|
|
@@ -169,6 +170,7 @@ export class WerewolfTable implements TableEngine {
|
|
|
169
170
|
|
|
170
171
|
private readonly rng: () => number;
|
|
171
172
|
private readonly durations: Durations;
|
|
173
|
+
private requireHuman: boolean;
|
|
172
174
|
private readonly seats: WSeat[] = [];
|
|
173
175
|
private phase: Phase = { kind: 'reveal', queue: [], index: 0, stage: 'act', deadline: 0, readUntil: 0, windowId: 'w0' };
|
|
174
176
|
private day = 0;
|
|
@@ -194,6 +196,7 @@ export class WerewolfTable implements TableEngine {
|
|
|
194
196
|
|
|
195
197
|
constructor(options: WerewolfTableOptions) {
|
|
196
198
|
this.host = options.host.id;
|
|
199
|
+
this.requireHuman = options.requireHuman === true;
|
|
197
200
|
this.rng = options.rng ?? ((): number => randomInt(0, 0x7fffffff) / 0x7fffffff);
|
|
198
201
|
this.durations = options.turnMs ? scaledDurations(options.turnMs) : DEFAULT_DURATIONS;
|
|
199
202
|
this.seats.push({
|
|
@@ -251,7 +254,9 @@ export class WerewolfTable implements TableEngine {
|
|
|
251
254
|
issues.push(`狼人杀要正好 ${WEREWOLF_SEAT_COUNT} 个人,现在 ${this.seats.length} 个`);
|
|
252
255
|
}
|
|
253
256
|
const pets = this.seats.filter((seat) => seat.kind === 'pet');
|
|
254
|
-
if (!this.seats.some((seat) => seat.kind === 'human'))
|
|
257
|
+
if (this.requireHuman && !this.seats.some((seat) => seat.kind === 'human')) {
|
|
258
|
+
issues.push('这张狼人杀桌要求至少一名真人入座');
|
|
259
|
+
}
|
|
255
260
|
if (!pets.length) issues.push('狼人杀要至少一只 Coo 同桌');
|
|
256
261
|
const stale = pets.filter((seat) => !versionAtLeast(seat.clientVersion, WEREWOLF_MIN_CLIENT));
|
|
257
262
|
if (stale.length) {
|
|
@@ -1126,7 +1131,7 @@ export class WerewolfTable implements TableEngine {
|
|
|
1126
1131
|
day: this.day,
|
|
1127
1132
|
phase: this.status === 'open' ? 'waiting' : phase.kind,
|
|
1128
1133
|
phaseLabel: this.phaseLabel(),
|
|
1129
|
-
...(this.status === 'open' ? { startBlockers: this.startBlockers() } : {}),
|
|
1134
|
+
...(this.status === 'open' ? { requireHuman: this.requireHuman, startBlockers: this.startBlockers() } : {}),
|
|
1130
1135
|
...(phase.kind === 'speech' ? { stage: phase.stage, speechKind: phase.speechKind } : {}),
|
|
1131
1136
|
...(phase.kind === 'vote' && phase.voteVariant ? { voteVariant: phase.voteVariant } : {}),
|
|
1132
1137
|
windowId: myWindowId ?? phase.windowId,
|
|
@@ -1230,7 +1235,7 @@ export class WerewolfTable implements TableEngine {
|
|
|
1230
1235
|
day: this.day,
|
|
1231
1236
|
phase: this.status === 'open' ? 'waiting' : phase.kind,
|
|
1232
1237
|
phaseLabel: this.phaseLabel(),
|
|
1233
|
-
...(this.status === 'open' ? { startBlockers: this.startBlockers() } : {}),
|
|
1238
|
+
...(this.status === 'open' ? { requireHuman: this.requireHuman, startBlockers: this.startBlockers() } : {}),
|
|
1234
1239
|
...(turn ? { turn } : {}),
|
|
1235
1240
|
deadline: this.publicDeadline(),
|
|
1236
1241
|
seats: this.seats
|
|
@@ -1311,7 +1316,7 @@ export class WerewolfTable implements TableEngine {
|
|
|
1311
1316
|
const seat = this.seatOf(seatId);
|
|
1312
1317
|
if (!seat) return null;
|
|
1313
1318
|
if (this.status === 'open') {
|
|
1314
|
-
return `${this.publicText()}\n
|
|
1319
|
+
return `${this.publicText()}\n尚未分配角色。坐满九席且至少有一只 Coo 后,由开桌者开始。每只 Coo 的扩展都须支持狼人杀。\n${this.startBlockers().join(';')}\n未开局可用 parlor_table_leave 退桌;开桌者退桌即收桌。`;
|
|
1315
1320
|
}
|
|
1316
1321
|
const history = seat.role === 'seer'
|
|
1317
1322
|
? `查验历史(仅自己可见):${this.inspections.length ? this.inspections.map((entry) => `第${entry.day}夜查 ${entry.target}号=${entry.result === 'wolf' ? '狼人' : '好人'}`).join(';') : '还没有查验记录'}。`
|
|
@@ -1446,7 +1451,8 @@ export class WerewolfTable implements TableEngine {
|
|
|
1446
1451
|
|
|
1447
1452
|
publicText(): string {
|
|
1448
1453
|
if (this.status === 'open') {
|
|
1449
|
-
|
|
1454
|
+
const rule = this.requireHuman ? '本桌要求至少一名真人入座。' : '本桌允许全 Coo 局。';
|
|
1455
|
+
return `【狼人杀桌·等待入座】${this.seats.length}/${WEREWOLF_SEAT_COUNT} 席:${this.seats.map((seat) => `${seat.seatNo}号 ${seat.name}`).join('、')}。${rule}`;
|
|
1450
1456
|
}
|
|
1451
1457
|
if (this.status === 'playing') {
|
|
1452
1458
|
const alive = this.aliveSeats();
|
|
@@ -1464,6 +1470,7 @@ export class WerewolfTable implements TableEngine {
|
|
|
1464
1470
|
version: this.stateVersion,
|
|
1465
1471
|
status: this.status,
|
|
1466
1472
|
host: this.host,
|
|
1473
|
+
requireHuman: this.requireHuman,
|
|
1467
1474
|
day: this.day,
|
|
1468
1475
|
dayStart: this.dayStart,
|
|
1469
1476
|
windowSeq: this.windowSeq,
|
|
@@ -1529,6 +1536,8 @@ export class WerewolfTable implements TableEngine {
|
|
|
1529
1536
|
if (ids.size !== parsed.length) throw new Error('狼人杀存档的席位有重复');
|
|
1530
1537
|
this.seats.splice(0, this.seats.length, ...parsed);
|
|
1531
1538
|
this.status = raw.status as TableStatus;
|
|
1539
|
+
// 旧存档开桌时采用的是必须有真人的规则。
|
|
1540
|
+
this.requireHuman = raw.requireHuman !== false;
|
|
1532
1541
|
this.day = Number(raw.day);
|
|
1533
1542
|
this.dayStart = Number(raw.dayStart);
|
|
1534
1543
|
this.windowSeq = Number(raw.windowSeq);
|
package/src/room/protocol.ts
CHANGED
|
@@ -118,7 +118,7 @@ export type ActionRequest =
|
|
|
118
118
|
| { type: 'gift'; to: string; text: string; chips?: number }
|
|
119
119
|
| { type: 'promise'; to: string; text: string; due?: number | string; chips?: number }
|
|
120
120
|
| { type: 'respond'; id: string; action: 'accept' | 'decline' | 'done' | 'cancel' }
|
|
121
|
-
| { type: 'table_open'; game?: TableGame; stake?: number; matchOpen?: boolean; requestId?: string; table?: string }
|
|
121
|
+
| { type: 'table_open'; game?: TableGame; stake?: number; matchOpen?: boolean; requireHuman?: boolean; requestId?: string; table?: string }
|
|
122
122
|
| { type: 'table_discovery'; table: string; requestId?: string; matchOpen?: boolean; text?: string; withdraw?: boolean }
|
|
123
123
|
| { type: 'table_join'; requestId?: string; table?: string }
|
|
124
124
|
| { type: 'table_leave'; requestId?: string; table?: string }
|
|
@@ -199,6 +199,7 @@ export interface DeliveryReceipt {
|
|
|
199
199
|
export interface ActionResponse {
|
|
200
200
|
ok: true;
|
|
201
201
|
tableId?: string;
|
|
202
|
+
table?: TableSummary | null;
|
|
202
203
|
revision?: number;
|
|
203
204
|
/** 发言本身,供本地记录按实际消息游标去重;不含其他人的私密事件。 */
|
|
204
205
|
event?: RoomEvent;
|
package/src/room/room-host.ts
CHANGED
|
@@ -659,7 +659,7 @@ export class RoomHost {
|
|
|
659
659
|
return this.tableHost.lockOf(cooId);
|
|
660
660
|
}
|
|
661
661
|
|
|
662
|
-
async openTable(cooId: string, input:
|
|
662
|
+
async openTable(cooId: string, input: Parameters<TableHost['open']>[1] = {}, requestId?: string): Promise<TableOpenResult> {
|
|
663
663
|
if ((await this.requireRoom()).kind === 'hall') {
|
|
664
664
|
throw new HostError('conflict', '大厅是进场和选房的地方,不能开桌;先走进一个客厅');
|
|
665
665
|
}
|
package/src/room/table-engine.ts
CHANGED
package/src/room/table-host.ts
CHANGED
|
@@ -435,7 +435,7 @@ export class TableHost {
|
|
|
435
435
|
} finally { release(); }
|
|
436
436
|
}
|
|
437
437
|
|
|
438
|
-
async open(cooId: string, input: { game?: string; stake?: unknown; clientVersion?: string; matchOpen?: boolean } = {}, requestId?: string): Promise<TableOpenResult> {
|
|
438
|
+
async open(cooId: string, input: { game?: string; stake?: unknown; clientVersion?: string; matchOpen?: boolean; requireHuman?: boolean } = {}, requestId?: string): Promise<TableOpenResult> {
|
|
439
439
|
// 开桌还没有 tableId,用房间级键;开桌与「数桌上限」要串行。
|
|
440
440
|
const releaseOpen = await this.lockTable('#room');
|
|
441
441
|
try {
|
|
@@ -451,6 +451,9 @@ export class TableHost {
|
|
|
451
451
|
const id = input.game ?? 'dice';
|
|
452
452
|
const def = gameById(id);
|
|
453
453
|
if (!def) throw new HostError('invalid', `不认识的桌子:现在有 ${gameIds().join(' / ')}`);
|
|
454
|
+
if (input.requireHuman !== undefined && id !== 'werewolf') {
|
|
455
|
+
throw new HostError('invalid', 'requireHuman 仅适用于狼人杀');
|
|
456
|
+
}
|
|
454
457
|
const stake = stakeOf(input.stake);
|
|
455
458
|
if (stake > 0) {
|
|
456
459
|
const balance = await this.ledger.balanceOf(cooId);
|
|
@@ -458,7 +461,11 @@ export class TableHost {
|
|
|
458
461
|
throw new HostError('invalid', `你只有 ${balance} 枚筹码,押不起 ${stake} 枚`);
|
|
459
462
|
}
|
|
460
463
|
}
|
|
461
|
-
const openKey = {
|
|
464
|
+
const openKey = {
|
|
465
|
+
type: 'table_open', game: id, stake,
|
|
466
|
+
...(input.matchOpen ? { matchOpen: true } : {}),
|
|
467
|
+
...(input.requireHuman ? { requireHuman: true } : {}),
|
|
468
|
+
};
|
|
462
469
|
const replay = await this.replayReceipt(cooId, requestId, openKey);
|
|
463
470
|
if (replay) {
|
|
464
471
|
const at = this.now();
|
|
@@ -485,6 +492,7 @@ export class TableHost {
|
|
|
485
492
|
...(typeof input.clientVersion === 'string' && input.clientVersion ? { clientVersion: input.clientVersion } : {}),
|
|
486
493
|
},
|
|
487
494
|
now,
|
|
495
|
+
requireHuman: input.requireHuman,
|
|
488
496
|
...(this.turnMs !== undefined ? { turnMs: this.turnMs } : {}),
|
|
489
497
|
});
|
|
490
498
|
const stateJson = JSON.stringify(engine.exportState());
|
package/src/room/world-server.ts
CHANGED
|
@@ -1963,11 +1963,15 @@ export class WorldServer {
|
|
|
1963
1963
|
throw new HttpError(410, '承诺功能已停用;已有筹码转移保留。');
|
|
1964
1964
|
} else if (type === 'table_open') {
|
|
1965
1965
|
if (body.matchOpen !== undefined && typeof body.matchOpen !== 'boolean') throw new HttpError(400, 'matchOpen 必须是 true 或 false');
|
|
1966
|
+
if (body.requireHuman !== undefined && typeof body.requireHuman !== 'boolean') {
|
|
1967
|
+
throw new HttpError(400, 'requireHuman 必须是 true 或 false');
|
|
1968
|
+
}
|
|
1966
1969
|
const opened = await host.openTable(seat.cooId, {
|
|
1967
1970
|
game: typeof body.game === 'string' ? body.game : undefined,
|
|
1968
1971
|
stake: body.stake,
|
|
1969
1972
|
clientVersion: headerValue(req, 'x-parlor-client').trim() || undefined,
|
|
1970
1973
|
...(typeof body.matchOpen === 'boolean' ? { matchOpen: body.matchOpen } : {}),
|
|
1974
|
+
requireHuman: body.requireHuman,
|
|
1971
1975
|
}, requestId);
|
|
1972
1976
|
tableId = opened.tableId;
|
|
1973
1977
|
revision = opened.receipt.revision;
|
|
@@ -5,8 +5,8 @@
|
|
|
5
5
|
*/
|
|
6
6
|
import { el, btn, icon } from './common.js';
|
|
7
7
|
/* 内部模块统一带同一个版本号:版本不一致会让浏览器当成两份,订阅会各记各的。 */
|
|
8
|
-
import { onAnnouncements } from './announcements.js?v=0.36.
|
|
9
|
-
import { pickAnnouncement, rememberDismissed, excerpt } from './announcement-rules.js?v=0.36.
|
|
8
|
+
import { onAnnouncements } from './announcements.js?v=0.36.6';
|
|
9
|
+
import { pickAnnouncement, rememberDismissed, excerpt } from './announcement-rules.js?v=0.36.6';
|
|
10
10
|
|
|
11
11
|
const DISMISSED_KEY = 'parlor-announcements-dismissed';
|
|
12
12
|
const SEEN_KEY = 'parlor-announcements-seen';
|
|
@@ -10,9 +10,9 @@
|
|
|
10
10
|
* - `blurb` / `foot` / `guide` 是大厅卡片的文案与玩法说明。
|
|
11
11
|
*/
|
|
12
12
|
import { mountDice } from './dice.js';
|
|
13
|
-
import { mountDdz } from './ddz.js?v=0.36.
|
|
13
|
+
import { mountDdz } from './ddz.js?v=0.36.6';
|
|
14
14
|
import { mountMonopoly } from './monopoly.js';
|
|
15
|
-
import { mountWerewolf } from './werewolf.js?v=0.36.
|
|
15
|
+
import { mountWerewolf } from './werewolf.js?v=0.36.6';
|
|
16
16
|
|
|
17
17
|
export const GAMES = {
|
|
18
18
|
dice: {
|
|
@@ -34,13 +34,13 @@ export const GAMES = {
|
|
|
34
34
|
minPlayers: 9,
|
|
35
35
|
botFill: false,
|
|
36
36
|
mount: mountWerewolf,
|
|
37
|
-
blurb: '
|
|
37
|
+
blurb: '支持全 Coo 局,也欢迎真人入座。固定九席,3 狼 / 3 平民 / 预言家 / 女巫 / 猎人。',
|
|
38
38
|
foot: '九席 · 夜谈 · 单次发言',
|
|
39
39
|
guide: [
|
|
40
40
|
'固定九席:3 狼人、3 平民(牌面写「平民」)、预言家、女巫、猎人;无警长、无自爆。',
|
|
41
|
-
'
|
|
41
|
+
'坐满九席且至少有一只 Coo 后,由开桌者开始。开桌时可要求至少一名真人入座。每只 Coo 的扩展都要支持狼人杀。',
|
|
42
42
|
'轮到你发言只有一条(≤300 字),提交或过麦后全桌阅读 20 秒;投票、夜晚、开枪是同时窗口,到点统一结算。',
|
|
43
|
-
'真人发言
|
|
43
|
+
'真人发言 3 分钟、Coo 60 秒。夜晚对所有人只显示一个完整的夜。',
|
|
44
44
|
'好人灭掉全部狼人获胜;狼人把平民全灭或把三神全灭(屠边)获胜;最多十二个白天。',
|
|
45
45
|
'身份牌、查验、狼聊与药只有本人看得见;终局公开全部身份,出局者保留座位观战。',
|
|
46
46
|
],
|