@myclaw163/clawclaw-cli 0.8.4 → 0.8.6

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 (330) hide show
  1. package/README.md +4 -3
  2. package/docs/configuration.md +44 -26
  3. package/docs/custom-modules/README.md +7 -10
  4. package/docs/custom-modules/behavior.md +10 -19
  5. package/docs/custom-modules/perception.md +1 -1
  6. package/docs/custom-modules/trigger.md +1 -1
  7. package/docs/runtime/README.md +4 -4
  8. package/docs/runtime/official-perception-modules.md +2 -2
  9. package/docs/runtime/owner-lifecycle-and-observability.md +1 -1
  10. package/package.json +15 -2
  11. package/scripts/enable_ccl_permissions.cjs +4 -2
  12. package/scripts/find-hide-spots.py +2 -2
  13. package/scripts/postinstall.mjs +1 -4
  14. package/scripts/sync-bundled-skill.mjs +12 -159
  15. package/skills/clawclaw/SKILL.md +25 -18
  16. package/skills/clawclaw/references/BEHAVIORS.md +15 -11
  17. package/skills/clawclaw/references/COMMANDS.md +45 -41
  18. package/skills/clawclaw/references/HUB.md +25 -38
  19. package/skills/clawclaw/references/TACTICS.md +1 -1
  20. package/src/commands/account.ts +58 -14
  21. package/src/commands/behavior.ts +116 -38
  22. package/src/commands/hub.ts +110 -153
  23. package/src/commands/load.ts +138 -33
  24. package/src/commands/perception.ts +55 -24
  25. package/src/commands/persona.ts +66 -20
  26. package/src/commands/skill.ts +12 -48
  27. package/src/commands/trigger.ts +68 -40
  28. package/src/lib/account-guidance.ts +54 -9
  29. package/src/lib/agent-workspace-client.ts +135 -0
  30. package/src/lib/agent-workspace-runtime.ts +154 -0
  31. package/src/lib/agent-workspace-skills.ts +177 -0
  32. package/src/lib/agent-workspace-sync.ts +852 -0
  33. package/src/lib/gameplay-config.ts +29 -15
  34. package/src/lib/hub-client.ts +252 -34
  35. package/src/lib/hub-reminder.ts +24 -11
  36. package/src/lib/init-command.ts +0 -6
  37. package/src/lib/load-context.ts +12 -6
  38. package/src/lib/persona.ts +141 -69
  39. package/src/lib/server-status.ts +78 -0
  40. package/src/lib/skill-host.ts +160 -0
  41. package/src/lib/user-data.ts +197 -4
  42. package/src/runtime/clawclaw/behavior-read-api.ts +1 -1
  43. package/src/{strategies/pathfind → runtime/clawclaw/navigation}/astar-path.ts +1 -1
  44. package/src/{strategies/pathfind → runtime/clawclaw/navigation}/escape-planner.ts +1 -1
  45. package/src/{strategies → runtime/clawclaw/navigation}/hide-spots.ts +2 -2
  46. package/src/{strategies → runtime/clawclaw/navigation}/off-route-points.ts +6 -3
  47. package/src/{strategies/pathfind → runtime/clawclaw/navigation}/walkable-grid.ts +1 -1
  48. package/src/runtime/clawclaw/owner.ts +63 -19
  49. package/src/runtime/clawclaw/plugins/behavior/activation-manager.ts +8 -2
  50. package/src/runtime/clawclaw/plugins/behavior/behavior-plugin.ts +2 -2
  51. package/src/runtime/clawclaw/plugins/game-query/game-query-plugin.ts +1 -1
  52. package/src/runtime/clawclaw/plugins/perception/perception-plugin.ts +4 -1
  53. package/src/runtime/clawclaw/plugins/perception/perception-source.ts +11 -5
  54. package/src/runtime/clawclaw/plugins/perception/replay.ts +0 -2
  55. package/src/runtime/framework/modules/runtime-module-loader.ts +0 -54
  56. package/src/sdk/behavior-toolkit/escape.ts +2 -2
  57. package/personas//345/217/243/346/230/257/345/277/203/351/235/236.md +0 -50
  58. package/personas//345/277/240/345/277/203/350/200/201/344/273/206.md +0 -51
  59. package/personas//346/227/240/344/272/272/350/256/276.md +0 -1
  60. package/personas//350/264/253/345/230/264/346/215/237/345/217/213.md +0 -48
  61. package/personas//350/275/257/350/220/214/350/205/271/351/273/221.md +0 -51
  62. package/scripts/compare-perception-replays.test.ts +0 -188
  63. package/scripts/enable_ccl_permissions.test.mjs +0 -163
  64. package/scripts/enable_monitor.test.mjs +0 -201
  65. package/scripts/sync-bundled-skill.test.mjs +0 -152
  66. package/scripts/watch-perception-events.test.ts +0 -43
  67. package/src/behaviors/official-finite/do-task.ts +0 -211
  68. package/src/behaviors/official-finite/evade.ts +0 -78
  69. package/src/behaviors/official-finite/find-player.ts +0 -50
  70. package/src/behaviors/official-finite/follow-player.ts +0 -70
  71. package/src/behaviors/official-finite/go-to.ts +0 -69
  72. package/src/behaviors/official-finite/hide-temporarily.ts +0 -77
  73. package/src/behaviors/official-finite/hold-position.ts +0 -48
  74. package/src/behaviors/official-finite/hunt-player.ts +0 -47
  75. package/src/behaviors/official-finite/index.test.ts +0 -249
  76. package/src/behaviors/official-finite/index.ts +0 -44
  77. package/src/behaviors/official-finite/inspect-corpse.ts +0 -64
  78. package/src/behaviors/official-finite/patrol-area.ts +0 -80
  79. package/src/behaviors/official-finite/report-corpse.ts +0 -73
  80. package/src/behaviors/official-finite/seek-kill-opportunity.ts +0 -152
  81. package/src/behaviors/official-finite/shared.ts +0 -27
  82. package/src/channel/claude-channel-server.test.ts +0 -202
  83. package/src/commands/account.test.ts +0 -570
  84. package/src/commands/behavior.test.ts +0 -158
  85. package/src/commands/communication.test.ts +0 -282
  86. package/src/commands/competition.test.ts +0 -116
  87. package/src/commands/data.test.ts +0 -89
  88. package/src/commands/events-canonical-state.test.ts +0 -406
  89. package/src/commands/events.test.ts +0 -58
  90. package/src/commands/game/index.test.ts +0 -1251
  91. package/src/commands/game-map.test.ts +0 -69
  92. package/src/commands/hub.test.ts +0 -124
  93. package/src/commands/load.test.ts +0 -440
  94. package/src/commands/perception.test.ts +0 -75
  95. package/src/commands/setup/hermes.test.ts +0 -96
  96. package/src/commands/setup/openclaw.test.ts +0 -124
  97. package/src/commands/trigger.test.ts +0 -140
  98. package/src/commands/upgrade.test.ts +0 -82
  99. package/src/lib/account-guidance.test.ts +0 -36
  100. package/src/lib/auth.test.ts +0 -151
  101. package/src/lib/behavior-export.test.ts +0 -326
  102. package/src/lib/behavior-export.ts +0 -537
  103. package/src/lib/clawclaw-skill-spectate-guidance.test.ts +0 -21
  104. package/src/lib/custom-tts.test.ts +0 -387
  105. package/src/lib/diagnostics-config.test.ts +0 -59
  106. package/src/lib/game-client-tts.test.ts +0 -151
  107. package/src/lib/game-client.test.ts +0 -250
  108. package/src/lib/gameplay-config.test.ts +0 -301
  109. package/src/lib/host-config-patcher.test.ts +0 -130
  110. package/src/lib/http-transport.test.ts +0 -124
  111. package/src/lib/hub-client.test.ts +0 -57
  112. package/src/lib/hub-install.test.ts +0 -135
  113. package/src/lib/hub-install.ts +0 -185
  114. package/src/lib/hub-unzip.test.ts +0 -69
  115. package/src/lib/init-command.test.ts +0 -103
  116. package/src/lib/load-context.test.ts +0 -62
  117. package/src/lib/match-state.test.ts +0 -134
  118. package/src/lib/official-resource-sync.test.ts +0 -199
  119. package/src/lib/official-resource-sync.ts +0 -221
  120. package/src/lib/perception-config.test.ts +0 -143
  121. package/src/lib/perception-export.test.ts +0 -145
  122. package/src/lib/perception-export.ts +0 -178
  123. package/src/lib/persona.test.ts +0 -84
  124. package/src/lib/room.test.ts +0 -88
  125. package/src/lib/server-registry.test.ts +0 -64
  126. package/src/lib/service-status.test.ts +0 -81
  127. package/src/lib/skill-version.test.ts +0 -48
  128. package/src/lib/trigger-config.test.ts +0 -102
  129. package/src/lib/trigger-export.test.ts +0 -80
  130. package/src/lib/trigger-export.ts +0 -210
  131. package/src/lib/user-data.test.ts +0 -121
  132. package/src/lib/workspace-argv.test.ts +0 -49
  133. package/src/pipeline/canonical-event-presentation.test.ts +0 -257
  134. package/src/pipeline/event-format.test.ts +0 -879
  135. package/src/pipeline/event-hints.test.ts +0 -337
  136. package/src/pipeline/game-sync-event-normalization.test.ts +0 -419
  137. package/src/pipeline/player-projection.test.ts +0 -247
  138. package/src/runtime/auto-upgrade.test.ts +0 -66
  139. package/src/runtime/canonical-event-emitter.test.ts +0 -70
  140. package/src/runtime/canonical-monitor.test.ts +0 -577
  141. package/src/runtime/clawclaw/agent-event-policy.test.ts +0 -60
  142. package/src/runtime/clawclaw/behavior-decision.test.ts +0 -43
  143. package/src/runtime/clawclaw/behavior-input-fields.test.ts +0 -175
  144. package/src/runtime/clawclaw/behavior-input.test.ts +0 -173
  145. package/src/runtime/clawclaw/behavior-observation-memory.test.ts +0 -59
  146. package/src/runtime/clawclaw/behavior-read-api.test.ts +0 -123
  147. package/src/runtime/clawclaw/notifications.test.ts +0 -47
  148. package/src/runtime/clawclaw/owner-lock.test.ts +0 -221
  149. package/src/runtime/clawclaw/owner.test.ts +0 -203
  150. package/src/runtime/clawclaw/plugins/action/action-plugin.test.ts +0 -328
  151. package/src/runtime/clawclaw/plugins/assembly.test.ts +0 -200
  152. package/src/runtime/clawclaw/plugins/behavior/activation-manager.test.ts +0 -180
  153. package/src/runtime/clawclaw/plugins/behavior/behavior-action.test.ts +0 -43
  154. package/src/runtime/clawclaw/plugins/behavior/behavior-catalog.test.ts +0 -156
  155. package/src/runtime/clawclaw/plugins/behavior/behavior-module-loader.test.ts +0 -182
  156. package/src/runtime/clawclaw/plugins/behavior/behavior-plugin.test.ts +0 -1094
  157. package/src/runtime/clawclaw/plugins/behavior/behavior-source.test.ts +0 -174
  158. package/src/runtime/clawclaw/plugins/behavior/control-driver.test.ts +0 -195
  159. package/src/runtime/clawclaw/plugins/behavior/official-goal-behavior.ts +0 -757
  160. package/src/runtime/clawclaw/plugins/behavior/thread-behavior-executor.test.ts +0 -283
  161. package/src/runtime/clawclaw/plugins/behavior-input-source.test.ts +0 -80
  162. package/src/runtime/clawclaw/plugins/derived-event/derived-event-plugin.test.ts +0 -267
  163. package/src/runtime/clawclaw/plugins/game-query/game-query-plugin.test.ts +0 -226
  164. package/src/runtime/clawclaw/plugins/mailbox/adapters/claude-channel-adapter.test.ts +0 -239
  165. package/src/runtime/clawclaw/plugins/mailbox/agent-mailbox-coordinator.test.ts +0 -407
  166. package/src/runtime/clawclaw/plugins/mailbox/desktop-event-push.integration.test.ts +0 -397
  167. package/src/runtime/clawclaw/plugins/mailbox/desktop-event-socket.test.ts +0 -270
  168. package/src/runtime/clawclaw/plugins/mailbox/mailbox-agent-event-batch.test.ts +0 -166
  169. package/src/runtime/clawclaw/plugins/mailbox/mailbox-event-batch-delivery.test.ts +0 -194
  170. package/src/runtime/clawclaw/plugins/mailbox/mailbox-plugin.test.ts +0 -87
  171. package/src/runtime/clawclaw/plugins/mailbox/mailbox-service.test.ts +0 -2012
  172. package/src/runtime/clawclaw/plugins/perception/module-runner.test.ts +0 -214
  173. package/src/runtime/clawclaw/plugins/perception/modules/co-movement-module.ts +0 -347
  174. package/src/runtime/clawclaw/plugins/perception/modules/corpse-visibility-module.test.ts +0 -92
  175. package/src/runtime/clawclaw/plugins/perception/modules/corpse-visibility-module.ts +0 -248
  176. package/src/runtime/clawclaw/plugins/perception/modules/follow-module.ts +0 -389
  177. package/src/runtime/clawclaw/plugins/perception/modules/index.ts +0 -8
  178. package/src/runtime/clawclaw/plugins/perception/modules/motion-module.test.ts +0 -342
  179. package/src/runtime/clawclaw/plugins/perception/modules/motion-module.ts +0 -475
  180. package/src/runtime/clawclaw/plugins/perception/modules/parallel-module-test-helpers.ts +0 -30
  181. package/src/runtime/clawclaw/plugins/perception/modules/relation-stability.test.ts +0 -304
  182. package/src/runtime/clawclaw/plugins/perception/modules/route-module.test.ts +0 -179
  183. package/src/runtime/clawclaw/plugins/perception/modules/route-module.ts +0 -364
  184. package/src/runtime/clawclaw/plugins/perception/modules/spatial-module.test.ts +0 -81
  185. package/src/runtime/clawclaw/plugins/perception/modules/spatial-module.ts +0 -200
  186. package/src/runtime/clawclaw/plugins/perception/modules/stop-module.test.ts +0 -216
  187. package/src/runtime/clawclaw/plugins/perception/modules/stop-module.ts +0 -284
  188. package/src/runtime/clawclaw/plugins/perception/modules/temporal-evidence.test.ts +0 -120
  189. package/src/runtime/clawclaw/plugins/perception/modules/visibility-module.test.ts +0 -105
  190. package/src/runtime/clawclaw/plugins/perception/modules/visibility-module.ts +0 -269
  191. package/src/runtime/clawclaw/plugins/perception/perception-analysis-thread-pool.test.ts +0 -865
  192. package/src/runtime/clawclaw/plugins/perception/perception-plugin.test.ts +0 -1878
  193. package/src/runtime/clawclaw/plugins/perception/perception-source.test.ts +0 -278
  194. package/src/runtime/clawclaw/plugins/perception/replay.test.ts +0 -77
  195. package/src/runtime/clawclaw/plugins/runtime-plugins.test.ts +0 -853
  196. package/src/runtime/clawclaw/plugins/source/game-transport.test.ts +0 -287
  197. package/src/runtime/clawclaw/plugins/source/player-change-tracker.test.ts +0 -321
  198. package/src/runtime/clawclaw/plugins/source/room-transport.test.ts +0 -307
  199. package/src/runtime/clawclaw/plugins/source/source-plugin.test.ts +0 -2646
  200. package/src/runtime/clawclaw/plugins/source/task-change-tracker.test.ts +0 -212
  201. package/src/runtime/clawclaw/plugins/trigger/trigger-plugin.test.ts +0 -548
  202. package/src/runtime/clawclaw/plugins/trigger/trigger-source.test.ts +0 -169
  203. package/src/runtime/clawclaw/runtime-data-export.test.ts +0 -249
  204. package/src/runtime/clawclaw-event-catalog.test.ts +0 -128
  205. package/src/runtime/framework/action-diagnostics.test.ts +0 -81
  206. package/src/runtime/framework/capability-registry.test.ts +0 -423
  207. package/src/runtime/framework/control-coordinator.test.ts +0 -675
  208. package/src/runtime/framework/events/event-delivery-service.test.ts +0 -84
  209. package/src/runtime/framework/events/event-ingress.test.ts +0 -203
  210. package/src/runtime/framework/events/mailbox-event-repositories.test.ts +0 -710
  211. package/src/runtime/framework/events/sqlite-event-repository.test.ts +0 -802
  212. package/src/runtime/framework/mailbox/coalescer.test.ts +0 -55
  213. package/src/runtime/framework/mailbox/identity.test.ts +0 -38
  214. package/src/runtime/framework/mailbox/mailbox-dispatcher.test.ts +0 -513
  215. package/src/runtime/framework/mailbox/notification-projector.test.ts +0 -77
  216. package/src/runtime/framework/modules/runtime-module-loader.test.ts +0 -435
  217. package/src/runtime/framework/participation-manager.test.ts +0 -108
  218. package/src/runtime/framework/plugins/runtime-input-journal.test.ts +0 -179
  219. package/src/runtime/framework/plugins/runtime-plugin-scheduler.test.ts +0 -2040
  220. package/src/runtime/framework/state/durable-agent-state-snapshot.test.ts +0 -144
  221. package/src/runtime/framework/state/history/sqlite-state-history-repository.test.ts +0 -157
  222. package/src/runtime/framework/state/history/state-history.test.ts +0 -251
  223. package/src/runtime/framework/state/state-core.test.ts +0 -197
  224. package/src/runtime/game-sync-protocol.test.ts +0 -123
  225. package/src/runtime/host-monitor-rate-gate.test.ts +0 -73
  226. package/src/runtime/mailbox-host-relay.test.ts +0 -293
  227. package/src/runtime/observability/observability.test.ts +0 -583
  228. package/src/runtime/owner-control.test.ts +0 -153
  229. package/src/runtime/parent-process-watch.test.ts +0 -27
  230. package/src/runtime/pending-event-handoff.test.ts +0 -29
  231. package/src/runtime/raw-ws-log.test.ts +0 -102
  232. package/src/runtime/runtime-logger.test.ts +0 -58
  233. package/src/runtime/runtime-persistence.test.ts +0 -26
  234. package/src/runtime/runtime.test.ts +0 -1770
  235. package/src/runtime/ws-client.test.ts +0 -562
  236. package/src/sdk/action.test.ts +0 -8
  237. package/src/sdk/behavior-plugin/index.test.ts +0 -74
  238. package/src/sdk/index.test.ts +0 -45
  239. package/src/sdk/module-input/index.test.ts +0 -49
  240. package/src/sdk/perception-plugin/index.test.ts +0 -22
  241. package/src/sdk/resource-metadata.test.ts +0 -40
  242. package/src/sdk/trigger-plugin/index.test.ts +0 -41
  243. package/src/short-command/classifier.test.ts +0 -107
  244. package/src/short-command/presenter.test.ts +0 -119
  245. package/src/short-command/runner.test.ts +0 -78
  246. package/src/short-command/sensitive-data-filter.test.ts +0 -56
  247. package/src/short-command/transport-response.test.ts +0 -39
  248. package/src/strategies/avoid-lone.ts +0 -32
  249. package/src/strategies/avoid-players.ts +0 -43
  250. package/src/strategies/corpse-patrol.ts +0 -50
  251. package/src/strategies/crab-sabotage.ts +0 -48
  252. package/src/strategies/custom-module.test.ts +0 -267
  253. package/src/strategies/find-player.ts +0 -49
  254. package/src/strategies/game-utils.test.ts +0 -305
  255. package/src/strategies/game-utils.ts +0 -927
  256. package/src/strategies/goals/anchor-linger.ts +0 -77
  257. package/src/strategies/goals/avoid-lone-top.ts +0 -189
  258. package/src/strategies/goals/avoid-players-top.test.ts +0 -95
  259. package/src/strategies/goals/avoid-players-top.ts +0 -122
  260. package/src/strategies/goals/conversation-goal.ts +0 -51
  261. package/src/strategies/goals/corpse-patrol-top.ts +0 -120
  262. package/src/strategies/goals/crab-octopus-reflexes.ts +0 -109
  263. package/src/strategies/goals/crab-sabotage-top.test.ts +0 -131
  264. package/src/strategies/goals/crab-sabotage-top.ts +0 -139
  265. package/src/strategies/goals/emergency-hunt-goal.ts +0 -40
  266. package/src/strategies/goals/find-player-top.ts +0 -136
  267. package/src/strategies/goals/flee-players-goal.ts +0 -55
  268. package/src/strategies/goals/follow-companion-goal.ts +0 -130
  269. package/src/strategies/goals/goal-manager.ts +0 -41
  270. package/src/strategies/goals/goal-root-strategy.ts +0 -49
  271. package/src/strategies/goals/goal.ts +0 -28
  272. package/src/strategies/goals/hide-top.ts +0 -240
  273. package/src/strategies/goals/keep-away-goal.ts +0 -243
  274. package/src/strategies/goals/kill-frenzy-top.ts +0 -90
  275. package/src/strategies/goals/kill-lone-top.test.ts +0 -96
  276. package/src/strategies/goals/kill-lone-top.ts +0 -166
  277. package/src/strategies/goals/kill-target-goal.ts +0 -69
  278. package/src/strategies/goals/kill-target-top.test.ts +0 -65
  279. package/src/strategies/goals/kill-target-top.ts +0 -121
  280. package/src/strategies/goals/leaf-goal.ts +0 -27
  281. package/src/strategies/goals/linger-corpse-goal.ts +0 -43
  282. package/src/strategies/goals/lone-kill-core.ts +0 -86
  283. package/src/strategies/goals/lone-kill-goal.ts +0 -24
  284. package/src/strategies/goals/lone-kill-task-top.test.ts +0 -84
  285. package/src/strategies/goals/lone-kill-task-top.ts +0 -133
  286. package/src/strategies/goals/move-room-goal.ts +0 -102
  287. package/src/strategies/goals/normal-shrimp-top.test.ts +0 -112
  288. package/src/strategies/goals/normal-shrimp-top.ts +0 -248
  289. package/src/strategies/goals/paradise-fish-top.test.ts +0 -203
  290. package/src/strategies/goals/paradise-fish-top.ts +0 -234
  291. package/src/strategies/goals/patrol-top.ts +0 -68
  292. package/src/strategies/goals/report-patrol-top.ts +0 -97
  293. package/src/strategies/goals/safe-task-goal.ts +0 -130
  294. package/src/strategies/goals/social-task-top.ts +0 -192
  295. package/src/strategies/goals/task-kill-report-top.ts +0 -187
  296. package/src/strategies/goals/task-only-top.test.ts +0 -88
  297. package/src/strategies/goals/task-only-top.ts +0 -64
  298. package/src/strategies/goals/task-or-patrol-goal.ts +0 -59
  299. package/src/strategies/goals/task-report-top.ts +0 -57
  300. package/src/strategies/goals/wander-task-goal.ts +0 -33
  301. package/src/strategies/goals/warrior-shrimp-top.test.ts +0 -138
  302. package/src/strategies/goals/warrior-shrimp-top.ts +0 -293
  303. package/src/strategies/greeting.ts +0 -60
  304. package/src/strategies/hide.ts +0 -51
  305. package/src/strategies/kill-frenzy.ts +0 -32
  306. package/src/strategies/kill-lone.ts +0 -52
  307. package/src/strategies/kill-target.ts +0 -48
  308. package/src/strategies/lone-kill-task.ts +0 -48
  309. package/src/strategies/meeting-gate.test.ts +0 -59
  310. package/src/strategies/meeting-gate.ts +0 -28
  311. package/src/strategies/move-room.ts +0 -46
  312. package/src/strategies/official-long-behavior.test.ts +0 -89
  313. package/src/strategies/paradise-fish.ts +0 -70
  314. package/src/strategies/pathfind/astar-path.test.ts +0 -198
  315. package/src/strategies/pathfind/escape-planner.test.ts +0 -223
  316. package/src/strategies/patrol.ts +0 -32
  317. package/src/strategies/player-targets.test.ts +0 -10
  318. package/src/strategies/player-targets.ts +0 -18
  319. package/src/strategies/report-patrol.ts +0 -32
  320. package/src/strategies/shrimp-memory.ts +0 -87
  321. package/src/strategies/social-task.ts +0 -67
  322. package/src/strategies/speech-module.ts +0 -123
  323. package/src/strategies/task-kill-report.ts +0 -49
  324. package/src/strategies/task-only.test.ts +0 -138
  325. package/src/strategies/task-only.ts +0 -34
  326. package/src/strategies/task-report.ts +0 -50
  327. package/src/strategies/types.ts +0 -116
  328. package/src/strategies/warrior-memory.ts +0 -54
  329. /package/src/{strategies/pathfind → runtime/clawclaw/navigation}/clawclaw-walkable.bin +0 -0
  330. /package/src/{strategies/pathfind → runtime/clawclaw/navigation}/distance-field.ts +0 -0
@@ -1,112 +0,0 @@
1
- import { describe, expect, it } from 'vitest';
2
- import type { GameState } from '../../sdk/types.js';
3
- import type { StrategyContext } from '../types.js';
4
- import { KeepAwayGoal } from './keep-away-goal.js';
5
- import { NormalShrimpTop } from './normal-shrimp-top.js';
6
-
7
- function stateWithStranger(distance: number): GameState {
8
- return {
9
- phase: 'wandering',
10
- tick: 1,
11
- you: {
12
- name: 'shrimp',
13
- x: 0,
14
- y: 0,
15
- room: 'control',
16
- role: 'shrimp',
17
- faction: 'lobster',
18
- is_alive: true,
19
- },
20
- your_tasks: [],
21
- players: [{ name: 'stranger', seat: 2, x: distance, y: 0, room: 'control', distance }],
22
- all_players: [{ name: 'stranger', seat: 2, role: 'unknown', is_alive: true }],
23
- corpses: [],
24
- stale: false,
25
- };
26
- }
27
-
28
- function context(overrides: Partial<StrategyContext> = {}): StrategyContext {
29
- return {
30
- taskData: [],
31
- emergency: null,
32
- taskLocalBlockedUntil: 0,
33
- reportCorpseTarget: null,
34
- reportBlockedUntil: 0,
35
- notifications: [],
36
- lastProgressNotifyAt: Date.now(),
37
- teammates: new Set(),
38
- rooms: [],
39
- playerNamesBySeat: { '2': 'stranger' },
40
- forcePatrolAdvance: false,
41
- blockedMoveTarget: null,
42
- mySeat: 1,
43
- speechNotifications: [],
44
- agentAlerts: [],
45
- ...overrides,
46
- };
47
- }
48
-
49
- describe('NormalShrimpTop vision thresholds', () => {
50
- it('starts backing off at the shrimp vision range', () => {
51
- const top = new NormalShrimpTop();
52
-
53
- top.tick(stateWithStranger(270), context());
54
-
55
- expect(top.subGoal).toBeInstanceOf(KeepAwayGoal);
56
- });
57
-
58
- it('does not start backing off just outside the vision enter range', () => {
59
- const top = new NormalShrimpTop();
60
-
61
- top.tick(stateWithStranger(271), context());
62
-
63
- expect(top.subGoal).not.toBeInstanceOf(KeepAwayGoal);
64
- });
65
-
66
- it('keeps backing off through the vision exit buffer', () => {
67
- const top = new NormalShrimpTop();
68
- const ctx = context();
69
-
70
- top.tick(stateWithStranger(270), ctx);
71
- expect(top.subGoal).toBeInstanceOf(KeepAwayGoal);
72
-
73
- top.tick(stateWithStranger(299), ctx);
74
- expect(top.subGoal).toBeInstanceOf(KeepAwayGoal);
75
-
76
- top.tick(stateWithStranger(300), ctx);
77
- expect(top.subGoal).not.toBeInstanceOf(KeepAwayGoal);
78
- });
79
-
80
- it('does not keep corpse-report state or direct-report messaging during octopus time', () => {
81
- const top = new NormalShrimpTop();
82
- const ctx = context({
83
- octopusTimeActive: true,
84
- reportCorpseTarget: { name: 'body', room: 'control', x: 0, y: 0 },
85
- knownCorpses: [{ name: 'body', room: 'control', x: 0, y: 0 }],
86
- });
87
-
88
- top.tick({
89
- ...stateWithStranger(100),
90
- corpses: [{ name: 'body', room: 'control', x: 0, y: 0, distance: 0 }],
91
- }, ctx);
92
-
93
- expect(ctx.reportCorpseTarget).toBeNull();
94
- expect(ctx.notifications.join('\n')).not.toContain('直接报警');
95
- });
96
-
97
- it('hard-avoids hostileTargets even outside the normal stranger enter range', () => {
98
- const top = new NormalShrimpTop([], [2]);
99
-
100
- top.tick(stateWithStranger(500), context());
101
-
102
- expect(top.subGoal).toBeInstanceOf(KeepAwayGoal);
103
- });
104
-
105
- it('gives trustedTargets priority over hostileTargets', () => {
106
- const top = new NormalShrimpTop([], [2], [2]);
107
-
108
- top.tick(stateWithStranger(100), context());
109
-
110
- expect(top.subGoal).not.toBeInstanceOf(KeepAwayGoal);
111
- });
112
- });
@@ -1,248 +0,0 @@
1
- import type { GameState, PlayerInfo } from '../../sdk/types.js';
2
- import {
3
- corpseAtScene,
4
- dist,
5
- firstAvailableTask,
6
- hasKnownCorpse,
7
- matchesAnyTarget,
8
- nonTeammatesVisible,
9
- PROGRESS_INTERVAL_MS,
10
- reportCorpseDecision,
11
- SHRIMP_VISION_RANGE,
12
- SHRIMP_VISION_RELEASE_RANGE,
13
- taskMoveDecision,
14
- } from '../game-utils.js';
15
- import type { BehaviorDecision, StrategyContext } from '../types.js';
16
- import { GreetingTracker } from '../greeting.js';
17
- import { Goal } from './goal.js';
18
- import { KeepAwayGoal, type KeepAwayGoalOptions, type ThreatResolver } from './keep-away-goal.js';
19
- import { SafeTaskOrPatrolGoal } from './safe-task-goal.js';
20
-
21
- const SUB_PRIORITY = 0.5;
22
- /** 陌生人贴近到这个距离才触发拉开(B 档入口)。 */
23
- const STRANGER_TRIGGER_RADIUS = SHRIMP_VISION_RANGE;
24
- /** B 档 KeepAwayGoal 的交战兼结束半径:270 进 / 300 出,天然滞回。 */
25
- const STRANGER_RELEASE_RADIUS = SHRIMP_VISION_RELEASE_RANGE;
26
- /** 目击者记忆 TTL;0 表示只按当前轮可见玩家判断。 */
27
- const WITNESS_MEMORY_MS = 0;
28
- /** 近期见过这么多个陌生人即豁免 B 档——蟹不敢当众动手,独处单个陌生人才危险。 */
29
- const WITNESS_EXEMPT_COUNT = 2;
30
- const TASK_RETURN_INERTIA_MS = 2_000;
31
- const FLEE_BAD_KEY = 'shrimp-flee-bad';
32
- const STRANGER_KEY = 'shrimp-stranger-distance';
33
-
34
- type Tier = 'flee-bad' | 'keep-distance' | 'task';
35
-
36
- /**
37
- * 普通虾·记忆进阶版(好人、不带刀)的核心 Goal,按行为表逐条判断,命中即执行:
38
- *
39
- * - P0 发现尸体:一律报警(reportCorpseDecision),并按参数名单描述尸体旁玩家。
40
- * - P1 规避危险:
41
- * · A 视野里有 hostileTargets 指定的危险玩家 → 寻路躲避(KeepAwayGoal,不限距离)。
42
- * · B 无 trustedTargets 同伴且其他玩家贴近(≤270px)→ 先拉开距离(KeepAwayGoal,拉开到 300px 即回任务)。
43
- * 目击者豁免:当前见到 ≥2 个陌生人时不触发后撤(蟹不敢当众动手,独处才危险);
44
- * 进行中的后撤也会重新判定,只有仍是单陌生人危险时才拉满到 300px。豁免期间陌生人也不算任务威胁点。
45
- * - P2 紧急任务:无危险时优先处理。
46
- * - P3 否则做任务 / 巡逻(SafeTaskOrPatrolGoal:测地最近、威胁旁/途经威胁的任务硬排除、带粘性)。
47
- *
48
- * 「认定坏人」「可信同伴」「天堂鱼」全部来自策略参数名单。
49
- * 队友由游戏事实判定(nonTeammatesVisible)。有可信同伴在场时不对陌生人触发 B 档。
50
- */
51
- export class NormalShrimpTop extends Goal {
52
- private readonly taskGoal = new SafeTaskOrPatrolGoal(
53
- // 豁免期间陌生人不算威胁点(与 B 档不触发保持视野半径对齐),认定坏人始终算。
54
- (s, c) => nonTeammatesVisible(s, c)
55
- .filter(p => !this.isTrusted(p, c))
56
- .filter(p => this.isHostile(p, c) || !this.witnessExempt)
57
- .map(p => ({ x: p.x, y: p.y })),
58
- );
59
- private readonly strangerSeenAt = new Map<string, number>();
60
- private witnessExempt = false;
61
- private readonly corpseWitnessNotified = new Set<string>();
62
- private readonly greeting: GreetingTracker;
63
-
64
- constructor(
65
- greetingPhrases: string[] = [],
66
- private readonly hostileTargets: number[] = [],
67
- private readonly trustedTargets: number[] = [],
68
- private readonly paradiseFishTargets: number[] = [],
69
- ) {
70
- super();
71
- this.greeting = new GreetingTracker(greetingPhrases);
72
- }
73
-
74
- tick(state: GameState, ctx: StrategyContext): BehaviorDecision[] {
75
- const visible = nonTeammatesVisible(state, ctx);
76
- this.updateWitnessMemory(visible, ctx);
77
- const decisions: BehaviorDecision[] = [];
78
- const greeting = this.greeting.tryGreeting(state);
79
- if (greeting) decisions.push(greeting);
80
-
81
- // ── P0 发现尸体 → 报警 ──
82
- // 章鱼时间服务端禁用报尸,reportCorpseDecision 本就会返回 null;此处把整块 P0 一并跳过,否则
83
- // notifyCorpseWitnesses 仍会推「尸体旁发现…,直接报警」这类提示,误导 Agent 以为仍应报尸召集会议。
84
- // 跳过后落到后续 P1 躲避 / P3 任务巡逻的生存分支,同时清掉之前“靠近尸体准备报告”的残留状态。
85
- if (ctx.octopusTimeActive) {
86
- ctx.reportCorpseTarget = null;
87
- this.corpseWitnessNotified.clear();
88
- } else if (hasKnownCorpse(ctx)) {
89
- // 「尸体旁目击者」只在此刻确实站在命案现场(当帧视野有尸体)时才标注——否则会把后来路上
90
- // 遇见的人误报成目击者。报尸本身可以追着记忆里已离开视野的尸体走回去。
91
- if (corpseAtScene(state)) this.notifyCorpseWitnesses(visible, ctx);
92
- else this.corpseWitnessNotified.clear();
93
- const report = reportCorpseDecision(state, ctx, { respectBlock: true });
94
- if (report) {
95
- this.clearSub();
96
- return [report, ...decisions];
97
- }
98
- // 报告短暂受阻时继续执行后续分支,避免在尸体旁空站。
99
- } else {
100
- this.corpseWitnessNotified.clear();
101
- }
102
-
103
- // ── P1-A 视野里有认定坏人 → 寻路躲避 ──
104
- const threats = visible.filter(p => this.isHostile(p, ctx));
105
- if (threats.length > 0) {
106
- this.taskGoal.planTask(state, ctx, { holdUnsafeCurrentForMs: TASK_RETURN_INERTIA_MS });
107
- this.setKeepAway(FLEE_BAD_KEY, (s, c) => nonTeammatesVisible(s, c).filter(p => this.isHostile(p, c)), {
108
- threatRadius: Infinity,
109
- noun: '认定坏人',
110
- });
111
- this.emitProgress(state, ctx, visible, 'flee-bad');
112
- return decisions;
113
- }
114
-
115
- // ── P1-B 无可信同伴且陌生人贴近 → 拉开距离再做任务 ──
116
- const trustedVisible = visible.some(p => this.isTrusted(p, ctx));
117
- if (!trustedVisible) {
118
- const you = state.you;
119
- const strangerClose = visible.some(p =>
120
- !this.isTrusted(p, ctx) && (p.distance ?? dist(p.x, p.y, you.x, you.y)) <= STRANGER_TRIGGER_RADIUS);
121
- const worker = this.subGoal;
122
- const stillBackingOff = worker instanceof KeepAwayGoal && worker.key === STRANGER_KEY && !worker.isFinish(state, ctx);
123
- // 第二个陌生人加入时重新判定,豁免生效后不继续旧的后撤。
124
- if (!this.witnessExempt && (strangerClose || stillBackingOff)) {
125
- this.taskGoal.planTask(state, ctx, { holdUnsafeCurrentForMs: TASK_RETURN_INERTIA_MS });
126
- this.setKeepAway(STRANGER_KEY, (s, c) => nonTeammatesVisible(s, c).filter(p => !this.isTrusted(p, c)), {
127
- threatRadius: STRANGER_RELEASE_RADIUS,
128
- noun: '陌生人',
129
- planOpts: { steps: 4 },
130
- });
131
- this.emitProgress(state, ctx, visible, 'keep-distance');
132
- return decisions;
133
- }
134
- }
135
-
136
- // ── P2 紧急任务 ──
137
- const emergency = firstAvailableTask([], t => t.faction !== 'crab', ctx.emergency, ctx.blockedMoveTarget);
138
- if (emergency) {
139
- this.clearSub();
140
- return [taskMoveDecision(state, ctx, emergency), ...decisions];
141
- }
142
-
143
- // ── P3 兜底 → 做任务 / 巡逻 ──
144
- this.clearSub();
145
- const work = this.taskGoal.tick(state, ctx);
146
- this.emitProgress(state, ctx, visible, 'task');
147
- return [...work, ...decisions];
148
- }
149
-
150
- /**
151
- * 目击者豁免:用 TTL 记忆平滑陌生人计数;当前设为 0,只看本轮可见玩家。
152
- */
153
- private updateWitnessMemory(visible: PlayerInfo[], ctx: StrategyContext): void {
154
- const now = Date.now();
155
- for (const p of visible) {
156
- if (this.isTrusted(p, ctx)) continue;
157
- const key = p.name || String(p.seat ?? '');
158
- if (key) this.strangerSeenAt.set(key, now);
159
- }
160
- for (const [key, at] of this.strangerSeenAt) {
161
- if (now - at > WITNESS_MEMORY_MS) this.strangerSeenAt.delete(key);
162
- }
163
- this.witnessExempt = this.strangerSeenAt.size >= WITNESS_EXEMPT_COUNT;
164
- }
165
-
166
- /** hostileTargets 中且不在 trustedTargets 中的玩家。 */
167
- private isHostile(p: PlayerInfo, ctx: StrategyContext): boolean {
168
- return !this.isTrusted(p, ctx) && matchesAnyTarget(p, this.hostileTargets, ctx);
169
- }
170
-
171
- /** trustedTargets 中的可信同伴;与 hostileTargets 重叠时优先。 */
172
- private isTrusted(p: PlayerInfo, ctx: StrategyContext): boolean {
173
- return matchesAnyTarget(p, this.trustedTargets, ctx);
174
- }
175
-
176
- private setKeepAway(key: string, resolve: ThreatResolver, options: KeepAwayGoalOptions): void {
177
- const worker = this.subGoal;
178
- if (worker instanceof KeepAwayGoal && worker.key === key) return;
179
- if (this.subGoal) this.removeSubGoal();
180
- this.setSubGoal(new KeepAwayGoal(key, resolve, options), SUB_PRIORITY);
181
- }
182
-
183
- private clearSub(): void {
184
- if (this.subGoal) this.removeSubGoal();
185
- }
186
-
187
- private notifyCorpseWitnesses(visible: PlayerInfo[], ctx: StrategyContext): void {
188
- const bad: string[] = [];
189
- const paradise: string[] = [];
190
- const unknown: string[] = [];
191
- const trusted: string[] = [];
192
-
193
- for (const player of visible) {
194
- const key = player.name || String(player.seat ?? '');
195
- if (!key || this.corpseWitnessNotified.has(key)) continue;
196
- this.corpseWitnessNotified.add(key);
197
-
198
- if (this.isHostile(player, ctx)) bad.push(player.name);
199
- else if (this.isKnownParadiseFish(player, ctx)) paradise.push(player.name);
200
- else if (this.isTrusted(player, ctx)) trusted.push(player.name);
201
- else unknown.push(player.name);
202
- }
203
-
204
- if (bad.length > 0) ctx.notifications.push(`尸体旁发现认定坏人${bad.join('、')},直接报警。`);
205
- if (paradise.length > 0) ctx.notifications.push(`尸体旁发现天堂鱼${paradise.join('、')},直接报警。`);
206
- if (unknown.length > 0) ctx.notifications.push(`尸体旁发现身份不明者${unknown.join('、')},直接报警;可按判断更新 hostileTargets。`);
207
- if (trusted.length > 0) ctx.notifications.push(`尸体旁发现可信同伴${trusted.join('、')},仍直接报警;建议复核 trustedTargets。`);
208
- }
209
-
210
- private isKnownParadiseFish(p: PlayerInfo, ctx: StrategyContext): boolean {
211
- return matchesAnyTarget(p, this.paradiseFishTargets, ctx);
212
- }
213
-
214
- private emitProgress(state: GameState, ctx: StrategyContext, visible: PlayerInfo[], tier: Tier): void {
215
- const now = Date.now();
216
- if (now - ctx.lastProgressNotifyAt < PROGRESS_INTERVAL_MS) return;
217
- ctx.lastProgressNotifyAt = now;
218
-
219
- const room = state.you.room ?? '未知';
220
- const completed = ctx.taskData.filter(t => t.status === 'completed').length;
221
- const total = ctx.taskData.filter(t => t.faction !== 'crab').length;
222
- const current = this.taskGoal.currentTask;
223
-
224
- let msg = `[进度] 当前在${room}`;
225
- if (tier === 'flee-bad') {
226
- const names = visible.filter(p => this.isHostile(p, ctx)).map(p => p.name).join('、');
227
- msg += `,发现认定坏人${names},正在远离。`;
228
- } else if (tier === 'keep-distance') {
229
- msg += `,陌生人靠得太近,先拉开距离再做任务。`;
230
- } else if (visible.length === 0) {
231
- msg += ',附近无人,做任务/巡逻。';
232
- } else if (visible.some(p => this.isTrusted(p, ctx))) {
233
- msg += `,附近有可信同伴,结伴做任务。`;
234
- } else if (this.witnessExempt && visible.length >= 2) {
235
- msg += `,附近${visible.length}个陌生人互为目击者,照常做任务。`;
236
- } else {
237
- msg += `,附近有${visible.length}人,继续做任务/巡逻。`;
238
- }
239
- if (current) {
240
- msg += ` 当前任务目标:${current.room}「${current.task_name}」。`;
241
- }
242
- msg += ` 已完成 ${completed}/${total} 个任务。`;
243
- if (state.emergency) {
244
- msg += ` 紧急任务进行中!`;
245
- }
246
- ctx.notifications.push(msg);
247
- }
248
- }
@@ -1,203 +0,0 @@
1
- import { describe, expect, it } from 'vitest';
2
- import type { GameState } from '../../sdk/types.js';
3
- import type { StrategyContext } from '../types.js';
4
- import { KeepAwayGoal } from './keep-away-goal.js';
5
- import { ParadiseFishTop } from './paradise-fish-top.js';
6
-
7
- function state(overrides: Partial<GameState> = {}): GameState {
8
- return {
9
- phase: 'wandering',
10
- tick: 1,
11
- you: {
12
- name: 'paradise',
13
- x: 1502,
14
- y: 2002,
15
- room: 'control',
16
- role: 'neutral_paradise_fish',
17
- faction: 'neutral',
18
- is_alive: true,
19
- },
20
- your_tasks: [],
21
- players: [],
22
- corpses: [],
23
- stale: false,
24
- ...overrides,
25
- };
26
- }
27
-
28
- function context(overrides: Partial<StrategyContext> = {}): StrategyContext {
29
- return {
30
- taskData: [],
31
- emergency: null,
32
- taskLocalBlockedUntil: 0,
33
- reportCorpseTarget: null,
34
- reportBlockedUntil: 0,
35
- notifications: [],
36
- lastProgressNotifyAt: Date.now(),
37
- teammates: new Set(),
38
- rooms: [
39
- { name: 'danger-route', x: 1602, y: 1402 },
40
- { name: 'safe-route', x: 2602, y: 586 },
41
- ],
42
- playerNamesBySeat: {},
43
- forcePatrolAdvance: false,
44
- blockedMoveTarget: null,
45
- mySeat: 1,
46
- speechNotifications: [],
47
- agentAlerts: [],
48
- ...overrides,
49
- };
50
- }
51
-
52
- describe('ParadiseFishTop patrol routing', () => {
53
- it('keeps recent avoid points when selecting a patrol target after losing sight', () => {
54
- const top = new ParadiseFishTop();
55
- const ctx = context();
56
-
57
- top.tick(state({
58
- you: { ...state().you, x: 2418, y: 590 },
59
- players: [{ name: 'stranger', x: 1986, y: 994, room: 'control', distance: 591 }],
60
- }), ctx);
61
-
62
- const decisions = top.tick(state({
63
- you: { ...state().you, x: 2418, y: 590 },
64
- }), ctx);
65
-
66
- expect(decisions).toHaveLength(1);
67
- expect(decisions[0].action.type).toBe('move');
68
- expect(decisions[0].action.payload).toMatchObject({ target_x: 2602, target_y: 586 });
69
- });
70
-
71
- it('backs away before lingering near a corpse when only one non-bad player is visible', () => {
72
- const top = new ParadiseFishTop();
73
- const ctx = context({
74
- knownCorpses: [{ name: 'body', room: 'control', x: 2100, y: 1800 }],
75
- });
76
-
77
- const decisions = top.tick(state({
78
- players: [{ name: 'stranger', x: 1986, y: 994, room: 'control', distance: 591 }],
79
- }), ctx);
80
-
81
- expect(decisions).toEqual([]);
82
- expect(top.subGoal).toBeInstanceOf(KeepAwayGoal);
83
- });
84
-
85
- it('does not back away from two visible non-bad players and can still linger near a corpse', () => {
86
- const top = new ParadiseFishTop();
87
- const corpse = { name: 'body', room: 'control', x: 2100, y: 1800 };
88
- const ctx = context({ knownCorpses: [corpse] });
89
-
90
- const decisions = top.tick(state({
91
- players: [
92
- { name: 'stranger-a', x: 1986, y: 994, room: 'control', distance: 591 },
93
- { name: 'stranger-b', x: 2300, y: 1200, room: 'control', distance: 650 },
94
- ],
95
- }), ctx);
96
-
97
- expect(top.subGoal).not.toBeInstanceOf(KeepAwayGoal);
98
- expect(decisions).toHaveLength(1);
99
- expect(decisions[0].action.type).toBe('move');
100
- const { target_x: x, target_y: y } = decisions[0].action.payload;
101
- expect(Math.hypot(x - corpse.x, y - corpse.y)).toBeLessThanOrEqual(100);
102
- });
103
-
104
- it('clears non-bad route avoidance once a second non-bad witness appears', () => {
105
- const top = new ParadiseFishTop();
106
- const ctx = context();
107
-
108
- top.tick(state({
109
- you: { ...state().you, x: 2418, y: 590 },
110
- players: [{ name: 'stranger-a', x: 1986, y: 994, room: 'control', distance: 591 }],
111
- }), ctx);
112
-
113
- const decisions = top.tick(state({
114
- you: { ...state().you, x: 2418, y: 590 },
115
- players: [
116
- { name: 'stranger-a', x: 1986, y: 994, room: 'control', distance: 591 },
117
- { name: 'stranger-b', x: 2600, y: 900, room: 'control', distance: 350 },
118
- ],
119
- }), ctx);
120
-
121
- expect(top.subGoal).not.toBeInstanceOf(KeepAwayGoal);
122
- expect(decisions).toHaveLength(1);
123
- expect(decisions[0].action.payload).toMatchObject({ target_x: 1602, target_y: 1402 });
124
- });
125
-
126
- it('hard-avoids hostileTargets', () => {
127
- const top = new ParadiseFishTop([], [2]);
128
-
129
- top.tick(state({
130
- players: [{ name: 'danger', seat: 2, x: 1986, y: 994, room: 'control', distance: 591 }],
131
- }), context({ playerNamesBySeat: { '2': 'danger' } }));
132
-
133
- expect(top.subGoal).toBeInstanceOf(KeepAwayGoal);
134
- });
135
-
136
- it('gives trustedTargets priority over hostileTargets', () => {
137
- const top = new ParadiseFishTop([], [2], [2]);
138
-
139
- top.tick(state({
140
- players: [{ name: 'friend', seat: 2, x: 1986, y: 994, room: 'control', distance: 591 }],
141
- }), context({ playerNamesBySeat: { '2': 'friend' } }));
142
-
143
- expect(top.subGoal).not.toBeInstanceOf(KeepAwayGoal);
144
- });
145
-
146
- it('does not resubmit an emergency task after authoritative state says it is running', () => {
147
- const top = new ParadiseFishTop();
148
- const ctx = context({
149
- emergency: {
150
- task_id: 'antidote',
151
- task_name: '解除毒药',
152
- room: 'control',
153
- status: 'emergency',
154
- x: 1502,
155
- y: 2002,
156
- remaining_secs: 30,
157
- },
158
- });
159
- const doingTask = state({
160
- alive_count: 6,
161
- you: {
162
- ...state().you,
163
- doing_task: true,
164
- task_name: '解除毒药',
165
- },
166
- });
167
-
168
- expect(top.tick(doingTask, ctx)).toEqual([]);
169
- expect(top.tick({ ...doingTask, tick: 2 }, ctx)).toEqual([]);
170
- expect(top.subGoal).toBeNull();
171
- });
172
-
173
- it('clears ordinary movement while a task is running', () => {
174
- const top = new ParadiseFishTop();
175
- const ctx = context();
176
-
177
- top.tick(state({
178
- players: [{ name: 'stranger', x: 1986, y: 994, room: 'control', distance: 591 }],
179
- }), ctx);
180
- expect(top.subGoal).toBeInstanceOf(KeepAwayGoal);
181
-
182
- const decisions = top.tick(state({
183
- tick: 2,
184
- you: { ...state().you, doing_task: true, task_name: '解除毒药' },
185
- }), ctx);
186
-
187
- expect(decisions).toEqual([]);
188
- expect(top.subGoal).toBeNull();
189
- });
190
-
191
- it('still escapes an explicitly hostile player while a task is running', () => {
192
- const top = new ParadiseFishTop([], [2]);
193
- const ctx = context({ playerNamesBySeat: { '2': 'danger' } });
194
- const current = state({
195
- you: { ...state().you, doing_task: true, task_name: '解除毒药' },
196
- players: [{ name: 'danger', seat: 2, x: 1580, y: 2002, room: 'control', distance: 78 }],
197
- });
198
-
199
- expect(top.tick(current, ctx)).toEqual([]);
200
- expect(top.subGoal).toBeInstanceOf(KeepAwayGoal);
201
- expect(top.subGoal?.tick(current, ctx)[0]?.action.type).toBe('move');
202
- });
203
- });