start_combat
Initiate a D&D combat encounter by specifying participants with initiative order to manage turn-based battles in your campaign.
Instructions
Start a combat encounter.
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| participants | Yes | Combat participants with initiative order |
Implementation Reference
- src/gamemaster_mcp/main.py:616-635 (handler)The main handler function for the 'start_combat' tool. It takes a list of participant dictionaries, sorts them by initiative, updates the game state to enter combat mode with the initiative order and sets the first turn, then returns a formatted string with the initiative order and current turn.def start_combat( participants: Annotated[list[dict], Field(description="Combat participants with initiative order")] ) -> str: """Start a combat encounter.""" # Sort by initiative (highest first) initiative_order = sorted(participants, key=lambda x: x.get("initiative", 0), reverse=True) storage.update_game_state( in_combat=True, initiative_order=initiative_order, current_turn=initiative_order[0]["name"] if initiative_order else None ) order_text = "\n".join([ f"{i+1}. {p['name']} (Initiative: {p.get('initiative', 0)})" for i, p in enumerate(initiative_order) ]) return f"**Combat Started!**\n\n**Initiative Order:**\n{order_text}\n\n**Current Turn:** {initiative_order[0]['name'] if initiative_order else 'None'}"