@myclaw163/clawclaw-cli 0.1.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/README.md +434 -0
- package/bin/clawclaw-cli.mjs +4 -0
- package/package.json +48 -0
- package/personas//345/217/243/346/230/257/345/277/203/351/235/236.md +50 -0
- package/personas//345/277/240/345/277/203/350/200/201/344/273/206.md +51 -0
- package/personas//346/227/240/344/272/272/350/256/276.md +1 -0
- package/personas//350/264/253/345/230/264/346/215/237/345/217/213.md +48 -0
- package/personas//350/275/257/350/220/214/350/205/271/351/273/221.md +51 -0
- package/scripts/check-skill-command-surface.mjs +118 -0
- package/scripts/check_monitor.cjs +435 -0
- package/scripts/check_monitor.test.mjs +212 -0
- package/scripts/enable_ccl_permissions.cjs +164 -0
- package/scripts/enable_ccl_permissions.test.mjs +163 -0
- package/scripts/enable_monitor.cjs +677 -0
- package/scripts/enable_monitor.test.mjs +201 -0
- package/scripts/find-hide-spots.py +157 -0
- package/scripts/postinstall.mjs +20 -0
- package/scripts/sync-bundled-skill.mjs +254 -0
- package/scripts/sync-bundled-skill.test.mjs +152 -0
- package/skills/clawclaw/.gitkeep +0 -0
- package/skills/clawclaw/SKILL.md +275 -0
- package/skills/clawclaw/references/CHATTERBOX.md +142 -0
- package/skills/clawclaw/references/CLAUDE-CODE-MONITOR.md +224 -0
- package/skills/clawclaw/references/COMMANDS.md +165 -0
- package/skills/clawclaw/references/GAME-MECHANICS.md +195 -0
- package/skills/clawclaw/references/HUB.md +48 -0
- package/skills/clawclaw/references/KNOWLEDGE.md +42 -0
- package/skills/clawclaw/references/STRATEGIES.md +59 -0
- package/skills/clawclaw/references/STREAM.md +75 -0
- package/skills/clawclaw/references/TACTICS.md +65 -0
- package/src/assets/clawclaw-ascii-map.txt +40 -0
- package/src/cli.ts +113 -0
- package/src/commands/_schema.ts +124 -0
- package/src/commands/account.test.ts +391 -0
- package/src/commands/account.ts +338 -0
- package/src/commands/competition.ts +42 -0
- package/src/commands/config.ts +30 -0
- package/src/commands/data.test.ts +33 -0
- package/src/commands/data.ts +22 -0
- package/src/commands/do.test.ts +117 -0
- package/src/commands/do.ts +195 -0
- package/src/commands/events.test.ts +144 -0
- package/src/commands/events.ts +268 -0
- package/src/commands/game-map.test.ts +28 -0
- package/src/commands/game-monitor-status.test.ts +58 -0
- package/src/commands/game-start-plan.test.ts +356 -0
- package/src/commands/game.ts +2046 -0
- package/src/commands/history-player.test.ts +105 -0
- package/src/commands/history.ts +573 -0
- package/src/commands/hub.test.ts +134 -0
- package/src/commands/hub.ts +249 -0
- package/src/commands/knowledge.test.ts +13 -0
- package/src/commands/knowledge.ts +176 -0
- package/src/commands/load.test.ts +107 -0
- package/src/commands/load.ts +26 -0
- package/src/commands/meeting-history.test.ts +106 -0
- package/src/commands/memory.ts +40 -0
- package/src/commands/peek.ts +45 -0
- package/src/commands/persona.ts +62 -0
- package/src/commands/setup/codex.ts +266 -0
- package/src/commands/setup/hermes.test.ts +96 -0
- package/src/commands/setup/hermes.ts +76 -0
- package/src/commands/setup/index.ts +13 -0
- package/src/commands/setup/openclaw.test.ts +124 -0
- package/src/commands/setup/openclaw.ts +162 -0
- package/src/commands/skill.ts +128 -0
- package/src/commands/state.ts +46 -0
- package/src/commands/strategy.test.ts +172 -0
- package/src/commands/strategy.ts +170 -0
- package/src/commands/upgrade.test.ts +82 -0
- package/src/commands/upgrade.ts +157 -0
- package/src/commands/watch.test.ts +1313 -0
- package/src/commands/watch.ts +824 -0
- package/src/lib/account-guidance.test.ts +32 -0
- package/src/lib/account-guidance.ts +62 -0
- package/src/lib/auth.test.ts +116 -0
- package/src/lib/auth.ts +189 -0
- package/src/lib/command-meta.ts +37 -0
- package/src/lib/competition.ts +79 -0
- package/src/lib/custom-tts.test.ts +387 -0
- package/src/lib/custom-tts.ts +463 -0
- package/src/lib/game-client-tts.test.ts +151 -0
- package/src/lib/game-client.test.ts +82 -0
- package/src/lib/game-client.ts +472 -0
- package/src/lib/game-context.ts +92 -0
- package/src/lib/host-config-patcher.test.ts +130 -0
- package/src/lib/host-config-patcher.ts +151 -0
- package/src/lib/http-keepalive.ts +15 -0
- package/src/lib/http-transport.test.ts +61 -0
- package/src/lib/http-transport.ts +118 -0
- package/src/lib/hub-client.test.ts +57 -0
- package/src/lib/hub-client.ts +88 -0
- package/src/lib/hub-install.test.ts +157 -0
- package/src/lib/hub-install.ts +213 -0
- package/src/lib/hub-reminder.ts +69 -0
- package/src/lib/hub-unzip.test.ts +69 -0
- package/src/lib/hub-unzip.ts +62 -0
- package/src/lib/init-command.test.ts +79 -0
- package/src/lib/init-command.ts +136 -0
- package/src/lib/knowledge-store.test.ts +170 -0
- package/src/lib/knowledge-store.ts +369 -0
- package/src/lib/load-context.test.ts +62 -0
- package/src/lib/load-context.ts +49 -0
- package/src/lib/match-state.test.ts +134 -0
- package/src/lib/match-state.ts +94 -0
- package/src/lib/normalize.ts +42 -0
- package/src/lib/persona.test.ts +84 -0
- package/src/lib/persona.ts +120 -0
- package/src/lib/room.test.ts +74 -0
- package/src/lib/room.ts +129 -0
- package/src/lib/server-registry.test.ts +54 -0
- package/src/lib/server-registry.ts +185 -0
- package/src/lib/skill-version.test.ts +48 -0
- package/src/lib/skill-version.ts +19 -0
- package/src/lib/strategy-export.test.ts +314 -0
- package/src/lib/strategy-export.ts +352 -0
- package/src/lib/user-data.test.ts +98 -0
- package/src/lib/user-data.ts +370 -0
- package/src/lib/workspace-argv.test.ts +49 -0
- package/src/lib/workspace-argv.ts +44 -0
- package/src/perception/player-history-store.test.ts +177 -0
- package/src/perception/player-history-store.ts +262 -0
- package/src/pipeline/event-format.test.ts +327 -0
- package/src/pipeline/event-format.ts +595 -0
- package/src/pipeline/event-hints.ts +204 -0
- package/src/pipeline/event-store.test.ts +28 -0
- package/src/pipeline/event-store.ts +193 -0
- package/src/pipeline/pipeline.ts +35 -0
- package/src/pipeline/player-projection.test.ts +168 -0
- package/src/pipeline/player-projection.ts +370 -0
- package/src/runtime/auto-upgrade.test.ts +66 -0
- package/src/runtime/auto-upgrade.ts +31 -0
- package/src/runtime/event-daemon.test.ts +268 -0
- package/src/runtime/event-daemon.ts +531 -0
- package/src/runtime/owner-control.ts +150 -0
- package/src/runtime/raw-ws-log.test.ts +33 -0
- package/src/runtime/raw-ws-log.ts +32 -0
- package/src/runtime/room-lobby-runtime.test.ts +95 -0
- package/src/runtime/room-lobby-runtime.ts +367 -0
- package/src/runtime/runtime-logger.ts +107 -0
- package/src/runtime/ws-client.test.ts +169 -0
- package/src/runtime/ws-client.ts +280 -0
- package/src/sdk/action.ts +155 -0
- package/src/sdk/index.ts +112 -0
- package/src/sdk/types.ts +163 -0
- package/src/strategies/avoid-lone.ts +14 -0
- package/src/strategies/avoid-players.knowledge.md +19 -0
- package/src/strategies/avoid-players.ts +18 -0
- package/src/strategies/corpse-patrol.ts +21 -0
- package/src/strategies/crab-sabotage.ts +24 -0
- package/src/strategies/custom-module.test.ts +270 -0
- package/src/strategies/find-player.ts +19 -0
- package/src/strategies/game-utils.test.ts +242 -0
- package/src/strategies/game-utils.ts +853 -0
- package/src/strategies/goals/anchor-linger.ts +77 -0
- package/src/strategies/goals/avoid-lone-top.ts +168 -0
- package/src/strategies/goals/avoid-players-top.test.ts +83 -0
- package/src/strategies/goals/avoid-players-top.ts +121 -0
- package/src/strategies/goals/conversation-goal.ts +51 -0
- package/src/strategies/goals/corpse-patrol-top.ts +113 -0
- package/src/strategies/goals/crab-octopus-reflexes.ts +101 -0
- package/src/strategies/goals/crab-sabotage-top.ts +226 -0
- package/src/strategies/goals/emergency-hunt-goal.ts +28 -0
- package/src/strategies/goals/find-player-top.ts +93 -0
- package/src/strategies/goals/flee-players-goal.ts +53 -0
- package/src/strategies/goals/follow-companion-goal.ts +106 -0
- package/src/strategies/goals/goal-manager.ts +41 -0
- package/src/strategies/goals/goal-root-strategy.ts +49 -0
- package/src/strategies/goals/goal.ts +28 -0
- package/src/strategies/goals/hide-top.ts +197 -0
- package/src/strategies/goals/keep-away-goal.ts +221 -0
- package/src/strategies/goals/kill-frenzy-top.ts +80 -0
- package/src/strategies/goals/kill-lone-top.ts +160 -0
- package/src/strategies/goals/kill-target-goal.ts +59 -0
- package/src/strategies/goals/kill-target-top.ts +109 -0
- package/src/strategies/goals/leaf-goal.ts +27 -0
- package/src/strategies/goals/linger-corpse-goal.ts +35 -0
- package/src/strategies/goals/lone-kill-core.ts +82 -0
- package/src/strategies/goals/lone-kill-goal.ts +24 -0
- package/src/strategies/goals/lone-kill-task-top.test.ts +85 -0
- package/src/strategies/goals/lone-kill-task-top.ts +133 -0
- package/src/strategies/goals/move-room-goal.ts +60 -0
- package/src/strategies/goals/normal-shrimp-top.test.ts +97 -0
- package/src/strategies/goals/normal-shrimp-top.ts +248 -0
- package/src/strategies/goals/paradise-fish-top.test.ts +126 -0
- package/src/strategies/goals/paradise-fish-top.ts +224 -0
- package/src/strategies/goals/patrol-top.ts +57 -0
- package/src/strategies/goals/report-patrol-top.ts +86 -0
- package/src/strategies/goals/safe-task-goal.ts +102 -0
- package/src/strategies/goals/social-task-top.ts +161 -0
- package/src/strategies/goals/task-kill-report-top.ts +163 -0
- package/src/strategies/goals/task-only-top.ts +57 -0
- package/src/strategies/goals/task-or-patrol-goal.ts +41 -0
- package/src/strategies/goals/task-report-top.ts +57 -0
- package/src/strategies/goals/wander-task-goal.ts +33 -0
- package/src/strategies/goals/warrior-shrimp-top.test.ts +87 -0
- package/src/strategies/goals/warrior-shrimp-top.ts +267 -0
- package/src/strategies/greeting.ts +53 -0
- package/src/strategies/hide-spots.ts +59 -0
- package/src/strategies/hide.ts +26 -0
- package/src/strategies/kill-frenzy.ts +15 -0
- package/src/strategies/kill-lone.knowledge.md +17 -0
- package/src/strategies/kill-lone.ts +16 -0
- package/src/strategies/kill-target.ts +21 -0
- package/src/strategies/knowledge-contract.ts +85 -0
- package/src/strategies/loader.test.ts +710 -0
- package/src/strategies/loader.ts +183 -0
- package/src/strategies/lone-kill-task.ts +24 -0
- package/src/strategies/meeting-gate.test.ts +59 -0
- package/src/strategies/meeting-gate.ts +28 -0
- package/src/strategies/move-room.ts +18 -0
- package/src/strategies/new-events-backfill.ts +98 -0
- package/src/strategies/off-route-points.ts +105 -0
- package/src/strategies/paradise-fish.knowledge.md +19 -0
- package/src/strategies/paradise-fish.ts +24 -0
- package/src/strategies/pathfind/clawclaw-walkable.bin +0 -0
- package/src/strategies/pathfind/distance-field.ts +150 -0
- package/src/strategies/pathfind/escape-planner.test.ts +197 -0
- package/src/strategies/pathfind/escape-planner.ts +355 -0
- package/src/strategies/pathfind/walkable-grid.ts +117 -0
- package/src/strategies/patrol.ts +14 -0
- package/src/strategies/player-targets.ts +13 -0
- package/src/strategies/report-patrol.ts +14 -0
- package/src/strategies/scanner.ts +238 -0
- package/src/strategies/shrimp-memory.knowledge.md +19 -0
- package/src/strategies/shrimp-memory.ts +24 -0
- package/src/strategies/social-task.test.ts +28 -0
- package/src/strategies/social-task.ts +52 -0
- package/src/strategies/spawn.ts +82 -0
- package/src/strategies/speech-module.ts +123 -0
- package/src/strategies/strategy-loop.test.ts +15 -0
- package/src/strategies/strategy-loop.ts +748 -0
- package/src/strategies/task-kill-report.ts +20 -0
- package/src/strategies/task-only.ts +14 -0
- package/src/strategies/task-report.ts +21 -0
- package/src/strategies/types.ts +155 -0
- package/src/strategies/warrior-memory.knowledge.md +21 -0
- package/src/strategies/warrior-memory.ts +19 -0
|
@@ -0,0 +1,204 @@
|
|
|
1
|
+
export interface EventHintContext {
|
|
2
|
+
summary?: any | null;
|
|
3
|
+
seats?: Record<string, number>;
|
|
4
|
+
isFirstVisibleEvent?: boolean;
|
|
5
|
+
maxTextLength?: number;
|
|
6
|
+
}
|
|
7
|
+
|
|
8
|
+
export type EventHintFormatter = (event: Record<string, any>, ctx: EventHintContext) => string | undefined;
|
|
9
|
+
|
|
10
|
+
function text(value: unknown, fallback = '?'): string {
|
|
11
|
+
if (typeof value === 'string' && value.length > 0) return value;
|
|
12
|
+
if (typeof value === 'number' && Number.isFinite(value)) return String(value);
|
|
13
|
+
return fallback;
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
function numberValue(value: unknown): number | undefined {
|
|
17
|
+
if (typeof value === 'number' && Number.isFinite(value)) return value;
|
|
18
|
+
if (typeof value === 'string' && value.trim() !== '') {
|
|
19
|
+
const parsed = Number(value);
|
|
20
|
+
if (Number.isFinite(parsed)) return parsed;
|
|
21
|
+
}
|
|
22
|
+
return undefined;
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
function firstString(event: Record<string, any>, keys: string[], fallback = '?'): string {
|
|
26
|
+
for (const key of keys) {
|
|
27
|
+
const value = event[key];
|
|
28
|
+
if (typeof value === 'string' && value.length > 0) return value;
|
|
29
|
+
if (typeof value === 'number' && Number.isFinite(value)) return String(value);
|
|
30
|
+
}
|
|
31
|
+
return fallback;
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
function isRoomGameEvent(event: Record<string, any>, ctx: EventHintContext): boolean {
|
|
35
|
+
return event.game_mode === 'room'
|
|
36
|
+
|| ctx.summary?.game?.mode === 'room'
|
|
37
|
+
|| ctx.summary?.game_mode === 'room';
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
function firstNumber(event: Record<string, any>, keys: string[]): number | undefined {
|
|
41
|
+
for (const key of keys) {
|
|
42
|
+
const value = numberValue(event[key]);
|
|
43
|
+
if (value !== undefined) return value;
|
|
44
|
+
}
|
|
45
|
+
return undefined;
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
function optionalSeatPlayerLabel(name: unknown, seat: unknown): string {
|
|
49
|
+
const resolved = numberValue(seat);
|
|
50
|
+
const displayName = text(name, 'someone');
|
|
51
|
+
return resolved === undefined ? displayName : `${resolved}号${displayName}`;
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
function actorName(event: Record<string, any>, fallback = 'someone'): string {
|
|
55
|
+
return text(event.actor_name ?? event.actor ?? event.player_name, fallback);
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
function coordPair(x: unknown, y: unknown): string {
|
|
59
|
+
return `(${text(x, '?')}, ${text(y, '?')})`;
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
export function roleAssignedHint(event: Record<string, any>): string {
|
|
63
|
+
const role = text(event.role_display_name ?? event.role_display ?? event.role, '?');
|
|
64
|
+
const faction = text(event.faction, '?');
|
|
65
|
+
const description = typeof event.role_description === 'string' && event.role_description.length > 0
|
|
66
|
+
? ` ${event.role_description}`
|
|
67
|
+
: '';
|
|
68
|
+
const fakeTaskBriefing = typeof event.fake_task_briefing === 'string' && event.fake_task_briefing.length > 0
|
|
69
|
+
? ` ${event.fake_task_briefing}`
|
|
70
|
+
: '';
|
|
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
|
+
}
|
|
73
|
+
|
|
74
|
+
function meetingBriefingHint(event: Record<string, any>): string | undefined {
|
|
75
|
+
if (!event.meeting_caller_name && !Array.isArray(event.reported_corpses)) return undefined;
|
|
76
|
+
const callerName = event.meeting_caller_name || event.caller || 'Someone';
|
|
77
|
+
const callerSeat = firstNumber(event, ['meeting_caller_seat', 'caller_seat', 'actor_seat']);
|
|
78
|
+
const callerLabel = callerSeat === undefined ? callerName : `seat ${callerSeat} ${callerName}`;
|
|
79
|
+
const corpses = Array.isArray(event.reported_corpses)
|
|
80
|
+
? event.reported_corpses
|
|
81
|
+
.map((corpse: any) => (
|
|
82
|
+
corpse?.seat === undefined
|
|
83
|
+
? text(corpse?.name, 'someone')
|
|
84
|
+
: `seat ${corpse.seat} ${text(corpse?.name, 'someone')}`
|
|
85
|
+
))
|
|
86
|
+
.filter(Boolean)
|
|
87
|
+
: [];
|
|
88
|
+
|
|
89
|
+
let callContext = `${callerLabel} called this meeting`;
|
|
90
|
+
if (corpses.length === 1) {
|
|
91
|
+
callContext = `${callerLabel} called this meeting after reporting the body of ${corpses[0]}`;
|
|
92
|
+
} else if (corpses.length > 1) {
|
|
93
|
+
callContext = `${callerLabel} called this meeting after reporting the bodies of ${corpses.join(', ')}`;
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
const teammates = Array.isArray(event.crab_teammates) ? event.crab_teammates : [];
|
|
97
|
+
const teammateHint = teammates.length > 0
|
|
98
|
+
? ` Your Crab teammate(s): ${teammates.map((teammate: any) => (
|
|
99
|
+
teammate?.seat === undefined
|
|
100
|
+
? text(teammate?.name, 'someone')
|
|
101
|
+
: `seat ${teammate.seat} ${text(teammate?.name, 'someone')}`
|
|
102
|
+
)).join(', ')}. Shield them, redirect heat, split suspicion, and control the vote.`
|
|
103
|
+
: '';
|
|
104
|
+
return `Meeting started — ${callContext}.${teammateHint} Prepare fast — every sentence is accusation, defense, or misdirection under a timer.`;
|
|
105
|
+
}
|
|
106
|
+
|
|
107
|
+
export const EVENT_HINT_FORMATTERS: Record<string, EventHintFormatter> = {
|
|
108
|
+
game_started: (event) => {
|
|
109
|
+
const playerCount = numberValue(event.player_count);
|
|
110
|
+
const countText = playerCount === undefined ? 'Game started.' : `Game started with ${playerCount} players.`;
|
|
111
|
+
return `${countText} Use \`ccl events game_started\` for opening map/seat context and \`ccl events role_assigned\` for role/tasks if you need details.`;
|
|
112
|
+
},
|
|
113
|
+
role_assigned: (event) => roleAssignedHint(event),
|
|
114
|
+
kill: (event) => (
|
|
115
|
+
`MURDER: ${text(event.actor_name, 'someone')} butchered ${text(event.target_name, 'someone')}. `
|
|
116
|
+
+ "Blood is on the floor, one voice is gone, and the killer's side moves closer to victory."
|
|
117
|
+
),
|
|
118
|
+
killed: (event) => (
|
|
119
|
+
`YOU ARE DEAD: ${optionalSeatPlayerLabel(event.killer_name, firstNumber(event, ['killer_seat', 'killer_player_seat']))} removed you from play.`
|
|
120
|
+
),
|
|
121
|
+
murder_witnessed: (event) => (
|
|
122
|
+
`WITNESS: You saw ${text(event.killer_name, 'someone')} kill ${text(event.target_name, 'someone')}. `
|
|
123
|
+
+ 'This is hard evidence; survive, report, or weaponize it.'
|
|
124
|
+
),
|
|
125
|
+
warrior_shrimp_self_destruct: (event) => (
|
|
126
|
+
`You executed ${text(event.target_name, 'a teammate')}, but they were a fellow Lobster. `
|
|
127
|
+
+ 'Warrior Shrimp justice backfired — your own blade takes you down too.'
|
|
128
|
+
),
|
|
129
|
+
task_completed: (event) => {
|
|
130
|
+
const taskName = text(event.task_name, 'a task');
|
|
131
|
+
const actor = actorName(event, 'You');
|
|
132
|
+
if (event.is_fake_shrimp) {
|
|
133
|
+
return `${actor} completed forged shrimp task ${taskName}. The work was fake — a clean piece of theater, but Lobster power does not move.`;
|
|
134
|
+
}
|
|
135
|
+
return `${actor} completed ${taskName}. Lobster momentum surges; the Crab win condition is pushed further away.`;
|
|
136
|
+
},
|
|
137
|
+
task_sabotaged: (event) => (
|
|
138
|
+
`Sabotage hit near ${actorName(event, 'you')}: ${text(event.task_name, 'nearby')} was compromised. Crab pressure is now on the board.`
|
|
139
|
+
),
|
|
140
|
+
corpse_spotted: (event) => (
|
|
141
|
+
`BODY FOUND: ${text(event.corpse_name, 'someone')} at ${coordPair(event.corpse_x, event.corpse_y)} in ${firstString(event, ['corpse_room', 'room'])}. `
|
|
142
|
+
+ 'This is leverage soaked in blood — report before the killer rewrites the room.'
|
|
143
|
+
),
|
|
144
|
+
octopus_time_start: () => (
|
|
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
|
+
),
|
|
147
|
+
emergency_started: (event) => (
|
|
148
|
+
`EMERGENCY: ${text(event.task_name, 'A sabotage')} detonated in ${text(event.room, 'somewhere')} `
|
|
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. Any surviving role can complete this real emergency repair; act according to your win condition now.`
|
|
151
|
+
),
|
|
152
|
+
emergency_resolved: (event) => `${actorName(event)} broke the emergency. Crab pressure collapses, for now.`,
|
|
153
|
+
exile: (event) => (
|
|
154
|
+
`Meeting ended — ${actorName(event, text(event.result_target, 'Someone'))} was exiled by the table. `
|
|
155
|
+
+ 'If this is you, your influence is dead — tell your user and ask whether to spectate or leave.'
|
|
156
|
+
),
|
|
157
|
+
no_exile: () => 'Meeting ended — no one was exiled. The table failed to strike, and every hidden threat gets another turn.',
|
|
158
|
+
crab_teammates: (event) => {
|
|
159
|
+
const raw = Array.isArray(event.crab_teammates)
|
|
160
|
+
? event.crab_teammates
|
|
161
|
+
: Array.isArray(event.teammates)
|
|
162
|
+
? event.teammates
|
|
163
|
+
: [];
|
|
164
|
+
const labels = raw
|
|
165
|
+
.map((teammate: any) => (
|
|
166
|
+
typeof teammate === 'string'
|
|
167
|
+
? teammate
|
|
168
|
+
: optionalSeatPlayerLabel(teammate?.name, teammate?.seat)
|
|
169
|
+
))
|
|
170
|
+
.filter((label: string) => label.length > 0);
|
|
171
|
+
return labels.length > 0
|
|
172
|
+
? `Your Crab teammate(s): ${labels.join(', ')}. Keep this private and coordinate cover stories.`
|
|
173
|
+
: 'Your Crab teammate list is available. Keep it private.';
|
|
174
|
+
},
|
|
175
|
+
meeting_briefing: (event) => meetingBriefingHint(event),
|
|
176
|
+
speech_skipped: (event) => `${actorName(event, 'Someone')} lost the floor — silence becomes evidence`,
|
|
177
|
+
speech_your_turn: () => 'Submit `ccl do -s "<draft>"` immediately. Server skips you after 45s.',
|
|
178
|
+
vote_phase_start: () => 'Voting has begun. Pick a side — this is where suspicion becomes a weapon.',
|
|
179
|
+
vote_cast: (event) => `${optionalSeatPlayerLabel(event.actor_name, firstNumber(event, ['actor_seat', 'seat']))} voted.`,
|
|
180
|
+
vote_speech_phase_ended: () => 'The vote speech window has closed. Cast your vote now.',
|
|
181
|
+
meeting_ended: (event) => {
|
|
182
|
+
const result = event.result;
|
|
183
|
+
const target = text(event.result_target, '');
|
|
184
|
+
if (result === 'exiled') return `Meeting ended — ${target} was voted out. One seat is gone, and the board is harsher now.`;
|
|
185
|
+
if (result === 'tie') return 'Meeting ended — tie vote, no exile. Deadlock shields the guilty and wastes the innocent\'s leverage.';
|
|
186
|
+
return 'Meeting ended — majority skipped, no exile. The table refused to pull the trigger.';
|
|
187
|
+
},
|
|
188
|
+
game_over: (event, ctx) => {
|
|
189
|
+
if (isRoomGameEvent(event, ctx)) {
|
|
190
|
+
return '本轮房间对局结束,将回到房间等待。';
|
|
191
|
+
}
|
|
192
|
+
if (event.reason === 'game_timeout') {
|
|
193
|
+
return 'Game over — match time limit reached. The round ends with no faction victory. Review this game with your user, discuss key moments and decisions, then ask if they want to play again.';
|
|
194
|
+
}
|
|
195
|
+
return `Game over — ${text(event.winner, '?')} faction takes the table. The power struggle is settled. Review this game with your user, discuss key moments and decisions, then ask if they want to play again.`;
|
|
196
|
+
},
|
|
197
|
+
death_speech: (event) => `${text(event.speaker_name ?? event.actor_name, 'Someone')} sent danmaku after death: ${text(event.text, '')}`,
|
|
198
|
+
wandering_speech: (event) => `${actorName(event, 'Someone')}: ${text(event.text, '')}`,
|
|
199
|
+
};
|
|
200
|
+
|
|
201
|
+
export function formatEventHint(event: Record<string, any>, ctx: EventHintContext = {}): string | undefined {
|
|
202
|
+
const formatter = typeof event.type === 'string' ? EVENT_HINT_FORMATTERS[event.type] : undefined;
|
|
203
|
+
return formatter?.(event, ctx);
|
|
204
|
+
}
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import { mkdtempSync } from 'fs';
|
|
2
|
+
import { tmpdir } from 'os';
|
|
3
|
+
import { join } from 'path';
|
|
4
|
+
import { describe, expect, it } from 'vitest';
|
|
5
|
+
import { CCL_EVENTS_CURSOR_TYPE, EventStore } from './event-store.js';
|
|
6
|
+
|
|
7
|
+
describe('EventStore cursor records', () => {
|
|
8
|
+
it('skips local cursor records when reading events', () => {
|
|
9
|
+
const dir = mkdtempSync(join(tmpdir(), 'event-store-'));
|
|
10
|
+
const store = new EventStore(join(dir, 'session.jsonl'));
|
|
11
|
+
|
|
12
|
+
store.append({ type: 'role_assigned', tick: 1 });
|
|
13
|
+
store.append({ type: 'kill', tick: 2 });
|
|
14
|
+
store.appendEventsCursor(2);
|
|
15
|
+
store.append({ type: 'speech', tick: 3 });
|
|
16
|
+
|
|
17
|
+
expect(store.readEventsCursor()).toBe(2);
|
|
18
|
+
expect(store.records().map((record) => record.event.type)).toEqual([
|
|
19
|
+
'role_assigned',
|
|
20
|
+
'kill',
|
|
21
|
+
CCL_EVENTS_CURSOR_TYPE,
|
|
22
|
+
'speech',
|
|
23
|
+
]);
|
|
24
|
+
expect(store.eventRecords().map((record) => record.line)).toEqual([1, 2, 4]);
|
|
25
|
+
expect(store.all().map((event) => event.type)).toEqual(['role_assigned', 'kill', 'speech']);
|
|
26
|
+
expect(store.tail(2).map((event) => event.type)).toEqual(['kill', 'speech']);
|
|
27
|
+
});
|
|
28
|
+
});
|
|
@@ -0,0 +1,193 @@
|
|
|
1
|
+
import { appendFileSync, readFileSync, existsSync, writeFileSync, mkdirSync, readdirSync, statSync } from 'fs';
|
|
2
|
+
import { dirname, join, basename } from 'path';
|
|
3
|
+
import { AuthStore } from '../lib/auth.js';
|
|
4
|
+
import { getProfileGamesDir } from '../lib/init-command.js';
|
|
5
|
+
|
|
6
|
+
export const CCL_EVENTS_CURSOR_TYPE = '_ccl_events_cursor';
|
|
7
|
+
export const CCL_EVENTS_CURSOR_NAME = 'agent_read';
|
|
8
|
+
|
|
9
|
+
interface GameSessionFile {
|
|
10
|
+
path: string;
|
|
11
|
+
sessionId: string;
|
|
12
|
+
mtimeMs: number;
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
export interface EventRecord {
|
|
16
|
+
line: number;
|
|
17
|
+
event: Record<string, any>;
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
export interface EventsCursorRecord {
|
|
21
|
+
type: typeof CCL_EVENTS_CURSOR_TYPE;
|
|
22
|
+
cursor: typeof CCL_EVENTS_CURSOR_NAME;
|
|
23
|
+
line: number;
|
|
24
|
+
ts: string;
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
export function isLocalControlEvent(event: any): boolean {
|
|
28
|
+
return !!(
|
|
29
|
+
event
|
|
30
|
+
&& typeof event === 'object'
|
|
31
|
+
&& typeof event.type === 'string'
|
|
32
|
+
&& event.type.startsWith('_ccl_')
|
|
33
|
+
);
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
export function extractNewEvents(source: any): Record<string, any>[] {
|
|
37
|
+
const candidates = [
|
|
38
|
+
source,
|
|
39
|
+
source?.new_events,
|
|
40
|
+
source?.data?.new_events,
|
|
41
|
+
source?.result?.new_events,
|
|
42
|
+
source?.result?.data?.new_events,
|
|
43
|
+
];
|
|
44
|
+
|
|
45
|
+
for (const candidate of candidates) {
|
|
46
|
+
if (Array.isArray(candidate)) {
|
|
47
|
+
return candidate.filter((evt) => evt && typeof evt === 'object');
|
|
48
|
+
}
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
return [];
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
export class EventStore {
|
|
55
|
+
constructor(private filePath: string) {}
|
|
56
|
+
|
|
57
|
+
get path(): string {
|
|
58
|
+
return this.filePath;
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
static forActiveAccount(): EventStore {
|
|
62
|
+
return EventStore.forLatestGame();
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
static forLatestGame(): EventStore {
|
|
66
|
+
const store = new AuthStore();
|
|
67
|
+
const profile = store.getActive();
|
|
68
|
+
if (!profile) throw new Error('Not logged in.');
|
|
69
|
+
|
|
70
|
+
const latest = EventStore.latestSessionFile(getProfileGamesDir(profile));
|
|
71
|
+
if (!latest) {
|
|
72
|
+
throw new Error('No game events found. Join a game first.');
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
return new EventStore(latest.path);
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
/** Returns the path to the latest session jsonl, or null if none exists. */
|
|
79
|
+
static latestSessionPath(): string | null {
|
|
80
|
+
const store = new AuthStore();
|
|
81
|
+
const profile = store.getActive();
|
|
82
|
+
if (!profile) return null;
|
|
83
|
+
return EventStore.latestSessionFile(getProfileGamesDir(profile))?.path ?? null;
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
static createSessionForActiveAccount(sessionId = EventStore.createSessionId()): EventStore {
|
|
87
|
+
const store = new AuthStore();
|
|
88
|
+
const profile = store.getActive();
|
|
89
|
+
if (!profile) throw new Error('Not logged in.');
|
|
90
|
+
|
|
91
|
+
const dir = getProfileGamesDir(profile);
|
|
92
|
+
mkdirSync(dir, { recursive: true });
|
|
93
|
+
const filePath = join(dir, `${sessionId}.jsonl`);
|
|
94
|
+
if (!existsSync(filePath)) writeFileSync(filePath, '');
|
|
95
|
+
return new EventStore(filePath);
|
|
96
|
+
}
|
|
97
|
+
|
|
98
|
+
append(event: Record<string, any>): void {
|
|
99
|
+
mkdirSync(dirname(this.filePath), { recursive: true });
|
|
100
|
+
const line = JSON.stringify(event) + '\n';
|
|
101
|
+
appendFileSync(this.filePath, line);
|
|
102
|
+
}
|
|
103
|
+
|
|
104
|
+
appendNewEvents(events: any): void {
|
|
105
|
+
const extracted = extractNewEvents(events);
|
|
106
|
+
if (extracted.length === 0) return;
|
|
107
|
+
for (const evt of extracted) {
|
|
108
|
+
this.append(evt);
|
|
109
|
+
}
|
|
110
|
+
}
|
|
111
|
+
|
|
112
|
+
records(): EventRecord[] {
|
|
113
|
+
if (!existsSync(this.filePath)) return [];
|
|
114
|
+
const content = readFileSync(this.filePath, 'utf8');
|
|
115
|
+
if (!content.trim()) return [];
|
|
116
|
+
const records: EventRecord[] = [];
|
|
117
|
+
const lines = content.split('\n');
|
|
118
|
+
for (let i = 0; i < lines.length; i += 1) {
|
|
119
|
+
const line = lines[i].trim();
|
|
120
|
+
if (!line) continue;
|
|
121
|
+
try {
|
|
122
|
+
const event = JSON.parse(line);
|
|
123
|
+
if (event && typeof event === 'object') {
|
|
124
|
+
records.push({ line: i + 1, event });
|
|
125
|
+
}
|
|
126
|
+
} catch {}
|
|
127
|
+
}
|
|
128
|
+
return records;
|
|
129
|
+
}
|
|
130
|
+
|
|
131
|
+
eventRecords(): EventRecord[] {
|
|
132
|
+
return this.records().filter((record) => !isLocalControlEvent(record.event));
|
|
133
|
+
}
|
|
134
|
+
|
|
135
|
+
readEventsCursor(): number {
|
|
136
|
+
let cursor = 0;
|
|
137
|
+
for (const record of this.records()) {
|
|
138
|
+
const event = record.event;
|
|
139
|
+
if (
|
|
140
|
+
event.type === CCL_EVENTS_CURSOR_TYPE
|
|
141
|
+
&& event.cursor === CCL_EVENTS_CURSOR_NAME
|
|
142
|
+
&& typeof event.line === 'number'
|
|
143
|
+
&& Number.isFinite(event.line)
|
|
144
|
+
) {
|
|
145
|
+
cursor = event.line;
|
|
146
|
+
}
|
|
147
|
+
}
|
|
148
|
+
return cursor;
|
|
149
|
+
}
|
|
150
|
+
|
|
151
|
+
appendEventsCursor(line: number): void {
|
|
152
|
+
if (!Number.isFinite(line) || line <= 0) return;
|
|
153
|
+
const event: EventsCursorRecord = {
|
|
154
|
+
type: CCL_EVENTS_CURSOR_TYPE,
|
|
155
|
+
cursor: CCL_EVENTS_CURSOR_NAME,
|
|
156
|
+
line,
|
|
157
|
+
ts: new Date().toISOString(),
|
|
158
|
+
};
|
|
159
|
+
this.append(event);
|
|
160
|
+
}
|
|
161
|
+
|
|
162
|
+
tail(n: number): Record<string, any>[] {
|
|
163
|
+
return this.eventRecords().slice(-n).map((record) => record.event);
|
|
164
|
+
}
|
|
165
|
+
|
|
166
|
+
all(): Record<string, any>[] {
|
|
167
|
+
return this.eventRecords().map((record) => record.event);
|
|
168
|
+
}
|
|
169
|
+
|
|
170
|
+
clear(): void {
|
|
171
|
+
writeFileSync(this.filePath, '');
|
|
172
|
+
}
|
|
173
|
+
|
|
174
|
+
private static createSessionId(): string {
|
|
175
|
+
const id = new Date().toISOString();
|
|
176
|
+
return process.platform === 'win32' ? id.replace(/:/g, '_') : id;
|
|
177
|
+
}
|
|
178
|
+
|
|
179
|
+
private static latestSessionFile(dir: string): GameSessionFile | null {
|
|
180
|
+
if (!existsSync(dir)) return null;
|
|
181
|
+
|
|
182
|
+
const files = readdirSync(dir)
|
|
183
|
+
.filter(name => name.endsWith('.jsonl') && !name.endsWith('.raw-ws.jsonl') && !name.startsWith('index.'))
|
|
184
|
+
.map(name => {
|
|
185
|
+
const path = join(dir, name);
|
|
186
|
+
const stat = statSync(path);
|
|
187
|
+
return { path, sessionId: basename(name, '.jsonl'), mtimeMs: stat.mtimeMs };
|
|
188
|
+
})
|
|
189
|
+
.sort((a, b) => b.sessionId.localeCompare(a.sessionId) || b.mtimeMs - a.mtimeMs);
|
|
190
|
+
|
|
191
|
+
return files[0] ?? null;
|
|
192
|
+
}
|
|
193
|
+
}
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
import { GameClient } from '../lib/game-client.js';
|
|
2
|
+
import { EventStore } from './event-store.js';
|
|
3
|
+
|
|
4
|
+
interface PipelineAction {
|
|
5
|
+
action: Record<string, any>;
|
|
6
|
+
needsWait: boolean;
|
|
7
|
+
}
|
|
8
|
+
|
|
9
|
+
export async function runPipeline(actions: PipelineAction[], initialWaitMs?: number): Promise<void> {
|
|
10
|
+
const client = GameClient.fromAuth();
|
|
11
|
+
const store = EventStore.forActiveAccount();
|
|
12
|
+
|
|
13
|
+
if (initialWaitMs && initialWaitMs > 0) {
|
|
14
|
+
await new Promise(r => setTimeout(r, initialWaitMs));
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
for (const item of actions) {
|
|
18
|
+
const result = await client.submitAction(item.action as any);
|
|
19
|
+
store.appendNewEvents(result);
|
|
20
|
+
const durationSecs = result?.data?.duration_secs ?? result?.duration_secs ?? 0;
|
|
21
|
+
|
|
22
|
+
if (item.needsWait && durationSecs > 0) {
|
|
23
|
+
await new Promise(r => setTimeout(r, (durationSecs + 0.5) * 1000));
|
|
24
|
+
try {
|
|
25
|
+
const state = await client.getGameState();
|
|
26
|
+
if (state) store.appendNewEvents(state.new_events);
|
|
27
|
+
} catch {}
|
|
28
|
+
store.append({ type: 'pipeline', action: item.action, status: 'done' });
|
|
29
|
+
} else {
|
|
30
|
+
store.append({ type: 'pipeline', action: item.action, result });
|
|
31
|
+
}
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
store.append({ type: 'pipeline_done', count: actions.length });
|
|
35
|
+
}
|
|
@@ -0,0 +1,168 @@
|
|
|
1
|
+
import { describe, expect, it } from 'vitest';
|
|
2
|
+
import { projectPlayers } from './player-projection.js';
|
|
3
|
+
|
|
4
|
+
describe('projectPlayers', () => {
|
|
5
|
+
it('projects known deaths from visible-safe events without inventing hidden deaths', () => {
|
|
6
|
+
const players = projectPlayers({
|
|
7
|
+
summary: {
|
|
8
|
+
you: { name: '我', seat: 1 },
|
|
9
|
+
game: {
|
|
10
|
+
all_players: [
|
|
11
|
+
{ name: '我', seat: 1 },
|
|
12
|
+
{ name: '蓝虾', seat: 2 },
|
|
13
|
+
{ name: '红蟹', seat: 3 },
|
|
14
|
+
{ name: '白虾', seat: 4 },
|
|
15
|
+
],
|
|
16
|
+
},
|
|
17
|
+
},
|
|
18
|
+
events: [
|
|
19
|
+
{ type: 'kill', target_name: '蓝虾', target_seat: 2, actor_name: '我' },
|
|
20
|
+
{ type: 'murder_witnessed', killer_name: '红蟹', target_name: '白虾', target_seat: 4 },
|
|
21
|
+
],
|
|
22
|
+
});
|
|
23
|
+
|
|
24
|
+
expect(players).toEqual([
|
|
25
|
+
{
|
|
26
|
+
name: '蓝虾',
|
|
27
|
+
seat: 2,
|
|
28
|
+
status: 'dead',
|
|
29
|
+
death: {
|
|
30
|
+
cause: 'killed',
|
|
31
|
+
killer: '我',
|
|
32
|
+
killer_is_you: true,
|
|
33
|
+
revealed: true,
|
|
34
|
+
source: 'event_log',
|
|
35
|
+
},
|
|
36
|
+
},
|
|
37
|
+
{
|
|
38
|
+
name: '红蟹',
|
|
39
|
+
seat: 3,
|
|
40
|
+
status: 'alive',
|
|
41
|
+
death: null,
|
|
42
|
+
},
|
|
43
|
+
{
|
|
44
|
+
name: '白虾',
|
|
45
|
+
seat: 4,
|
|
46
|
+
status: 'dead',
|
|
47
|
+
death: {
|
|
48
|
+
cause: 'killed',
|
|
49
|
+
killer: '红蟹',
|
|
50
|
+
killer_is_you: false,
|
|
51
|
+
revealed: true,
|
|
52
|
+
source: 'event_log',
|
|
53
|
+
},
|
|
54
|
+
},
|
|
55
|
+
]);
|
|
56
|
+
});
|
|
57
|
+
|
|
58
|
+
it('uses meeting alive lists only as revealed meeting knowledge', () => {
|
|
59
|
+
const players = projectPlayers({
|
|
60
|
+
summary: { you: { name: '我' } },
|
|
61
|
+
events: [
|
|
62
|
+
{ type: 'game_started', players: [{ name: '我', seat: 1 }, { name: '蓝虾', seat: 2 }, { name: '红蟹', seat: 3 }] },
|
|
63
|
+
{ type: 'meeting_state', alive_players: [{ name: '我', seat: 1 }, { name: '红蟹', seat: 3 }] },
|
|
64
|
+
],
|
|
65
|
+
});
|
|
66
|
+
|
|
67
|
+
expect(players.find((player) => player.name === '蓝虾')).toMatchObject({
|
|
68
|
+
status: 'dead',
|
|
69
|
+
death: {
|
|
70
|
+
cause: 'killed',
|
|
71
|
+
source: 'meeting_alive_list',
|
|
72
|
+
},
|
|
73
|
+
});
|
|
74
|
+
expect(players.find((player) => player.name === '红蟹')).toMatchObject({
|
|
75
|
+
status: 'alive',
|
|
76
|
+
death: null,
|
|
77
|
+
});
|
|
78
|
+
});
|
|
79
|
+
|
|
80
|
+
it('merges name-only death events into roster players with seats', () => {
|
|
81
|
+
const players = projectPlayers({
|
|
82
|
+
summary: { you: { name: 'Self' } },
|
|
83
|
+
events: [
|
|
84
|
+
{
|
|
85
|
+
type: 'game_started',
|
|
86
|
+
all_seats: { Self: 1, Blue: 2, Red: 3 },
|
|
87
|
+
},
|
|
88
|
+
{
|
|
89
|
+
type: 'corpse_spotted',
|
|
90
|
+
corpse_name: 'Blue',
|
|
91
|
+
},
|
|
92
|
+
{
|
|
93
|
+
type: 'meeting_state',
|
|
94
|
+
alive_players: ['Self', 'Red'],
|
|
95
|
+
},
|
|
96
|
+
],
|
|
97
|
+
});
|
|
98
|
+
|
|
99
|
+
expect(players).toEqual([
|
|
100
|
+
{
|
|
101
|
+
name: 'Blue',
|
|
102
|
+
seat: 2,
|
|
103
|
+
status: 'dead',
|
|
104
|
+
death: {
|
|
105
|
+
cause: 'killed',
|
|
106
|
+
killer: null,
|
|
107
|
+
revealed: true,
|
|
108
|
+
source: 'corpse_spotted',
|
|
109
|
+
},
|
|
110
|
+
},
|
|
111
|
+
{
|
|
112
|
+
name: 'Red',
|
|
113
|
+
seat: 3,
|
|
114
|
+
status: 'alive',
|
|
115
|
+
death: null,
|
|
116
|
+
},
|
|
117
|
+
]);
|
|
118
|
+
});
|
|
119
|
+
|
|
120
|
+
it('treats unconfirmed roster players as alive even if a backend snapshot omits proof', () => {
|
|
121
|
+
const players = projectPlayers({
|
|
122
|
+
summary: {
|
|
123
|
+
you: { name: 'Self', seat: 1 },
|
|
124
|
+
game: {
|
|
125
|
+
all_players: [
|
|
126
|
+
{ name: 'Self', seat: 1 },
|
|
127
|
+
{ name: 'Blue', seat: 2, is_alive: false },
|
|
128
|
+
{ name: 'Red', seat: 3 },
|
|
129
|
+
],
|
|
130
|
+
},
|
|
131
|
+
},
|
|
132
|
+
events: [],
|
|
133
|
+
});
|
|
134
|
+
|
|
135
|
+
expect(players).toEqual([
|
|
136
|
+
{ name: 'Blue', seat: 2, status: 'alive', death: null },
|
|
137
|
+
{ name: 'Red', seat: 3, status: 'alive', death: null },
|
|
138
|
+
]);
|
|
139
|
+
});
|
|
140
|
+
|
|
141
|
+
it('keeps only confirmed meeting, witnessed, and self-caused deaths as dead', () => {
|
|
142
|
+
const players = projectPlayers({
|
|
143
|
+
summary: { you: { name: 'Self', seat: 1 } },
|
|
144
|
+
events: [
|
|
145
|
+
{
|
|
146
|
+
type: 'game_started',
|
|
147
|
+
players: [
|
|
148
|
+
{ name: 'Self', seat: 1 },
|
|
149
|
+
{ name: 'MeetingDead', seat: 2 },
|
|
150
|
+
{ name: 'WitnessedDead', seat: 3 },
|
|
151
|
+
{ name: 'SelfKilled', seat: 4 },
|
|
152
|
+
{ name: 'NoProof', seat: 5 },
|
|
153
|
+
],
|
|
154
|
+
},
|
|
155
|
+
{ type: 'meeting_state', alive_players: [{ name: 'Self', seat: 1 }, { name: 'WitnessedDead', seat: 3 }, { name: 'SelfKilled', seat: 4 }, { name: 'NoProof', seat: 5 }] },
|
|
156
|
+
{ type: 'murder_witnessed', killer_name: 'Crab', target_name: 'WitnessedDead', target_seat: 3 },
|
|
157
|
+
{ type: 'kill', actor_name: 'Self', target_name: 'SelfKilled', target_seat: 4 },
|
|
158
|
+
],
|
|
159
|
+
});
|
|
160
|
+
|
|
161
|
+
expect(players.map((player) => [player.name, player.status, player.death?.source ?? null])).toEqual([
|
|
162
|
+
['MeetingDead', 'dead', 'meeting_alive_list'],
|
|
163
|
+
['WitnessedDead', 'dead', 'event_log'],
|
|
164
|
+
['SelfKilled', 'dead', 'event_log'],
|
|
165
|
+
['NoProof', 'alive', null],
|
|
166
|
+
]);
|
|
167
|
+
});
|
|
168
|
+
});
|