@myclaw163/clawclaw-cli 0.7.14 → 0.7.16

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.
Files changed (45) hide show
  1. package/docs/runtime/strategy-runtime.md +1 -1
  2. package/docs//350/207/252/345/256/232/344/271/211/347/255/226/347/225/245.md +4 -4
  3. package/package.json +1 -1
  4. package/skills/clawclaw/SKILL.md +2 -2
  5. package/skills/clawclaw/references/COMMANDS.md +1 -1
  6. package/skills/clawclaw/references/STRATEGIES.md +4 -4
  7. package/src/lib/game-client.ts +2 -0
  8. package/src/lib/strategy-export.test.ts +13 -0
  9. package/src/runtime/clawclaw/plugins/action/action-plugin.ts +1 -0
  10. package/src/runtime/clawclaw/plugins/runtime-plugins.test.ts +1 -0
  11. package/src/runtime/clawclaw/plugins/strategy/strategy-module-loader.ts +1 -1
  12. package/src/runtime/clawclaw/plugins/strategy/strategy-plugin.test.ts +203 -0
  13. package/src/runtime/clawclaw/plugins/strategy/strategy-plugin.ts +209 -5
  14. package/src/sdk/index.ts +2 -2
  15. package/src/sdk/strategy-plugin/index.test.ts +10 -4
  16. package/src/sdk/strategy-plugin/index.ts +13 -2
  17. package/src/strategies/avoid-players.ts +4 -5
  18. package/src/strategies/find-player.ts +5 -6
  19. package/src/strategies/game-utils.test.ts +22 -0
  20. package/src/strategies/game-utils.ts +12 -39
  21. package/src/strategies/goals/avoid-players-top.test.ts +2 -2
  22. package/src/strategies/goals/avoid-players-top.ts +1 -1
  23. package/src/strategies/goals/crab-octopus-reflexes.ts +10 -10
  24. package/src/strategies/goals/find-player-top.ts +7 -8
  25. package/src/strategies/goals/kill-lone-top.test.ts +27 -2
  26. package/src/strategies/goals/kill-lone-top.ts +16 -12
  27. package/src/strategies/goals/kill-target-goal.ts +3 -3
  28. package/src/strategies/goals/kill-target-top.test.ts +66 -0
  29. package/src/strategies/goals/kill-target-top.ts +4 -6
  30. package/src/strategies/goals/normal-shrimp-top.test.ts +2 -2
  31. package/src/strategies/goals/normal-shrimp-top.ts +3 -3
  32. package/src/strategies/goals/paradise-fish-top.test.ts +3 -3
  33. package/src/strategies/goals/paradise-fish-top.ts +2 -2
  34. package/src/strategies/goals/social-task-top.ts +3 -3
  35. package/src/strategies/goals/task-kill-report-top.ts +2 -2
  36. package/src/strategies/goals/warrior-shrimp-top.test.ts +3 -3
  37. package/src/strategies/goals/warrior-shrimp-top.ts +11 -7
  38. package/src/strategies/kill-lone.ts +7 -12
  39. package/src/strategies/kill-target.ts +5 -6
  40. package/src/strategies/paradise-fish.ts +8 -8
  41. package/src/strategies/player-targets.ts +0 -8
  42. package/src/strategies/shrimp-memory.ts +13 -13
  43. package/src/strategies/social-task.ts +4 -4
  44. package/src/strategies/task-kill-report.ts +5 -5
  45. package/src/strategies/warrior-memory.ts +7 -12
@@ -27,7 +27,7 @@ export class FindPlayerTop extends Goal {
27
27
  private foundNotified = false;
28
28
 
29
29
  constructor(
30
- private readonly target: string,
30
+ private readonly target: number,
31
31
  private readonly trackDistance: number = DEFAULT_TRACK_DISTANCE,
32
32
  ) {
33
33
  super();
@@ -39,7 +39,7 @@ export class FindPlayerTop extends Goal {
39
39
  setStrategyIntent(ctx, {
40
40
  activity: 'idle',
41
41
  summary: `${this.targetLabel(ctx)}已死亡,正在等待下一步指令。`,
42
- targetPlayer: this.target,
42
+ targetPlayer: this.targetLabel(ctx),
43
43
  });
44
44
  this.emitProgress(state, ctx);
45
45
  return [];
@@ -76,7 +76,7 @@ export class FindPlayerTop extends Goal {
76
76
  activity: 'moving',
77
77
  summary: `正在前往${this.lastSeenRoom || '最后目击区域'}寻找${this.targetLabel(ctx)}。`,
78
78
  ...(this.lastSeenRoom ? { room: this.lastSeenRoom } : {}),
79
- targetPlayer: this.target,
79
+ targetPlayer: this.targetLabel(ctx),
80
80
  })];
81
81
  }
82
82
  this.lastSeenX = null;
@@ -94,7 +94,7 @@ export class FindPlayerTop extends Goal {
94
94
  setStrategyIntent(ctx, {
95
95
  activity: 'waiting',
96
96
  summary: `暂无可巡逻房间,正在等待${this.targetLabel(ctx)}出现。`,
97
- targetPlayer: this.target,
97
+ targetPlayer: this.targetLabel(ctx),
98
98
  });
99
99
  return [];
100
100
  }
@@ -107,15 +107,14 @@ export class FindPlayerTop extends Goal {
107
107
  Action.move({ x: room.x, y: room.y }),
108
108
  {
109
109
  ...patrolStrategyIntent(room, `巡逻寻找${this.targetLabel(ctx)}`),
110
- targetPlayer: this.target,
110
+ targetPlayer: this.targetLabel(ctx),
111
111
  },
112
112
  )];
113
113
  }
114
114
 
115
115
  private targetLabel(ctx: StrategyContext): string {
116
- const seat = this.target.trim();
117
- const name = /^\d+$/.test(seat) ? ctx.playerNamesBySeat[seat] : undefined;
118
- return name ? `${seat}号${name}` : this.target;
116
+ const name = ctx.playerNamesBySeat[String(this.target)];
117
+ return name ? `${this.target}号${name}` : `${this.target}号`;
119
118
  }
120
119
 
121
120
  private emitProgress(state: GameState, ctx: StrategyContext): void {
@@ -55,7 +55,7 @@ function context(): StrategyContext {
55
55
 
56
56
  describe('KillLoneTop player-list controls', () => {
57
57
  it('lets huntTargets bypass the lone-player condition', () => {
58
- const top = new KillLoneTop([], ['target']);
58
+ const top = new KillLoneTop([], [2]);
59
59
 
60
60
  top.tick(state(), context());
61
61
 
@@ -63,10 +63,35 @@ describe('KillLoneTop player-list controls', () => {
63
63
  });
64
64
 
65
65
  it('gives protectedTargets priority over huntTargets', () => {
66
- const top = new KillLoneTop(['target'], ['target']);
66
+ const top = new KillLoneTop([2], [2]);
67
67
 
68
68
  top.tick(state(), context());
69
69
 
70
70
  expect(top.subGoal).not.toBeInstanceOf(KillVisibleTargetGoal);
71
71
  });
72
+
73
+ it('keeps hunting the configured seat when players share the same name', () => {
74
+ const top = new KillLoneTop([], [6]);
75
+ const current = state();
76
+ current.players = [
77
+ { name: '木桩机器虾', seat: 2, x: 20, y: 0, room: 'control', distance: 20 },
78
+ { name: '木桩机器虾', seat: 6, x: 100, y: 0, room: 'control', distance: 100 },
79
+ { name: '木桩机器虾', seat: 3, x: 120, y: 0, room: 'control', distance: 120 },
80
+ ];
81
+ current.all_players = current.players.map((player) => ({
82
+ name: player.name,
83
+ seat: player.seat!,
84
+ role: 'unknown',
85
+ is_alive: true,
86
+ }));
87
+
88
+ top.tick(current, context());
89
+
90
+ expect(top.subGoal).toBeInstanceOf(KillVisibleTargetGoal);
91
+ expect((top.subGoal as KillVisibleTargetGoal).targetSeat).toBe(6);
92
+ expect(top.subGoal?.tick(current, context())[0]?.action.payload).toMatchObject({
93
+ target_x: 100,
94
+ target_y: 0,
95
+ });
96
+ });
72
97
  });
@@ -22,11 +22,11 @@ export class KillLoneTop extends Goal {
22
22
  private readonly patrol = new PatrolState();
23
23
  private loneIgnoreUntil = 0;
24
24
  private patrolStopOnPlayer: boolean | null = null;
25
- private lastFlaggedTarget = '';
25
+ private lastFlaggedTarget: number | null = null;
26
26
 
27
27
  constructor(
28
- private readonly protectedTargets: string[] = [],
29
- private readonly huntTargets: string[] = [],
28
+ private readonly protectedTargets: number[] = [],
29
+ private readonly huntTargets: number[] = [],
30
30
  ) {
31
31
  super();
32
32
  }
@@ -45,15 +45,15 @@ export class KillLoneTop extends Goal {
45
45
  state,
46
46
  nonTeammates.filter(p => matchesAnyTarget(p, this.huntTargets, ctx) && !this.isProtected(p, ctx)),
47
47
  );
48
- if (flagged) {
49
- if (flagged.name !== this.lastFlaggedTarget) {
48
+ if (flagged?.seat != null) {
49
+ if (flagged.seat !== this.lastFlaggedTarget) {
50
50
  ctx.notifications.push(`根据情报,${flagged.name}被标记为目标,主动出击!`);
51
- this.lastFlaggedTarget = flagged.name;
51
+ this.lastFlaggedTarget = flagged.seat;
52
52
  }
53
- this.setHuntGoal(flagged.name, true);
53
+ this.setHuntGoal(flagged.seat, true);
54
54
  return [];
55
55
  } else {
56
- this.lastFlaggedTarget = '';
56
+ this.lastFlaggedTarget = null;
57
57
  }
58
58
 
59
59
  if (nonTeammates.length === 0 && state.players.length > 0) {
@@ -81,7 +81,11 @@ export class KillLoneTop extends Goal {
81
81
  return [];
82
82
  }
83
83
 
84
- this.setHuntGoal(target.name);
84
+ if (target.seat == null) {
85
+ this.setPatrolGoal(state, ctx, false);
86
+ return [];
87
+ }
88
+ this.setHuntGoal(target.seat);
85
89
  this.emitProgress(state, ctx);
86
90
  return [];
87
91
  }
@@ -91,11 +95,11 @@ export class KillLoneTop extends Goal {
91
95
  return matchesAnyTarget(p, this.protectedTargets, ctx);
92
96
  }
93
97
 
94
- private setHuntGoal(targetName: string, ignoreCrowd = false): void {
98
+ private setHuntGoal(targetSeat: number, ignoreCrowd = false): void {
95
99
  const worker = this.subGoal;
96
- if (worker instanceof KillVisibleTargetGoal && worker.targetName === targetName && worker.ignoreCrowd === ignoreCrowd) return;
100
+ if (worker instanceof KillVisibleTargetGoal && worker.targetSeat === targetSeat && worker.ignoreCrowd === ignoreCrowd) return;
97
101
  if (this.subGoal) this.removeSubGoal();
98
- this.setSubGoal(new KillVisibleTargetGoal(targetName, this.protectedTargets, ignoreCrowd), HUNT_PRIORITY);
102
+ this.setSubGoal(new KillVisibleTargetGoal(targetSeat, this.protectedTargets, ignoreCrowd), HUNT_PRIORITY);
99
103
  this.patrolStopOnPlayer = null;
100
104
  }
101
105
 
@@ -18,8 +18,8 @@ import { Goal } from './goal.js';
18
18
 
19
19
  export class KillVisibleTargetGoal extends Goal {
20
20
  constructor(
21
- public readonly targetName: string,
22
- private readonly protectedTargets: string[],
21
+ public readonly targetSeat: number,
22
+ private readonly protectedTargets: number[],
23
23
  public readonly ignoreCrowd = false,
24
24
  ) {
25
25
  super();
@@ -61,7 +61,7 @@ export class KillVisibleTargetGoal extends Goal {
61
61
  private target(state: GameState, ctx: StrategyContext): PlayerInfo | null {
62
62
  const visible = nonTeammatesVisible(state, ctx);
63
63
  if (!this.ignoreCrowd && visible.length !== 1) return null;
64
- const target = visible.find(p => p.name === this.targetName) ?? null;
64
+ const target = visible.find(p => p.seat === this.targetSeat) ?? null;
65
65
  if (!target) return null;
66
66
  if (matchesAnyTarget(target, this.protectedTargets, ctx)) return null;
67
67
  return target;
@@ -0,0 +1,66 @@
1
+ import { describe, expect, it } from 'vitest';
2
+ import type { GameState } from '../../sdk/types.js';
3
+ import type { StrategyContext } from '../types.js';
4
+ import { KillTargetTop } from './kill-target-top.js';
5
+
6
+ function state(): GameState {
7
+ return {
8
+ phase: 'wandering',
9
+ tick: 1,
10
+ you: {
11
+ name: 'hunter',
12
+ x: 0,
13
+ y: 0,
14
+ room: 'control',
15
+ role: 'neutral_octopus',
16
+ faction: 'neutral',
17
+ is_alive: true,
18
+ kill_cooldown_secs: 0,
19
+ },
20
+ your_tasks: [],
21
+ players: [],
22
+ all_players: [
23
+ { name: '木桩机器虾', seat: 1, role: 'unknown', is_alive: false },
24
+ { name: '木桩机器虾', seat: 3, role: 'unknown', is_alive: true },
25
+ ],
26
+ corpses: [],
27
+ stale: false,
28
+ };
29
+ }
30
+
31
+ function context(): StrategyContext {
32
+ return {
33
+ taskData: [],
34
+ emergency: null,
35
+ taskLocalBlockedUntil: 0,
36
+ reportCorpseTarget: null,
37
+ reportBlockedUntil: 0,
38
+ notifications: [],
39
+ lastProgressNotifyAt: Date.now(),
40
+ teammates: new Set(),
41
+ alarmDone: false,
42
+ rooms: [{ name: 'patrol', x: 500, y: 0 }],
43
+ playerNamesBySeat: {
44
+ '1': '木桩机器虾',
45
+ '3': '木桩机器虾',
46
+ },
47
+ forcePatrolAdvance: false,
48
+ blockedMoveTarget: null,
49
+ mySeat: 4,
50
+ speechNotifications: [],
51
+ agentAlerts: [],
52
+ };
53
+ }
54
+
55
+ describe('KillTargetTop seat targeting', () => {
56
+ it('does not complete seat 3 when a different player with the same name is dead', () => {
57
+ const top = new KillTargetTop([3]);
58
+ const ctx = context();
59
+
60
+ const decisions = top.tick(state(), ctx);
61
+
62
+ expect(decisions[0]?.intent?.summary).toContain('巡逻寻找追杀目标');
63
+ expect(decisions[0]?.intent?.summary).not.toContain('离开现场巡逻');
64
+ expect(ctx.notifications).not.toContain('击杀目标已完成,切换巡逻离开现场。');
65
+ });
66
+ });
@@ -15,7 +15,6 @@ import {
15
15
  pursueVisibleTarget,
16
16
  setStrategyIntent,
17
17
  strategyPlayerLabel,
18
- targetSeat,
19
18
  } from '../game-utils.js';
20
19
  import type { BehaviorDecision, StrategyContext } from '../types.js';
21
20
  import { Goal } from './goal.js';
@@ -26,7 +25,7 @@ export class KillTargetTop extends Goal {
26
25
  private completedAfterKill = false;
27
26
  private completedNotified = false;
28
27
 
29
- constructor(private readonly targets: string[]) {
28
+ constructor(private readonly targets: number[]) {
30
29
  super();
31
30
  }
32
31
 
@@ -91,17 +90,16 @@ export class KillTargetTop extends Goal {
91
90
  return patrolStep(state, ctx, this.patrol, false, '离开现场巡逻');
92
91
  }
93
92
 
94
- private isValidTarget(t: string, state: GameState, ctx: StrategyContext): boolean {
93
+ private isValidTarget(t: number, state: GameState, ctx: StrategyContext): boolean {
95
94
  if (!isTargetAlive(state, t, ctx)) return false;
96
- const seat = targetSeat(t, ctx);
97
- return !(seat != null && ctx.teammates.has(String(seat)));
95
+ return !ctx.teammates.has(String(t));
98
96
  }
99
97
 
100
98
  private allTargetsDeadInState(state: GameState, ctx: StrategyContext): boolean {
101
99
  return this.targets.length > 0 && this.targets.every(target => this.targetDeadInState(target, state, ctx));
102
100
  }
103
101
 
104
- private targetDeadInState(target: string, state: GameState, ctx: StrategyContext): boolean {
102
+ private targetDeadInState(target: number, state: GameState, ctx: StrategyContext): boolean {
105
103
  const player = state.all_players?.find(p => matchesTarget(target, p, ctx));
106
104
  if (player) return player.is_alive === false;
107
105
  return (ctx.knownCorpses ?? []).some(corpse => matchesTarget(target, corpse, ctx));
@@ -96,7 +96,7 @@ describe('NormalShrimpTop vision thresholds', () => {
96
96
  });
97
97
 
98
98
  it('hard-avoids hostileTargets even outside the normal stranger enter range', () => {
99
- const top = new NormalShrimpTop([], ['stranger']);
99
+ const top = new NormalShrimpTop([], [2]);
100
100
 
101
101
  top.tick(stateWithStranger(500), context());
102
102
 
@@ -104,7 +104,7 @@ describe('NormalShrimpTop vision thresholds', () => {
104
104
  });
105
105
 
106
106
  it('gives trustedTargets priority over hostileTargets', () => {
107
- const top = new NormalShrimpTop([], ['stranger'], ['stranger']);
107
+ const top = new NormalShrimpTop([], [2], [2]);
108
108
 
109
109
  top.tick(stateWithStranger(100), context());
110
110
 
@@ -63,9 +63,9 @@ export class NormalShrimpTop extends Goal {
63
63
 
64
64
  constructor(
65
65
  greetingPhrases: string[] = [],
66
- private readonly hostileTargets: string[] = [],
67
- private readonly trustedTargets: string[] = [],
68
- private readonly paradiseFishTargets: string[] = [],
66
+ private readonly hostileTargets: number[] = [],
67
+ private readonly trustedTargets: number[] = [],
68
+ private readonly paradiseFishTargets: number[] = [],
69
69
  ) {
70
70
  super();
71
71
  this.greeting = new GreetingTracker(greetingPhrases);
@@ -125,7 +125,7 @@ describe('ParadiseFishTop patrol routing', () => {
125
125
  });
126
126
 
127
127
  it('hard-avoids hostileTargets', () => {
128
- const top = new ParadiseFishTop([], ['danger']);
128
+ const top = new ParadiseFishTop([], [2]);
129
129
 
130
130
  top.tick(state({
131
131
  players: [{ name: 'danger', seat: 2, x: 1986, y: 994, room: 'control', distance: 591 }],
@@ -135,7 +135,7 @@ describe('ParadiseFishTop patrol routing', () => {
135
135
  });
136
136
 
137
137
  it('gives trustedTargets priority over hostileTargets', () => {
138
- const top = new ParadiseFishTop([], ['friend'], ['friend']);
138
+ const top = new ParadiseFishTop([], [2], [2]);
139
139
 
140
140
  top.tick(state({
141
141
  players: [{ name: 'friend', seat: 2, x: 1986, y: 994, room: 'control', distance: 591 }],
@@ -190,7 +190,7 @@ describe('ParadiseFishTop patrol routing', () => {
190
190
  });
191
191
 
192
192
  it('still escapes an explicitly hostile player while a task is running', () => {
193
- const top = new ParadiseFishTop([], ['danger']);
193
+ const top = new ParadiseFishTop([], [2]);
194
194
  const ctx = context({ playerNamesBySeat: { '2': 'danger' } });
195
195
  const current = state({
196
196
  you: { ...state().you, doing_task: true, task_name: '解除毒药' },
@@ -34,8 +34,8 @@ export class ParadiseFishTop extends Goal {
34
34
 
35
35
  constructor(
36
36
  greetingPhrases: string[] = [],
37
- private readonly hostileTargets: string[] = [],
38
- private readonly trustedTargets: string[] = [],
37
+ private readonly hostileTargets: number[] = [],
38
+ private readonly trustedTargets: number[] = [],
39
39
  ) {
40
40
  super();
41
41
  this.greeting = new GreetingTracker(greetingPhrases);
@@ -16,7 +16,7 @@ import type { BehaviorDecision, StrategyContext } from '../types.js';
16
16
  import { Goal } from './goal.js';
17
17
 
18
18
  export interface SocialTarget {
19
- target: string;
19
+ target: number;
20
20
  greeting: string | null;
21
21
  }
22
22
 
@@ -31,7 +31,7 @@ const SILENCE_TIMEOUT_MS = 10_000;
31
31
 
32
32
  export class SocialTaskTop extends Goal {
33
33
  private readonly socialTargets: SocialTarget[];
34
- private readonly targetStates = new Map<string, SocialTargetState>();
34
+ private readonly targetStates = new Map<number, SocialTargetState>();
35
35
 
36
36
  constructor(socialTargets: SocialTarget[]) {
37
37
  super();
@@ -63,7 +63,7 @@ export class SocialTaskTop extends Goal {
63
63
 
64
64
  const targetState = this.targetStates.get(st.target)!;
65
65
  const d = visiblePlayer.distance ?? dist(state.you.x, state.you.y, visiblePlayer.x, visiblePlayer.y);
66
- const targetName = visiblePlayer.name || st.target;
66
+ const targetName = visiblePlayer.name || `${st.target}号`;
67
67
  const targetLabel = strategyPlayerLabel(visiblePlayer);
68
68
  const targetRoom = visiblePlayer.room || state.you.room || '当前位置';
69
69
 
@@ -28,10 +28,10 @@ type VisibleTargetMatch = {
28
28
  };
29
29
 
30
30
  export class TaskKillReportTop extends Goal {
31
- private readonly targets: string[];
31
+ private readonly targets: number[];
32
32
  private readonly targetSpottedNotified = new Set<string>();
33
33
 
34
- constructor(targets: string[]) {
34
+ constructor(targets: number[]) {
35
35
  super();
36
36
  this.targets = [...targets];
37
37
  }
@@ -62,7 +62,7 @@ describe('WarriorShrimpTop parameter tiers', () => {
62
62
  });
63
63
 
64
64
  it('hunts configured targets', () => {
65
- const top = new WarriorShrimpTop(['target']);
65
+ const top = new WarriorShrimpTop([2]);
66
66
 
67
67
  top.tick(state(), context());
68
68
 
@@ -70,7 +70,7 @@ describe('WarriorShrimpTop parameter tiers', () => {
70
70
  });
71
71
 
72
72
  it('gives trustedTargets priority over huntTargets', () => {
73
- const top = new WarriorShrimpTop(['target'], ['target']);
73
+ const top = new WarriorShrimpTop([2], [2]);
74
74
 
75
75
  top.tick(state(), context());
76
76
 
@@ -126,7 +126,7 @@ describe('WarriorShrimpTop parameter tiers', () => {
126
126
  });
127
127
 
128
128
  it('still attacks an explicitly hostile player while a task is running', () => {
129
- const top = new WarriorShrimpTop(['target']);
129
+ const top = new WarriorShrimpTop([2]);
130
130
  const ctx = context();
131
131
  const current = state({
132
132
  you: { ...state().you, doing_task: true, task_name: '修复火灾-通讯间' },
@@ -66,8 +66,8 @@ export class WarriorShrimpTop extends Goal {
66
66
  private witnessExempt = false;
67
67
 
68
68
  constructor(
69
- private readonly huntTargets: string[] = [],
70
- private readonly trustedTargets: string[] = [],
69
+ private readonly huntTargets: number[] = [],
70
+ private readonly trustedTargets: number[] = [],
71
71
  ) {
72
72
  super();
73
73
  }
@@ -98,7 +98,7 @@ export class WarriorShrimpTop extends Goal {
98
98
  const huntTargets = visible.filter(p => !this.isTrusted(p, ctx) && this.isHuntTarget(p, ctx));
99
99
  if (huntTargets.length > 0) {
100
100
  if (killReady) {
101
- this.setHunt(this.nearestByDistance(state, huntTargets).name);
101
+ this.setHunt(this.nearestByDistance(state, huntTargets));
102
102
  } else {
103
103
  this.taskGoal.planTask(state, ctx, { holdUnsafeCurrentForMs: TASK_RETURN_INERTIA_MS });
104
104
  this.setFlee();
@@ -125,7 +125,7 @@ export class WarriorShrimpTop extends Goal {
125
125
  const huntTargets = threats.filter(p => this.isHuntTarget(p, ctx));
126
126
  // P1-A 坏人/启动目标且刀好 → 主动追杀。
127
127
  if (killReady && huntTargets.length > 0) {
128
- this.setHunt(this.nearestByDistance(state, huntTargets).name);
128
+ this.setHunt(this.nearestByDistance(state, huntTargets));
129
129
  return [];
130
130
  }
131
131
 
@@ -222,11 +222,15 @@ export class WarriorShrimpTop extends Goal {
222
222
  .sort((a, b) => a.d - b.d)[0].p;
223
223
  }
224
224
 
225
- private setHunt(targetName: string): void {
225
+ private setHunt(target: PlayerInfo): void {
226
+ if (target.seat == null) {
227
+ this.clearSub();
228
+ return;
229
+ }
226
230
  const worker = this.subGoal;
227
- if (worker instanceof KillVisibleTargetGoal && worker.targetName === targetName) return;
231
+ if (worker instanceof KillVisibleTargetGoal && worker.targetSeat === target.seat) return;
228
232
  if (this.subGoal) this.removeSubGoal();
229
- this.setSubGoal(new KillVisibleTargetGoal(targetName, this.trustedTargets, true), SUB_PRIORITY);
233
+ this.setSubGoal(new KillVisibleTargetGoal(target.seat, this.trustedTargets, true), SUB_PRIORITY);
230
234
  }
231
235
 
232
236
  private setFlee(): void {
@@ -1,10 +1,9 @@
1
1
  import {
2
2
  ClawclawGoalStrategy,
3
- clawclawStrategyStringList,
3
+ clawclawStrategySeatList,
4
4
  } from '../sdk/strategy-plugin/index.js';
5
5
  import { GoalRootStrategy } from './goals/goal-root-strategy.js';
6
6
  import { KillLoneTop } from './goals/kill-lone-top.js';
7
- import { parseTargetArgs } from './player-targets.js';
8
7
 
9
8
  export default class KillLoneStrategy extends ClawclawGoalStrategy {
10
9
  static readonly manifest = {
@@ -15,14 +14,14 @@ export default class KillLoneStrategy extends ClawclawGoalStrategy {
15
14
  controls: [
16
15
  {
17
16
  id: 'protectedTargets',
18
- type: 'player_refs',
19
- description: '禁止击杀的座位号或玩家名列表;与 huntTargets 重叠时保护优先。',
17
+ type: 'player_seats',
18
+ description: '禁止击杀的玩家座位号列表;与 huntTargets 重叠时保护优先。',
20
19
  default: [],
21
20
  },
22
21
  {
23
22
  id: 'huntTargets',
24
- type: 'player_refs',
25
- description: '主动猎杀的座位号或玩家名列表;看见后可越过落单人数限制追杀。',
23
+ type: 'player_seats',
24
+ description: '主动猎杀的玩家座位号列表;看见后可越过落单人数限制追杀。',
26
25
  default: [],
27
26
  },
28
27
  ],
@@ -32,12 +31,8 @@ export default class KillLoneStrategy extends ClawclawGoalStrategy {
32
31
  super(parameters, {
33
32
  id: 'kill-lone',
34
33
  create: (values) => {
35
- const protectedTargets = parseTargetArgs(
36
- clawclawStrategyStringList(values, 'protectedTargets'),
37
- );
38
- const huntTargets = parseTargetArgs(
39
- clawclawStrategyStringList(values, 'huntTargets'),
40
- );
34
+ const protectedTargets = clawclawStrategySeatList(values, 'protectedTargets');
35
+ const huntTargets = clawclawStrategySeatList(values, 'huntTargets');
41
36
  return new GoalRootStrategy('kill-lone', () => new KillLoneTop(protectedTargets, huntTargets), {
42
37
  resetOnMeetingResume: false,
43
38
  });
@@ -1,10 +1,9 @@
1
1
  import {
2
2
  ClawclawGoalStrategy,
3
- clawclawStrategyStringList,
3
+ clawclawStrategySeatList,
4
4
  } from '../sdk/strategy-plugin/index.js';
5
5
  import { GoalRootStrategy } from './goals/goal-root-strategy.js';
6
6
  import { KillTargetTop } from './goals/kill-target-top.js';
7
- import { parseTargetArgs } from './player-targets.js';
8
7
 
9
8
  export default class KillTargetStrategy extends ClawclawGoalStrategy {
10
9
  static readonly manifest = {
@@ -14,8 +13,8 @@ export default class KillTargetStrategy extends ClawclawGoalStrategy {
14
13
  execution: 'parallel_analyze',
15
14
  controls: [{
16
15
  id: 'targets',
17
- type: 'player_refs',
18
- description: '要追杀的玩家列表。',
16
+ type: 'player_seats',
17
+ description: '要追杀的玩家座位号列表。',
19
18
  }],
20
19
  } as const;
21
20
 
@@ -23,12 +22,12 @@ export default class KillTargetStrategy extends ClawclawGoalStrategy {
23
22
  super(parameters, {
24
23
  id: 'kill-target',
25
24
  validateParameters: (values) => (
26
- parseTargetArgs(clawclawStrategyStringList(values, 'targets')).length > 0
25
+ clawclawStrategySeatList(values, 'targets').length > 0
27
26
  ? undefined
28
27
  : '追杀策略至少需要配置一个目标玩家。'
29
28
  ),
30
29
  create: (values) => {
31
- const targets = parseTargetArgs(clawclawStrategyStringList(values, 'targets'));
30
+ const targets = clawclawStrategySeatList(values, 'targets');
32
31
  return new GoalRootStrategy('kill-target', () => new KillTargetTop(targets), {
33
32
  resetOnMeetingResume: false,
34
33
  });
@@ -1,14 +1,14 @@
1
1
  import {
2
2
  ClawclawGoalStrategy,
3
+ clawclawStrategySeatList,
3
4
  clawclawStrategyStringList,
4
5
  } from '../sdk/strategy-plugin/index.js';
5
6
  import { GoalRootStrategy } from './goals/goal-root-strategy.js';
6
7
  import { ParadiseFishTop } from './goals/paradise-fish-top.js';
7
8
  import { parseGreetingArgs } from './greeting.js';
8
- import { parseTargetArgs } from './player-targets.js';
9
9
 
10
10
  class ParadiseFishStrategy extends GoalRootStrategy {
11
- constructor(greetingPhrases: string[], hostileTargets: string[], trustedTargets: string[]) {
11
+ constructor(greetingPhrases: string[], hostileTargets: number[], trustedTargets: number[]) {
12
12
  super('paradise-fish', () => new ParadiseFishTop(greetingPhrases, hostileTargets, trustedTargets), {
13
13
  resetOnMeetingResume: false,
14
14
  });
@@ -24,14 +24,14 @@ export default class ParadiseFishGoalStrategy extends ClawclawGoalStrategy {
24
24
  controls: [
25
25
  {
26
26
  id: 'hostileTargets',
27
- type: 'player_refs',
28
- description: '需要硬回避的座位号或玩家名列表;与 trustedTargets 重叠时 trustedTargets 优先。',
27
+ type: 'player_seats',
28
+ description: '需要硬回避的玩家座位号列表;与 trustedTargets 重叠时 trustedTargets 优先。',
29
29
  default: [],
30
30
  },
31
31
  {
32
32
  id: 'trustedTargets',
33
- type: 'player_refs',
34
- description: '可信、可抱团跟随的座位号或玩家名列表。',
33
+ type: 'player_seats',
34
+ description: '可信、可抱团跟随的玩家座位号列表。',
35
35
  default: [],
36
36
  },
37
37
  {
@@ -51,8 +51,8 @@ export default class ParadiseFishGoalStrategy extends ClawclawGoalStrategy {
51
51
  sidecarSpeech: true,
52
52
  create: (values) => new ParadiseFishStrategy(
53
53
  parseGreetingArgs(clawclawStrategyStringList(values, 'greetings'), 'paradise-fish'),
54
- parseTargetArgs(clawclawStrategyStringList(values, 'hostileTargets')),
55
- parseTargetArgs(clawclawStrategyStringList(values, 'trustedTargets')),
54
+ clawclawStrategySeatList(values, 'hostileTargets'),
55
+ clawclawStrategySeatList(values, 'trustedTargets'),
56
56
  ),
57
57
  });
58
58
  }
@@ -1,11 +1,3 @@
1
- /** Split CLI args on commas and/or whitespace (Windows may pass `3,5` as one token). */
2
- export function parseTargetArgs(args: string[]): string[] {
3
- return args
4
- .flatMap((a) => a.split(/[,\s]+/))
5
- .map((t) => t.trim())
6
- .filter((t) => t.length > 0);
7
- }
8
-
9
1
  export const ROLE_ID_RE = /\b(?:shrimp_generic|shrimp_warrior|shrimp_pistol|crab_generic|neutral_paradise_fish|neutral_octopus)\b/g;
10
2
 
11
3
  export function stripRoleIds(text: string): string {