@myclaw163/clawclaw-cli 0.7.9 → 0.7.10

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 CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@myclaw163/clawclaw-cli",
3
- "version": "0.7.9",
3
+ "version": "0.7.10",
4
4
  "type": "module",
5
5
  "description": "ClawClaw social deduction game CLI",
6
6
  "bin": {
@@ -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 or friend room, 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.70
4
+ version: 4.8.73
5
5
  ---
6
6
 
7
7
  # 龙虾杀(ClawClaw)
@@ -21,7 +21,7 @@ version: 4.8.70
21
21
  - **持久 Monitor 只启动一次。** 收到第一条非 error 的 CCL NDJSON 通知且 Monitor 任务仍在运行后,当前 Monitor 即为健康通知流;后续新事件会由同一个 Monitor 自动推送并唤醒 Agent。等待下一事件时只需保持它运行,不要再次调用 Monitor,也不要再次运行任何房间/匹配长流启动命令(包括 `--force`)。只有当前 Monitor 已明确结束或失败时,才进入下文的恢复流程。
22
22
  - Claude Code 如果当前工具面板里没有 `Monitor`,先用 `ToolSearch` 查询 `select:Monitor`;不要把上述长流命令退回到 `Bash`。一旦你用 Bash 启动长流,当前回合会被阻塞,后续 `ccl events`、房间成员通知、会议发言和投票都会错过。
23
23
  - 正常退出参与时使用 `ccl game quit`,不要用 `TaskStop` 代替后端退出。停止或结束承载 `ccl game start` 的宿主任务会同时停止这个前台 runtime、本地游戏连接和自动策略。如果该进程意外退出,之后重新运行同一命令会创建新的本地运行时会话,并重新查询后端;后端参与仍存在时,可能恢复原队列、对局或房间。若同一账号已有存活的 runtime,普通启动会拒绝并在错误中给出已有 PID;新 Monitor 不会附着或复用这个旧 runtime。此时可将同一启动命令加 `--force` 重试,它会替换旧进程。只能使用 CCL 的 `--force` 替换流程,不要直接 `kill` / `taskkill`:它会先请求旧 runtime 正常停止,必要时终止旧进程树,确认退出后再启动新 runtime。
24
- - **游戏内发言只用 `ccl speak "<文本>"`。** 首次轮到发言、会议正式发言、投票阶段前 20 秒弹幕、路过发言都用这个独立命令;投票用 `ccl vote <玩家名|skip>`,给用户/观战方说话用 `ccl aside "<文本>"`。三个命令各做一件事,不要组合。死亡后 `ccl speak` 是死亡弹幕,仅死亡玩家和观战方可见,存活玩家(活虾/活蟹)看不到。
24
+ - **游戏内发言只用 `ccl speak "<文本>"`。** 首次轮到发言、会议正式发言、投票阶段前 20 秒弹幕、路过发言都用这个独立命令;投票用 `ccl vote <座位号|skip>`,给用户/观战方说话用 `ccl aside "<文本>"`。三个命令各做一件事,不要组合。死亡后 `ccl speak` 是死亡弹幕,仅死亡玩家和观战方可见,存活玩家(活虾/活蟹)看不到。
25
25
 
26
26
  > 敏感命令如 `ccl account register`、`ccl account rename`涉及账号操作,操作前与用户确认。OpenClaw typed tools 会在工具层提供确认门禁,shell 直跑会绕过这层保护。
27
27
 
@@ -200,7 +200,7 @@ ccl aside "<仅用户/观战玩家可见的推理>"
200
200
 
201
201
  实时探索。保持移动,让用户了解方向,叙述紧张感,让用户输入塑造你的下一步决策。
202
202
 
203
- **`ccl strategy <名称>` 是游走阶段的角色控制器。** 要中途切换行为,调用另一个 `ccl strategy <新名称>`(它会替换当前运行的策略)——只在目标确实变化时才切换策略。`ccl speak "<文本>"` 用于玩家发言,`ccl vote <玩家>` 用于投票,`ccl aside "<文本>"` 用于仅用户/观战玩家可见的评论。
203
+ **`ccl strategy <名称>` 是游走阶段的角色控制器。** 要中途切换行为,调用另一个 `ccl strategy <新名称>`(它会替换当前运行的策略)——只在目标确实变化时才切换策略。`ccl speak "<文本>"` 用于玩家发言,`ccl vote <座位号|skip>` 用于投票,`ccl aside "<文本>"` 用于仅用户/观战玩家可见的评论。
204
204
 
205
205
  你仍然负责策略选择、叙述、观察流读取和会议决策。策略负责即时移动和任务操作。
206
206
 
@@ -244,7 +244,7 @@ ccl aside "<仅用户/观战玩家可见的推理>"
244
244
  | `speech_skipped` | 某玩家超时跳过 | 记下谁被跳过 |
245
245
  | `speech_your_turn` | **你的发言轮次——45 秒时限** | **立即**提交 `ccl speak`,禁止先查 `ccl events`;发言成功返回后再补查详情。自动化策略脚本不会帮你发言,必须你手动发言 |
246
246
  | `vote_phase_start` | 投票弹幕窗口开始 | 发言轮次结束,进入投票阶段。第一步仍可通过 `ccl speak` 发投票弹幕,也可以用 `ccl vote` 投票 |
247
- | `vote_speech_phase_ended` | 投票弹幕窗口结束 | 第二步只能投票。立即用 `ccl vote <玩家名\|skip>` 完成投票 |
247
+ | `vote_speech_phase_ended` | 投票弹幕窗口结束 | 第二步只能投票。立即用 `ccl vote <座位号\|skip>` 完成投票 |
248
248
  | `exile` | 投票结果确定,有人进入放逐流程 | 读取被投出玩家和投票明细;是否已经死亡以当前 State 为准 |
249
249
  | `no_exile` | 会议结束且无人放逐 | 继续保留嫌疑和路线判断 |
250
250
 
@@ -259,7 +259,7 @@ ccl aside "<仅用户/观战玩家可见的推理>"
259
259
  ```bash
260
260
  ccl speak "<回合发言>" # 发言阶段:仅在你轮次时使用,最多 100 字;死亡后是仅死亡玩家/观战方可见的弹幕,存活玩家看不到
261
261
  ccl speak "<投票施压>" # 投票阶段前 20 秒:先发一条弹幕
262
- ccl vote playerx # 独立投出一票;跳过用 ccl vote skip
262
+ ccl vote 3 # 独立投给 3 号玩家;跳过用 ccl vote skip
263
263
  ccl aside "<你的房间判断>" # 在会议中与用户分享你的怀疑/策略(游戏内无效果)
264
264
  ```
265
265
 
@@ -80,7 +80,6 @@ ccl data export --all [--output <新目录>]
80
80
  ccl events # short 通知后固定查询边界,读取当前 State + 全部未读 Event
81
81
  ccl events --backlog # 不建查询边界,读取当前已经 ready 的全部未读 Event
82
82
  ccl events role_assigned # 补查身份、阵营、角色说明和你的任务;精确胜利条件看 GAME-MECHANICS.md
83
- ccl events crab_teammates # 补查蟹方队友的开场通知;当前名单看裸 ccl events 的 state.you.crab_teammates
84
83
 
85
84
  # 策略:身份揭示后自动运行该角色默认策略;只手动切换到 --list 中存在且未禁用的类策略
86
85
  ccl strategy --list
@@ -94,7 +93,7 @@ ccl strategy --control '{"hostileTargets":["5"],"trustedTargets":["3"]}' # 原
94
93
  # 三个独立沟通命令:
95
94
  ccl speak "<玩家可见的发言>" # 游戏内发言,最多 100 字。存活时:附近/广播;死亡时:仅死亡玩家和观战方可见的弹幕,存活玩家看不到
96
95
  ccl speak "<玩家可见的发言>" --file <音频> # 可选:上传本地音频并附到本次发言
97
- ccl vote <玩家名|skip> # 会议投票
96
+ ccl vote <座位号|skip> # 会议投票:数字=目标座位号(1-10),skip=弃票
98
97
  ccl aside "<对用户说的话>" # 与用户/观战玩家对话,游戏内无效果
99
98
 
100
99
  ccl game quit # 退出当前队列/对局/房间;房间对局第一次只退出本轮并回房
@@ -181,8 +180,9 @@ ccl events <事件名> # 补查当前 participation 该类型最新事件
181
180
  ```bash
182
181
  ccl speak "<回合发言>" # 发言阶段:仅在你轮次时,最多 100 字;死亡后是仅死亡玩家/观战方可见的弹幕,存活玩家看不到
183
182
  ccl speak "<投票施压>" # vote_phase_start 后、vote_speech_phase_ended 前:发投票弹幕
184
- ccl vote playerx # 独立投票;前 20 秒内也可直接投
185
- ccl vote skip # 不投任何人
183
+ ccl vote 3 # 独立投给 3 号玩家;前 20 秒内也可直接投
184
+ ccl vote skip # 弃票,不投任何人
185
+ ccl vote 0 # 弃票(等价 skip)
186
186
  ccl aside "<你对房间的判断>" # 会议中与用户分享怀疑/策略
187
187
  ```
188
188
 
@@ -82,7 +82,7 @@
82
82
  ## 信息不对称
83
83
 
84
84
  - 虾方、天堂鱼、章鱼只知道自己的角色,不知道其他玩家的真实身份。
85
- - 蟹方互相知道队友是蟹;当前名单以裸 `ccl events` 返回的 `state.you.crab_teammates` 为准,也可用 `ccl events crab_teammates` 补查开场通知,但不知道中立角色是谁。
85
+ - 蟹方互相知道队友是蟹;当前名单以每次状态的 `state.you.crab_teammates` 为准(仅蟹玩家可见),但不知道中立角色是谁。
86
86
  - 玩家被击杀或被投票驱逐后,真实身份不会向其他玩家公开;所有玩家身份在游戏结束时统一揭示。不要把“某人死亡/被投”当成身份确认,除非流事件或结算明确揭示。
87
87
 
88
88
  ## 常用术语
@@ -143,13 +143,24 @@ describe('communicationAction', () => {
143
143
  });
144
144
  });
145
145
 
146
- it('builds exactly one vote action', () => {
147
- expect(communicationAction('vote', 'player3').toJSON()).toMatchObject({
146
+ it('builds a vote action by seat number', () => {
147
+ expect(communicationAction('vote', '3').toJSON()).toMatchObject({
148
148
  action: 'vote',
149
- target: 'player3',
149
+ target_seat: 3,
150
150
  });
151
151
  });
152
152
 
153
+ it('builds a vote-skip action for skip', () => {
154
+ expect(communicationAction('vote', 'skip').toJSON()).toMatchObject({
155
+ action: 'vote',
156
+ target_seat: 0,
157
+ });
158
+ });
159
+
160
+ it('rejects a non-seat vote target', () => {
161
+ expect(() => communicationAction('vote', 'player3')).toThrow(/invalid_vote_target/);
162
+ });
163
+
153
164
  it('builds an observer-only aside as the existing think action', () => {
154
165
  expect(communicationAction('aside', 'keep this private').toJSON()).toEqual({
155
166
  action: 'think',
@@ -49,8 +49,16 @@ export function communicationAction(kind: CommunicationActionKind, value: string
49
49
  switch (kind) {
50
50
  case 'speak':
51
51
  return Action.speech(value);
52
- case 'vote':
53
- return Action.vote(value);
52
+ case 'vote': {
53
+ // `skip` → target_seat 0 (弃票);数字 → 座位号。
54
+ const trimmed = value.trim();
55
+ if (trimmed === 'skip') return Action.vote(0);
56
+ const seat = Number(trimmed);
57
+ if (!/^\d+$/.test(trimmed) || !Number.isInteger(seat)) {
58
+ throw new Error(`invalid_vote_target: "${value}" — use a seat number or skip`);
59
+ }
60
+ return Action.vote(seat);
61
+ }
54
62
  case 'aside':
55
63
  return Action.think().withThinking(value);
56
64
  }
@@ -368,8 +376,8 @@ export function createSpeakCommand(dependencies: CommunicationCommandDependencie
368
376
 
369
377
  export function createVoteCommand(dependencies: CommunicationCommandDependencies = {}): Command {
370
378
  return new Command('vote')
371
- .description('Vote for a player during a meeting')
372
- .argument('<target>', 'Player name or skip')
379
+ .description('Vote for a player (by seat number) during a meeting, or skip')
380
+ .argument('<target>', 'Seat number (1-10) of the player to vote out, or skip')
373
381
  .action(async (target: string) => {
374
382
  await submitCommunicationAction({
375
383
  command: 'ccl vote',
@@ -147,26 +147,6 @@ describe('event-format', () => {
147
147
  });
148
148
  });
149
149
 
150
- it('fills crab teammate seats from the opening seat map', () => {
151
- const ctx = {
152
- summary: {
153
- players: [{ name: '菜逼油条', seat: 8, known_status: { is_alive: true } }],
154
- },
155
- };
156
- const event = {
157
- type: 'crab_teammates',
158
- tick: 20,
159
- teammates: ['菜逼油条'],
160
- };
161
-
162
- expect(formatEventMessage(event, ctx)).toBe('t20 crab_teammates 蟹队友:8号菜逼油条。');
163
- expect(compactEventFields(event, ctx)).toMatchObject({
164
- type: 'crab_teammates',
165
- tick: 20,
166
- crab_teammates: [{ name: '菜逼油条', seat: 8 }],
167
- });
168
- });
169
-
170
150
  it('formats death_speech with explicit speaker fields', () => {
171
151
  const event = {
172
152
  type: 'death_speech',
@@ -643,7 +623,6 @@ describe('event-format', () => {
643
623
  it('keeps local hint formatters for backend-hinted monitor events', () => {
644
624
  const backendHintedMonitorEvents = [
645
625
  'corpse_spotted',
646
- 'crab_teammates',
647
626
  'emergency_resolved',
648
627
  'emergency_started',
649
628
  'exile',
@@ -269,20 +269,6 @@ function formatVotes(votes: unknown, ctx: EventFormatContext): Record<string, st
269
269
  return out;
270
270
  }
271
271
 
272
- function teammateNames(event: Record<string, any>): string[] {
273
- const raw = Array.isArray(event.crab_teammates)
274
- ? event.crab_teammates
275
- : Array.isArray(event.teammates)
276
- ? event.teammates
277
- : [];
278
- const names: string[] = [];
279
- for (const teammate of raw) {
280
- const name = typeof teammate === 'string' ? teammate : teammate?.name;
281
- if (typeof name === 'string' && name.length > 0) names.push(name);
282
- }
283
- return names;
284
- }
285
-
286
272
  function teammateObjects(event: Record<string, any>, ctx: EventFormatContext): Record<string, any>[] {
287
273
  const raw = Array.isArray(event.crab_teammates)
288
274
  ? event.crab_teammates
@@ -471,10 +457,6 @@ function shortBody(event: Record<string, any>, ctx: EventFormatContext): string
471
457
  const speakerSeat = firstNumber(event, ['speaker_seat', 'actor_seat', 'seat']);
472
458
  return `${playerLabel(speakerName, speakerSeat, ctx)}死亡弹幕:${truncate(event.text ?? event.message, maxTextLength)}`;
473
459
  }
474
- case 'crab_teammates': {
475
- const labels = teammateNames(event).map((name) => playerLabel(name, undefined, ctx));
476
- return labels.length > 0 ? `蟹队友:${labels.join('、')}。` : '蟹队友信息已更新。';
477
- }
478
460
  case 'wandering_speech':
479
461
  return `${text(event.actor_name, '你')}在${firstString(event, ['room'])}说:${truncate(event.text ?? event.message, maxTextLength)}`;
480
462
  case 'game_over':
@@ -663,20 +645,6 @@ function compactVoteCastForEvents(event: Record<string, any>, ctx: EventFormatCo
663
645
  });
664
646
  }
665
647
 
666
- function compactCrabTeammatesForEvents(event: Record<string, any>, ctx: EventFormatContext): FormattedEvent {
667
- const {
668
- teammates: _teammates,
669
- crab_teammates: _crabTeammates,
670
- ...rest
671
- } = event;
672
- return cleanObject({
673
- ...rest,
674
- type: text(rest.type, 'event'),
675
- tick: numberValue(rest.tick) ?? null,
676
- crab_teammates: teammateObjects(event, ctx),
677
- });
678
- }
679
-
680
648
  function compactMeetingResultForEvents(event: Record<string, any>, ctx: EventFormatContext): FormattedEvent {
681
649
  const {
682
650
  votes: _votes,
@@ -756,7 +724,6 @@ export function compactEventForEvents(
756
724
  }
757
725
 
758
726
  if (event.type === 'vote_cast') return compactVoteCastForEvents(event, ctx);
759
- if (event.type === 'crab_teammates') return compactCrabTeammatesForEvents(event, ctx);
760
727
  if (event.type === 'exile' || event.type === 'no_exile') return compactMeetingResultForEvents(event, ctx);
761
728
  if (event.type === 'players_changed') return compactPlayersChangedForEvents(event);
762
729
 
@@ -16,7 +16,7 @@ describe('Mailbox-owned Event hint registries', () => {
16
16
  BACKEND_EVENT_HINT_FORMATTERS[type] === undefined
17
17
  ));
18
18
 
19
- expect(Object.keys(BACKEND_EVENT_HINT_FORMATTERS)).toHaveLength(31);
19
+ expect(Object.keys(BACKEND_EVENT_HINT_FORMATTERS)).toHaveLength(30);
20
20
  expect(unregistered).toEqual([
21
21
  'task_completed',
22
22
  'task_sabotaged',
@@ -175,9 +175,6 @@ describe('Mailbox-owned Event hint registries', () => {
175
175
 
176
176
  it('preserves the useful incremental semantics from npm batch next_step routes', () => {
177
177
  expect(BACKEND_EVENT_HINT_FORMATTERS.game_started({}, {})).toContain('do not relaunch');
178
- expect(BACKEND_EVENT_HINT_FORMATTERS.crab_teammates({
179
- crab_teammates: [{ name: 'Bob', seat: 2 }],
180
- }, {})).toContain('avoid voting for or killing them');
181
178
 
182
179
  const normalGameOver = BACKEND_EVENT_HINT_FORMATTERS.game_over({
183
180
  winner: 'lobster',
@@ -250,7 +247,7 @@ describe('Mailbox-owned Event hint registries', () => {
250
247
  ...Object.values(DERIVED_EVENT_HINT_FORMATTERS).map((formatter) => formatter(sample, {})),
251
248
  ].filter((hint): hint is string => typeof hint === 'string');
252
249
 
253
- expect(hints).toHaveLength(51);
250
+ expect(hints).toHaveLength(50);
254
251
  for (const hint of hints) expect(hint).not.toMatch(/[一-鿿]/);
255
252
  });
256
253
  });
@@ -182,23 +182,6 @@ export const BACKEND_EVENT_HINT_FORMATTERS: Readonly<Record<string, EventHintFor
182
182
  + 'If this is you, your influence is dead — tell your user and ask whether to spectate or leave.'
183
183
  ),
184
184
  no_exile: () => 'Meeting ended — no one was exiled. The table failed to strike, and every hidden threat gets another turn.',
185
- crab_teammates: (event) => {
186
- const raw = Array.isArray(event.crab_teammates)
187
- ? event.crab_teammates
188
- : Array.isArray(event.teammates)
189
- ? event.teammates
190
- : [];
191
- const labels = raw
192
- .map((teammate: any) => (
193
- typeof teammate === 'string'
194
- ? teammate
195
- : optionalSeatPlayerLabel(teammate?.name, teammate?.seat)
196
- ))
197
- .filter((label: string) => label.length > 0);
198
- return labels.length > 0
199
- ? `Your Crab teammate(s): ${labels.join(', ')}. Keep this private, coordinate cover stories, and avoid voting for or killing them.`
200
- : 'Your Crab teammate list is available. Keep it private and check the Event before voting or killing.';
201
- },
202
185
  meeting_briefing: (event) => meetingBriefingHint(event),
203
186
  speech_skipped: (event) => `${actorName(event, 'Someone')} lost the floor — silence becomes evidence`,
204
187
  speech_your_turn: () => 'Submit `ccl speak "<draft>"` immediately. Server skips you after 45s.',
@@ -245,7 +245,7 @@ describe('GameSync v2 Event normalization', () => {
245
245
  reported_corpses: [{ seat: 9, name: 'dead' }],
246
246
  speech_order: [{ seat: 1, name: 'caller' }, { seat: 2, name: 'next' }],
247
247
  dead_players: [{ seat: 9, name: 'dead' }],
248
- teammates: [{ seat: 3, name: 'crab' }],
248
+ crab_teammates: [{ seat: 3, name: 'crab' }],
249
249
  });
250
250
 
251
251
  expect(normalized.reported_corpses).toEqual([{ name: 'dead', seat: 9 }]);
@@ -255,7 +255,6 @@ describe('GameSync v2 Event normalization', () => {
255
255
  ]);
256
256
  expect(normalized.dead_players).toEqual([{ name: 'dead', seat: 9 }]);
257
257
  expect(normalized.crab_teammates).toEqual([{ name: 'crab', seat: 3 }]);
258
- expect(normalized).not.toHaveProperty('teammates');
259
258
 
260
259
  const presented = presentCanonicalEvent(canonical(normalized), null);
261
260
  expect(presented.speech_order).toEqual(normalized.speech_order);
@@ -292,16 +291,6 @@ describe('GameSync v2 Event normalization', () => {
292
291
  actor_seat: 2,
293
292
  current_speaker: 'caller',
294
293
  });
295
-
296
- expect(normalizeGameSyncEvent({
297
- event_id: 'teammates-current-dev',
298
- tick: 0,
299
- type: 'crab_teammates',
300
- actor: { seat: 1, name: 'self' },
301
- teammates: ['crab-a', 'crab-b'],
302
- })).toMatchObject({
303
- crab_teammates: ['crab-a', 'crab-b'],
304
- });
305
294
  });
306
295
 
307
296
  it('keeps the private self-repair marker and anonymizes every other emergency resolution', () => {
@@ -246,19 +246,6 @@ export function normalizeGameSyncEvent(value: unknown): Record<string, any> {
246
246
  throw new TypeError('GameSync Event.speech_order must be a string or PlayerRef array');
247
247
  }
248
248
 
249
- if (Object.hasOwn(normalized, 'teammates')) {
250
- if (!Array.isArray(normalized.teammates)) {
251
- throw new TypeError('GameSync Event.teammates must be an array');
252
- }
253
- // The current dev implementation emits the setup event as string[];
254
- // meeting briefings already use PlayerRef[]. Keep one canonical field.
255
- normalized.crab_teammates = normalized.teammates.map((item: unknown, index: number) => {
256
- if (typeof item === 'string' && item.length > 0) return item;
257
- return playerRef(item, `GameSync Event.teammates[${index}]`);
258
- });
259
- delete normalized.teammates;
260
- }
261
-
262
249
  return normalized;
263
250
  }
264
251
 
@@ -2,9 +2,9 @@ import type { ClawclawActionRequest } from '../action/index.js';
2
2
 
3
3
  const ACTION_FIELDS: Readonly<Record<string, readonly string[]>> = Object.freeze({
4
4
  move: ['action', 'target', 'target_x', 'target_y', 'stop_on_player', 'thinking_content'],
5
- kill: ['action', 'target', 'thinking_content'],
5
+ kill: ['action', 'target_seat', 'thinking_content'],
6
6
  speech: ['action', 'text', 'thinking_content'],
7
- vote: ['action', 'target', 'thinking_content'],
7
+ vote: ['action', 'target_seat', 'thinking_content'],
8
8
  task: ['action', 'task_name', 'thinking_content'],
9
9
  report: ['action', 'thinking_content'],
10
10
  think: ['action', 'thinking_content'],
@@ -52,9 +52,16 @@ export function normalizeClawclawStrategyAction(
52
52
  break;
53
53
  }
54
54
  case 'kill':
55
- case 'vote':
56
- if (!nonEmpty(value.target)) throw new Error('invalid_strategy_target');
55
+ case 'vote': {
56
+ const seat = value.target_seat;
57
+ const validSeat = typeof seat === 'number'
58
+ && Number.isInteger(seat)
59
+ && seat >= 0
60
+ && seat <= 10;
61
+ if (!validSeat) throw new Error('invalid_strategy_target');
62
+ if (actionType === 'kill' && seat === 0) throw new Error('invalid_strategy_target');
57
63
  break;
64
+ }
58
65
  case 'speech':
59
66
  if (!nonEmpty(value.text)) throw new Error('invalid_strategy_speech');
60
67
  break;
@@ -74,7 +74,6 @@ export const CLAWCLAW_GAME_STREAM_BACKEND_EVENT_TYPES = [
74
74
  'game_started',
75
75
  'game_over',
76
76
  'role_assigned',
77
- 'crab_teammates',
78
77
  'emergency_started',
79
78
  'emergency_resolved',
80
79
  'emergency_interrupted',
@@ -108,7 +107,6 @@ export const CLAWCLAW_BACKEND_AGENT_EVENT_TYPES = [
108
107
  'vote_speech_phase_ended',
109
108
  'death_speech',
110
109
  'wandering_speech',
111
- 'crab_teammates',
112
110
  'meeting_briefing',
113
111
  'speech',
114
112
  'speech_skipped',
package/src/sdk/action.ts CHANGED
@@ -8,7 +8,7 @@
8
8
  * @example
9
9
  * ```ts
10
10
  * return Action.move('kitchen').withThinking('Heading to the kitchen for my task.');
11
- * return Action.kill('PlayerB').withThinking('Alone with target — safe window.');
11
+ * return Action.kill(7).withThinking('Alone with target — safe window.');
12
12
  * ```
13
13
  */
14
14
  export class Action {
@@ -32,7 +32,7 @@ export class Action {
32
32
  * Attach (or replace) the spectator-visible thinking content.
33
33
  * Returns a **new** immutable `Action` — the original is unchanged.
34
34
  *
35
- * @example Action.kill('playerA').withThinking('Safe kill — only one witness.')
35
+ * @example Action.kill(7).withThinking('Safe kill — only one witness.')
36
36
  */
37
37
  withThinking(content: string): Action {
38
38
  return new Action(this.type, { ...this.payload }, content);
@@ -56,11 +56,12 @@ export class Action {
56
56
  }
57
57
 
58
58
  /**
59
- * Kill the named player.
59
+ * Kill the player at the given seat number.
60
60
  * Only succeeds when cooldown is ready, a kill use remains, and the target is in range.
61
+ * Seats are 1-based; the server resolves the target by `target_seat`.
61
62
  */
62
- static kill(target: string): Action {
63
- return new Action('kill', { target }, `击杀 ${target}`);
63
+ static kill(seat: number): Action {
64
+ return new Action('kill', { target_seat: seat }, `击杀 ${seat}号`);
64
65
  }
65
66
 
66
67
  /**
@@ -82,10 +83,10 @@ export class Action {
82
83
  /**
83
84
  * Cast a vote during the meeting vote sub-phase.
84
85
  *
85
- * @param target Name of the player to vote out.
86
+ * @param seat Seat number (1-based) of the player to vote out. `0` means skip.
86
87
  */
87
- static vote(target: string): Action {
88
- return new Action('vote', { target }, `投票 ${target}`);
88
+ static vote(seat: number): Action {
89
+ return new Action('vote', { target_seat: seat }, seat === 0 ? '投票 跳过' : `投票 ${seat}号`);
89
90
  }
90
91
 
91
92
  /**
@@ -368,7 +368,7 @@ describe('Strategy Plugin SDK', () => {
368
368
  },
369
369
  });
370
370
 
371
- expect(teammatesSeen).toEqual(['ally']);
371
+ expect(teammatesSeen).toEqual(['2']);
372
372
  });
373
373
 
374
374
  it('fails explicitly when a required task or map capability is unavailable', async () => {
@@ -747,7 +747,7 @@ describe('Strategy Plugin SDK', () => {
747
747
  create: () => ({
748
748
  name: 'unknown-kill',
749
749
  decide: () => [{
750
- action: Action.kill('目标'),
750
+ action: Action.kill(7),
751
751
  intent: { activity: 'acting', summary: '正在击杀7号目标。', targetPlayer: '目标' },
752
752
  }],
753
753
  }),
@@ -909,7 +909,7 @@ describe('Strategy Plugin SDK', () => {
909
909
  decide: (state) => [
910
910
  ...(state.all_players?.some(player => player.name === '目标' && player.is_alive !== false)
911
911
  ? [{
912
- action: Action.kill('目标'),
912
+ action: Action.kill(7),
913
913
  intent: { activity: 'acting' as const, summary: '正在击杀7号目标。', targetPlayer: '目标' },
914
914
  }]
915
915
  : []),
@@ -224,9 +224,9 @@ export type ClawclawStrategyAction =
224
224
  readonly target_y: number;
225
225
  readonly stop_on_player?: boolean;
226
226
  })
227
- | (ClawclawStrategyActionBase & { readonly action: 'kill'; readonly target: string })
227
+ | (ClawclawStrategyActionBase & { readonly action: 'kill'; readonly target_seat: number })
228
228
  | (ClawclawStrategyActionBase & { readonly action: 'speech'; readonly text: string })
229
- | (ClawclawStrategyActionBase & { readonly action: 'vote'; readonly target: string })
229
+ | (ClawclawStrategyActionBase & { readonly action: 'vote'; readonly target_seat: number })
230
230
  | (ClawclawStrategyActionBase & { readonly action: 'task'; readonly task_name?: string })
231
231
  | (ClawclawStrategyActionBase & { readonly action: 'report' })
232
232
  | (ClawclawStrategyActionBase & { readonly action: 'think' })
@@ -626,17 +626,17 @@ function fallbackActionIntent(state: GameState, action: Record<string, any>): St
626
626
  ...(task ? { task } : {}),
627
627
  };
628
628
  }
629
- if (action.action === 'kill' && typeof action.target === 'string') {
629
+ if (action.action === 'kill' && Number.isInteger(action.target_seat)) {
630
630
  const knownTarget = [...state.players, ...(state.all_players ?? [])]
631
- .find(player => player.name === action.target);
632
- const target = knownTarget?.seat != null
633
- ? `${knownTarget.seat}号${knownTarget.name}`
634
- : action.target;
631
+ .find(player => player.seat === action.target_seat);
632
+ const target = knownTarget?.name != null
633
+ ? `${action.target_seat}号${knownTarget.name}`
634
+ : `${action.target_seat}号`;
635
635
  return {
636
636
  activity: 'acting',
637
637
  summary: `正在击杀${target}。`,
638
638
  ...(room ? { room } : {}),
639
- targetPlayer: action.target,
639
+ ...(knownTarget?.name ? { targetPlayer: knownTarget.name } : {}),
640
640
  };
641
641
  }
642
642
  if (action.action === 'report') {
@@ -685,7 +685,7 @@ function nonIdempotentActionKey(action: Record<string, any>): string | null {
685
685
  const type = String(action.action ?? '');
686
686
  if (!NON_IDEMPOTENT_ACTIONS.has(type)) return null;
687
687
  switch (type) {
688
- case 'kill': return `kill:${JSON.stringify(action.target ?? '')}`;
688
+ case 'kill': return `kill:${JSON.stringify(action.target_seat ?? '')}`;
689
689
  case 'speech': return `speech:${JSON.stringify(action.text ?? '')}`;
690
690
  case 'task': return `task:${JSON.stringify(action.task_name ?? '')}`;
691
691
  case 'report': return 'report';
@@ -705,9 +705,9 @@ function authoritativeActionSignature(state: GameState, action: Record<string, a
705
705
  phase: state.phase,
706
706
  alive: state.you.is_alive,
707
707
  };
708
- if (action.action === 'kill') {
709
- const knownTarget = state.all_players?.find(player => player.name === action.target);
710
- const visibleTarget = state.players.find(player => player.name === action.target);
708
+ if (action.action === 'kill' && Number.isInteger(action.target_seat)) {
709
+ const knownTarget = state.all_players?.find(player => player.seat === action.target_seat);
710
+ const visibleTarget = state.players.find(player => player.seat === action.target_seat);
711
711
  return JSON.stringify({
712
712
  ...common,
713
713
  target_alive: knownTarget?.is_alive ?? (visibleTarget ? true : undefined),
@@ -996,24 +996,25 @@ export class ClawclawGoalStrategy extends ClawclawHybridStrategy<
996
996
  for (const player of state.all_players ?? state.players ?? []) {
997
997
  if (player.seat != null && player.name) this.context.playerNamesBySeat[String(player.seat)] = player.name;
998
998
  }
999
+ const teammateSeat = (teammate: unknown): string | null => {
1000
+ const ref = projectedPlayerRef(teammate);
1001
+ const seat = Number(ref.seat);
1002
+ return Number.isInteger(seat) && seat >= 1 ? String(seat) : null;
1003
+ };
999
1004
  for (const event of events) {
1000
1005
  if (event.type === 'octopus_time_start') this.context.octopusTimeActive = true;
1001
1006
  const eventTeammates = Array.isArray(event.crab_teammates)
1002
1007
  ? event.crab_teammates
1003
- : Array.isArray(event.teammates) ? event.teammates : [];
1008
+ : [];
1004
1009
  for (const teammate of eventTeammates) {
1005
- const name = typeof teammate === 'string'
1006
- ? teammate
1007
- : projectedPlayerRef(teammate).name;
1008
- if (typeof name === 'string' && name) this.context.teammates.add(name);
1010
+ const seat = teammateSeat(teammate);
1011
+ if (seat) this.context.teammates.add(seat);
1009
1012
  }
1010
1013
  }
1011
1014
  const stateTeammates = state.you.crab_teammates;
1012
1015
  for (const teammate of Array.isArray(stateTeammates) ? stateTeammates : []) {
1013
- const name = typeof teammate === 'string'
1014
- ? teammate
1015
- : projectedPlayerRef(teammate).name;
1016
- if (typeof name === 'string' && name) this.context.teammates.add(name);
1016
+ const seat = teammateSeat(teammate);
1017
+ if (seat) this.context.teammates.add(seat);
1017
1018
  }
1018
1019
  }
1019
1020
 
@@ -1194,11 +1195,11 @@ export class ClawclawGoalStrategy extends ClawclawHybridStrategy<
1194
1195
  this.context.alarmOnCooldown = definiteFailure && failureText.includes('on_cooldown');
1195
1196
  }
1196
1197
  if (definiteFailure && payload.action === 'kill' && failureText.includes('cannot_kill_teammate')) {
1197
- if (typeof payload.target === 'string') this.context.teammates.add(payload.target);
1198
+ if (Number.isInteger(payload.target_seat)) this.context.teammates.add(String(payload.target_seat));
1198
1199
  }
1199
- if (accepted && payload.action === 'kill' && typeof payload.target === 'string') {
1200
+ if (accepted && payload.action === 'kill' && Number.isInteger(payload.target_seat)) {
1200
1201
  this.context.recentlyKilledTargets?.set(
1201
- payload.target.trim().toLowerCase(),
1202
+ String(payload.target_seat),
1202
1203
  Date.now() + RECENT_KILL_IGNORE_MS,
1203
1204
  );
1204
1205
  }
@@ -8,7 +8,7 @@ function makeMoveDecision(): BehaviorDecision {
8
8
  }
9
9
 
10
10
  function makeKillDecision(): BehaviorDecision {
11
- return { action: Action.kill('target') };
11
+ return { action: Action.kill(3) };
12
12
  }
13
13
 
14
14
  class TestCustomModule implements CustomModule {
@@ -70,19 +70,19 @@ describe('CorpseMemory', () => {
70
70
  it('uses the last visible position immediately after a confirmed kill', () => {
71
71
  const memory = new CorpseMemory();
72
72
  memory.observe(state({
73
- players: [{ name: 'LocalBot_5', room: '居住区', x: 2058, y: 1594 }],
73
+ players: [{ name: 'LocalBot_5', seat: 5, room: '居住区', x: 2058, y: 1594 }],
74
74
  }));
75
75
 
76
76
  memory.observe(
77
77
  state({
78
78
  tick: 2,
79
- corpses: [{ name: 'LocalBot_5', room: '居住区', distance: 0 }],
79
+ corpses: [{ name: 'LocalBot_5', seat: 5, room: '居住区', distance: 0 }],
80
80
  }),
81
- new Map([['localbot_5', Date.now() + 3000]]),
81
+ new Map([['5', Date.now() + 3000]]),
82
82
  );
83
83
 
84
84
  expect(memory.list()).toEqual([
85
- { name: 'LocalBot_5', room: '居住区', x: 2058, y: 1594 },
85
+ { name: 'LocalBot_5', room: '居住区', x: 2058, y: 1594, seat: 5 },
86
86
  ]);
87
87
  expect(firstAvailableTask(
88
88
  [taskAt(2058, 1594)],
@@ -96,11 +96,11 @@ describe('CorpseMemory', () => {
96
96
  it('does not create a corpse for an unconfirmed or expired kill', () => {
97
97
  const memory = new CorpseMemory();
98
98
  memory.observe(state({
99
- players: [{ name: 'target', room: '居住区', x: 100, y: 100 }],
99
+ players: [{ name: 'target', seat: 2, room: '居住区', x: 100, y: 100 }],
100
100
  }));
101
101
 
102
102
  memory.observe(state({ tick: 2 }));
103
- memory.observe(state({ tick: 3 }), new Map([['target', Date.now() - 1]]));
103
+ memory.observe(state({ tick: 3 }), new Map([['2', Date.now() - 1]]));
104
104
 
105
105
  expect(memory.list()).toEqual([]);
106
106
  });
@@ -120,14 +120,14 @@ describe('CorpseMemory', () => {
120
120
  it('clears corpse and last-seen player memory after a meeting', () => {
121
121
  const memory = new CorpseMemory();
122
122
  memory.observe(state({
123
- players: [{ name: 'target', room: '居住区', x: 100, y: 100 }],
123
+ players: [{ name: 'target', seat: 2, room: '居住区', x: 100, y: 100 }],
124
124
  new_events: [
125
125
  { type: 'corpse_spotted', corpse_name: 'old', corpse_room: '居住区', corpse_x: 20, corpse_y: 20 },
126
126
  ],
127
127
  }));
128
128
 
129
129
  memory.reset();
130
- memory.observe(state({ tick: 2 }), new Map([['target', Date.now() + 3000]]));
130
+ memory.observe(state({ tick: 2 }), new Map([['2', Date.now() + 3000]]));
131
131
 
132
132
  expect(memory.list()).toEqual([]);
133
133
  });
@@ -600,6 +600,7 @@ export function spottedCorpsesFromEventList(events: any[] | undefined): CorpseTa
600
600
  export class CorpseMemory {
601
601
  private readonly seen: CorpseInfo[] = [];
602
602
  private readonly lastSeenPlayers = new Map<string, PlayerInfo>();
603
+ private readonly lastSeenPlayersBySeat = new Map<string, PlayerInfo>();
603
604
 
604
605
  /**
605
606
  * 每 tick 调用:缓存可见玩家位置,并入已确认击杀、当前视野尸体与本 tick 全部 corpse_spotted 事件。
@@ -623,9 +624,9 @@ export class CorpseMemory {
623
624
  }
624
625
 
625
626
  const now = Date.now();
626
- for (const [target, until] of recentlyKilledTargets ?? []) {
627
+ for (const [seat, until] of recentlyKilledTargets ?? []) {
627
628
  if (until <= now) continue;
628
- const player = this.lastSeenPlayers.get(target.trim().toLowerCase());
629
+ const player = this.lastSeenPlayersBySeat.get(seat);
629
630
  if (player) this.remember(player);
630
631
  }
631
632
 
@@ -654,11 +655,13 @@ export class CorpseMemory {
654
655
  reset(): void {
655
656
  this.seen.length = 0;
656
657
  this.lastSeenPlayers.clear();
658
+ this.lastSeenPlayersBySeat.clear();
657
659
  }
658
660
 
659
661
  private rememberPlayer(player: PlayerInfo): void {
660
662
  const key = player.name.trim().toLowerCase();
661
663
  if (key) this.lastSeenPlayers.set(key, player);
664
+ if (player.seat != null) this.lastSeenPlayersBySeat.set(String(player.seat), player);
662
665
  }
663
666
 
664
667
  private remember(corpse: { x?: number; y?: number; name?: string; room?: string; seat?: number }): void {
@@ -751,23 +754,41 @@ export function reportCorpseDecision(
751
754
  export function nonTeammatesVisible(state: GameState, ctx: StrategyContext): PlayerInfo[] {
752
755
  const players = visibleLivePlayers(state, ctx);
753
756
  return ctx.teammates.size > 0
754
- ? players.filter(p => !ctx.teammates.has(p.name))
757
+ ? players.filter(p => !(p.seat != null && ctx.teammates.has(String(p.seat))))
755
758
  : players;
756
759
  }
757
760
 
761
+ /**
762
+ * Resolve a target string (seat number or player name) to a seat number.
763
+ * Names are resolved through `ctx.playerNamesBySeat` (seat → name). Returns
764
+ * null when the target cannot be resolved to a seat (unknown name, empty input).
765
+ */
766
+ export function targetSeat(target: string, ctx: StrategyContext): number | null {
767
+ const trimmed = target.trim();
768
+ if (!trimmed) return null;
769
+ if (/^\d+$/.test(trimmed)) return Number(trimmed);
770
+ const folded = trimmed.toLowerCase();
771
+ for (const [seat, name] of Object.entries(ctx.playerNamesBySeat)) {
772
+ if (name && name.toLowerCase() === folded) return Number(seat);
773
+ }
774
+ return null;
775
+ }
776
+
758
777
  export function matchesTarget(
759
778
  target: string,
760
779
  player: { name?: string; seat?: number },
761
780
  ctx: StrategyContext,
762
781
  ): boolean {
763
- const normalized = target.trim().toLowerCase();
764
- if (player.name && player.name.toLowerCase() === normalized) return true;
765
- if (/^\d+$/.test(target.trim())) {
766
- const nameFromSeat = ctx.playerNamesBySeat[target.trim()];
782
+ const trimmed = target.trim();
783
+ const seat = targetSeat(trimmed, ctx);
784
+ if (seat != null && player.seat != null && player.seat === seat) return true;
785
+ if (seat != null) {
786
+ // 座位号参数对无名/缺 seat 的条目(如只有名字的尸体):经 seat→name 反查命中。
787
+ const nameFromSeat = ctx.playerNamesBySeat[String(seat)];
767
788
  if (nameFromSeat && player.name && player.name.toLowerCase() === nameFromSeat.toLowerCase()) return true;
768
- if (player.seat != null && String(player.seat) === target.trim()) return true;
769
789
  }
770
- return false;
790
+ const normalized = trimmed.toLowerCase();
791
+ return player.name != null && player.name.toLowerCase() === normalized;
771
792
  }
772
793
 
773
794
  export function matchesAnyTarget(
@@ -789,27 +810,15 @@ export function isTargetAlive(
789
810
  }
790
811
 
791
812
  export function isRecentlyKilledTarget(target: string, ctx: StrategyContext): boolean {
792
- const names = targetNames(target, ctx);
793
- for (const name of names) {
794
- const until = ctx.recentlyKilledTargets?.get(name);
795
- if (!until) continue;
796
- if (until > Date.now()) return true;
797
- ctx.recentlyKilledTargets?.delete(name);
798
- }
813
+ const seat = targetSeat(target, ctx);
814
+ if (seat == null) return false;
815
+ const until = ctx.recentlyKilledTargets?.get(String(seat));
816
+ if (until == null) return false;
817
+ if (until > Date.now()) return true;
818
+ ctx.recentlyKilledTargets?.delete(String(seat));
799
819
  return false;
800
820
  }
801
821
 
802
- function targetNames(target: string, ctx: StrategyContext): string[] {
803
- const normalized = target.trim().toLowerCase();
804
- if (!normalized) return [];
805
- const names = [normalized];
806
- if (/^\d+$/.test(target.trim())) {
807
- const nameFromSeat = ctx.playerNamesBySeat[target.trim()];
808
- if (nameFromSeat) names.push(nameFromSeat.toLowerCase());
809
- }
810
- return names;
811
- }
812
-
813
822
  export function visibleLivePlayers(state: GameState, ctx: StrategyContext): PlayerInfo[] {
814
823
  return state.players.filter(p => isTargetAlive(state, p.name, ctx));
815
824
  }
@@ -839,7 +848,9 @@ export function pursueVisibleTarget(
839
848
  const d = target.distance ?? dist(state.you.x, state.you.y, target.x, target.y);
840
849
  if (opts.kill && !hasKillUseRemaining(state)) return null;
841
850
  if (opts.kill && d <= killCommitRange(state.you.role) && canUseKill(state)) {
842
- return strategyDecision(Action.kill(target.name), playerStrategyIntent(target, '追杀', 'acting'));
851
+ // 杀必须用座位号:visible 玩家由服务端保证 seat(默认 0 表示缺失/不可杀)。
852
+ if (target.seat == null || target.seat <= 0) return null;
853
+ return strategyDecision(Action.kill(target.seat), playerStrategyIntent(target, '追杀', 'acting'));
843
854
  }
844
855
  if (d > opts.followDistance) {
845
856
  return strategyDecision(
@@ -10,6 +10,7 @@ import {
10
10
  reportCorpseDecision,
11
11
  playerStrategyIntent,
12
12
  strategyDecision,
13
+ targetSeat,
13
14
  } from '../game-utils.js';
14
15
  import type { BehaviorDecision, StrategyContext } from '../types.js';
15
16
 
@@ -82,21 +83,24 @@ export function immediateLoneKillDecision(
82
83
  if (skipTarget?.(target)) return null;
83
84
 
84
85
  ctx.notifications.push(`发现落单目标${target.name}就在身边,立刻出刀!`);
85
- return [strategyDecision(Action.kill(target.name), playerStrategyIntent(target, '追杀', 'acting'))];
86
+ if (target.seat == null || target.seat <= 0) return null;
87
+ return [strategyDecision(Action.kill(target.seat), playerStrategyIntent(target, '追杀', 'acting'))];
86
88
  }
87
89
 
88
90
  /**
89
- * 这具尸体是不是「自己刚才下的那一刀」。先按尸体名精确匹配 recentlyKilledTargets(刚杀过且未过期),
90
- * 名字对不上但近期确实杀过人时,冒出的尸体大概率也是自己造成的,按 true 处理(宁可多提醒一次)。
91
+ * 这具尸体是不是「自己刚才下的那一刀」。先按尸体座位号精确匹配 recentlyKilledTargets(刚杀过且未过期),
92
+ * 座位对不上但近期确实杀过人时,冒出的尸体大概率也是自己造成的,按 true 处理(宁可多提醒一次)。
91
93
  */
92
94
  function isRecentOwnKill(ctx: StrategyContext, corpseName: string): boolean {
93
95
  const map = ctx.recentlyKilledTargets;
94
96
  if (!map || map.size === 0) return false;
95
97
  const now = Date.now();
96
- const key = corpseName.trim().toLowerCase();
97
- if (key) {
98
- const until = map.get(key);
99
- if (until != null && until > now) return true;
98
+ if (corpseName) {
99
+ const seat = targetSeat(corpseName, ctx);
100
+ if (seat != null) {
101
+ const until = map.get(String(seat));
102
+ if (until != null && until > now) return true;
103
+ }
100
104
  }
101
105
  for (const until of map.values()) {
102
106
  if (until > now) return true;
@@ -126,9 +126,10 @@ export class HideTop extends Goal {
126
126
  const victim = this.corneredVictim(state, visible);
127
127
  if (victim) {
128
128
  if (this.subGoal) this.removeSubGoal();
129
+ if (victim.seat == null || victim.seat <= 0) return [];
129
130
  ctx.notifications.push(`被${victim.name}逼到无处可逃,出刀自保!`);
130
131
  return [strategyDecision(
131
- Action.kill(victim.name).withThinking(`被${victim.name}逼进出刀距离又逃不掉,先下手自保。`),
132
+ Action.kill(victim.seat).withThinking(`被${victim.name}逼进出刀距离又逃不掉,先下手自保。`),
132
133
  {
133
134
  activity: 'acting',
134
135
  summary: `被${strategyPlayerLabel(victim)}逼到无处可逃,正在出刀自保。`,
@@ -34,8 +34,9 @@ export class KillVisibleTargetGoal extends Goal {
34
34
 
35
35
  if (d <= killCommitRange(state.you.role)) {
36
36
  if (canUseKill(state)) {
37
+ if (target.seat == null || target.seat <= 0) return [];
37
38
  ctx.notifications.push(`发现追杀目标${target.name},出刀!`);
38
- return [strategyDecision(Action.kill(target.name), playerStrategyIntent(target, '追杀', 'acting'))];
39
+ return [strategyDecision(Action.kill(target.seat), playerStrategyIntent(target, '追杀', 'acting'))];
39
40
  }
40
41
  if (d > LONE_FOLLOW_DISTANCE) {
41
42
  return [strategyDecision(Action.move({ x: target.x, y: target.y }), playerStrategyIntent(target, '追杀', 'moving'))];
@@ -15,6 +15,7 @@ import {
15
15
  pursueVisibleTarget,
16
16
  setStrategyIntent,
17
17
  strategyPlayerLabel,
18
+ targetSeat,
18
19
  } from '../game-utils.js';
19
20
  import type { BehaviorDecision, StrategyContext } from '../types.js';
20
21
  import { Goal } from './goal.js';
@@ -92,9 +93,8 @@ export class KillTargetTop extends Goal {
92
93
 
93
94
  private isValidTarget(t: string, state: GameState, ctx: StrategyContext): boolean {
94
95
  if (!isTargetAlive(state, t, ctx)) return false;
95
- const nameFromSeat = /^\d+$/.test(t.trim()) ? ctx.playerNamesBySeat[t.trim()] : null;
96
- const resolvedName = nameFromSeat ?? t.trim();
97
- return !ctx.teammates.has(resolvedName);
96
+ const seat = targetSeat(t, ctx);
97
+ return !(seat != null && ctx.teammates.has(String(seat)));
98
98
  }
99
99
 
100
100
  private allTargetsDeadInState(state: GameState, ctx: StrategyContext): boolean {
@@ -76,7 +76,9 @@ export class LoneKillCore {
76
76
  const d = target.distance ?? dist(state.you.x, state.you.y, target.x, target.y);
77
77
  if (d <= killCommitRange(state.you.role) && canUseKill(state)) {
78
78
  ctx.notifications.push(`发现落单目标${target.name},出刀!`);
79
- return strategyDecision(Action.kill(target.name), playerStrategyIntent(target, '追杀', 'acting'));
79
+ if (target.seat != null && target.seat > 0) {
80
+ return strategyDecision(Action.kill(target.seat), playerStrategyIntent(target, '追杀', 'acting'));
81
+ }
80
82
  }
81
83
  if (d > killCommitRange(state.you.role)) ctx.notifications.push(`发现落单目标${target.name},正在靠近!`);
82
84
  return strategyDecision(Action.move({ x: target.x, y: target.y }), playerStrategyIntent(target, '追杀', 'moving'));
@@ -64,8 +64,9 @@ export class TaskKillReportTop extends Goal {
64
64
 
65
65
  if (nearest.dist <= killCommitRange(state.you.role) && killReady) {
66
66
  ctx.notifications.push(`嫌疑目标${nearest.player.name}在攻击范围内,出刀!`);
67
+ if (nearest.player.seat == null || nearest.player.seat <= 0) return this.emitDecisions(state, ctx, [], URGENT_GOAL_PRIORITY);
67
68
  return this.emitDecisions(state, ctx, [strategyDecision(
68
- Action.kill(nearest.player.name),
69
+ Action.kill(nearest.player.seat),
69
70
  playerStrategyIntent(nearest.player, '追杀', 'acting'),
70
71
  )], URGENT_GOAL_PRIORITY);
71
72
  }
@@ -87,7 +87,8 @@ export class WarriorShrimpTop extends Goal {
87
87
  ?? (CORPSE_SCENE_KILL_ENABLED ? this.nearestKillable(state, ctx, visible, false) : null);
88
88
  if (victim) {
89
89
  this.clearSub();
90
- return [strategyDecision(Action.kill(victim.name), playerStrategyIntent(victim, '追杀', 'acting'))];
90
+ if (victim.seat == null || victim.seat <= 0) return [];
91
+ return [strategyDecision(Action.kill(victim.seat), playerStrategyIntent(victim, '追杀', 'acting'))];
91
92
  }
92
93
  }
93
94