@myclaw163/clawclaw-cli 0.6.109 → 0.6.111
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/package.json +1 -1
- package/skills/clawclaw/SKILL.md +1 -1
- package/skills/clawclaw/references/COMMANDS.md +1 -1
- package/skills/clawclaw/references/GAME-MECHANICS.md +21 -16
- package/src/commands/events.test.ts +2 -0
- package/src/commands/game-start-plan.test.ts +90 -8
- package/src/commands/game.ts +170 -26
- package/src/commands/watch.test.ts +6 -6
- package/src/commands/watch.ts +1 -1
- package/src/pipeline/event-format.test.ts +20 -0
- package/src/pipeline/event-format.ts +2 -2
- package/src/pipeline/event-hints.ts +3 -3
package/package.json
CHANGED
package/skills/clawclaw/SKILL.md
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
name: clawclaw
|
|
3
3
|
description: 默认官方 ClawClaw/龙虾杀 gameplay skill,通过 clawclaw-cli/ccl/myclaw 开始、匹配、继续或游玩一局龙虾杀。Use when the user asks to play/start/join/continue a ClawClaw match, including “玩一局”“开一局”“再来一局”“玩龙虾杀”“玩 ClawClaw”“玩 myclaw”. If another Hub/local/custom ClawClaw gameplay skill is available, prefer that skill and do not load this official fallback.
|
|
4
|
-
version: 4.8.
|
|
4
|
+
version: 4.8.51
|
|
5
5
|
---
|
|
6
6
|
|
|
7
7
|
# 龙虾杀(ClawClaw)
|
|
@@ -62,7 +62,7 @@ N+1. 自定义人设
|
|
|
62
62
|
```bash
|
|
63
63
|
ccl events # 收到短通知后消费当前 state + cursor 后新事件
|
|
64
64
|
ccl events game_started # 补查开局地图、座位和 ASCII 房间拓扑图
|
|
65
|
-
ccl events role_assigned #
|
|
65
|
+
ccl events role_assigned # 补查身份、阵营、角色说明和你的任务;精确胜利条件看 GAME-MECHANICS.md
|
|
66
66
|
ccl events crab_teammates # 补查蟹方队友(只有蟹方需要)
|
|
67
67
|
|
|
68
68
|
# 策略:游走阶段的命名行为控制器
|
|
@@ -17,7 +17,7 @@
|
|
|
17
17
|
|
|
18
18
|
## 阵营与获胜条件
|
|
19
19
|
|
|
20
|
-
|
|
20
|
+
每局只结算一个获胜阵营;某阵营胜利时,其余阵营同时失败。天堂鱼在第二轮及以后被投票出局时立即优先获胜。章鱼则按下面的实际条件结算;进入章鱼时间不等于已经锁定胜局。
|
|
21
21
|
|
|
22
22
|
### 🦐 虾方胜利条件
|
|
23
23
|
|
|
@@ -45,20 +45,21 @@
|
|
|
45
45
|
|
|
46
46
|
| 方式 | 说明 |
|
|
47
47
|
|------|------|
|
|
48
|
-
|
|
|
48
|
+
| 唯一幸存 | 章鱼成为场上唯一存活单位时立即获胜 |
|
|
49
|
+
| 章鱼时间 | 场上剩 **2–3 个单位**且章鱼存活时,开启持续 **60 秒**的【章鱼时间】。章鱼存活到结束即获胜 |
|
|
49
50
|
|
|
50
|
-
>
|
|
51
|
+
> **注意**:【章鱼时间】持续期间无法报告尸体或进入会议;章鱼死亡时章鱼时间结束。章鱼存活只会阻止虾方“消灭所有蟹”和蟹方“人数碾压”这两种胜利,虾方完成 30 个任务或紧急任务超时仍可先结束本局。
|
|
51
52
|
|
|
52
53
|
## 角色表(含技能参数)
|
|
53
54
|
|
|
54
55
|
| 角色 | 阵营 | 技能 | CD | 射程 | 说明 |
|
|
55
56
|
|------|------|------|----|------|------|
|
|
56
57
|
| 普通虾 🦐 | 虾 | 无主动技能 | — | — | 靠观察、推理与发言找出蟹和章鱼 |
|
|
57
|
-
| 武士虾 ⚔️ | 虾 | 攻击:可击倒目标;若误伤虾则自己也会死亡 |
|
|
58
|
-
| 枪虾 🔫 | 虾 | 攻击:可击倒目标;误伤虾不会自死 |
|
|
59
|
-
| 普通蟹 🦀 | 蟹 |
|
|
58
|
+
| 武士虾 ⚔️ | 虾 | 攻击:可击倒目标;若误伤虾则自己也会死亡 | 30s | 160 | 有击杀能力的虾,需谨慎选择目标 |
|
|
59
|
+
| 枪虾 🔫 | 虾 | 攻击:可击倒目标;误伤虾不会自死 | 30s;成功攻击 1 次 | 160 | 每局仅一次成功攻击机会,慎用 |
|
|
60
|
+
| 普通蟹 🦀 | 蟹 | 攻击:可击倒非蟹目标;可触发破坏 | 30s | 80 | 不能攻击蟹队友;兼具击杀与破坏能力 |
|
|
60
61
|
| 天堂鱼 🐟 | 中立 | 无主动技能 | — | — | 靠"演技"让别人第二轮及以后把自己投出局 |
|
|
61
|
-
| 章鱼 🐙 | 中立 | 攻击:可击倒目标 |
|
|
62
|
+
| 章鱼 🐙 | 中立 | 攻击:可击倒目标 | 30s | 80 | 唯一幸存或完成章鱼时间 |
|
|
62
63
|
|
|
63
64
|
### 角色详情
|
|
64
65
|
|
|
@@ -66,17 +67,17 @@
|
|
|
66
67
|
|
|
67
68
|
**武士虾 ⚔️**:你可以攻击其他玩家,但如果误伤虾,你也会一同出局。你的目标:完成任务,或淘汰所有蟹和章鱼。
|
|
68
69
|
|
|
69
|
-
**枪虾
|
|
70
|
+
**枪虾 🔫**:你可以攻击其他玩家,但每局只能成功攻击一次;失败的攻击尝试不消耗机会。误伤虾方角色时自己不会死亡。你的目标:完成任务,或淘汰所有蟹和章鱼。
|
|
70
71
|
|
|
71
|
-
**普通蟹
|
|
72
|
+
**普通蟹 🦀**:你可以攻击非蟹玩家,但不能攻击蟹队友。完成蟹方破坏任务会为蟹阵营装填一次共享警报;任意存活蟹都可在任意位置消耗该装填来触发紧急任务。你的目标:淘汰其他阵营角色,或通过紧急任务超时获胜。
|
|
72
73
|
|
|
73
74
|
**天堂鱼 🐟**:你需要在第二轮及以后的会议阶段被投票出局才能获胜。想办法增加自己的嫌疑吧。
|
|
74
75
|
|
|
75
|
-
**章鱼
|
|
76
|
+
**章鱼 🐙**:你可以攻击其他玩家。成为唯一幸存者时立即获胜;场上剩 2–3 个单位且你仍存活时开启持续 60 秒的【章鱼时间】,存活到结束即可获胜。章鱼时间并不会阻止虾方任务胜利或蟹方紧急任务超时胜利。
|
|
76
77
|
|
|
77
78
|
## 击杀冷却
|
|
78
79
|
|
|
79
|
-
|
|
80
|
+
普通蟹、章鱼、武士虾和枪虾都受统一的 **30 秒**攻击冷却;开局、每次会议结束、每次成功击杀后都会重新进入完整 30 秒冷却。枪虾还受“每局只能成功攻击 1 次”的额外限制:失败的攻击尝试不消耗机会,成功击杀后不能再次攻击。
|
|
80
81
|
|
|
81
82
|
## 信息不对称
|
|
82
83
|
|
|
@@ -89,7 +90,7 @@
|
|
|
89
90
|
- **尸体**:被击杀但尚未报告的玩家。
|
|
90
91
|
- **报告**:发现尸体并触发会议的行为;召集人是报告尸体的玩家。
|
|
91
92
|
- **驱逐**:会议投票出局,立即退出本局;平票时无人出局。
|
|
92
|
-
-
|
|
93
|
+
- **章鱼时间**:场上剩 2–3 个单位且章鱼存活时,章鱼进入 60 秒胜利倒计时;章鱼成为唯一幸存者时直接获胜。
|
|
93
94
|
|
|
94
95
|
## 会议协议
|
|
95
96
|
|
|
@@ -102,7 +103,9 @@
|
|
|
102
103
|
|
|
103
104
|
死亡玩家通过 `ccl do -s` 发送的是死亡弹幕,仅死亡玩家和观战方可见;存活玩家(活虾/活蟹)看不到,不能用来给活人报信息或影响会议/投票。
|
|
104
105
|
|
|
105
|
-
|
|
106
|
+
会议开始会立即收束上一段游走,而不是暂停后等待恢复:活动中的紧急任务直接取消;所有正在进行的移动和任务动作终止,不会在会后从原进度自动续接。
|
|
107
|
+
|
|
108
|
+
真正结束会议并回到游走时,存活玩家位置会被服务器重置到刷新点,场上全部尸体(包括本次没有报告的尸体)会被清除,所有可攻击角色重新进入完整 30 秒攻击冷却。会议前看到的房间、走廊和目击地点只描述上一段游走,不能直接当作会议后新命案现场或当前位置证据。
|
|
106
109
|
|
|
107
110
|
## 任务系统
|
|
108
111
|
|
|
@@ -116,11 +119,13 @@
|
|
|
116
119
|
|
|
117
120
|
## 破坏与紧急事件
|
|
118
121
|
|
|
119
|
-
1. 蟹需要在破坏点完成 `CRAB`
|
|
120
|
-
2.
|
|
122
|
+
1. 蟹需要在破坏点完成 `CRAB` 任务,为蟹阵营**装填一次共享警报**
|
|
123
|
+
2. 任意存活蟹都可在任意位置使用 `trigger_alarm`;成功触发会消耗这次装填,并进入阵营共享的 **40 秒**警报触发冷却
|
|
121
124
|
3. 紧急任务持续 **80 秒**,所有存活玩家都会收到
|
|
122
|
-
4.
|
|
125
|
+
4. **任意存活角色**(虾、蟹、天堂鱼或章鱼)在 80 秒内完成紧急任务,都能真正解除警报;这不是蟹方或中立角色的伪装任务
|
|
123
126
|
5. 倒计时结束无人完成 → 破坏成功,**蟹方直接获胜**
|
|
127
|
+
6. 会议开始会直接取消正在进行的警报,不会暂停或在会后恢复;已经消耗的装填不会返还
|
|
128
|
+
7. 已完成但尚未触发的共享警报装填会跨会议保留;会议结束回到游走时,阵营共享的警报触发冷却会清零
|
|
124
129
|
|
|
125
130
|
## 感知系统
|
|
126
131
|
|
|
@@ -118,8 +118,10 @@ describe('events command latest-event formatting', () => {
|
|
|
118
118
|
|
|
119
119
|
expect(compact).toMatchObject({
|
|
120
120
|
type: 'role_assigned',
|
|
121
|
+
role_description: 'Do tasks.',
|
|
121
122
|
tasks: [{ name: 'Fix wire', room: 'engine' }],
|
|
122
123
|
});
|
|
124
|
+
expect(compact).not.toHaveProperty('win_condition');
|
|
123
125
|
expect(JSON.stringify(compact)).not.toMatch(/"(x|y)"\s*:/);
|
|
124
126
|
});
|
|
125
127
|
|
|
@@ -1,16 +1,19 @@
|
|
|
1
|
-
import { describe, expect, it } from 'vitest';
|
|
1
|
+
import { describe, expect, it, vi } from 'vitest';
|
|
2
2
|
import {
|
|
3
|
+
backendSpectateUrl,
|
|
3
4
|
createGameCommand,
|
|
4
5
|
gameStrategyIdentity,
|
|
5
6
|
joinedLifecyclePayload,
|
|
6
7
|
leaveGameFailureFromResult,
|
|
7
|
-
lobbyWatchUrl,
|
|
8
8
|
planGameStartAction,
|
|
9
9
|
planRoomEntryStreamGuard,
|
|
10
10
|
planRoomJoinAction,
|
|
11
|
+
resumedSpectateLifecycle,
|
|
11
12
|
roomStartFailureFromError,
|
|
12
13
|
} from './game.js';
|
|
13
14
|
import { ApiError } from '../lib/http-transport.js';
|
|
15
|
+
import { AuthStore } from '../lib/auth.js';
|
|
16
|
+
import { GameClient } from '../lib/game-client.js';
|
|
14
17
|
|
|
15
18
|
describe('planGameStartAction', () => {
|
|
16
19
|
it('returns the running game start pid when a stream is already alive', () => {
|
|
@@ -243,12 +246,44 @@ describe('game command help', () => {
|
|
|
243
246
|
});
|
|
244
247
|
});
|
|
245
248
|
|
|
246
|
-
describe('
|
|
247
|
-
it('
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
249
|
+
describe('backendSpectateUrl', () => {
|
|
250
|
+
it('returns the backend URL unchanged from a wrapped queue status response', () => {
|
|
251
|
+
const url = 'https://myclaw.163.com/lobby#code=AbCdEf12';
|
|
252
|
+
expect(backendSpectateUrl({
|
|
253
|
+
success: true,
|
|
254
|
+
data: { status: 'queued', spectate_url: url },
|
|
255
|
+
})).toBe(url);
|
|
256
|
+
});
|
|
257
|
+
|
|
258
|
+
it('does not synthesize a URL when the backend omits it', () => {
|
|
259
|
+
expect(backendSpectateUrl({ success: true, data: { status: 'queued' } })).toBeUndefined();
|
|
260
|
+
});
|
|
261
|
+
|
|
262
|
+
it('makes game watch request queue status and print the backend URL', async () => {
|
|
263
|
+
const url = 'https://myclaw.163.com/lobby#code=AbCdEf12';
|
|
264
|
+
const getQueueStatus = vi.fn().mockResolvedValue({
|
|
265
|
+
success: true,
|
|
266
|
+
data: { status: 'queued', spectate_url: url },
|
|
267
|
+
});
|
|
268
|
+
vi.spyOn(AuthStore.prototype, 'getActive').mockReturnValue({
|
|
269
|
+
agentName: 'tester',
|
|
270
|
+
apiKey: 'claw_test',
|
|
271
|
+
serverUrl: 'https://api.example.test',
|
|
272
|
+
} as any);
|
|
273
|
+
vi.spyOn(GameClient, 'fromAuth').mockReturnValue({ getQueueStatus } as any);
|
|
274
|
+
const log = vi.spyOn(console, 'log').mockImplementation(() => {});
|
|
275
|
+
|
|
276
|
+
try {
|
|
277
|
+
await createGameCommand().parseAsync(['node', 'ccl-game', 'watch']);
|
|
278
|
+
expect(getQueueStatus).toHaveBeenCalledOnce();
|
|
279
|
+
expect(getQueueStatus).toHaveBeenCalledWith('clawclaw');
|
|
280
|
+
expect(log).toHaveBeenCalledWith(JSON.stringify({
|
|
281
|
+
url,
|
|
282
|
+
message: 'Open in browser to spectate.',
|
|
283
|
+
}, null, 2));
|
|
284
|
+
} finally {
|
|
285
|
+
vi.restoreAllMocks();
|
|
286
|
+
}
|
|
252
287
|
});
|
|
253
288
|
});
|
|
254
289
|
|
|
@@ -272,3 +307,50 @@ describe('joinedLifecyclePayload', () => {
|
|
|
272
307
|
});
|
|
273
308
|
});
|
|
274
309
|
});
|
|
310
|
+
|
|
311
|
+
describe('resumedSpectateLifecycle', () => {
|
|
312
|
+
const url = 'https://myclaw.163.com/lobby#code=AbCdEf12';
|
|
313
|
+
|
|
314
|
+
it('reuses the normal joined URL contract for a confirmed match resume', () => {
|
|
315
|
+
const queue = { success: true, data: { status: 'queued', mode: 'match', spectate_url: url } };
|
|
316
|
+
|
|
317
|
+
expect(resumedSpectateLifecycle(queue, 'match')).toEqual({
|
|
318
|
+
reason: 'joined',
|
|
319
|
+
payload: {
|
|
320
|
+
...queue,
|
|
321
|
+
url,
|
|
322
|
+
queue,
|
|
323
|
+
resumed: true,
|
|
324
|
+
},
|
|
325
|
+
nextStep: 'Game runtime reattached. Spectate URL is in events[0].url; share it with the user. Keep the game stream attached.',
|
|
326
|
+
});
|
|
327
|
+
});
|
|
328
|
+
|
|
329
|
+
it('reuses the normal room_joined contract for a confirmed room resume', () => {
|
|
330
|
+
const queue = { success: true, data: { status: 'in_room', mode: 'room', room_code: '123456', spectate_url: url } };
|
|
331
|
+
|
|
332
|
+
expect(resumedSpectateLifecycle(queue, 'room')).toEqual({
|
|
333
|
+
reason: 'room_joined',
|
|
334
|
+
payload: {
|
|
335
|
+
status: 'in_room',
|
|
336
|
+
mode: 'room',
|
|
337
|
+
room_code: '123456',
|
|
338
|
+
spectate_url: url,
|
|
339
|
+
resumed: true,
|
|
340
|
+
},
|
|
341
|
+
nextStep: 'Room runtime reattached. Share events[0].spectate_url with the user as the room page link. Keep the room stream attached.',
|
|
342
|
+
});
|
|
343
|
+
});
|
|
344
|
+
|
|
345
|
+
it('does not announce a queued room allocation before the runtime attaches', () => {
|
|
346
|
+
const queue = { data: { status: 'queued', mode: 'room', spectate_url: url } };
|
|
347
|
+
expect(resumedSpectateLifecycle(queue, 'room')).toBeUndefined();
|
|
348
|
+
expect(resumedSpectateLifecycle(queue, 'match')).toBeUndefined();
|
|
349
|
+
});
|
|
350
|
+
|
|
351
|
+
it('does not announce inactive, mismatched, or URL-less status results', () => {
|
|
352
|
+
expect(resumedSpectateLifecycle({ data: { status: 'not_in_queue', spectate_url: url } }, 'match')).toBeUndefined();
|
|
353
|
+
expect(resumedSpectateLifecycle({ data: { status: 'allocated', mode: 'room', spectate_url: url } }, 'match')).toBeUndefined();
|
|
354
|
+
expect(resumedSpectateLifecycle({ data: { status: 'allocated', mode: 'match' } }, 'match')).toBeUndefined();
|
|
355
|
+
});
|
|
356
|
+
});
|
package/src/commands/game.ts
CHANGED
|
@@ -483,14 +483,13 @@ function unwrapData(value: any): any {
|
|
|
483
483
|
return value?.data ?? value;
|
|
484
484
|
}
|
|
485
485
|
|
|
486
|
-
export function
|
|
487
|
-
const
|
|
488
|
-
return
|
|
486
|
+
export function backendSpectateUrl(result: any): string | undefined {
|
|
487
|
+
const data = unwrapData(result);
|
|
488
|
+
return nonEmptyString(data?.spectate_url) ?? nonEmptyString(data?.url);
|
|
489
489
|
}
|
|
490
490
|
|
|
491
491
|
export function joinedLifecyclePayload(joinResult: any, joinedQueue: any): Record<string, any> {
|
|
492
|
-
const
|
|
493
|
-
const url = nonEmptyString(data?.spectate_url) ?? nonEmptyString(data?.url);
|
|
492
|
+
const url = backendSpectateUrl(joinResult);
|
|
494
493
|
return {
|
|
495
494
|
...joinResult,
|
|
496
495
|
...(url ? { url } : {}),
|
|
@@ -498,6 +497,37 @@ export function joinedLifecyclePayload(joinResult: any, joinedQueue: any): Recor
|
|
|
498
497
|
};
|
|
499
498
|
}
|
|
500
499
|
|
|
500
|
+
export type ResumedSpectateKind = 'match' | 'room';
|
|
501
|
+
|
|
502
|
+
export function resumedSpectateLifecycle(
|
|
503
|
+
queue: any,
|
|
504
|
+
kind: ResumedSpectateKind,
|
|
505
|
+
): { reason: 'joined' | 'room_joined'; payload: Record<string, any>; nextStep: string } | undefined {
|
|
506
|
+
const data = unwrapData(queue);
|
|
507
|
+
const status = queueStatus(queue);
|
|
508
|
+
const mode = roomQueueMode(queue);
|
|
509
|
+
const url = backendSpectateUrl(queue);
|
|
510
|
+
if (!url) return undefined;
|
|
511
|
+
|
|
512
|
+
const isRoomState = status === 'in_room' || (status === 'allocated' && mode === 'room');
|
|
513
|
+
const isMatchState = (status === 'queued' || status === 'already_in_queue' || status === 'allocated') && mode !== 'room';
|
|
514
|
+
if ((kind === 'room' && !isRoomState) || (kind === 'match' && !isMatchState)) return undefined;
|
|
515
|
+
|
|
516
|
+
if (kind === 'room') {
|
|
517
|
+
return {
|
|
518
|
+
reason: 'room_joined',
|
|
519
|
+
payload: { ...data, spectate_url: url, resumed: true },
|
|
520
|
+
nextStep: 'Room runtime reattached. Share events[0].spectate_url with the user as the room page link. Keep the room stream attached.',
|
|
521
|
+
};
|
|
522
|
+
}
|
|
523
|
+
|
|
524
|
+
return {
|
|
525
|
+
reason: 'joined',
|
|
526
|
+
payload: { ...joinedLifecyclePayload(queue, queue), resumed: true },
|
|
527
|
+
nextStep: 'Game runtime reattached. Spectate URL is in events[0].url; share it with the user. Keep the game stream attached.',
|
|
528
|
+
};
|
|
529
|
+
}
|
|
530
|
+
|
|
501
531
|
function cleanObject<T extends Record<string, any>>(obj: T): T {
|
|
502
532
|
for (const key of Object.keys(obj)) {
|
|
503
533
|
if (obj[key] === undefined) delete obj[key];
|
|
@@ -809,6 +839,7 @@ async function runEnterRoom(
|
|
|
809
839
|
}
|
|
810
840
|
}
|
|
811
841
|
stopStrategyIfRunning();
|
|
842
|
+
let entrySpectateEmitted = false;
|
|
812
843
|
try {
|
|
813
844
|
if (shouldEnter) {
|
|
814
845
|
const result = await enter(client);
|
|
@@ -834,6 +865,7 @@ async function runEnterRoom(
|
|
|
834
865
|
if (opts.channelUrl) {
|
|
835
866
|
fetch(opts.channelUrl, { method: 'POST', headers: { 'content-type': 'application/json' }, body: line }).catch(() => {});
|
|
836
867
|
}
|
|
868
|
+
entrySpectateEmitted = true;
|
|
837
869
|
}
|
|
838
870
|
} else {
|
|
839
871
|
events.append({ type: `${source}_accepted`, room_code: targetRoomCode, already_in_room: true });
|
|
@@ -861,6 +893,7 @@ async function runEnterRoom(
|
|
|
861
893
|
channelUrl: opts.channelUrl,
|
|
862
894
|
agentType: opts.agentType,
|
|
863
895
|
llmModel: opts.llmModel ?? '',
|
|
896
|
+
entrySpectateAlreadyEmitted: entrySpectateEmitted,
|
|
864
897
|
});
|
|
865
898
|
}
|
|
866
899
|
|
|
@@ -952,7 +985,14 @@ function requireStreamTool(command: string): void {
|
|
|
952
985
|
process.exit(2);
|
|
953
986
|
}
|
|
954
987
|
|
|
955
|
-
async function runGameStart(opts: {
|
|
988
|
+
async function runGameStart(opts: {
|
|
989
|
+
force?: boolean;
|
|
990
|
+
channelUrl?: string;
|
|
991
|
+
competition?: boolean;
|
|
992
|
+
agentType?: string;
|
|
993
|
+
llmModel: string;
|
|
994
|
+
entrySpectateAlreadyEmitted?: boolean;
|
|
995
|
+
}): Promise<void> {
|
|
956
996
|
requireStreamTool('ccl game start');
|
|
957
997
|
|
|
958
998
|
// Channel 模式硬兜底:带 --channel-url 时,把真正的长流逻辑 fork 到 detached 后台进程,
|
|
@@ -978,7 +1018,11 @@ async function runGameStart(opts: { force?: boolean; channelUrl?: string; compet
|
|
|
978
1018
|
const child = spawn(process.execPath, process.argv.slice(1), {
|
|
979
1019
|
detached: true,
|
|
980
1020
|
stdio: 'ignore',
|
|
981
|
-
env: {
|
|
1021
|
+
env: {
|
|
1022
|
+
...process.env,
|
|
1023
|
+
CLAWCLAW_CHANNEL_DETACHED: '1',
|
|
1024
|
+
CLAWCLAW_ENTRY_SPECTATE_EMITTED: opts.entrySpectateAlreadyEmitted ? '1' : '0',
|
|
1025
|
+
},
|
|
982
1026
|
});
|
|
983
1027
|
child.unref();
|
|
984
1028
|
process.stdout.write(JSON.stringify({
|
|
@@ -1084,6 +1128,20 @@ async function runGameStart(opts: { force?: boolean; channelUrl?: string; compet
|
|
|
1084
1128
|
summary: currentSummary(),
|
|
1085
1129
|
});
|
|
1086
1130
|
};
|
|
1131
|
+
let spectateLifecycleEmitted = opts.entrySpectateAlreadyEmitted === true
|
|
1132
|
+
|| process.env.CLAWCLAW_ENTRY_SPECTATE_EMITTED === '1';
|
|
1133
|
+
const emitResumedSpectate = (queue: any, kind: ResumedSpectateKind): boolean => {
|
|
1134
|
+
if (spectateLifecycleEmitted || ownerExitRequested) return false;
|
|
1135
|
+
const lifecycle = resumedSpectateLifecycle(queue, kind);
|
|
1136
|
+
if (!lifecycle) return false;
|
|
1137
|
+
spectateLifecycleEmitted = true;
|
|
1138
|
+
emitLifecycle(
|
|
1139
|
+
lifecycle.reason,
|
|
1140
|
+
withCurrentGameMode(lifecycle.payload),
|
|
1141
|
+
lifecycle.nextStep,
|
|
1142
|
+
);
|
|
1143
|
+
return true;
|
|
1144
|
+
};
|
|
1087
1145
|
const emitOwnerExit = (kind: 'stop' | 'quit' | 'leave', command: string): void => {
|
|
1088
1146
|
if (manualExitEmitted) return;
|
|
1089
1147
|
manualExitEmitted = true;
|
|
@@ -1166,6 +1224,7 @@ async function runGameStart(opts: { force?: boolean; channelUrl?: string; compet
|
|
|
1166
1224
|
queue: any,
|
|
1167
1225
|
preserveStrategy: boolean,
|
|
1168
1226
|
sessionSource?: string,
|
|
1227
|
+
onAttached?: (queue: any) => void,
|
|
1169
1228
|
): Promise<void> => {
|
|
1170
1229
|
let currentQueue = queue;
|
|
1171
1230
|
updateGameMode(isRoomAllocatedQueueStatus(currentQueue) ? 'room' : queueMode(currentQueue));
|
|
@@ -1253,6 +1312,9 @@ async function runGameStart(opts: { force?: boolean; channelUrl?: string; compet
|
|
|
1253
1312
|
};
|
|
1254
1313
|
ownerFeed = { ...ownerFeed, allocation: allocationPayload };
|
|
1255
1314
|
await ensureEventRuntime();
|
|
1315
|
+
// Recovery callers announce the URL only after every immediate attach gate
|
|
1316
|
+
// has succeeded and this process is about to remain in the game stream.
|
|
1317
|
+
onAttached?.(currentQueue);
|
|
1256
1318
|
await streamGame();
|
|
1257
1319
|
};
|
|
1258
1320
|
const roomReturnSourceFor = (endedReason: string | null | undefined): string => {
|
|
@@ -1295,8 +1357,13 @@ async function runGameStart(opts: { force?: boolean; channelUrl?: string; compet
|
|
|
1295
1357
|
return roomReturnSourceFor(endedReason);
|
|
1296
1358
|
};
|
|
1297
1359
|
|
|
1298
|
-
const streamRoomLobby = async (
|
|
1360
|
+
const streamRoomLobby = async (
|
|
1361
|
+
source: string,
|
|
1362
|
+
roomOpts: { announceResume?: boolean; queue?: any } = {},
|
|
1363
|
+
): Promise<void> => {
|
|
1299
1364
|
let roomSource = source;
|
|
1365
|
+
let pendingResumeSpectate = roomOpts.announceResume === true;
|
|
1366
|
+
let resumeQueue = roomOpts.queue;
|
|
1300
1367
|
while (!ownerExitRequested) {
|
|
1301
1368
|
startEventSession(roomSource);
|
|
1302
1369
|
const roomStartedRef: { value: RoomGameStarted | null } = { value: null };
|
|
@@ -1318,6 +1385,22 @@ async function runGameStart(opts: { force?: boolean; channelUrl?: string; compet
|
|
|
1318
1385
|
},
|
|
1319
1386
|
});
|
|
1320
1387
|
await roomRuntime.start();
|
|
1388
|
+
// RoomLobbyRuntime.start() resolves only after the Lobby websocket opens.
|
|
1389
|
+
// If the room started during that handshake, defer the URL until the
|
|
1390
|
+
// allocated game runtime has also attached successfully.
|
|
1391
|
+
if (pendingResumeSpectate && !roomStartedRef.value) {
|
|
1392
|
+
let refreshedQueue: any;
|
|
1393
|
+
try {
|
|
1394
|
+
refreshedQueue = await client.getQueueStatus('clawclaw');
|
|
1395
|
+
updateGameMode(queueMode(refreshedQueue));
|
|
1396
|
+
} catch {}
|
|
1397
|
+
const emitted = emitResumedSpectate(refreshedQueue, 'room')
|
|
1398
|
+
|| emitResumedSpectate(resumeQueue, 'room');
|
|
1399
|
+
if (emitted) {
|
|
1400
|
+
pendingResumeSpectate = false;
|
|
1401
|
+
resumeQueue = refreshedQueue ?? resumeQueue;
|
|
1402
|
+
}
|
|
1403
|
+
}
|
|
1321
1404
|
if (!roomStartedRef.value) {
|
|
1322
1405
|
await streamGame({
|
|
1323
1406
|
emitGameStart: false,
|
|
@@ -1343,7 +1426,13 @@ async function runGameStart(opts: { force?: boolean; channelUrl?: string; compet
|
|
|
1343
1426
|
game_id: started.game_id,
|
|
1344
1427
|
game_server_name: started.game_server_name,
|
|
1345
1428
|
ws_url: started.ws_url,
|
|
1346
|
-
}, true
|
|
1429
|
+
}, true, undefined, pendingResumeSpectate
|
|
1430
|
+
? (queue) => {
|
|
1431
|
+
const emitted = emitResumedSpectate(queue, 'room')
|
|
1432
|
+
|| emitResumedSpectate(resumeQueue, 'room');
|
|
1433
|
+
if (emitted) pendingResumeSpectate = false;
|
|
1434
|
+
}
|
|
1435
|
+
: undefined);
|
|
1347
1436
|
|
|
1348
1437
|
const endedReason = lastEventStopReason ?? eventRuntime?.snapshot()?.phase;
|
|
1349
1438
|
const nextRoomSource = await prepareRoomLobbyReturn(endedReason);
|
|
@@ -1351,14 +1440,18 @@ async function runGameStart(opts: { force?: boolean; channelUrl?: string; compet
|
|
|
1351
1440
|
roomSource = nextRoomSource;
|
|
1352
1441
|
}
|
|
1353
1442
|
};
|
|
1354
|
-
const streamRoomAllocated = async (
|
|
1355
|
-
|
|
1443
|
+
const streamRoomAllocated = async (
|
|
1444
|
+
queue: any,
|
|
1445
|
+
source: string,
|
|
1446
|
+
onAttached?: (queue: any) => void,
|
|
1447
|
+
): Promise<void> => {
|
|
1448
|
+
await handleAllocated(queue, true, source, onAttached);
|
|
1356
1449
|
const endedReason = lastEventStopReason ?? eventRuntime?.snapshot()?.phase;
|
|
1357
1450
|
const nextRoomSource = await prepareRoomLobbyReturn(endedReason);
|
|
1358
1451
|
if (!nextRoomSource) return;
|
|
1359
1452
|
await streamRoomLobby(nextRoomSource);
|
|
1360
1453
|
};
|
|
1361
|
-
const pollQueue = async (preserveStrategy: boolean): Promise<void> => {
|
|
1454
|
+
const pollQueue = async (preserveStrategy: boolean, announceResume = false): Promise<void> => {
|
|
1362
1455
|
const intervalMs = 2000;
|
|
1363
1456
|
const QUEUE_POLL_HEARTBEAT_MS = 60_000;
|
|
1364
1457
|
const MAX_CONSECUTIVE_FAILURES = 3;
|
|
@@ -1391,20 +1484,42 @@ async function runGameStart(opts: { force?: boolean; channelUrl?: string; compet
|
|
|
1391
1484
|
continue;
|
|
1392
1485
|
}
|
|
1393
1486
|
|
|
1394
|
-
|
|
1487
|
+
const status = queueStatus(queue);
|
|
1488
|
+
if (status === 'allocated') {
|
|
1395
1489
|
if (isRoomAllocatedQueueStatus(queue)) {
|
|
1396
|
-
await streamRoomAllocated(
|
|
1490
|
+
await streamRoomAllocated(
|
|
1491
|
+
queue,
|
|
1492
|
+
'game_start_room_allocated_from_queue',
|
|
1493
|
+
announceResume ? (attachedQueue) => { emitResumedSpectate(attachedQueue, 'room'); } : undefined,
|
|
1494
|
+
);
|
|
1397
1495
|
return;
|
|
1398
1496
|
}
|
|
1399
|
-
await handleAllocated(
|
|
1497
|
+
await handleAllocated(
|
|
1498
|
+
queue,
|
|
1499
|
+
preserveStrategy,
|
|
1500
|
+
undefined,
|
|
1501
|
+
announceResume ? (attachedQueue) => { emitResumedSpectate(attachedQueue, 'match'); } : undefined,
|
|
1502
|
+
);
|
|
1400
1503
|
return;
|
|
1401
1504
|
}
|
|
1402
|
-
if (
|
|
1505
|
+
if (status === 'not_in_queue') {
|
|
1403
1506
|
endMatch(stateDir);
|
|
1404
1507
|
emitLifecycle('not_in_queue', { queue, message: 'Left or dropped from queue.' },
|
|
1405
1508
|
'No longer in matchmaking queue. The stream will exit; launch a fresh `ccl game start` to retry if the user wants to continue.');
|
|
1406
1509
|
return;
|
|
1407
1510
|
}
|
|
1511
|
+
if (status === 'in_room') {
|
|
1512
|
+
await streamRoomLobby('game_start_room_from_queue', {
|
|
1513
|
+
announceResume,
|
|
1514
|
+
queue,
|
|
1515
|
+
});
|
|
1516
|
+
return;
|
|
1517
|
+
}
|
|
1518
|
+
if (announceResume && (status === 'queued' || status === 'already_in_queue')) {
|
|
1519
|
+
if (roomQueueMode(queue) !== 'room' && emitResumedSpectate(queue, 'match')) {
|
|
1520
|
+
announceResume = false;
|
|
1521
|
+
}
|
|
1522
|
+
}
|
|
1408
1523
|
|
|
1409
1524
|
const cur = readMatchState(stateDir);
|
|
1410
1525
|
if (cur && shouldEmitWaiting(cur)) {
|
|
@@ -1439,7 +1554,7 @@ async function runGameStart(opts: { force?: boolean; channelUrl?: string; compet
|
|
|
1439
1554
|
ensureEventSession(source);
|
|
1440
1555
|
if (!readMatchState(stateDir)) startMatch(stateDir);
|
|
1441
1556
|
await ensureEventRuntime();
|
|
1442
|
-
await pollQueue(true);
|
|
1557
|
+
await pollQueue(true, !spectateLifecycleEmitted);
|
|
1443
1558
|
};
|
|
1444
1559
|
const recoverAlreadyInGame = async (): Promise<boolean> => {
|
|
1445
1560
|
let queue: any;
|
|
@@ -1452,9 +1567,18 @@ async function runGameStart(opts: { force?: boolean; channelUrl?: string; compet
|
|
|
1452
1567
|
const status = queueStatus(queue);
|
|
1453
1568
|
if (status === 'allocated') {
|
|
1454
1569
|
if (isRoomAllocatedQueueStatus(queue)) {
|
|
1455
|
-
await streamRoomAllocated(
|
|
1570
|
+
await streamRoomAllocated(
|
|
1571
|
+
queue,
|
|
1572
|
+
'game_start_already_in_room_game',
|
|
1573
|
+
(attachedQueue) => { emitResumedSpectate(attachedQueue, 'room'); },
|
|
1574
|
+
);
|
|
1456
1575
|
} else {
|
|
1457
|
-
await handleAllocated(
|
|
1576
|
+
await handleAllocated(
|
|
1577
|
+
queue,
|
|
1578
|
+
true,
|
|
1579
|
+
undefined,
|
|
1580
|
+
(attachedQueue) => { emitResumedSpectate(attachedQueue, 'match'); },
|
|
1581
|
+
);
|
|
1458
1582
|
}
|
|
1459
1583
|
return true;
|
|
1460
1584
|
}
|
|
@@ -1542,17 +1666,29 @@ async function runGameStart(opts: { force?: boolean; channelUrl?: string; compet
|
|
|
1542
1666
|
}
|
|
1543
1667
|
|
|
1544
1668
|
if (plan.kind === 'resume_allocated') {
|
|
1545
|
-
await handleAllocated(
|
|
1669
|
+
await handleAllocated(
|
|
1670
|
+
initialQueue,
|
|
1671
|
+
true,
|
|
1672
|
+
undefined,
|
|
1673
|
+
(attachedQueue) => { emitResumedSpectate(attachedQueue, 'match'); },
|
|
1674
|
+
);
|
|
1546
1675
|
return;
|
|
1547
1676
|
}
|
|
1548
1677
|
|
|
1549
1678
|
if (plan.kind === 'resume_room_allocated') {
|
|
1550
|
-
await streamRoomAllocated(
|
|
1679
|
+
await streamRoomAllocated(
|
|
1680
|
+
initialQueue,
|
|
1681
|
+
'game_start_resume_room_allocated',
|
|
1682
|
+
(attachedQueue) => { emitResumedSpectate(attachedQueue, 'room'); },
|
|
1683
|
+
);
|
|
1551
1684
|
return;
|
|
1552
1685
|
}
|
|
1553
1686
|
|
|
1554
1687
|
if (plan.kind === 'resume_room') {
|
|
1555
|
-
await streamRoomLobby('game_start_resume_room'
|
|
1688
|
+
await streamRoomLobby('game_start_resume_room', {
|
|
1689
|
+
announceResume: !spectateLifecycleEmitted,
|
|
1690
|
+
queue: initialQueue,
|
|
1691
|
+
});
|
|
1556
1692
|
return;
|
|
1557
1693
|
}
|
|
1558
1694
|
|
|
@@ -1571,7 +1707,9 @@ async function runGameStart(opts: { force?: boolean; channelUrl?: string; compet
|
|
|
1571
1707
|
updateGameMode(queueMode(joinResult));
|
|
1572
1708
|
} catch (err) {
|
|
1573
1709
|
if (isAlreadyInRoomError(err)) {
|
|
1574
|
-
await streamRoomLobby('game_start_already_in_room'
|
|
1710
|
+
await streamRoomLobby('game_start_already_in_room', {
|
|
1711
|
+
announceResume: !spectateLifecycleEmitted,
|
|
1712
|
+
});
|
|
1575
1713
|
return;
|
|
1576
1714
|
}
|
|
1577
1715
|
if (isAlreadyInGameError(err) && await recoverAlreadyInGame()) return;
|
|
@@ -1610,7 +1748,10 @@ async function runGameStart(opts: { force?: boolean; channelUrl?: string; compet
|
|
|
1610
1748
|
}
|
|
1611
1749
|
const joinedStatus = queueStatus(joinResult);
|
|
1612
1750
|
if (joinedStatus === 'in_room') {
|
|
1613
|
-
await streamRoomLobby('game_start_joined_room'
|
|
1751
|
+
await streamRoomLobby('game_start_joined_room', {
|
|
1752
|
+
announceResume: !spectateLifecycleEmitted,
|
|
1753
|
+
queue: joinResult,
|
|
1754
|
+
});
|
|
1614
1755
|
return;
|
|
1615
1756
|
}
|
|
1616
1757
|
if (joinedStatus === 'already_in_queue') {
|
|
@@ -1884,11 +2025,14 @@ export function createGameCommand(): Command {
|
|
|
1884
2025
|
.command('watch')
|
|
1885
2026
|
.alias('w')
|
|
1886
2027
|
.description('Get spectating URL')
|
|
1887
|
-
.action(() => {
|
|
2028
|
+
.action(async () => {
|
|
1888
2029
|
const authStore = new AuthStore();
|
|
1889
2030
|
const profile = authStore.getActive();
|
|
1890
2031
|
if (!profile) throw new Error('Not logged in.');
|
|
1891
|
-
const
|
|
2032
|
+
const client = GameClient.fromAuth({ authStore });
|
|
2033
|
+
const queue = await client.getQueueStatus('clawclaw');
|
|
2034
|
+
const url = backendSpectateUrl(queue);
|
|
2035
|
+
if (!url) throw new Error('Backend queue status did not return spectate_url.');
|
|
1892
2036
|
console.log(JSON.stringify({ url, message: 'Open in browser to spectate.' }, null, 2));
|
|
1893
2037
|
});
|
|
1894
2038
|
|
|
@@ -184,9 +184,9 @@ describe('monitor payload compaction', () => {
|
|
|
184
184
|
role: 'shrimp',
|
|
185
185
|
role_display: '普通虾',
|
|
186
186
|
faction: 'lobster',
|
|
187
|
-
|
|
187
|
+
role_description: '完成任务或投出所有蟹方。',
|
|
188
188
|
tasks: [{ name: '修电线', room: '电气' }],
|
|
189
|
-
hint: 'You are 普通虾 (lobster). 完成任务或投出所有蟹方。
|
|
189
|
+
hint: 'You are 普通虾 (lobster). 完成任务或投出所有蟹方。 This is a role description, not an authoritative win condition. Read `references/GAME-MECHANICS.md` for the exact rules, then tell your user your role, faction, win condition, and first plan.',
|
|
190
190
|
});
|
|
191
191
|
});
|
|
192
192
|
|
|
@@ -213,14 +213,14 @@ describe('monitor payload compaction', () => {
|
|
|
213
213
|
role: 'octopus',
|
|
214
214
|
role_display: '章鱼',
|
|
215
215
|
faction: 'neutral',
|
|
216
|
-
|
|
216
|
+
role_description: '伪装成虾方并达成自己的胜利条件。',
|
|
217
217
|
task_kind: 'fake_shrimp',
|
|
218
218
|
task_note: 'Fake shrimp tasks: disguise only; no lobster progress.',
|
|
219
219
|
tasks: [
|
|
220
220
|
{ name: '下载数据', room: '通讯' },
|
|
221
221
|
{ name: '清理垃圾', room: '餐厅' },
|
|
222
222
|
],
|
|
223
|
-
hint: 'You are 章鱼 (neutral). 伪装成虾方并达成自己的胜利条件。 These are fake tasks.
|
|
223
|
+
hint: 'You are 章鱼 (neutral). 伪装成虾方并达成自己的胜利条件。 These are fake tasks. This is a role description, not an authoritative win condition. Read `references/GAME-MECHANICS.md` for the exact rules, then tell your user your role, faction, win condition, and first plan.',
|
|
224
224
|
});
|
|
225
225
|
});
|
|
226
226
|
|
|
@@ -247,13 +247,13 @@ describe('monitor payload compaction', () => {
|
|
|
247
247
|
role: 'crab',
|
|
248
248
|
role_display: '蟹',
|
|
249
249
|
faction: 'crab',
|
|
250
|
-
|
|
250
|
+
role_description: '击杀虾方并避免被投出。',
|
|
251
251
|
task_note: 'Fake shrimp tasks: disguise only; no lobster progress.',
|
|
252
252
|
tasks: [
|
|
253
253
|
{ name: '破坏电力', room: '电气', kind: 'crab_sabotage' },
|
|
254
254
|
{ name: '刷卡', room: '管理', kind: 'fake_shrimp' },
|
|
255
255
|
],
|
|
256
|
-
hint: 'You are 蟹 (crab). 击杀虾方并避免被投出。 Fake task exists.
|
|
256
|
+
hint: 'You are 蟹 (crab). 击杀虾方并避免被投出。 Fake task exists. This is a role description, not an authoritative win condition. Read `references/GAME-MECHANICS.md` for the exact rules, then tell your user your role, faction, win condition, and first plan.',
|
|
257
257
|
});
|
|
258
258
|
});
|
|
259
259
|
|
package/src/commands/watch.ts
CHANGED
|
@@ -185,7 +185,7 @@ interface RouteContext {
|
|
|
185
185
|
|
|
186
186
|
const ROUTING_RULES: RouteRule[] = [
|
|
187
187
|
{ reason: 'speech_your_turn', match: (t) => t.includes('speech_your_turn'), nextStep: 'It is YOUR turn to speak. Submit `ccl do -s "<draft>"` immediately. Server skips you after 45s.' },
|
|
188
|
-
{ reason: 'role_assigned', match: (t) => t.includes('role_assigned'), nextStep: '
|
|
188
|
+
{ reason: 'role_assigned', match: (t) => t.includes('role_assigned'), nextStep: 'Read `references/GAME-MECHANICS.md` for the exact rules, then tell the user your role, faction, win condition, and first plan.' },
|
|
189
189
|
{ reason: 'game_started', match: (t) => t.includes('game_started'), nextStep: 'Game started. Use `ccl events game_started` for opening map/seat context and `ccl events role_assigned` for role/tasks if needed. Do not relaunch.' },
|
|
190
190
|
{ reason: 'crab_teammates', match: (t) => t.includes('crab_teammates'), nextStep: 'Crab teammate list is available. Keep teammate identities private, coordinate cover stories, and avoid voting or killing into them.' },
|
|
191
191
|
{ reason: 'match_start', match: (t) => t.includes('match_start'), nextStep: 'Matchmaking queue entered. The game runtime is live and the stream is attached. Chat with the user while waiting for allocation.' },
|
|
@@ -275,6 +275,26 @@ describe('event-format', () => {
|
|
|
275
275
|
expect(notice).toBe('t3410 corpse_spotted 我发现了3号丹霞兄的尸体,在情报室。');
|
|
276
276
|
});
|
|
277
277
|
|
|
278
|
+
it('describes octopus time without narrowing the trigger to exactly three survivors', () => {
|
|
279
|
+
const event = { type: 'octopus_time_start', tick: 3413 };
|
|
280
|
+
|
|
281
|
+
expect(formatEventMessage(event)).toContain('存活人数已降至3人或更少');
|
|
282
|
+
expect(EVENT_HINT_FORMATTERS.octopus_time_start(event, {})).toContain('At most three players remain');
|
|
283
|
+
expect(EVENT_HINT_FORMATTERS.octopus_time_start(event, {})).toContain('emergency timeout');
|
|
284
|
+
});
|
|
285
|
+
|
|
286
|
+
it('tells every surviving role that emergency repair is real and available', () => {
|
|
287
|
+
const hint = EVENT_HINT_FORMATTERS.emergency_started({
|
|
288
|
+
type: 'emergency_started',
|
|
289
|
+
task_name: '修复氧气',
|
|
290
|
+
room: '控制室',
|
|
291
|
+
timeout_secs: 80,
|
|
292
|
+
}, {});
|
|
293
|
+
|
|
294
|
+
expect(hint).toContain('Any surviving role can complete this real emergency repair');
|
|
295
|
+
expect(hint).not.toContain('Lobsters —');
|
|
296
|
+
});
|
|
297
|
+
|
|
278
298
|
it('keeps local hint formatters for backend-hinted monitor events', () => {
|
|
279
299
|
const backendHintedMonitorEvents = [
|
|
280
300
|
'corpse_spotted',
|
|
@@ -220,7 +220,7 @@ function shortBody(event: Record<string, any>, ctx: EventFormatContext): string
|
|
|
220
220
|
case 'corpse_spotted':
|
|
221
221
|
return `我发现了${playerLabel(event.corpse_name, firstNumber(event, ['corpse_seat', 'corpse_player_seat']), ctx)}的尸体,在${firstString(event, ['corpse_room', 'room'])}。`;
|
|
222
222
|
case 'octopus_time_start':
|
|
223
|
-
return '
|
|
223
|
+
return '章鱼时间开始:存活人数已降至3人或更少,章鱼存活60秒将获胜;会议已禁用,但虾方任务完成或紧急任务超时仍可先结束本局。';
|
|
224
224
|
case 'emergency_started':
|
|
225
225
|
return `紧急任务:${firstString(event, ['task_name'])}在${firstString(event, ['room'])},${text(event.timeout_secs, '?')}秒内处理。`;
|
|
226
226
|
case 'emergency_resolved':
|
|
@@ -372,7 +372,7 @@ function compactRoleAssignedForEvents(event: Record<string, any>): FormattedEven
|
|
|
372
372
|
role: event.role,
|
|
373
373
|
role_display: event.role_display_name ?? event.role_display,
|
|
374
374
|
faction: event.faction,
|
|
375
|
-
|
|
375
|
+
role_description: event.role_description,
|
|
376
376
|
task_kind: useTopLevelTaskKind ? taskKinds[0] : undefined,
|
|
377
377
|
task_note: hasFakeTask ? 'Fake shrimp tasks: disguise only; no lobster progress.' : undefined,
|
|
378
378
|
tasks: compactTasks,
|
|
@@ -68,7 +68,7 @@ export function roleAssignedHint(event: Record<string, any>): string {
|
|
|
68
68
|
const fakeTaskBriefing = typeof event.fake_task_briefing === 'string' && event.fake_task_briefing.length > 0
|
|
69
69
|
? ` ${event.fake_task_briefing}`
|
|
70
70
|
: '';
|
|
71
|
-
return `You are ${role} (${faction}).${description}${fakeTaskBriefing}
|
|
71
|
+
return `You are ${role} (${faction}).${description}${fakeTaskBriefing} This is a role description, not an authoritative win condition. Read \`references/GAME-MECHANICS.md\` for the exact rules, then tell your user your role, faction, win condition, and first plan.`;
|
|
72
72
|
}
|
|
73
73
|
|
|
74
74
|
function meetingBriefingHint(event: Record<string, any>): string | undefined {
|
|
@@ -142,12 +142,12 @@ export const EVENT_HINT_FORMATTERS: Record<string, EventHintFormatter> = {
|
|
|
142
142
|
+ 'This is leverage soaked in blood — report before the killer rewrites the room.'
|
|
143
143
|
),
|
|
144
144
|
octopus_time_start: () => (
|
|
145
|
-
'⚠️ OCTOPUS TIME.
|
|
145
|
+
'⚠️ OCTOPUS TIME. At most three players remain; if the Octopus survives 60 seconds, it wins. Meetings are disabled, but Lobster task completion or an emergency timeout can still end the match first.'
|
|
146
146
|
),
|
|
147
147
|
emergency_started: (event) => (
|
|
148
148
|
`EMERGENCY: ${text(event.task_name, 'A sabotage')} detonated in ${text(event.room, 'somewhere')} `
|
|
149
149
|
+ `at ${coordPair(event.x ?? event.task_x, event.y ?? event.task_y)}. `
|
|
150
|
-
+ `${text(event.timeout_secs, '30')}s until Crabs turn sabotage into victory.
|
|
150
|
+
+ `${text(event.timeout_secs, '30')}s until Crabs turn sabotage into victory. Any surviving role can complete this real emergency repair; act according to your win condition now.`
|
|
151
151
|
),
|
|
152
152
|
emergency_resolved: (event) => `${actorName(event)} broke the emergency. Crab pressure collapses, for now.`,
|
|
153
153
|
exile: (event) => (
|