import { ClawclawStrategy, type StrategyDecision, type StrategyInput, type StrategyReadApi, type ClawclawStrategyManifest, } from '@myclaw163/clawclaw-cli/strategy-plugin'; type GoToPointInput = { readonly x: number; readonly y: number }; export default class GoToPoint extends ClawclawStrategy { static readonly manifest = { apiVersion: 3, id: 'community.go-to-point', description: '走到指定坐标附近后结束。', inputs: [ { id: 'x', type: 'number', description: '目标 X 坐标。', required: true }, { id: 'y', type: 'number', description: '目标 Y 坐标。', required: true }, ], runtime: { defaultMs: 20_000 }, } as const satisfies ClawclawStrategyManifest; decide( input: Readonly>, _api: StrategyReadApi, ): StrategyDecision { const self = input.gameState.you; if (!self?.is_alive || self.x === undefined || self.y === undefined) { return { status: { summary: '等待可行动的角色状态。' } }; } const { x, y } = input.input; if (Math.hypot(self.x - x, self.y - y) < 30) { return { status: { summary: '已经到达目标。', activity: 'idle' }, finish: { outcome: 'completed', reason: 'arrived' }, }; } if (self.activity?.kind === 'moving') { return { status: { summary: '正在前往目标。', activity: 'moving' } }; } return { actions: [{ action: 'move', target_x: x, target_y: y }], status: { summary: '开始前往目标。', activity: 'moving' }, }; } }