add_pushable_rock
Add pushable rocks to Ice Puzzle levels at specified coordinates to create obstacles and movement challenges for puzzle solving.
Instructions
Add pushable rocks
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| positions | Yes | Positions for pushable rocks |
Implementation Reference
- src/tools/special-elements.ts:233-278 (handler)The add_pushable_rock tool handler that validates input, checks positions, and calls the store method to add pushable rocks to the draft{ name: 'add_pushable_rock', description: 'Add pushable rocks that can be pushed one square by the player', inputSchema: { type: 'object', properties: { positions: { type: 'array', items: { type: 'object', properties: { x: { type: 'number' }, y: { type: 'number' } }, required: ['x', 'y'] }, description: 'Array of positions to place pushable rocks' } }, required: ['positions'] }, handler: async (args: { positions: Position[] }) => { const error = checkActiveDraft(); if (error) { return { content: [{ type: 'text', text: error }] }; } const draft = draftStore.getCurrentDraft()!; for (const pos of args.positions) { const validationError = checkPositionValid(pos.x, pos.y, draft.gridWidth, draft.gridHeight); if (validationError) { return { content: [{ type: 'text', text: validationError }] }; } } draftStore.addPushableRock(args.positions); const result = autoSolveAndVisualize(); return { content: [{ type: 'text', text: `Added pushable rock(s) at ${args.positions.length} position(s)\n\n${result}` }] }; }
- src/store/draft-store.ts:658-673 (handler)The addPushableRock store method that performs the actual state update - dedupes positions, clears existing items at those positions, and updates the draft with new pushable rocksaddPushableRock(positions: Position[]): DraftState { if (!this.currentDraft) { throw new Error('No current draft'); } this.pushHistorySnapshot(); return this.runWithHistorySuspended(() => { const incoming = this.dedupePositions(positions); for (const position of incoming) { this.clearPosition(position.x, position.y); } const pushableRocks = this.dedupePositions([...this.currentDraft!.pushableRocks, ...incoming]); return this.updateDraft({ pushableRocks }, { trackHistory: false }); }); }
- Input schema for add_pushable_rock tool - defines positions array with x, y coordinatesinputSchema: { type: 'object', properties: { positions: { type: 'array', items: { type: 'object', properties: { x: { type: 'number' }, y: { type: 'number' } }, required: ['x', 'y'] }, description: 'Array of positions to place pushable rocks' } }, required: ['positions'] },
- src/tools/special-elements.ts:52-54 (registration)Export function that registers all special element tools including add_pushable_rockexport function getSpecialElementTools(): ToolDefinition[] { return [ {
- src/tools/special-elements.ts:36-50 (helper)Helper functions used by the handler - checkActiveDraft validates a draft exists, checkPositionValid validates coordinates are within grid boundsfunction checkActiveDraft(): string | null { const draft = draftStore.getCurrentDraft(); if (!draft) { return 'No active draft. Use create_level first.'; } return null; } function checkPositionValid(x: number, y: number, width: number, height: number): string | null { const result = validatePosition(x, y, width, height); if (!result.valid) { return result.error || `Position (${x}, ${y}) is out of bounds for ${width}x${height} grid`; } return null; }