create_encounter
Generate D&D 5e combat encounters with participants, terrain, and initiative tracking for roleplaying games.
Instructions
Create a D&D 5e combat encounter with participants, terrain, and initiative tracking
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| seed | No | ||
| participants | Yes | ||
| terrain | No | ||
| lighting | No | bright | |
| surprise | No |
Implementation Reference
- src/registry.ts:755-773 (registration)Registration of the 'create_encounter' tool, including name, description, input schema conversion from Zod schema, and handler function that validates arguments using createEncounterSchema and calls the createEncounter function to perform the logic.create_encounter: { name: 'create_encounter', description: 'Create a D&D 5e combat encounter with participants, terrain, and initiative tracking', inputSchema: toJsonSchema(createEncounterSchema), handler: async (args) => { try { const validated = createEncounterSchema.parse(args); const result = createEncounter(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:759-772 (handler)The tool handler executes the core logic: Zod validation with createEncounterSchema, execution of createEncounter(validated), and formatting success/error response.handler: async (args) => { try { const validated = createEncounterSchema.parse(args); const result = createEncounter(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:761-761 (schema)Usage of createEncounterSchema for input validation (schema imported from './modules/combat.js'). The schema definition itself is not in this file.const validated = createEncounterSchema.parse(args);
- src/registry.ts:762-762 (helper)Call to the helper function createEncounter which contains the detailed implementation logic (imported from './modules/combat.js').const result = createEncounter(validated);
- src/registry.ts:225-225 (registration)Import statement bringing in createEncounter function and createEncounterSchema 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';