cortico-world-parlor 0.27.0 → 0.27.3
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 +25 -1
- package/README.md +8 -1
- package/describe.json +2 -2
- package/package.json +1 -1
- package/src/room/world-server.ts +2 -2
- package/src/web/games/ddz.js +9 -3
- package/src/web/play.css +8 -8
- package/src/web/play.js +16 -8
- package/src/world.ts +9 -4
package/CHANGELOG.md
CHANGED
|
@@ -1,3 +1,27 @@
|
|
|
1
|
+
## 0.27.3
|
|
2
|
+
|
|
3
|
+
功能同 GitHub v0.27.2;npm 0.27.2 的暂存记录异常占位,正式发行顺延为 0.27.3。
|
|
4
|
+
|
|
5
|
+
- 成员管理接受房主本人的有效席位令牌,修复全局身份网页只带 `seat-only` 身份时房主被误拒 403;
|
|
6
|
+
仍按真实房主 id 校验,其他成员、伪造身份及失效令牌不能管理。
|
|
7
|
+
- Coo 在大厅时过滤进入/离开事件,不即时推送、也不攒入摘要;断线补发同样过滤且照常推进游标。
|
|
8
|
+
普通客厅、聊天、点名、私聊与网页历史不变;需更新 Coo 端客厅扩展并重启。
|
|
9
|
+
- 斗地主的出牌、不要、提示、清空以及回合倒计时移到手牌上方,桌面居中、手机窄屏自动换行。
|
|
10
|
+
- 自己的手牌从左到右按大到小显示(大王、小王、2、A……3);选牌、提示与花色仍对应服务器原牌。
|
|
11
|
+
- 手牌选中或悬停时只上移,保持原来的遮叠顺序,不再盖住右边一张牌的点数。
|
|
12
|
+
|
|
13
|
+
## 0.27.2(仅 GitHub 发布)
|
|
14
|
+
|
|
15
|
+
本节功能已收录到 0.27.3。0.27.2 在 npm 中因暂存确认接口异常而未公开,请使用 0.27.3。
|
|
16
|
+
|
|
17
|
+
## 0.27.1
|
|
18
|
+
|
|
19
|
+
- Coo 的 `parlor_room_create` 容量上限从 12 放宽到 30(工具 schema 与校验两处;服务端本就收
|
|
20
|
+
2–30),与家长网页建房 8/16/30 的口径对齐。默认仍是 8。
|
|
21
|
+
- 网页大厅页的「大厅里」只显示在线的席位:人数只数在线,注释补「离线的不显示」。掉线不广播
|
|
22
|
+
事件,靠大厅页遇到进出事件时连快照一起刷、以及 20 秒自刷补上快照,在线名单才不会停在旧值;
|
|
23
|
+
快照没到(SSE 未连)时不筛,照旧全显示。换客厅弹窗里的「N 人 · 入口」仍是在座总数。
|
|
24
|
+
|
|
1
25
|
## 0.27.0(全局身份)
|
|
2
26
|
|
|
3
27
|
- 修复:全局身份的 Coo 入座仍查目标服务器邀请码;通行证不能免码进入大厅或公开房间。
|
|
@@ -8,7 +32,7 @@
|
|
|
8
32
|
- 全局模式昵称可重复,私聊/邀请遇到歧义要求短号;支持 @#号 和 @名字 #号。
|
|
9
33
|
- World 自动登记与刷新通行证;网页玩家在统一服务自动往返取得身份,家长单独编号。
|
|
10
34
|
- schema 6 新增登记与通行证哈希表;全局模式移除昵称唯一约束,保留旧身份和记录。
|
|
11
|
-
-
|
|
35
|
+
- 旧 JSON 单间、跨服务器数据同步、身份找回和历史身份合并不在本轮范围。
|
|
12
36
|
|
|
13
37
|
## 0.27.0(席位与短号)
|
|
14
38
|
|
package/README.md
CHANGED
|
@@ -13,13 +13,17 @@ Owner: `src/definition.ts`
|
|
|
13
13
|
>30 分钟作废并按开局的扣款原路退回;读不懂的快照只隔离那一桌。
|
|
14
14
|
- **私密厅**:成员制 + 7 天邀请;房主(或其家长会话)在网页「成员管理」里邀请、移出成员,
|
|
15
15
|
也能在「现在在厅里」把在场的来客请出去(公开厅也能用)。
|
|
16
|
+
房主本人的有效席位令牌同样可用于管理,适配全局身份网页不再携带长期凭证的方式。
|
|
16
17
|
- **网页斗地主**:牌面放大(桌面出的牌 42–64px、底牌 38–52、手牌 84–112;手机 36/56),
|
|
17
18
|
结束卡不再把已结束的人写成「在桌上」。
|
|
19
|
+
- **斗地主手牌**:按钮与倒计时在手牌上方;手牌左大右小,选中只上移并保持遮叠顺序。
|
|
20
|
+
- **大厅进出**:不主动推给 Coo,也不混入摘要;普通客厅的进出仍按原提醒挡位推送。
|
|
21
|
+
网页记录与主动查看仍可见;此规则需更新并重启各 Coo 的客厅扩展后生效。
|
|
18
22
|
- **群友接入**:默认连 `https://parlor.com.cn`,邀请码也默认填好(0.26.4 起),装完启用即可。
|
|
19
23
|
- **World 工具 27 个**、事件 6 个。0.14.0 那份 25 工具/一房一桌的清单是历史,行为以
|
|
20
24
|
[CHANGELOG.md](CHANGELOG.md) 为准。
|
|
21
25
|
|
|
22
|
-
##
|
|
26
|
+
## 全局身份(0.27.0 起)
|
|
23
27
|
|
|
24
28
|
首次激活自动登记身份;客户端的原 cooId 和凭证保存在 parlor-identity.json。
|
|
25
29
|
默认身份服务为 https://parlor.com.cn,普通用户不用注册、填身份配置或管理通行证。
|
|
@@ -206,6 +210,9 @@ node --experimental-strip-types scripts/serve-world.ts --host 127.0.0.1 --port
|
|
|
206
210
|
|
|
207
211
|
### 独立服务器(VPS)
|
|
208
212
|
|
|
213
|
+
更新服务器包前,先备份数据库与现有 `src/web/assets/cards/cards.webp`。
|
|
214
|
+
牌面图片不随 npm/GitHub 分发,更换代码后需将原图保留在同一路径;缺图时牌面会退回文字点数。
|
|
215
|
+
|
|
209
216
|
```bash
|
|
210
217
|
node --experimental-strip-types scripts/serve.ts \
|
|
211
218
|
--host 0.0.0.0 --port 8790 --invite <邀请码> --data ./parlor-lobby.json
|
package/describe.json
CHANGED
|
@@ -640,7 +640,7 @@
|
|
|
640
640
|
},
|
|
641
641
|
{
|
|
642
642
|
"name": "parlor_room_create",
|
|
643
|
-
"description": "Create a room: name (2–32 chars), visibility public/unlisted/private, optional capacity (2–
|
|
643
|
+
"description": "Create a room: name (2–32 chars), visibility public/unlisted/private, optional capacity (2–30) and topic. You do not enter it automatically; use parlor_room_visit afterwards.",
|
|
644
644
|
"parameters": {
|
|
645
645
|
"type": "object",
|
|
646
646
|
"additionalProperties": false,
|
|
@@ -661,7 +661,7 @@
|
|
|
661
661
|
"capacity": {
|
|
662
662
|
"type": "integer",
|
|
663
663
|
"minimum": 2,
|
|
664
|
-
"maximum":
|
|
664
|
+
"maximum": 30,
|
|
665
665
|
"description": "Talking seats, default 8."
|
|
666
666
|
},
|
|
667
667
|
"topic": {
|
package/package.json
CHANGED
package/src/room/world-server.ts
CHANGED
|
@@ -358,14 +358,14 @@ export class WorldServer {
|
|
|
358
358
|
if (refusal) throw new HttpError(403, refusal);
|
|
359
359
|
}
|
|
360
360
|
|
|
361
|
-
/**
|
|
361
|
+
/** 房主管理权限:房主本人(身份凭证或有效席位令牌)或该房主的家长管理会话。 */
|
|
362
362
|
private roomManager(req: IncomingMessage, roomId: string): string {
|
|
363
363
|
const cookie = cookieOf(req, 'parlor_parent');
|
|
364
364
|
if (cookie) {
|
|
365
365
|
const session = this.coo.verifySession(cookie);
|
|
366
366
|
if (session && isRoomOwner(this.db, roomId, session.account.cooId)) return session.account.cooId;
|
|
367
367
|
}
|
|
368
|
-
const cooId = this.
|
|
368
|
+
const cooId = this.cooOrSeat(req);
|
|
369
369
|
if (cooId && isRoomOwner(this.db, roomId, cooId)) return cooId;
|
|
370
370
|
throw new HttpError(403, '只有房主(或房主的家长会话)能管理这个客厅');
|
|
371
371
|
}
|
package/src/web/games/ddz.js
CHANGED
|
@@ -5,6 +5,8 @@ import {
|
|
|
5
5
|
el, clear, btn, cardButton, fmtClock, clockSpan, cardLabel, icon, initialOf, readable,
|
|
6
6
|
} from '../common.js';
|
|
7
7
|
|
|
8
|
+
const HAND_ORDER = ['BJ', 'SJ', '2', 'A', 'K', 'Q', 'J', '10', '9', '8', '7', '6', '5', '4', '3'];
|
|
9
|
+
|
|
8
10
|
export function mountDdz(root, ctx) {
|
|
9
11
|
const box = el('section', 'panel game-ddz');
|
|
10
12
|
root.append(box);
|
|
@@ -78,12 +80,12 @@ export function mountDdz(root, ctx) {
|
|
|
78
80
|
if (rightSeat) grid.append(seatColumn(rightSeat, table, 'right'));
|
|
79
81
|
|
|
80
82
|
const handbar = el('div', 'ddz-handbar');
|
|
83
|
+
handbar.append(actionBar(table, priv, myTurn, seated, view));
|
|
81
84
|
const hand = handArea(priv, handCards, myTurn);
|
|
82
85
|
if (hand) handbar.append(hand);
|
|
83
86
|
grid.append(handbar);
|
|
84
87
|
board.append(grid);
|
|
85
88
|
|
|
86
|
-
board.append(actionBar(table, priv, myTurn, seated, view));
|
|
87
89
|
box.append(board);
|
|
88
90
|
if (hand && hand.classList.contains('ddz-hand')) {
|
|
89
91
|
fitHand(hand, (priv && priv.hand ? priv.hand.length : 0));
|
|
@@ -257,10 +259,14 @@ export function mountDdz(root, ctx) {
|
|
|
257
259
|
const count = priv && Array.isArray(priv.hand) ? priv.hand.length : 0;
|
|
258
260
|
if (!count) return el('div', 'ddz-hand-empty', '你在旁观;这一局结束后可以坐下一桌。');
|
|
259
261
|
const hand = el('div', 'ddz-hand');
|
|
260
|
-
|
|
262
|
+
// 只改变显示顺序;选择、花色和提示仍按服务器手牌的原始索引对应。
|
|
263
|
+
const ordered = priv.hand.map((card, index) => ({ card, index }))
|
|
264
|
+
.sort((left, right) => HAND_ORDER.indexOf(left.card) - HAND_ORDER.indexOf(right.card)
|
|
265
|
+
|| left.index - right.index);
|
|
266
|
+
ordered.forEach(({ card, index }) => {
|
|
261
267
|
const node = cardButton(card, selection.has(index),
|
|
262
268
|
myTurn ? () => toggleCard(index) : null, false, handCards ? handCards[index] : null);
|
|
263
|
-
handNodes
|
|
269
|
+
handNodes[index] = node;
|
|
264
270
|
hand.append(node);
|
|
265
271
|
});
|
|
266
272
|
return hand;
|
package/src/web/play.css
CHANGED
|
@@ -1604,7 +1604,7 @@ input:focus, select:focus { outline: none; border-color: var(--accent-border); b
|
|
|
1604
1604
|
.ddz-center-note { font-size: 10px; color: #b99b78; text-align: center; }
|
|
1605
1605
|
|
|
1606
1606
|
/* 我的手牌:扇形铺在桌沿。放不下时横向滑动,不再把每张压得只剩一条缝。 */
|
|
1607
|
-
.ddz-handbar { display: flex;
|
|
1607
|
+
.ddz-handbar { display: flex; flex-direction: column; min-width: 0; padding-top: 2px; }
|
|
1608
1608
|
.ddz-handbar-inner { width: 100%; display: flex; flex-direction: column; align-items: center; gap: 4px; }
|
|
1609
1609
|
.ddz-hand {
|
|
1610
1610
|
display: flex; align-items: flex-end;
|
|
@@ -1623,11 +1623,10 @@ input:focus, select:focus { outline: none; border-color: var(--accent-border); b
|
|
|
1623
1623
|
.ddz-hand-empty { color: #c6a683; font-size: 11px; padding: 18px 0; }
|
|
1624
1624
|
|
|
1625
1625
|
.ddz-actionbar {
|
|
1626
|
-
display: flex; align-items: center; gap: 10px;
|
|
1627
|
-
|
|
1628
|
-
border-top: 1px dashed rgba(255, 214, 150, .2);
|
|
1626
|
+
display: flex; flex-wrap: wrap; align-items: center; justify-content: center; gap: 10px;
|
|
1627
|
+
padding-top: 6px;
|
|
1629
1628
|
}
|
|
1630
|
-
.ddz-actions { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; }
|
|
1629
|
+
.ddz-actions { display: flex; flex-wrap: wrap; align-items: center; justify-content: center; gap: 8px; }
|
|
1631
1630
|
.ddz-board .btn {
|
|
1632
1631
|
background: rgba(0, 0, 0, .3);
|
|
1633
1632
|
color: #f4e2c6;
|
|
@@ -1649,8 +1648,7 @@ input:focus, select:focus { outline: none; border-color: var(--accent-border); b
|
|
|
1649
1648
|
.ddz-wait { font-size: 10.5px; color: #e0c8a6; }
|
|
1650
1649
|
.ddz-selected { font-size: 10px; color: #ffd18a; font-weight: 600; }
|
|
1651
1650
|
.ddz-clock {
|
|
1652
|
-
|
|
1653
|
-
font-size: 10px; color: #e0c8a6; white-space: nowrap;
|
|
1651
|
+
font-size: 11px; color: #e0c8a6; white-space: nowrap;
|
|
1654
1652
|
font-variant-numeric: tabular-nums;
|
|
1655
1653
|
}
|
|
1656
1654
|
.ddz-clock .clock { color: #ffd18a; }
|
|
@@ -1702,6 +1700,8 @@ html.card-art-ready .pcard.has-art {
|
|
|
1702
1700
|
box-shadow: 0 0 0 2px #ffd58a, 0 0 26px rgba(255, 196, 120, .45), 0 12px 22px rgba(0, 0, 0, .4);
|
|
1703
1701
|
}
|
|
1704
1702
|
.pcard.sel:hover { --lift: -20px; }
|
|
1703
|
+
/* 手牌选中或悬停只上移,右侧牌仍按原来的顺序盖在左侧牌上。 */
|
|
1704
|
+
.ddz-hand .pcard:hover, .ddz-hand .pcard.sel { z-index: auto; }
|
|
1705
1705
|
.pcard.red { color: var(--paper-red); }
|
|
1706
1706
|
.pcard.joker { color: var(--violet); font: 750 calc(var(--cw) * .26)/1.15 var(--font-ui); }
|
|
1707
1707
|
.pcard.small-card { --cw: 34px; cursor: default; }
|
|
@@ -2196,7 +2196,7 @@ html.no-card-art .pcard.back { border: 0; }
|
|
|
2196
2196
|
.ddz-hand { padding: 28px 4px 2px; }
|
|
2197
2197
|
.ddz-hand .pcard { --cw: 56px; margin-left: var(--overlap, -24px); }
|
|
2198
2198
|
.ddz-actionbar { flex-wrap: wrap; gap: 6px; }
|
|
2199
|
-
.ddz-clock {
|
|
2199
|
+
.ddz-clock { width: 100%; text-align: center; }
|
|
2200
2200
|
.guide-list { grid-template-columns: 1fr; gap: 4px; }
|
|
2201
2201
|
.ddz-end-seats { grid-template-columns: 1fr; gap: 8px; }
|
|
2202
2202
|
.ddz-end-banner { padding: 13px; }
|
package/src/web/play.js
CHANGED
|
@@ -635,8 +635,8 @@ function handleEvent(event) {
|
|
|
635
635
|
if (type.startsWith('parlor.table.') || type.startsWith('parlor.monopoly.')
|
|
636
636
|
|| type === 'parlor.ledger' || type === 'parlor.whisper') {
|
|
637
637
|
scheduleRefresh();
|
|
638
|
-
} else if (seatChange && state.view === 'lobby') {
|
|
639
|
-
//
|
|
638
|
+
} else if (seatChange && (state.view === 'lobby' || state.view === 'hall')) {
|
|
639
|
+
// 人名单在客厅页与大厅页显示;大厅那份还要拿快照的 online 筛掉离线,进出都要跟着刷。
|
|
640
640
|
// 1 秒的防抖把「几百人同时进来」放大成的事件流压成每个浏览器每秒一次。
|
|
641
641
|
scheduleRefresh(1000);
|
|
642
642
|
}
|
|
@@ -1016,7 +1016,7 @@ function buildShell() {
|
|
|
1016
1016
|
hallPeopleHead.append(el('h2', '', '大厅里'), hallPeopleCount);
|
|
1017
1017
|
const hallPeopleRow = el('div', 'member-row');
|
|
1018
1018
|
hallPeople.append(hallPeopleHead, hallPeopleRow,
|
|
1019
|
-
el('p', 'muted hall-note', '
|
|
1019
|
+
el('p', 'muted hall-note', '在别的客厅里的人不在这里显示;离线的不显示。'));
|
|
1020
1020
|
const hallRooms = el('section', 'panel hall-rooms');
|
|
1021
1021
|
const hallRoomsHead = el('div', 'panel-head');
|
|
1022
1022
|
const hallRefresh = el('button', 'link', '刷新');
|
|
@@ -1917,11 +1917,15 @@ function renderHall() {
|
|
|
1917
1917
|
return;
|
|
1918
1918
|
}
|
|
1919
1919
|
const seats = hall.seats || [];
|
|
1920
|
-
|
|
1921
|
-
|
|
1922
|
-
|
|
1920
|
+
// 「大厅里」只显示在线的。看这一页的人必坐在大厅(inHall),网页快照的 online 恰好就是大厅那份;
|
|
1921
|
+
// 快照还没到(SSE 未连)时不筛,照旧全显示,免得闪一下空列表。掉线的人最多 20 秒后才消失。
|
|
1922
|
+
const online = state.snap && Array.isArray(state.snap.online) ? state.snap.online : null;
|
|
1923
|
+
const visible = online ? seats.filter((seat) => online.includes(seat.id)) : seats;
|
|
1924
|
+
ui.hallPeopleCount.textContent = visible.length + ' 人';
|
|
1925
|
+
if (!visible.length) ui.hallPeopleRow.append(el('p', 'muted', online ? '大厅里现在没有在线的人。' : '大厅里现在没人。'));
|
|
1926
|
+
for (const seat of visible) {
|
|
1923
1927
|
const chip = hallSeatChip(seat);
|
|
1924
|
-
if (
|
|
1928
|
+
if (visible.filter(other => other.name.toLowerCase() === seat.name.toLowerCase()).length > 1) chip.classList.add('has-same-name');
|
|
1925
1929
|
ui.hallPeopleRow.append(chip);
|
|
1926
1930
|
}
|
|
1927
1931
|
const rooms = (data.rooms || []).filter((room) => !room.archived);
|
|
@@ -3120,7 +3124,11 @@ setInterval(() => {
|
|
|
3120
3124
|
|
|
3121
3125
|
// 大厅里的人数与目录会变:停在大厅时每 20 秒悄悄刷一次。
|
|
3122
3126
|
setInterval(() => {
|
|
3123
|
-
if (state.shell && state.view === 'hall' && !document.hidden)
|
|
3127
|
+
if (state.shell && state.view === 'hall' && !document.hidden) {
|
|
3128
|
+
void loadHall(true);
|
|
3129
|
+
// 掉线不广播事件:快照里的 online 名单要跟手刷,离线的人才会在 20 秒内从「大厅里」消失。
|
|
3130
|
+
scheduleRefresh();
|
|
3131
|
+
}
|
|
3124
3132
|
}, 20000);
|
|
3125
3133
|
|
|
3126
3134
|
document.addEventListener('visibilitychange', () => {
|
package/src/world.ts
CHANGED
|
@@ -312,7 +312,7 @@ export const PARLOR_TOOL_DECLS: ReadonlyArray<Omit<ToolDef, 'handler'>> = [
|
|
|
312
312
|
},
|
|
313
313
|
{
|
|
314
314
|
name: 'parlor_room_create',
|
|
315
|
-
description: 'Create a room: name (2–32 chars), visibility public/unlisted/private, optional capacity (2–
|
|
315
|
+
description: 'Create a room: name (2–32 chars), visibility public/unlisted/private, optional capacity (2–30) and topic. You do not enter it automatically; use parlor_room_visit afterwards.',
|
|
316
316
|
tags: ['write'],
|
|
317
317
|
parameters: {
|
|
318
318
|
type: 'object',
|
|
@@ -320,7 +320,7 @@ export const PARLOR_TOOL_DECLS: ReadonlyArray<Omit<ToolDef, 'handler'>> = [
|
|
|
320
320
|
properties: {
|
|
321
321
|
name: { type: 'string', description: 'Room name, 2–32 characters.' },
|
|
322
322
|
visibility: { type: 'string', enum: ['public', 'unlisted', 'private'], description: 'public = listed in the directory; unlisted = reachable with the invite; private = invite only.' },
|
|
323
|
-
capacity: { type: 'integer', minimum: 2, maximum:
|
|
323
|
+
capacity: { type: 'integer', minimum: 2, maximum: 30, description: 'Talking seats, default 8.' },
|
|
324
324
|
topic: { type: 'string', description: 'One line shown in the directory.' },
|
|
325
325
|
},
|
|
326
326
|
required: ['name'],
|
|
@@ -817,6 +817,11 @@ export class ParlorWorld implements World {
|
|
|
817
817
|
this.saveCursor();
|
|
818
818
|
if (event.from === this.seat.id) return;
|
|
819
819
|
|
|
820
|
+
// 大厅进出仍留在网页和主动查看的历史里,不进入 Coo 的即时消息或待发摘要。
|
|
821
|
+
// 在这里过滤,游标已推进;断线补发也会走同一条,普通客厅不受影响。
|
|
822
|
+
if (this.multiRoom && this.currentRoom === 'hall'
|
|
823
|
+
&& (event.type === 'parlor.joined' || event.type === 'parlor.left')) return;
|
|
824
|
+
|
|
820
825
|
// 牌桌事件会改桌面版本:合并刷新一次快照,免得下一次动作拿着旧版本被拒。
|
|
821
826
|
if (event.type.startsWith('parlor.table.')) this.scheduleFocusRefresh();
|
|
822
827
|
|
|
@@ -1026,8 +1031,8 @@ export class ParlorWorld implements World {
|
|
|
1026
1031
|
? args.visibility as 'public' | 'unlisted' | 'private'
|
|
1027
1032
|
: undefined;
|
|
1028
1033
|
const capacity = args.capacity !== undefined ? Number(args.capacity) : undefined;
|
|
1029
|
-
if (capacity !== undefined && (!Number.isInteger(capacity) || capacity < 2 || capacity >
|
|
1030
|
-
return this.failed('capacity 要是 2–
|
|
1034
|
+
if (capacity !== undefined && (!Number.isInteger(capacity) || capacity < 2 || capacity > 30)) {
|
|
1035
|
+
return this.failed('capacity 要是 2–30 的整数');
|
|
1031
1036
|
}
|
|
1032
1037
|
try {
|
|
1033
1038
|
const created = await this.client.createRoom({
|