Manage D&D 5e combat encounters with turn-based mechanics, spellcasting, attack rolls, and HP tracking...
Orchestrate D&D 5th Edition combat encounters in a training arena setting with full spellcasting support. Handle equipment assignment, spell selection, monster selection, initiative rolls, turn-based combat with weapon attacks OR spell casting, spell slot management, and post-combat healing. Combat follows 5e rules for attack resolution (d20 + bonus vs AC), spell attacks, saving throws, and supports multiple end conditions (victory, defeat, flee, surrender).
Access six Python scripts in the scripts/ directory:
All scripts are located at: ~/.claude/skills/tutorial-4/scripts/
Tutorial 4 adds a complete spellcasting system with spell slot management and three resolution mechanics:
Cantrips (Level 0): Cast unlimited times, no spell slots required
Leveled Spells (Level 1+): Consume spell slots when cast
Spell Attacks (like Fire Bolt):
Saving Throws (like Burning Hands):
Auto-Hit (like Magic Missile):
Each spellcasting class uses a different ability:
Formulas:
For complete spell mechanics documentation, see references/spell-mechanics.md
Follow this workflow when conducting a training arena combat encounter:
On first use, seed the bestiary and spell databases:
python3 ~/.claude/skills/tutorial-4/scripts/bestiary.py seed
python3 ~/.claude/skills/tutorial-4/scripts/spells.py seed
This adds:
assets/data/spells_core.jsonBefore combat, verify the character has equipment:
python3 ~/.claude/skills/tutorial-4/scripts/equipment.py show CHARACTER_NAME
If no equipment found, equip starting gear based on their class:
python3 ~/.claude/skills/tutorial-4/scripts/equipment.py equip CHARACTER_NAME CLASS_NAME
Starting equipment by class:
Initialize the combat encounter:
python3 ~/.claude/skills/tutorial-4/scripts/combat.py start CHARACTER_NAME MAX_CR
MAX_CR calculation: Use character_level / 4 as a guideline. Level 1 character = CR 0.25.
This command outputs JSON containing:
Parse this JSON and display the combat start state to the user in narrative form.
For narrative guidance on setting the scene, see references/narrative-guide.md
Execute turns in initiative order. Continue until an end condition is met.
Ask the user what they want to do:
To execute a weapon attack:
python3 ~/.claude/skills/tutorial-4/scripts/combat.py character-attack CHARACTER_NAME MONSTER_NAME MONSTER_AC MONSTER_HP
The command outputs JSON with:
Parse and narrate the results with dramatic descriptions.
To cast a spell:
First, check if character has spell slots available (for leveled spells). Cantrips don't require slots.
python3 ~/.claude/skills/tutorial-4/scripts/combat.py character-cast CHARACTER_NAME "SPELL_NAME" MONSTER_NAME MONSTER_AC MONSTER_HP 'MONSTER_STATS_JSON'
MONSTER_STATS_JSON must include the monster's abilities for saving throws. Get this from the start combat JSON.
The command outputs JSON with:
After casting a leveled spell, the character's spell slots are automatically updated in the database.
For detailed spell casting narrative examples, see references/narrative-guide.md
The monster always attacks (simple AI). Execute the monster's attack:
python3 ~/.claude/skills/tutorial-4/scripts/combat.py monster-attack MONSTER_NAME MONSTER_ATTACK_BONUS MONSTER_DAMAGE CHARACTER_NAME CHARACTER_AC
The command outputs JSON with:
The character's HP is automatically updated in the database.
Parse and narrate the monster's attack dramatically.
After each turn, check if combat should end:
If no end condition met, continue to next turn in initiative order.
When combat ends, call the end combat command:
python3 ~/.claude/skills/tutorial-4/scripts/combat.py end CHARACTER_NAME OUTCOME
OUTCOME must be one of: victory, defeat, fled
On victory or fled: Character is automatically healed to full HP and spell slots refreshed.
On defeat: Character HP remains at 0 (or current value). No death saves in this tutorial - just narrative defeat.
Narrate the outcome with appropriate drama and closure.
Show equipment:
python3 ~/.claude/skills/tutorial-4/scripts/equipment.py show CHARACTER_NAME
Calculate AC:
python3 ~/.claude/skills/tutorial-4/scripts/equipment.py ac CHARACTER_NAME
Get weapon stats:
python3 ~/.claude/skills/tutorial-4/scripts/equipment.py weapon CHARACTER_NAME
Returns JSON with weapon name, damage dice, attack bonus, and ability modifier.
List all spells:
python3 ~/.claude/skills/tutorial-4/scripts/spells.py list
List spells by level:
python3 ~/.claude/skills/tutorial-4/scripts/spells.py list --level 1
List spells by class:
python3 ~/.claude/skills/tutorial-4/scripts/spells.py list --class wizard
Show spell details:
python3 ~/.claude/skills/tutorial-4/scripts/spells.py show "Fire Bolt"
Get spell data as JSON:
python3 ~/.claude/skills/tutorial-4/scripts/spells.py get "Fire Bolt"
Take long rest:
python3 ~/.claude/skills/tutorial-4/scripts/character.py long-rest CHARACTER_NAME
Restores character to full HP and refreshes all spell slots.
Show character:
python3 ~/.claude/skills/tutorial-4/scripts/character.py show CHARACTER_NAME
Displays character stats including spell slots (if caster).
List all monsters:
python3 ~/.claude/skills/tutorial-4/scripts/bestiary.py list
List monsters by max CR:
python3 ~/.claude/skills/tutorial-4/scripts/bestiary.py list --max-cr 0.5
Show monster details:
python3 ~/.claude/skills/tutorial-4/scripts/bestiary.py show MONSTER_NAME
Add new monster:
python3 ~/.claude/skills/tutorial-4/scripts/bestiary.py add NAME CR 'JSON_STAT_BLOCK'
JSON stat block format:
{
"ac": 15,
"hp_dice": "2d6",
"hp_avg": 7,
"abilities": {
"str": 8, "dex": 14, "con": 10,
"int": 10, "wis": 8, "cha": 8
},
"attack": {
"name": "Weapon Name",
"bonus": 4,
"damage_dice": "1d6+2",
"damage_type": "slashing"
}
}
Present combat as a radio drama - create vivid scenes with words so the listener can see, hear, and feel the action.
🎲 Roll: 15 + 4 = 19 vs AC 15)For complete narrative guidance with extensive examples, see references/narrative-guide.md
~/.claude/data/dnd-dm.dbHandle these common errors gracefully:
character.py list to see available charactersbestiary.py seed to add initial monstersspells.py seed to add initial spellsbestiary.py addFor detailed information on specific topics, see:
references/narrative-guide.md - Complete radio drama narrative guide with extensive examples for combat openings, attacks, spellcasting, and endingsreferences/spell-mechanics.md - Detailed spellcasting system documentation including spell types, resolution mechanics, spell slots, and class-specific spellcastingreferences/dnd-5e-rules.md - D&D 5th Edition combat rules reference including initiative, attack rolls, damage, AC calculation, proficiency bonuses, and ability scoresLoad these references as needed when conducting combat encounters.