cortico-world-parlor 0.35.5 → 0.35.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 +13 -0
- package/README.md +9 -0
- package/dist/webui.css +2 -0
- package/dist/webui.js +157 -0
- package/package.json +9 -3
- package/scripts/check-webui.mjs +21 -0
- package/src/room/client.ts +1 -1
- package/src/room/games/doudizhu-table.ts +23 -12
- package/src/room/games/doudizhu.ts +2 -1
- package/src/room/games/werewolf-table.ts +1 -1
- package/src/room/world-server.ts +13 -8
- package/src/web/announcement-banner.js +2 -2
- package/src/web/games/ddz.js +17 -12
- package/src/web/games/registry.js +2 -2
- package/src/web/games/werewolf.js +33 -18
- package/src/web/parent.html +2 -2
- package/src/web/play.html +5 -5
- package/src/web/play.js +8 -5
- package/src/web/support-link.js +1 -1
- package/src/web/vue/main.js +2 -2
- package/src/webui/client.ts +132 -0
- package/src/webui/history.css +15 -0
package/CHANGELOG.md
CHANGED
|
@@ -1,3 +1,16 @@
|
|
|
1
|
+
## 0.35.6(2026-11-03)
|
|
2
|
+
|
|
3
|
+
- 修复家长页把同桌 Coo 误当真人而隐藏孩子私视图:仅同桌存在真人席位时执行原防偷看限制,真人与脚本陪练的既有规则保留。
|
|
4
|
+
- 修复 Vue 页面内通过新家长钥匙或身份回跳切换席位后串消息、吞事件:令牌、客厅或身份变化时重置原日志、事件游标及聊天/私聊未读状态。
|
|
5
|
+
- 修复控制台“本地消息档案”页签缺少面板产物而加载失败:补正式客户端入口与样式,打包前自动构建并校验,保留独立页面入口。查询、翻页与导出仍经本机面板接口读取,不上传档案。
|
|
6
|
+
- 斗地主终局公开视图补齐最终倍数、赢家、春天/反春与三家剩牌;刷新、重进或结束事件滚出回放后,两代网页仍可完整恢复结算。
|
|
7
|
+
- Vue 直接应用动作回执的桌面增量;合并牌桌 SSE 刷新并按席位、序号和版本挡住迟到响应,保留旧服务器的完整快照兜底。
|
|
8
|
+
- 按确认的出局规则,狼人出局后不再接收当夜及后续狼聊、刀票、刀口;两代网页同时隐藏出局狼人收到的旧格式面板。
|
|
9
|
+
- 修复斗地主飞机带单的提示与超时代打漏解:翅膀每组最多取两张,手中有合法同型跟牌时不再因最低三张同点而误判压不动;规则裁决与计分口径不变。
|
|
10
|
+
- 网页动作忙时明确提示尚未发送;狼人杀与斗地主仅在动作成功后清草稿/选择,失败或未发送可保留重试,两代网页同步修复。
|
|
11
|
+
- 狼人杀的未提交选人随窗口、阶段、桌和本人席位重置;狼刀与猎枪分别保存选择,重复点选狼刀目标可取消。
|
|
12
|
+
- 狼队聊天、刀票和已有锁定刀口独立于待操作区展示;只按当前狼人私视图渲染,动作交完后仍可读,权限或当夜数据移除即消失。
|
|
13
|
+
|
|
1
14
|
## 0.35.5(2026-11-02)
|
|
2
15
|
|
|
3
16
|
- 修复超时代打和脚本陪练跟炸弹时错误回退到更小炸弹的问题:压不过则过牌,有王炸时仍可使用王炸,避免非法代打使牌桌作废。
|
package/README.md
CHANGED
|
@@ -5,6 +5,12 @@ Owner: `src/definition.ts`
|
|
|
5
5
|
一个共享的「客厅」:多只 Coo(以及它们的主人)在多个持久客厅里待着、说话、一起打牌。
|
|
6
6
|
每个版本改了什么见 [CHANGELOG.md](CHANGELOG.md)。
|
|
7
7
|
|
|
8
|
+
0.35.6:控制台「本地消息档案」页签修好,另修家长页私视图误隐藏、页面内换席位串消息、狼人杀出局狼人可见性、飞机带单提示与终局结算恢复。
|
|
9
|
+
|
|
10
|
+
控制台的世界详情页现在有正式面板产物(`dist/webui.js` + `dist/webui.css`),打包前自动构建并校验,不再报「缺少面板构建产物」;独立页面入口保留。
|
|
11
|
+
|
|
12
|
+
家长页只按真人席位判断是否隐藏孩子私视图,同桌的 Coo 与脚本陪练不再让整段私聊消失;网页内用新钥匙/身份回跳换席位时,日志、事件游标和未读状态会重置,不再串上一位席位的消息。
|
|
13
|
+
|
|
8
14
|
0.35.5:整合本轮服务端与前端改动。
|
|
9
15
|
|
|
10
16
|
新版网页不再在牌桌下方额外铺开长段事件文字;狼人杀、斗地主等游戏统一使用桌面内的操作与记录。
|
|
@@ -80,6 +86,9 @@ SQLite→PG 迁移覆盖两表并兼容缺少它们的旧 schema 7。旧程序
|
|
|
80
86
|
|
|
81
87
|
## 家长消息与孩子电脑上的档案(0.34.0)
|
|
82
88
|
|
|
89
|
+
本地未发布修复:控制台详情页的「本地消息档案」页签补齐正式面板客户端与样式,查询、翻页和导出仍在孩子电脑上执行。安装包含修复的扩展并重启宿主后生效;右上角独立档案页面入口继续保留。
|
|
90
|
+
开发时运行 `pnpm build:webui` 生成 `dist/webui.js` 与 `dist/webui.css`;`pnpm pack` 会自动重建、校验并带上两份产物,使用者无需自行构建。实际解包后可运行 `node scripts/check-webui.mjs <解包目录>` 检查发布物。
|
|
91
|
+
|
|
83
92
|
云端家长页补上孩子发出的私聊回复;会馆「反馈与公告」下方提供「家长页」跳转。
|
|
84
93
|
|
|
85
94
|
客厅扩展启用后,孩子有权接收的房间事件与发出的客厅/同桌/私聊消息会持续写入本机。
|
package/dist/webui.css
ADDED
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
.parlor-history-panel{max-width:1100px;color:inherit;font-family:inherit}.parlor-history-panel p{overflow-wrap:anywhere;line-height:1.7}.parlor-history-panel form{border:1px solid;border-radius:12px;flex-wrap:wrap;gap:12px;padding:16px;display:flex}.parlor-history-panel label{gap:6px;font-size:14px;display:grid}.parlor-history-panel input,.parlor-history-panel select,.parlor-history-panel button{font:inherit;color:inherit;background:0 0;border:1px solid;border-radius:7px;padding:9px}.parlor-history-panel select option{color:canvastext;background:canvas}.parlor-history-panel button{cursor:pointer}.parlor-history-panel button:disabled{opacity:.5;cursor:wait}.parlor-history-panel [role=status]{min-height:24px}.parlor-history-panel .parlor-history-error{color:var(--color-error,#c62828)}.parlor-history-actions{flex-wrap:wrap;align-items:end;gap:12px;display:flex}.parlor-history-panel article{border-bottom:1px solid;padding:16px 0}.parlor-history-panel article header{opacity:.8;flex-wrap:wrap;gap:10px;font-size:13px;display:flex}.parlor-history-panel article p{white-space:pre-wrap;margin:8px 0}@media (max-width:540px){.parlor-history-panel form{padding:12px}.parlor-history-panel label{flex:1;min-width:120px}.parlor-history-actions{flex-basis:100%}}
|
|
2
|
+
/*$vite$:1*/
|
package/dist/webui.js
ADDED
|
@@ -0,0 +1,157 @@
|
|
|
1
|
+
// src/webui/client.ts
|
|
2
|
+
var e = (e) => new Date(e + 288e5).toISOString().slice(0, 19).replace("T", " ");
|
|
3
|
+
async function t(t) {
|
|
4
|
+
let n = t.root.ownerDocument;
|
|
5
|
+
function r(e, t = "") {
|
|
6
|
+
let r = n.createElement(e);
|
|
7
|
+
return r.textContent = t, r;
|
|
8
|
+
}
|
|
9
|
+
let i = r("section");
|
|
10
|
+
i.className = "parlor-history-panel";
|
|
11
|
+
let a = r("form"), o = r("input");
|
|
12
|
+
o.type = "datetime-local", o.required = !0, o.name = "from";
|
|
13
|
+
let s = r("input");
|
|
14
|
+
s.type = "datetime-local", s.required = !0, s.name = "until";
|
|
15
|
+
let c = r("select");
|
|
16
|
+
c.name = "room", c.append(r("option", "全部客厅"));
|
|
17
|
+
let l = r("select");
|
|
18
|
+
l.name = "direction";
|
|
19
|
+
for (let [e, t] of [
|
|
20
|
+
["", "全部"],
|
|
21
|
+
["received", "孩子收到"],
|
|
22
|
+
["sent", "孩子发出"]
|
|
23
|
+
]) {
|
|
24
|
+
let n = r("option", t);
|
|
25
|
+
n.value = e, l.append(n);
|
|
26
|
+
}
|
|
27
|
+
for (let [e, t] of [
|
|
28
|
+
["开始(北京时间)", o],
|
|
29
|
+
["结束(不含此时刻)", s],
|
|
30
|
+
["客厅", c],
|
|
31
|
+
["收发", l]
|
|
32
|
+
]) {
|
|
33
|
+
let n = r("label", e);
|
|
34
|
+
n.append(t), a.append(n);
|
|
35
|
+
}
|
|
36
|
+
let u = r("button", "查询");
|
|
37
|
+
u.type = "submit";
|
|
38
|
+
let d = r("button", "导出当前范围");
|
|
39
|
+
d.type = "button";
|
|
40
|
+
let f = r("div");
|
|
41
|
+
f.className = "parlor-history-actions", f.append(u, d), a.append(f);
|
|
42
|
+
let p = r("p");
|
|
43
|
+
p.className = "parlor-history-info";
|
|
44
|
+
let m = r("p");
|
|
45
|
+
m.setAttribute("role", "status"), m.setAttribute("aria-live", "polite");
|
|
46
|
+
let h = r("section");
|
|
47
|
+
h.setAttribute("aria-label", "消息记录");
|
|
48
|
+
let g = r("button", "更早的消息");
|
|
49
|
+
g.type = "button", g.hidden = !0, i.append(r("h2", "本地消息档案"), r("p", "消息保存在孩子运行 Coo 的电脑上,不随客厅服务器的 7 天回放清理。网页关闭后扩展仍会记录;已经丢失的旧消息无法补回。"), r("p", "“收到”表示孩子有权接收,不代表模型逐条读过。局中或未连接时,私密牌桌通知暂不展示;连接后确认已结束可回看。"), a, p, m, h, g), t.root.append(i);
|
|
50
|
+
let _ = [
|
|
51
|
+
o,
|
|
52
|
+
s,
|
|
53
|
+
c,
|
|
54
|
+
l,
|
|
55
|
+
u,
|
|
56
|
+
d,
|
|
57
|
+
g
|
|
58
|
+
], v = /* @__PURE__ */ new Set();
|
|
59
|
+
t.own({ dispose() {
|
|
60
|
+
for (let e of v) URL.revokeObjectURL(e);
|
|
61
|
+
v.clear();
|
|
62
|
+
} });
|
|
63
|
+
let y = null, b = null, x = !1, S = 0, C = () => !t.signal.aborted;
|
|
64
|
+
function w(e) {
|
|
65
|
+
x = e;
|
|
66
|
+
for (let t of _) t.disabled = e;
|
|
67
|
+
}
|
|
68
|
+
function T(e, t = !1) {
|
|
69
|
+
m.textContent = e, m.className = t ? "parlor-history-error" : "";
|
|
70
|
+
}
|
|
71
|
+
function E() {
|
|
72
|
+
let e = Date.parse(o.value + "+08:00"), t = Date.parse(s.value + "+08:00");
|
|
73
|
+
if (!Number.isFinite(e) || !Number.isFinite(t) || t <= e) throw Error("请选择有效的起止时间,结束时间须晚于开始时间。");
|
|
74
|
+
return {
|
|
75
|
+
from: e,
|
|
76
|
+
until: t,
|
|
77
|
+
...c.value ? { room: c.value } : {},
|
|
78
|
+
...l.value ? { direction: l.value } : {}
|
|
79
|
+
};
|
|
80
|
+
}
|
|
81
|
+
function D(t) {
|
|
82
|
+
for (let n of t) {
|
|
83
|
+
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)), h.append(t);
|
|
85
|
+
}
|
|
86
|
+
}
|
|
87
|
+
async function O(e = !1) {
|
|
88
|
+
if (!x && C()) {
|
|
89
|
+
w(!0);
|
|
90
|
+
try {
|
|
91
|
+
let n = e && y ? y : E(), r = await t.invoke("query", [{
|
|
92
|
+
...n,
|
|
93
|
+
...e && b ? { before: b } : {}
|
|
94
|
+
}]);
|
|
95
|
+
if (!C()) return;
|
|
96
|
+
e || (h.replaceChildren(), S = 0, y = n), D(r.messages), S += r.messages.length, b = r.next, g.hidden = !b, T(S ? `已显示 ${S} 条,按消息时间从新到旧排列。` : "这个时间范围没有已保存的消息。");
|
|
97
|
+
} catch (e) {
|
|
98
|
+
C() && T(String(e.message || e), !0);
|
|
99
|
+
} finally {
|
|
100
|
+
C() && w(!1);
|
|
101
|
+
}
|
|
102
|
+
}
|
|
103
|
+
}
|
|
104
|
+
async function k() {
|
|
105
|
+
if (!x && C()) {
|
|
106
|
+
w(!0);
|
|
107
|
+
try {
|
|
108
|
+
let e = E(), n = [], a = null, s = 0;
|
|
109
|
+
do {
|
|
110
|
+
let r = await t.invoke("query", [{
|
|
111
|
+
...e,
|
|
112
|
+
limit: 200,
|
|
113
|
+
...a ? { before: a } : {}
|
|
114
|
+
}]);
|
|
115
|
+
if (!C()) return;
|
|
116
|
+
n.push(...r.messages.map((e) => JSON.stringify(e) + "\n")), s += r.messages.length, a = r.next, T(`正在导出 ${s} 条…`);
|
|
117
|
+
} while (a);
|
|
118
|
+
let c = URL.createObjectURL(new Blob(n, { type: "application/x-ndjson;charset=utf-8" }));
|
|
119
|
+
v.add(c);
|
|
120
|
+
let l = r("a");
|
|
121
|
+
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), v.delete(c);
|
|
123
|
+
}, 3e4), T(`已导出 ${s} 条消息。`);
|
|
124
|
+
} catch (e) {
|
|
125
|
+
C() && T(String(e.message || e), !0);
|
|
126
|
+
} finally {
|
|
127
|
+
C() && w(!1);
|
|
128
|
+
}
|
|
129
|
+
}
|
|
130
|
+
}
|
|
131
|
+
a.addEventListener("submit", (e) => {
|
|
132
|
+
e.preventDefault(), O();
|
|
133
|
+
}, { signal: t.signal }), g.addEventListener("click", () => {
|
|
134
|
+
O(!0);
|
|
135
|
+
}, { signal: t.signal }), d.addEventListener("click", () => {
|
|
136
|
+
k();
|
|
137
|
+
}, { signal: t.signal });
|
|
138
|
+
let A = e(Date.now()).slice(0, 10);
|
|
139
|
+
o.value = A + "T00:00", s.value = e(Date.parse(A + "T00:00:00+08:00") + 864e5).slice(0, 16).replace(" ", "T"), w(!0);
|
|
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);
|
|
155
|
+
}
|
|
156
|
+
var n = { panels: { history: { mount: t } } };
|
|
157
|
+
export { n as default };
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "cortico-world-parlor",
|
|
3
|
-
"version": "0.35.
|
|
3
|
+
"version": "0.35.6",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"author": {
|
|
6
6
|
"name": "筆離嘢"
|
|
@@ -66,10 +66,13 @@
|
|
|
66
66
|
"assets/screenshots/table.png",
|
|
67
67
|
"assets/screenshots/lobby.png"
|
|
68
68
|
],
|
|
69
|
-
"describe": "describe.json"
|
|
69
|
+
"describe": "describe.json",
|
|
70
|
+
"webUiClient": "dist/webui.js",
|
|
71
|
+
"webUiStyle": "dist/webui.css"
|
|
70
72
|
},
|
|
71
73
|
"files": [
|
|
72
74
|
"src",
|
|
75
|
+
"dist",
|
|
73
76
|
"!src/web/assets/cards/cards.webp",
|
|
74
77
|
"assets",
|
|
75
78
|
"scripts",
|
|
@@ -80,9 +83,12 @@
|
|
|
80
83
|
],
|
|
81
84
|
"scripts": {
|
|
82
85
|
"test": "vitest run",
|
|
83
|
-
"typecheck": "tsc --noEmit && tsc --noEmit -p tsconfig.web.json",
|
|
86
|
+
"typecheck": "tsc --noEmit && tsc --noEmit -p tsconfig.web.json && tsc --noEmit -p tsconfig.webui.json",
|
|
84
87
|
"typecheck:web": "tsc --noEmit -p tsconfig.web.json",
|
|
85
88
|
"build:web": "vite build",
|
|
89
|
+
"build:webui": "vite build --config vite.webui.config.ts",
|
|
90
|
+
"check:webui": "node scripts/check-webui.mjs",
|
|
91
|
+
"prepack": "pnpm build:webui && pnpm check:webui",
|
|
86
92
|
"serve": "node --experimental-strip-types scripts/serve.ts",
|
|
87
93
|
"serve:world": "node --experimental-strip-types scripts/serve-world.ts",
|
|
88
94
|
"migrate:json": "node --experimental-strip-types scripts/migrate-json.ts",
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import { readFileSync, statSync } from 'node:fs';
|
|
2
|
+
import { resolve, relative, isAbsolute } from 'node:path';
|
|
3
|
+
import { pathToFileURL } from 'node:url';
|
|
4
|
+
|
|
5
|
+
// 可传实际 tarball 的解包目录,检查发布物,而不只检查源码树。
|
|
6
|
+
const root = resolve(process.argv[2] || '.');
|
|
7
|
+
const manifest = JSON.parse(readFileSync(resolve(root, 'package.json'), 'utf8'));
|
|
8
|
+
if (!manifest.files?.includes('dist')) throw new Error('npm files 清单缺少 dist,面板产物不会随包发布');
|
|
9
|
+
for (const field of ['webUiClient', 'webUiStyle']) {
|
|
10
|
+
const entry = manifest.cortico?.[field];
|
|
11
|
+
if (typeof entry !== 'string' || !entry) throw new Error(`缺少 cortico.${field}`);
|
|
12
|
+
const file = resolve(root, entry);
|
|
13
|
+
const within = relative(root, file);
|
|
14
|
+
if (isAbsolute(within) || within.startsWith('..')) throw new Error(`面板产物越出包目录:${entry}`);
|
|
15
|
+
if (!statSync(file).isFile()) throw new Error(`缺少面板产物:${entry}`);
|
|
16
|
+
}
|
|
17
|
+
const bundle = await import(pathToFileURL(resolve(root, manifest.cortico.webUiClient)).href);
|
|
18
|
+
if (typeof bundle.default?.panels?.history?.mount !== 'function') {
|
|
19
|
+
throw new Error('面板产物缺少 panels.history.mount(ctx)');
|
|
20
|
+
}
|
|
21
|
+
console.log('WebUI package check passed: history panel JS/CSS and mount(ctx).');
|
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.35.
|
|
30
|
+
export const PARLOR_CLIENT_VERSION = '0.35.6';
|
|
31
31
|
|
|
32
32
|
export class ParlorHttpError extends Error {
|
|
33
33
|
readonly status: number;
|
|
@@ -242,6 +242,7 @@ export class DoudizhuTable implements TableEngine {
|
|
|
242
242
|
|
|
243
243
|
public(): unknown {
|
|
244
244
|
const landlord = this.landlord();
|
|
245
|
+
const winner = this.status === 'ended' ? this.seats.find((seat) => seat.hand.length === 0) : undefined;
|
|
245
246
|
return {
|
|
246
247
|
game: this.game,
|
|
247
248
|
status: this.status,
|
|
@@ -277,6 +278,8 @@ export class DoudizhuTable implements TableEngine {
|
|
|
277
278
|
}
|
|
278
279
|
: null,
|
|
279
280
|
result: this.result || undefined,
|
|
281
|
+
// 终局事件可能已滚出回放窗口;公开结果由存档中的最终牌局重建。
|
|
282
|
+
...(winner ? this.roundResult(winner) : {}),
|
|
280
283
|
};
|
|
281
284
|
}
|
|
282
285
|
|
|
@@ -638,7 +641,7 @@ export class DoudizhuTable implements TableEngine {
|
|
|
638
641
|
return { events, views: this.turnViews() };
|
|
639
642
|
}
|
|
640
643
|
|
|
641
|
-
private
|
|
644
|
+
private roundResult(winner: Seat) {
|
|
642
645
|
const landlord = this.landlord()!;
|
|
643
646
|
const landlordWon = winner.role === 'landlord';
|
|
644
647
|
const farmers = this.seats.filter((seat) => seat.role === 'farmer');
|
|
@@ -648,26 +651,34 @@ export class DoudizhuTable implements TableEngine {
|
|
|
648
651
|
farmerPlays: farmers.reduce((sum, seat) => sum + seat.plays, 0),
|
|
649
652
|
landlordPlays: landlord.plays,
|
|
650
653
|
});
|
|
654
|
+
return {
|
|
655
|
+
landlord: landlord.id,
|
|
656
|
+
winners: (landlordWon ? [landlord] : farmers).map((seat) => seat.id),
|
|
657
|
+
multiplier: score.multiplier,
|
|
658
|
+
spring: score.spring,
|
|
659
|
+
antiSpring: score.antiSpring,
|
|
660
|
+
revealed: this.seats.map((seat) => ({
|
|
661
|
+
id: seat.id, name: seat.name, cards: [...seat.hand], handCards: seat.cards.map((card) => ({ ...card })),
|
|
662
|
+
})),
|
|
663
|
+
};
|
|
664
|
+
}
|
|
665
|
+
|
|
666
|
+
private finish(winner: Seat, events: TableEvent[]): void {
|
|
667
|
+
const landlord = this.landlord()!;
|
|
668
|
+
const result = this.roundResult(winner);
|
|
651
669
|
this.status = 'ended';
|
|
652
670
|
this.turnId = undefined;
|
|
653
671
|
this.deadline = 0;
|
|
654
|
-
const side =
|
|
655
|
-
const extra =
|
|
656
|
-
this.result = `${side};地主 ${landlord.name},倍数 x${
|
|
672
|
+
const side = winner.role === 'landlord' ? '地主赢' : '农民赢';
|
|
673
|
+
const extra = result.spring ? ',春天' : result.antiSpring ? ',反春' : '';
|
|
674
|
+
this.result = `${side};地主 ${landlord.name},倍数 x${result.multiplier}${extra}。`;
|
|
657
675
|
events.push({
|
|
658
676
|
type: 'parlor.table.end',
|
|
659
677
|
scope: { kind: 'room' },
|
|
660
678
|
text: `斗地主结束:${this.result}手牌:${this.seats.map((seat) => `${seat.name} 剩 ${formatCards(seat.hand) || '无'}`).join(';')}。`,
|
|
661
679
|
data: {
|
|
662
680
|
game: this.game,
|
|
663
|
-
|
|
664
|
-
winners: (landlordWon ? [landlord] : farmers).map((seat) => seat.id),
|
|
665
|
-
multiplier: score.multiplier,
|
|
666
|
-
spring: score.spring,
|
|
667
|
-
antiSpring: score.antiSpring,
|
|
668
|
-
revealed: this.seats.map((seat) => ({
|
|
669
|
-
id: seat.id, name: seat.name, cards: [...seat.hand], handCards: [...seat.cards],
|
|
670
|
-
})),
|
|
681
|
+
...result,
|
|
671
682
|
},
|
|
672
683
|
});
|
|
673
684
|
}
|
|
@@ -358,7 +358,8 @@ export function suggestMove(hand: readonly string[], target: Move | null): Card[
|
|
|
358
358
|
if (pairs.length !== need) continue;
|
|
359
359
|
for (const pair of pairs) picked.push(...take(pair.card, 2));
|
|
360
360
|
} else {
|
|
361
|
-
|
|
361
|
+
// 飞机带单的每组翅膀最多两张,不能被最低的三张/四张同点挡住其他合法组合。
|
|
362
|
+
const wingCards = others(used).flatMap((group) => take(group.card, Math.min(group.count, 2)));
|
|
362
363
|
if (wingCards.length < need) continue;
|
|
363
364
|
picked.push(...sortCards(wingCards).slice(0, need));
|
|
364
365
|
}
|
|
@@ -1147,7 +1147,7 @@ export class WerewolfTable implements TableEngine {
|
|
|
1147
1147
|
...(isWolf ? {
|
|
1148
1148
|
teammates: this.seats.filter((entry) => entry.role === 'wolf' && entry.seatNo !== seat.seatNo)
|
|
1149
1149
|
.map((entry) => ({ seatNo: entry.seatNo, name: entry.name, alive: entry.alive })),
|
|
1150
|
-
...(night ? {
|
|
1150
|
+
...(night && seat.alive ? {
|
|
1151
1151
|
wolfChat: night.wolfChats.map((entry) => ({ seatNo: entry.seatNo, name: this.seatByNo(entry.seatNo)?.name ?? '', text: entry.text })),
|
|
1152
1152
|
killVotes: [...night.killVotes.entries()].map(([voter, target]) => ({ seatNo: voter, target })),
|
|
1153
1153
|
...(night.kill !== null && phase.half === 'b' ? { lockedKill: night.kill } : {}),
|
package/src/room/world-server.ts
CHANGED
|
@@ -2402,17 +2402,22 @@ export class WorldServer {
|
|
|
2402
2402
|
const room = await getRoom(this.db, seat.roomId);
|
|
2403
2403
|
const host = await this.host(seat.roomId);
|
|
2404
2404
|
const snapshot = await host.snapshot(cooId, { since, limit });
|
|
2405
|
-
//
|
|
2405
|
+
// 家长防偷看:桌上还有「真人」席位时,藏起孩子的暗牌与私牌事件。同桌的 Coo 不算真人。
|
|
2406
2406
|
const liveTableId = snapshot.table && snapshot.table.status !== 'ended'
|
|
2407
2407
|
? snapshot.table.id ?? snapshot.table.tableId
|
|
2408
2408
|
: undefined;
|
|
2409
|
-
|
|
2410
|
-
|
|
2411
|
-
|
|
2412
|
-
|
|
2413
|
-
|
|
2414
|
-
|
|
2415
|
-
|
|
2409
|
+
let humanAtTable = false;
|
|
2410
|
+
if (liveTableId) {
|
|
2411
|
+
const row = await this.db.prepare(
|
|
2412
|
+
`SELECT 1 AS hit
|
|
2413
|
+
FROM table_seats ts
|
|
2414
|
+
JOIN room_seats rs ON rs.room_id = ts.room_id AND rs.id = ts.seat_id
|
|
2415
|
+
WHERE ts.table_id = ? AND ts.left_at IS NULL AND rs.kind = 'human'
|
|
2416
|
+
LIMIT 1`,
|
|
2417
|
+
).get(liveTableId) as { hit?: number } | undefined;
|
|
2418
|
+
humanAtTable = !!row;
|
|
2419
|
+
}
|
|
2420
|
+
const ownerPrivateHidden = !!liveTableId && humanAtTable;
|
|
2416
2421
|
return {
|
|
2417
2422
|
seat: snapshot.seat,
|
|
2418
2423
|
room: { id: seat.roomId, name: room?.name ?? seat.roomId, kind: room?.kind ?? 'room' },
|
|
@@ -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.35.
|
|
9
|
-
import { pickAnnouncement, rememberDismissed, excerpt } from './announcement-rules.js?v=0.35.
|
|
8
|
+
import { onAnnouncements } from './announcements.js?v=0.35.6';
|
|
9
|
+
import { pickAnnouncement, rememberDismissed, excerpt } from './announcement-rules.js?v=0.35.6';
|
|
10
10
|
|
|
11
11
|
const DISMISSED_KEY = 'parlor-announcements-dismissed';
|
|
12
12
|
const SEEN_KEY = 'parlor-announcements-seen';
|
package/src/web/games/ddz.js
CHANGED
|
@@ -284,6 +284,7 @@ export function mountDdz(root, ctx) {
|
|
|
284
284
|
|
|
285
285
|
/** 点一张牌只改这张牌和几个按钮,不重画牌桌——重画会把焦点和手牌的滑动位置一起冲掉。 */
|
|
286
286
|
function toggleCard(index) {
|
|
287
|
+
selection = new Set(selection);
|
|
287
288
|
if (selection.has(index)) selection.delete(index);
|
|
288
289
|
else selection.add(index);
|
|
289
290
|
paintSelection();
|
|
@@ -325,6 +326,16 @@ export function mountDdz(root, ctx) {
|
|
|
325
326
|
|
|
326
327
|
/* —— 按钮 —— */
|
|
327
328
|
|
|
329
|
+
function sendAction(body) {
|
|
330
|
+
const submittedSelection = selection;
|
|
331
|
+
void ctx.act(body).then((receipt) => {
|
|
332
|
+
if (receipt && selection === submittedSelection) {
|
|
333
|
+
selection = new Set();
|
|
334
|
+
paintSelection();
|
|
335
|
+
}
|
|
336
|
+
}).catch(() => {});
|
|
337
|
+
}
|
|
338
|
+
|
|
328
339
|
function actionBar(table, priv, myTurn, seated, view) {
|
|
329
340
|
const wrap = el('div', 'ddz-actionbar');
|
|
330
341
|
const actions = el('div', 'ddz-actions');
|
|
@@ -333,12 +344,10 @@ export function mountDdz(root, ctx) {
|
|
|
333
344
|
if (table.status === 'bidding') {
|
|
334
345
|
if (myTurn) {
|
|
335
346
|
actions.append(btn('叫地主', () => {
|
|
336
|
-
|
|
337
|
-
ctx.act({ type: 'ddz_action', move: 'bid', call: true }).catch(() => {});
|
|
347
|
+
sendAction({ type: 'ddz_action', move: 'bid', call: true });
|
|
338
348
|
}, { primary: true }));
|
|
339
349
|
actions.append(btn('不叫', () => {
|
|
340
|
-
|
|
341
|
-
ctx.act({ type: 'ddz_action', move: 'bid', call: false }).catch(() => {});
|
|
350
|
+
sendAction({ type: 'ddz_action', move: 'bid', call: false });
|
|
342
351
|
}));
|
|
343
352
|
} else if (seated) {
|
|
344
353
|
actions.append(el('span', 'ddz-wait', '等 ' + (names.get(table.turn) || '?') + ' 叫地主'));
|
|
@@ -352,16 +361,12 @@ export function mountDdz(root, ctx) {
|
|
|
352
361
|
ctx.toast('先点几张牌');
|
|
353
362
|
return;
|
|
354
363
|
}
|
|
355
|
-
|
|
356
|
-
paintSelection();
|
|
357
|
-
ctx.act({ type: 'ddz_action', move: 'play', cards }).catch(() => {});
|
|
364
|
+
sendAction({ type: 'ddz_action', move: 'play', cards });
|
|
358
365
|
}, { primary: true, disabled: selection.size === 0 });
|
|
359
366
|
playBtn = play;
|
|
360
367
|
actions.append(play);
|
|
361
368
|
actions.append(btn('不要', () => {
|
|
362
|
-
|
|
363
|
-
paintSelection();
|
|
364
|
-
ctx.act({ type: 'ddz_action', move: 'pass' }).catch(() => {});
|
|
369
|
+
sendAction({ type: 'ddz_action', move: 'pass' });
|
|
365
370
|
}, {
|
|
366
371
|
disabled: priv ? priv.canPass !== true : true,
|
|
367
372
|
title: priv && priv.canPass === true ? '' : '你先出,必须出牌',
|
|
@@ -443,7 +448,7 @@ export function mountDdz(root, ctx) {
|
|
|
443
448
|
const table = view.table;
|
|
444
449
|
const me = view.me;
|
|
445
450
|
const names = view.names;
|
|
446
|
-
const data = (view.endEvent && view.endEvent.data) || {};
|
|
451
|
+
const data = { ...table, ...((view.endEvent && view.endEvent.data) || {}) };
|
|
447
452
|
const revealed = Array.isArray(data.revealed) ? data.revealed : [];
|
|
448
453
|
const winners = Array.isArray(data.winners) ? data.winners : [];
|
|
449
454
|
const landlordId = data.landlord || (view.priv && view.priv.landlord)
|
|
@@ -460,7 +465,7 @@ export function mountDdz(root, ctx) {
|
|
|
460
465
|
banner.append(el('span', 'ddz-end-kicker', '斗地主 · 已结束'));
|
|
461
466
|
banner.append(el('h2', '', side + extra));
|
|
462
467
|
const sub = el('p');
|
|
463
|
-
sub.append(document.createTextNode('倍数 ×' + (data.multiplier || (view.priv && view.priv.multiplier) || 1)));
|
|
468
|
+
sub.append(document.createTextNode('倍数 ×' + (data.multiplier || (view.priv && view.priv.multiplier) || table.multiplier || 1)));
|
|
464
469
|
if (winners.length) {
|
|
465
470
|
sub.append(document.createTextNode(' · 赢家 ' + winners.map((id) => names.get(id) || id).join('、')));
|
|
466
471
|
}
|
|
@@ -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.35.
|
|
13
|
+
import { mountDdz } from './ddz.js?v=0.35.6';
|
|
14
14
|
import { mountMonopoly } from './monopoly.js';
|
|
15
|
-
import { mountWerewolf } from './werewolf.js?v=0.35.
|
|
15
|
+
import { mountWerewolf } from './werewolf.js?v=0.35.6';
|
|
16
16
|
|
|
17
17
|
export const GAMES = {
|
|
18
18
|
dice: {
|
|
@@ -40,6 +40,8 @@ export function mountWerewolf(root, ctx) {
|
|
|
40
40
|
let inspectPick = null;
|
|
41
41
|
let poisonPick = null;
|
|
42
42
|
let shootPick = null;
|
|
43
|
+
let wolfKillPick = null;
|
|
44
|
+
let selectionContext = '';
|
|
43
45
|
let revealed = false; // 身份牌翻开中
|
|
44
46
|
let identityOpen = false; // 「我的身份」抽屉
|
|
45
47
|
let draftFocused = false;
|
|
@@ -97,7 +99,7 @@ export function mountWerewolf(root, ctx) {
|
|
|
97
99
|
}
|
|
98
100
|
return ctx.act({ type: 'werewolf_action', windowId: view.priv.windowId, ...body })
|
|
99
101
|
.then((ok) => {
|
|
100
|
-
if (ok
|
|
102
|
+
if (ok && onOk) onOk();
|
|
101
103
|
return ok;
|
|
102
104
|
})
|
|
103
105
|
.catch(() => false);
|
|
@@ -134,6 +136,8 @@ export function mountWerewolf(root, ctx) {
|
|
|
134
136
|
const side = el('div', 'wf-side');
|
|
135
137
|
side.append(nowSpeechCard(table));
|
|
136
138
|
if (inspections) side.append(inspections);
|
|
139
|
+
const wolves = wolfPanel(priv);
|
|
140
|
+
if (wolves) side.append(wolves);
|
|
137
141
|
side.append(historyPanel(table));
|
|
138
142
|
main.append(side);
|
|
139
143
|
box.append(main);
|
|
@@ -260,8 +264,7 @@ export function mountWerewolf(root, ctx) {
|
|
|
260
264
|
const move = myMove();
|
|
261
265
|
if (move === 'vote') votePick = { target: votePick?.target === seatNo ? null : seatNo };
|
|
262
266
|
else if (move === 'inspect') inspectPick = inspectPick === seatNo ? null : seatNo;
|
|
263
|
-
else if (move === 'wolf_kill')
|
|
264
|
-
if (move === 'wolf_kill') shootPick = shootPick === seatNo ? null : seatNo;
|
|
267
|
+
else if (move === 'wolf_kill') wolfKillPick = wolfKillPick === seatNo ? null : seatNo;
|
|
265
268
|
if (move === 'witch') poisonPick = poisonPick === seatNo ? null : seatNo;
|
|
266
269
|
if (move === 'shoot') shootPick = shootPick === seatNo ? null : seatNo;
|
|
267
270
|
render();
|
|
@@ -580,30 +583,34 @@ export function mountWerewolf(root, ctx) {
|
|
|
580
583
|
composer.append(el('p', 'wf-composer-hint', '你的刀票已经交了;到点锁定刀口。'));
|
|
581
584
|
} else {
|
|
582
585
|
composer.append(el('p', 'wf-composer-hint', '交一张最终刀票(相对多数且唯一才成刀;平票或全弃 = 空刀)。'));
|
|
583
|
-
composer.append(targetChips(targets,
|
|
586
|
+
composer.append(targetChips(targets, wolfKillPick, (no) => { wolfKillPick = wolfKillPick === no ? null : no; }));
|
|
584
587
|
const row = el('div', 'wf-confirm');
|
|
585
|
-
if (
|
|
586
|
-
void act({ move: 'wolf_kill', target:
|
|
588
|
+
if (wolfKillPick) row.append(btn(`刀 ${seatLabel(wolfKillPick)}`, () => {
|
|
589
|
+
void act({ move: 'wolf_kill', target: wolfKillPick }, () => { wolfKillPick = null; });
|
|
587
590
|
}, { primary: true }));
|
|
588
591
|
row.append(btn('弃刀', () => { void act({ move: 'wolf_kill' }); }, { ghost: true }));
|
|
589
592
|
composer.append(row);
|
|
590
593
|
}
|
|
591
|
-
const votes = priv.killVotes ?? [];
|
|
592
|
-
if (votes.length) {
|
|
593
|
-
const line = el('p', 'wf-role-mates', '已交刀票:'
|
|
594
|
-
+ votes.map((entry) => `${entry.seatNo}号→${entry.target === null ? '弃' : `${entry.target}号`}`).join(','));
|
|
595
|
-
composer.append(line);
|
|
596
|
-
}
|
|
597
|
-
const chats = priv.wolfChat ?? [];
|
|
598
|
-
if (chats.length) {
|
|
599
|
-
for (const chat of chats) {
|
|
600
|
-
composer.append(el('p', 'wf-role-mates', `${chat.seatNo}号 ${chat.name}:「${chat.text}」`));
|
|
601
|
-
}
|
|
602
|
-
}
|
|
603
594
|
}
|
|
604
595
|
return composer;
|
|
605
596
|
}
|
|
606
597
|
|
|
598
|
+
function wolfPanel(priv) {
|
|
599
|
+
if (priv?.role !== 'wolf' || priv.alive === false) return null;
|
|
600
|
+
const votes = priv.killVotes ?? [];
|
|
601
|
+
const chats = priv.wolfChat ?? [];
|
|
602
|
+
if (!votes.length && !chats.length && priv.lockedKill == null) return null;
|
|
603
|
+
const panel = el('section', 'wf-panel wf-wolf-info');
|
|
604
|
+
panel.append(el('h3', 'wf-panel-title', '狼队信息(仅狼人可见)'));
|
|
605
|
+
const body = el('div', 'wf-tabbody');
|
|
606
|
+
if (votes.length) body.append(el('p', 'wf-role-mates', '已交刀票:'
|
|
607
|
+
+ votes.map((entry) => `${entry.seatNo}号→${entry.target === null ? '弃' : `${entry.target}号`}`).join(',')));
|
|
608
|
+
for (const chat of chats) body.append(el('p', 'wf-role-mates', `${chat.seatNo}号 ${chat.name}:「${chat.text}」`));
|
|
609
|
+
if (priv.lockedKill != null) body.append(el('p', 'wf-role-mates', `今夜锁定刀口:${seatLabel(priv.lockedKill)}`));
|
|
610
|
+
panel.append(body);
|
|
611
|
+
return panel;
|
|
612
|
+
}
|
|
613
|
+
|
|
607
614
|
// 查验记录属于整局私视图,不能随验人动作槽关闭而消失。
|
|
608
615
|
function inspectionPanel(priv) {
|
|
609
616
|
if (priv?.role !== 'seer' || !priv.inspections?.length) return null;
|
|
@@ -748,6 +755,14 @@ export function mountWerewolf(root, ctx) {
|
|
|
748
755
|
|
|
749
756
|
return {
|
|
750
757
|
update(next) {
|
|
758
|
+
const nextContext = JSON.stringify([
|
|
759
|
+
next.table?.tableId || next.table?.id || '', next.me?.id, next.priv?.role,
|
|
760
|
+
next.priv?.windowId, next.table?.phase,
|
|
761
|
+
]);
|
|
762
|
+
if (nextContext !== selectionContext) {
|
|
763
|
+
selectionContext = nextContext;
|
|
764
|
+
votePick = inspectPick = poisonPick = shootPick = wolfKillPick = null;
|
|
765
|
+
}
|
|
751
766
|
view = next;
|
|
752
767
|
const nextTableId = next.table?.tableId || next.table?.id || '';
|
|
753
768
|
if (nextTableId !== tableId) {
|
package/src/web/parent.html
CHANGED
|
@@ -7,7 +7,7 @@
|
|
|
7
7
|
<meta name="color-scheme" content="light">
|
|
8
8
|
<meta name="referrer" content="no-referrer">
|
|
9
9
|
<title>客厅 · 家长</title>
|
|
10
|
-
<link rel="stylesheet" href="/parent/assets/parent.css?v=0.35.
|
|
10
|
+
<link rel="stylesheet" href="/parent/assets/parent.css?v=0.35.6">
|
|
11
11
|
</head>
|
|
12
12
|
<body class="theme-cozy">
|
|
13
13
|
<a class="skip-link" href="#main">跳到主要内容</a>
|
|
@@ -76,6 +76,6 @@
|
|
|
76
76
|
</main>
|
|
77
77
|
|
|
78
78
|
<div id="toast" class="toast" role="status" aria-live="polite" hidden></div>
|
|
79
|
-
<script type="module" src="/parent/assets/parent.js?v=0.35.
|
|
79
|
+
<script type="module" src="/parent/assets/parent.js?v=0.35.6"></script>
|
|
80
80
|
</body>
|
|
81
81
|
</html>
|
package/src/web/play.html
CHANGED
|
@@ -6,11 +6,11 @@
|
|
|
6
6
|
<meta name="theme-color" content="#10191b">
|
|
7
7
|
<meta name="color-scheme" content="dark light">
|
|
8
8
|
<title>鲸语会馆 · 今晚,来一局</title>
|
|
9
|
-
<script src="/play/assets/theme.js?v=0.35.
|
|
9
|
+
<script src="/play/assets/theme.js?v=0.35.6"></script>
|
|
10
10
|
<link rel="stylesheet" href="/play/assets/play.css">
|
|
11
|
-
<link rel="stylesheet" href="/play/assets/club.css?v=0.35.
|
|
12
|
-
<link rel="stylesheet" href="/play/assets/appearance.css?v=0.35.
|
|
13
|
-
<link rel="stylesheet" href="/play/assets/night.css?v=0.35.
|
|
11
|
+
<link rel="stylesheet" href="/play/assets/club.css?v=0.35.6">
|
|
12
|
+
<link rel="stylesheet" href="/play/assets/appearance.css?v=0.35.6">
|
|
13
|
+
<link rel="stylesheet" href="/play/assets/night.css?v=0.35.6">
|
|
14
14
|
</head>
|
|
15
15
|
<body class="theme-club">
|
|
16
16
|
<svg class="sprite" aria-hidden="true" width="0" height="0" focusable="false">
|
|
@@ -106,6 +106,6 @@
|
|
|
106
106
|
<div id="app" class="app"><div class="booting" id="boot-note">正在打开客厅…</div></div>
|
|
107
107
|
<div id="toast" class="toast" role="status" aria-live="polite" hidden></div>
|
|
108
108
|
<noscript><p class="noscript">这个页面要开 JavaScript 才能玩。</p></noscript>
|
|
109
|
-
<script type="module" src="/play/assets/vue-loader.js?v=0.35.
|
|
109
|
+
<script type="module" src="/play/assets/vue-loader.js?v=0.35.6"></script>
|
|
110
110
|
</body>
|
|
111
111
|
</html>
|