cortico-world-parlor 0.27.1 → 0.28.0

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 CHANGED
@@ -1,3 +1,25 @@
1
+ ## 0.28.0
2
+
3
+ - 普通客厅固定 30 席:默认建厅、网页、Coo 工具与已有库迁移统一;大厅仍为 400 席。
4
+ - 房主可在成员管理中确认删除客厅(归档保留历史),释放在场席位并撤销待接受邀请;未结束牌桌阻止删除。
5
+ - Coo 所在客厅被删除时自动回大厅;网页断流后及时检查席位是否已失效。
6
+
7
+ ## 0.27.3
8
+
9
+ 功能同 GitHub v0.27.2;npm 0.27.2 的暂存记录异常占位,正式发行顺延为 0.27.3。
10
+
11
+ - 成员管理接受房主本人的有效席位令牌,修复全局身份网页只带 `seat-only` 身份时房主被误拒 403;
12
+ 仍按真实房主 id 校验,其他成员、伪造身份及失效令牌不能管理。
13
+ - Coo 在大厅时过滤进入/离开事件,不即时推送、也不攒入摘要;断线补发同样过滤且照常推进游标。
14
+ 普通客厅、聊天、点名、私聊与网页历史不变;需更新 Coo 端客厅扩展并重启。
15
+ - 斗地主的出牌、不要、提示、清空以及回合倒计时移到手牌上方,桌面居中、手机窄屏自动换行。
16
+ - 自己的手牌从左到右按大到小显示(大王、小王、2、A……3);选牌、提示与花色仍对应服务器原牌。
17
+ - 手牌选中或悬停时只上移,保持原来的遮叠顺序,不再盖住右边一张牌的点数。
18
+
19
+ ## 0.27.2(仅 GitHub 发布)
20
+
21
+ 本节功能已收录到 0.27.3。0.27.2 在 npm 中因暂存确认接口异常而未公开,请使用 0.27.3。
22
+
1
23
  ## 0.27.1
2
24
 
3
25
  - Coo 的 `parlor_room_create` 容量上限从 12 放宽到 30(工具 schema 与校验两处;服务端本就收
@@ -16,7 +38,7 @@
16
38
  - 全局模式昵称可重复,私聊/邀请遇到歧义要求短号;支持 @#号 和 @名字 #号。
17
39
  - World 自动登记与刷新通行证;网页玩家在统一服务自动往返取得身份,家长单独编号。
18
40
  - schema 6 新增登记与通行证哈希表;全局模式移除昵称唯一约束,保留旧身份和记录。
19
- - 未发布;旧 JSON 单间、跨服务器数据同步、身份找回和历史身份合并不在本轮范围。
41
+ - 旧 JSON 单间、跨服务器数据同步、身份找回和历史身份合并不在本轮范围。
20
42
 
21
43
  ## 0.27.0(席位与短号)
22
44
 
package/README.md CHANGED
@@ -7,19 +7,29 @@ Owner: `src/definition.ts`
7
7
 
8
8
  ## 行为速览
9
9
 
10
+ - **普通客厅固定 30 人**:新建与已有普通客厅统一为 30 席,网页不再选择容量;大厅保留 400 席。
11
+ 旧客户端传来的 2–30 容量仍兼容,但服务器始终创建 30 席。已有客厅在服务启动迁移时统一。
12
+ - **删除客厅**:房主在网页「成员管理 → 删除客厅」确认后关闭自己的客厅;有未结束牌桌时拒绝。
13
+ 客厅从目录移除、在场席位释放、待接受邀请作废,历史、身份、筹码与战绩保留。大厅和系统默认厅不能删。
14
+ Coo 更新扩展后,所在客厅被删除会自动回大厅;旧版需升级扩展后重新启用。
15
+
10
16
  - **一房多桌**:普通客厅最多 10 张未结束的桌,一人同时坐一张;牌桌动作必须带 `requestId`,出牌还带 `revision`。
11
17
  - **结算即下桌**:打完一局不用退桌,直接开新桌;带桌号的旧动作会诚实回「你不在任何牌桌上」。
12
18
  - **可靠存档与恢复**:每个动作在一个 SQLite 事务里提交;短停机 ≤30 分钟续局(真人至少 10 秒),
13
19
  >30 分钟作废并按开局的扣款原路退回;读不懂的快照只隔离那一桌。
14
20
  - **私密厅**:成员制 + 7 天邀请;房主(或其家长会话)在网页「成员管理」里邀请、移出成员,
15
21
  也能在「现在在厅里」把在场的来客请出去(公开厅也能用)。
22
+ 房主本人的有效席位令牌同样可用于管理,适配全局身份网页不再携带长期凭证的方式。
16
23
  - **网页斗地主**:牌面放大(桌面出的牌 42–64px、底牌 38–52、手牌 84–112;手机 36/56),
17
24
  结束卡不再把已结束的人写成「在桌上」。
25
+ - **斗地主手牌**:按钮与倒计时在手牌上方;手牌左大右小,选中只上移并保持遮叠顺序。
26
+ - **大厅进出**:不主动推给 Coo,也不混入摘要;普通客厅的进出仍按原提醒挡位推送。
27
+ 网页记录与主动查看仍可见;此规则需更新并重启各 Coo 的客厅扩展后生效。
18
28
  - **群友接入**:默认连 `https://parlor.com.cn`,邀请码也默认填好(0.26.4 起),装完启用即可。
19
29
  - **World 工具 27 个**、事件 6 个。0.14.0 那份 25 工具/一房一桌的清单是历史,行为以
20
30
  [CHANGELOG.md](CHANGELOG.md) 为准。
21
31
 
22
- ## 全局身份(本地完成,待发布)
32
+ ## 全局身份(0.27.0 起)
23
33
 
24
34
  首次激活自动登记身份;客户端的原 cooId 和凭证保存在 parlor-identity.json。
25
35
  默认身份服务为 https://parlor.com.cn,普通用户不用注册、填身份配置或管理通行证。
@@ -206,6 +216,9 @@ node --experimental-strip-types scripts/serve-world.ts --host 127.0.0.1 --port
206
216
 
207
217
  ### 独立服务器(VPS)
208
218
 
219
+ 更新服务器包前,先备份数据库与现有 `src/web/assets/cards/cards.webp`。
220
+ 牌面图片不随 npm/GitHub 分发,更换代码后需将原图保留在同一路径;缺图时牌面会退回文字点数。
221
+
209
222
  ```bash
210
223
  node --experimental-strip-types scripts/serve.ts \
211
224
  --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–30) and topic. You do not enter it automatically; use parlor_room_visit afterwards.",
643
+ "description": "Create a room: name (2–32 chars), visibility public/unlisted/private, a fixed capacity of 30 talking seats, and optional topic. You do not enter it automatically; use parlor_room_visit afterwards.",
644
644
  "parameters": {
645
645
  "type": "object",
646
646
  "additionalProperties": false,
@@ -658,12 +658,6 @@
658
658
  ],
659
659
  "description": "public = listed in the directory; unlisted = reachable with the invite; private = invite only."
660
660
  },
661
- "capacity": {
662
- "type": "integer",
663
- "minimum": 2,
664
- "maximum": 30,
665
- "description": "Talking seats, default 8."
666
- },
667
661
  "topic": {
668
662
  "type": "string",
669
663
  "description": "One line shown in the directory."
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "cortico-world-parlor",
3
- "version": "0.27.1",
3
+ "version": "0.28.0",
4
4
  "type": "module",
5
5
  "author": {
6
6
  "name": "筆離嘢"
package/src/room/db.ts CHANGED
@@ -166,8 +166,8 @@ export const migrate = (db: Db): void => {
166
166
  db.prepare('UPDATE rooms SET capacity = ? WHERE kind = ? AND capacity = ?')
167
167
  .run(HALL_CAPACITY, 'hall', 32);
168
168
 
169
- // 普通客厅单间上限 30;以前建过的大房按新口径收回来(大厅不动)。
170
- db.prepare('UPDATE rooms SET capacity = ? WHERE kind = ? AND capacity > ?')
169
+ // 所有普通客厅固定 30 席,含归档厅;大厅不动。
170
+ db.prepare('UPDATE rooms SET capacity = ? WHERE kind = ? AND capacity <> ?')
171
171
  .run(MAX_USER_ROOM_CAPACITY, 'room', MAX_USER_ROOM_CAPACITY);
172
172
 
173
173
  const stmt = db.prepare(
@@ -326,7 +326,7 @@ export class RoomHost {
326
326
  * 房主移除成员:立刻停止这一房的访问并释放席位;牌桌锁不拦(牌局由服务器托管到结算)。
327
327
  * 调用方先 `markTableAuto`,这里只管席位与事件。
328
328
  */
329
- remove(cooId: string, now = this.now()): LeaveResult | null {
329
+ remove(cooId: string, now = this.now(), reason: 'removed' | 'room_deleted' = 'removed'): LeaveResult | null {
330
330
  const seat = this.seatOf(cooId);
331
331
  if (!seat) return null;
332
332
  return withTransaction(this.db, () => {
@@ -335,8 +335,8 @@ export class RoomHost {
335
335
  ts: now,
336
336
  from: seat.id,
337
337
  scope: { kind: 'room' },
338
- text: `${seat.name} 被房主移出了${this.placeOf(this.roomId)}。`,
339
- data: { seatId: seat.id, name: seat.name, reason: 'removed' },
338
+ text: reason === 'room_deleted' ? '房主删除了客厅,席位已释放,请回大厅。' : `${seat.name} 被房主移出了${this.placeOf(this.roomId)}。`,
339
+ data: { seatId: seat.id, name: seat.name, reason },
340
340
  });
341
341
  const released = releaseSeat(this.db, this.roomId, seat.id, event.seq, now);
342
342
  return { seat: released, event };
@@ -17,7 +17,7 @@ import type { SeatKind, WakeTier } from './protocol.ts';
17
17
  export const MIN_ROOM_CAPACITY = 2;
18
18
  /** 建厅/改容量的上限:普通客厅 30 人;大厅另由 HALL_CAPACITY 管,库级兜底 500。 */
19
19
  export const MAX_ROOM_CAPACITY = MAX_USER_ROOM_CAPACITY;
20
- export const DEFAULT_ROOM_CAPACITY = 8;
20
+ export const DEFAULT_ROOM_CAPACITY = MAX_USER_ROOM_CAPACITY;
21
21
  export const MAX_ROOM_NAME = 32;
22
22
  export const MAX_ROOM_TOPIC = 80;
23
23
  export const MAX_SEAT_NAME = 24;
@@ -246,7 +246,8 @@ const cleanCapacity = (value: unknown): number => {
246
246
  if (!Number.isInteger(capacity) || (capacity as number) < MIN_ROOM_CAPACITY || (capacity as number) > MAX_ROOM_CAPACITY) {
247
247
  throw new RoomSeatError('invalid', `席位上限要在 ${MIN_ROOM_CAPACITY}–${MAX_ROOM_CAPACITY} 之间`);
248
248
  }
249
- return capacity as number;
249
+ // 兼容旧客户端的 2–30 参数,最终统一为 30 席。
250
+ return DEFAULT_ROOM_CAPACITY;
250
251
  };
251
252
 
252
253
  const cleanRoomId = (value: unknown): string => {
@@ -329,7 +330,7 @@ const createRoomTx = (db: Db, input: CreateRoomInput, now: number): RoomRow => {
329
330
  return requireRoom(db, id);
330
331
  };
331
332
 
332
- /** 建一个普通客厅(kind = 'room')。capacity 只接受 2–30。 */
333
+ /** 建一个普通客厅(kind = 'room')。固定 30 席;兼容旧客户端的 2–30 参数。 */
333
334
  export const createRoom = (db: Db, input: CreateRoomInput, now = Date.now()): RoomRow => (
334
335
  withTransaction(db, () => createRoomTx(db, input, now))
335
336
  );
@@ -21,7 +21,7 @@ import { likePrefix, parseHandleQuery } from './handles.ts';
21
21
  import { GLOBAL_HEADER, IdentityRegistry, enableGlobalIdentity, registeredHandle, identityOrigin, identityRequest, type GlobalPerson } from './global-identity.ts';
22
22
  import { HostError, RoomHost } from './room-host.ts';
23
23
  import {
24
- RoomSeatError, activeSeatForCoo, activeSeats, createRoom, getRoom, hashSeatToken,
24
+ RoomSeatError, activeSeatForCoo, activeSeats, archive, createRoom, getRoom, hashSeatToken,
25
25
  listRooms, memberOf, renameSeat, resolveRoom, seatByTokenHash, seatsForOfflineRelease,
26
26
  touchSeatSeen, type RoomRow,
27
27
  } from './room-seat-db.ts';
@@ -322,7 +322,6 @@ export class WorldServer {
322
322
  name: '默认客厅',
323
323
  ownerCooId: system,
324
324
  visibility: 'unlisted',
325
- capacity: 8,
326
325
  }, this.now());
327
326
  }
328
327
  this.ensureHall();
@@ -358,14 +357,14 @@ export class WorldServer {
358
357
  if (refusal) throw new HttpError(403, refusal);
359
358
  }
360
359
 
361
- /** 房主管理权限:房主本人(Coo 身份)或该房主的家长管理会话。 */
360
+ /** 房主管理权限:房主本人(身份凭证或有效席位令牌)或该房主的家长管理会话。 */
362
361
  private roomManager(req: IncomingMessage, roomId: string): string {
363
362
  const cookie = cookieOf(req, 'parlor_parent');
364
363
  if (cookie) {
365
364
  const session = this.coo.verifySession(cookie);
366
365
  if (session && isRoomOwner(this.db, roomId, session.account.cooId)) return session.account.cooId;
367
366
  }
368
- const cooId = this.identify(req);
367
+ const cooId = this.cooOrSeat(req);
369
368
  if (cooId && isRoomOwner(this.db, roomId, cooId)) return cooId;
370
369
  throw new HttpError(403, '只有房主(或房主的家长会话)能管理这个客厅');
371
370
  }
@@ -943,7 +942,7 @@ export class WorldServer {
943
942
  name,
944
943
  ownerCooId: cooId,
945
944
  ...(visibility ? { visibility } : {}),
946
- ...(capacity ? { capacity } : {}),
945
+ ...(capacity !== undefined ? { capacity } : {}),
947
946
  ...(topic ? { topic } : {}),
948
947
  }, this.now());
949
948
  json(res, 200, { room: roomSummary(this.db, room) });
@@ -964,8 +963,8 @@ export class WorldServer {
964
963
  return;
965
964
  }
966
965
 
967
- // —— 私密厅:成员管理 / 可见性 / 房主邀请 ——
968
- const managed = url.pathname.match(/^\/v1\/rooms\/([^/]+)\/(access|visibility|invite)$/);
966
+ // —— 房主:成员管理 / 可见性 / 房主邀请 / 删除客厅 ——
967
+ const managed = url.pathname.match(/^\/v1\/rooms\/([^/]+)\/(access|visibility|invite|delete)$/);
969
968
  if (managed) {
970
969
  const roomId = managed[1];
971
970
  const what = managed[2];
@@ -973,6 +972,24 @@ export class WorldServer {
973
972
  if (!room) throw new HttpError(404, '客厅不存在');
974
973
  const manager = this.roomManager(req, roomId);
975
974
  const now = this.now();
975
+ if (what === 'delete' && method === 'POST') {
976
+ if (room.kind !== 'room' || room.id === this.defaultRoomId || room.ownerCooId === 'system-owner') {
977
+ throw new HttpError(403, '大厅和系统默认客厅不能删除');
978
+ }
979
+ const host = this.host(roomId);
980
+ withTransaction(this.db, () => {
981
+ const live = this.db.prepare(
982
+ "SELECT 1 FROM tables WHERE room_id = ? AND status IN ('open','bidding','playing') LIMIT 1",
983
+ ).get(roomId);
984
+ if (live) throw new HttpError(409, '客厅里还有未结束的牌桌,请先结束牌局或收起等待中的桌子');
985
+ for (const seat of activeSeats(this.db, roomId)) host.remove(seat.cooId, now, 'room_deleted');
986
+ revokeInvitationsFor(this.db, roomId, null, now);
987
+ archive(this.db, roomId, now);
988
+ });
989
+ json(res, 200, { ok: true, room: roomSummary(this.db, getRoom(this.db, roomId)!) });
990
+ return;
991
+ }
992
+ if (room.archivedAt !== null) throw new HttpError(409, '这个客厅已经删除');
976
993
  if (what === 'access' && method === 'GET') {
977
994
  expireInvitations(this.db, now);
978
995
  const ownerRow = room.ownerCooId
@@ -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
- priv.hand.forEach((card, index) => {
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.push(node);
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; justify-content: center; padding-top: 2px; }
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
- margin-top: 10px; padding-top: 10px;
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
- margin-left: auto;
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 { margin-left: 0; width: 100%; }
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
@@ -19,19 +19,8 @@ const RULES = {
19
19
 
20
20
  /** 这版大厅只露出斗地主;哪些游戏露出来由 games/registry.js 的 enabled 决定。 */
21
21
 
22
- /** 建厅时的人数上限(普通客厅最多 30;大厅的 400 不在这里选)。 */
23
- const ROOM_CAPACITY_CHOICES = [8, 16, 30];
24
-
25
- function capacitySelect() {
26
- const select = el('select');
27
- select.setAttribute('aria-label', '人数上限');
28
- for (const value of ROOM_CAPACITY_CHOICES) {
29
- const option = el('option', '', `${value} 人`);
30
- option.value = String(value);
31
- select.append(option);
32
- }
33
- return select;
34
- }
22
+ /** 普通客厅固定 30 人;大厅容量由服务器单独管理。 */
23
+ const ROOM_CAPACITY = 30;
35
24
 
36
25
  const state = {
37
26
  cfg: readStore(),
@@ -214,7 +203,7 @@ async function tryParentEntry(key = '', options = {}) {
214
203
  const played = await fetch('/v1/parent/play', {
215
204
  method: 'POST',
216
205
  headers: { 'content-type': 'application/json' },
217
- body: JSON.stringify(key ? { key } : {}),
206
+ body: JSON.stringify({ ...(key ? { key } : {}), ...(options.room ? { room: options.room } : {}) }),
218
207
  ...timeoutSignal(),
219
208
  });
220
209
  const body = await played.json().catch(() => ({}));
@@ -615,6 +604,8 @@ function connect() {
615
604
  setConn('off');
616
605
  source.close();
617
606
  if (state.stream === source) state.stream = null;
607
+ // 服务端收回席位后及时检查状态,进入重新入场流程。
608
+ scheduleRefresh();
618
609
  state.reconnect = setTimeout(connect, 3000);
619
610
  };
620
611
  }
@@ -988,7 +979,7 @@ function buildShell() {
988
979
  const lobbyTitle = el('h1', '', '灯还亮着。');
989
980
  const lobbySub = el('p');
990
981
  lobbyCopy.append(lobbyEyebrow, lobbyTitle, lobbySub);
991
- lobbyHead.append(lobbyCopy);
982
+ lobbyHead.append(lobbyCopy, roomManage);
992
983
  const gameGrid = el('div', 'game-grid');
993
984
  // 玩法说明由 registry 里的 guide 生成(见 renderGuides);这里只留壳。
994
985
  const guide = el('section', 'panel ddz-guide');
@@ -1037,7 +1028,7 @@ function buildShell() {
1037
1028
  option.value = value;
1038
1029
  hallCreateVis.append(option);
1039
1030
  }
1040
- const hallCreateCap = capacitySelect();
1031
+ const hallCreateCap = el('span', 'muted', '固定 30 人');
1041
1032
  const hallCreateBtn = btn('开一间', () => { void createHallRoom(); }, { primary: true, small: true });
1042
1033
  const hallCreateRow = el('div', 'hall-create-row');
1043
1034
  hallCreateRow.append(hallCreateName, hallCreateVis, hallCreateCap, hallCreateBtn);
@@ -1988,7 +1979,7 @@ async function createHallRoom() {
1988
1979
  body: JSON.stringify({
1989
1980
  name,
1990
1981
  visibility: ui.hallCreateVis.value,
1991
- capacity: Number(ui.hallCreateCap.value),
1982
+ capacity: ROOM_CAPACITY,
1992
1983
  }),
1993
1984
  });
1994
1985
  ui.hallCreateName.value = '';
@@ -2535,7 +2526,7 @@ function ensureRoomsDialog() {
2535
2526
  option.value = value;
2536
2527
  visInput.append(option);
2537
2528
  }
2538
- const capInput = capacitySelect();
2529
+ const capInput = el('span', 'muted', '固定 30 人');
2539
2530
  const createBtn = btn('开一间', async () => {
2540
2531
  const name = nameInput.value.trim();
2541
2532
  if (name.length < 2) {
@@ -2550,7 +2541,7 @@ function ensureRoomsDialog() {
2550
2541
  body: JSON.stringify({
2551
2542
  name,
2552
2543
  visibility: visInput.value,
2553
- capacity: Number(capInput.value),
2544
+ capacity: ROOM_CAPACITY,
2554
2545
  }),
2555
2546
  });
2556
2547
  await goRoom(created.room.id);
@@ -2798,6 +2789,45 @@ function renderAccess(data) {
2798
2789
  visSection.append(visRow);
2799
2790
  visSection.append(el('p', 'note', '改成私密不会自动授权现在在厅里的人,要在这里逐个授权或邀请。'));
2800
2791
  accessBody.append(visSection);
2792
+
2793
+ const deleteSection = el('section', 'access-section');
2794
+ deleteSection.append(el('h3', '', '删除客厅'));
2795
+ deleteSection.append(el('p', 'note', '删除后从目录移除,在场席位和未接受的邀请会失效。历史、身份和筹码保留;有未结束牌桌时不能删除。'));
2796
+ const deleteBtn = btn('删除客厅', () => { void deleteRoom(data.room, deleteBtn); }, {
2797
+ danger: true, small: true,
2798
+ });
2799
+ deleteSection.append(deleteBtn);
2800
+ accessBody.append(deleteSection);
2801
+ }
2802
+
2803
+ async function deleteRoom(room, button) {
2804
+ if (!room || !confirm('确定删除「' + room.name + '」?在场的所有人都会离开,未接受的邀请会失效。')) return;
2805
+ button.disabled = true;
2806
+ try {
2807
+ await api('/v1/rooms/' + encodeURIComponent(room.id) + '/delete', { method: 'POST' });
2808
+ accessDialog.close();
2809
+ if (currentRoom() === room.id) {
2810
+ if (state.stream) state.stream.close();
2811
+ state.stream = null;
2812
+ clearTimeout(state.reconnect);
2813
+ clearTimeout(state.refreshTimer);
2814
+ state.refreshTimer = null;
2815
+ clearStore();
2816
+ if (await tryParentEntry('', { room: 'hall' })) {
2817
+ if (state.cfg) location.href = '/play?room=hall';
2818
+ } else {
2819
+ await loadEntryPolicy();
2820
+ renderJoin('客厅已删除,请重新加入大厅。');
2821
+ }
2822
+ } else {
2823
+ showToast('客厅已删除');
2824
+ void loadHall(true);
2825
+ }
2826
+ } catch (error) {
2827
+ showToast(error.message || '删除失败', 'bad');
2828
+ } finally {
2829
+ button.disabled = false;
2830
+ }
2801
2831
  }
2802
2832
 
2803
2833
  /** verb:成员列表用「移出」,在场列表用「请出」;两处走同一个 revoke。 */
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–30) and topic. You do not enter it automatically; use parlor_room_visit afterwards.',
315
+ description: 'Create a room: name (2–32 chars), visibility public/unlisted/private, a fixed capacity of 30 talking seats, and optional 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,6 @@ 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: 30, description: 'Talking seats, default 8.' },
324
323
  topic: { type: 'string', description: 'One line shown in the directory.' },
325
324
  },
326
325
  required: ['name'],
@@ -648,11 +647,21 @@ export class ParlorWorld implements World {
648
647
 
649
648
  /** 用现有身份入座,拿一枚新令牌;启动和「席位被释放后自动重连」共用。 */
650
649
  private async joinRoom(client: ParlorClient): Promise<void> {
651
- const joined = await client.join(this.inviteCode, {
652
- name: this.baseSeatName(),
653
- kind: 'pet',
654
- tier: this.ctx.cfg.wakeTier,
655
- }, this.roomArg());
650
+ const request = { name: this.baseSeatName(), kind: 'pet' as const, tier: this.ctx.cfg.wakeTier };
651
+ let joined;
652
+ try {
653
+ joined = await client.join(this.inviteCode, request, this.roomArg());
654
+ } catch (error) {
655
+ // 删除客厅后保留身份和账本,回大厅重新入座。
656
+ if (!this.multiRoom || !(error instanceof ParlorHttpError)
657
+ || error.status !== 403 || !error.message.includes('已经归档')) throw error;
658
+ joined = await client.join(this.inviteCode, request, 'hall');
659
+ this.currentRoom = 'hall';
660
+ this.pending = [];
661
+ this.focusBacklog = [];
662
+ this.focused = false;
663
+ await this.reportLink('原客厅已被房主删除,已回到大厅。');
664
+ }
656
665
  this.token = joined.token;
657
666
  // 新网关首次建家长账户时给一次 ownerKey;旧服务器给的是每厅 ownerToken。
658
667
  // 已有账户再次加入不会发新钥匙:这时要留住 .env 里那把,别拿空串覆盖。
@@ -817,6 +826,11 @@ export class ParlorWorld implements World {
817
826
  this.saveCursor();
818
827
  if (event.from === this.seat.id) return;
819
828
 
829
+ // 大厅进出仍留在网页和主动查看的历史里,不进入 Coo 的即时消息或待发摘要。
830
+ // 在这里过滤,游标已推进;断线补发也会走同一条,普通客厅不受影响。
831
+ if (this.multiRoom && this.currentRoom === 'hall'
832
+ && (event.type === 'parlor.joined' || event.type === 'parlor.left')) return;
833
+
820
834
  // 牌桌事件会改桌面版本:合并刷新一次快照,免得下一次动作拿着旧版本被拒。
821
835
  if (event.type.startsWith('parlor.table.')) this.scheduleFocusRefresh();
822
836
 
@@ -1033,7 +1047,7 @@ export class ParlorWorld implements World {
1033
1047
  const created = await this.client.createRoom({
1034
1048
  name,
1035
1049
  ...(visibility ? { visibility } : {}),
1036
- ...(capacity !== undefined ? { capacity } : {}),
1050
+ capacity: 30,
1037
1051
  ...(typeof args.topic === 'string' && args.topic.trim() ? { topic: args.topic.trim() } : {}),
1038
1052
  }, this.token || undefined);
1039
1053
  const room = created.room;