cortico-world-doudizhu 0.2.2 → 0.2.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 CHANGED
@@ -1,5 +1,11 @@
1
1
  # 更新日志
2
2
 
3
+ ## 0.2.3
4
+
5
+ - **说了不打就离桌**:之前投「不打」但服务端回 `pending`(其它座位未表态)时,到点会被默认「继续」拖进下一局;
6
+ 现在 `verdict != quit` 且自己的票是「不打」,2 秒后主动断桌换桌(日志 `next_leave` + `leave_table`),不再陪跑。
7
+ AI 座位本来就不在投票范围里,所以这不会影响真人局。
8
+
3
9
  ## 0.2.2
4
10
 
5
11
  - **自动续桌 `autoNext`**(配合服务端 S-1):打开后每局结算由服务端代投「继续」,不用每局表态;auth 请求体新增 `autoNext`(默认 false)。
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "cortico-world-doudizhu",
3
- "version": "0.2.2",
3
+ "version": "0.2.3",
4
4
  "type": "module",
5
5
  "description": "斗地主 World 扩展:桌面宠物自动入座、自己出牌,每天自动领欢乐豆;主人可在官网参与对局、观战(/watch)、或点「插手」接管出牌。QQ 群 483590438。",
6
6
  "author": "大肥鱼",
package/src/world.ts CHANGED
@@ -390,6 +390,22 @@ export class DoudizhuWorld implements World {
390
390
  return true;
391
391
  }
392
392
 
393
+ /** 离桌:断开当前桌,清桌号,重新找一张(说"不打"后调用,不等别人投票)。 */
394
+ private leaveTable(): void {
395
+ this.log({ event: 'leave_table', tableId: this.tableId });
396
+ clearTimeout(this.fallbackTimer);
397
+ this.fallbackTimer = undefined;
398
+ try {
399
+ this.ws?.close();
400
+ } catch {
401
+ /* 已关闭 */
402
+ }
403
+ this.ws = undefined;
404
+ this.tableId = '';
405
+ this.view = undefined;
406
+ setTimeout(() => void this.reconnect(), 1500);
407
+ }
408
+
393
409
  private async nextTool(args: Record<string, unknown>) {
394
410
  if (!this.tableId) return { failed: true as const, text: '还没入座,没有可结算的牌桌' };
395
411
  const raw = args.play ?? args.again ?? args.want;
@@ -413,6 +429,13 @@ export class DoudizhuWorld implements World {
413
429
  setTimeout(() => void this.reconnect(), 1500);
414
430
  return { text: `已表态${play ? '继续' : '不打'}(服务端判定:本桌散场)。我去找下一张桌。` };
415
431
  }
432
+ if (!play) {
433
+ // 说了不打就走:AI 座位不投票,若服务端迟迟不判 quit,到点会默认"继续",把她拖进下一局。
434
+ // 所以表完态自己离桌,不等别人。
435
+ this.log({ event: 'next_leave', verdict: verdict || 'pending' });
436
+ setTimeout(() => this.leaveTable(), 2000);
437
+ return { text: '已表态不打。不等别人了,直接离桌换一张。' };
438
+ }
416
439
  return { text: `已表态${play ? '继续' : '不打'},等其他人表态。` };
417
440
  } catch (e) {
418
441
  return { failed: true as const, text: `表态失败:${(e as Error).message}` };