end_encounter
Conclude combat encounters in ChatRPG by recording outcomes like victory or defeat, generating statistics, and preserving logs for review.
Instructions
End a combat encounter with outcome tracking and optional summary generation. Supports victory, defeat, fled, negotiated outcomes. Can preserve encounter log for review.
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| encounterId | Yes | The encounter to end | |
| outcome | Yes | How combat ended | |
| generateSummary | No | Include combat statistics | |
| preserveLog | No | Keep encounter accessible after end | |
| notes | No | DM notes about the encounter |
Implementation Reference
- src/registry.ts:920-938 (registration)Registration of the 'end_encounter' tool in the central tool registry, including name, description, input schema conversion from Zod endEncounterSchema, and handler wrapper.end_encounter: { name: 'end_encounter', description: 'End a combat encounter with outcome tracking and optional summary generation. Supports victory, defeat, fled, negotiated outcomes. Can preserve encounter log for review.', inputSchema: toJsonSchema(endEncounterSchema), handler: async (args) => { try { const validated = endEncounterSchema.parse(args); const result = endEncounter(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:924-936 (handler)The MCP tool handler for end_encounter. Validates input arguments using endEncounterSchema, executes the core endEncounter function with validated args, and formats success/error responses.handler: async (args) => { try { const validated = endEncounterSchema.parse(args); const result = endEncounter(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:225-225 (schema)Import statement bringing in endEncounterSchema (Zod schema for input validation) and endEncounter (core handler function) 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';