modify_terrain
Modify combat terrain by adding, removing, or clearing obstacles, difficult terrain, water, and hazards to simulate spells, abilities, and environmental effects.
Instructions
Add, remove, or clear terrain in a combat encounter. Supports obstacles, difficult terrain, water, and hazards. Use for dynamic battlefield changes from spells (Wall of Stone, Spike Growth), abilities, or environmental effects.
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| encounterId | Yes | The encounter to modify | |
| operation | Yes | Operation type | |
| terrainType | Yes | Type of terrain | |
| positions | No | Array of "x,y" coordinate strings | |
| hazardDetails | No | Details for hazard terrain | |
| source | No | Source of terrain change (spell, ability, etc.) | |
| duration | No | Rounds until auto-removed |
Implementation Reference
- src/registry.ts:860-878 (registration)Registration of the 'modify_terrain' tool in the central registry. Includes description, input schema conversion from Zod schema, and a handler that performs validation and delegates to the core modifyTerrain implementation.modify_terrain: { name: 'modify_terrain', description: 'Add, remove, or clear terrain in a combat encounter. Supports obstacles, difficult terrain, water, and hazards. Use for dynamic battlefield changes from spells (Wall of Stone, Spike Growth), abilities, or environmental effects.', inputSchema: toJsonSchema(modifyTerrainSchema), handler: async (args) => { try { const validated = modifyTerrainSchema.parse(args); const result = modifyTerrain(validated); return success(result); } catch (err) { if (err instanceof z.ZodError) { const messages = err.errors.map(e => `${e.path.join('.')}: ${e.message}`).join(', '); return error(`Validation failed: ${messages}`); } const message = err instanceof Error ? err.message : String(err); return error(message); } }, },
- src/registry.ts:864-877 (handler)The tool handler function for modify_terrain. It validates the input arguments using modifyTerrainSchema, calls the modifyTerrain function with validated args, and returns the result wrapped in a success response. Handles Zod validation errors and general exceptions.handler: async (args) => { try { const validated = modifyTerrainSchema.parse(args); const result = modifyTerrain(validated); return success(result); } catch (err) { if (err instanceof z.ZodError) { const messages = err.errors.map(e => `${e.path.join('.')}: ${e.message}`).join(', '); return error(`Validation failed: ${messages}`); } const message = err instanceof Error ? err.message : String(err); return error(message); } },
- src/registry.ts:863-863 (schema)Reference to the input schema for the tool, converted from the Zod schema modifyTerrainSchema using toJsonSchema for MCP compatibility.inputSchema: toJsonSchema(modifyTerrainSchema),
- src/registry.ts:225-225 (registration)Import statement bringing in the modifyTerrain function (handler logic) and modifyTerrainSchema from the combat module.import { manageCondition, manageConditionSchema, createEncounter, createEncounterSchema, executeAction, executeActionSchema, advanceTurn, advanceTurnSchema, rollDeathSave, rollDeathSaveSchema, modifyTerrain, modifyTerrainSchema, renderBattlefield, renderBattlefieldSchema, getEncounter, getEncounterSchema, endEncounter, endEncounterSchema, manageEncounter, manageEncounterSchema } from './modules/combat.js';