dnd-5e-core
Complete D&D 5e Rules Engine - 24 Class Abilities, 20 Racial Traits, 40+ Subclasses, Multiclassing, Advanced Combat, 332 Monsters, 319+ Spells, 49 Magic Items, Treasure System, Conditions. 100% Offline with 8.7MB bundled data.
🚀 Quick Start
pip install dnd-5e-core
from dnd_5e_core.data.loaders import simple_character_generator
from dnd_5e_core import load_monster
from dnd_5e_core.combat import CombatSystem
# Create characters
fighter = simple_character_generator(5, "human", "fighter", "Conan")
wizard = simple_character_generator(5, "elf", "wizard", "Gandalf")
# Load monster
orc = load_monster("orc")
# Combat
combat = CombatSystem(verbose=True)
party = [fighter, wizard]
combat.character_turn(wizard, party, [orc], party)
✨ Features
Complete D&D 5e Implementation
- 24 Class Abilities - Rage, Extra Attack, Sneak Attack, Ki Points, etc.
- 20 Racial Traits - Darkvision, Lucky, Fey Ancestry, Relentless Endurance, etc.
- 40+ Subclasses - Champion, Evocation, Life Domain, etc.
- Multiclassing - Full support with spell slot calculation
- Advanced Combat - Automatic spellcasting, conditions, special attacks
- 49 Magic Items - Rings, Wands, Weapons, Armor with magical properties
- Treasure System - DMG-compliant treasure generation by CR/level
- Conditions System - Poisoned, Paralyzed, Frightened, etc.
Bundled Data (8.7MB)
- 332 Monsters with complete stats and abilities
- 319+ Spells with full descriptions and mechanics
- 65+ Weapons with damage, properties, ranges
- 30+ Armors with AC calculations
- 237+ Equipment items
- 100% Offline - No API calls required
📚 Documentation
- API Reference - Complete API for external projects
- Examples & Demos - Working examples
- Full Applications - Complete games
🎮 Examples
Character Creation
from dnd_5e_core.data.loaders import simple_character_generator
# Automatic abilities and traits
fighter = simple_character_generator(5, "dwarf", "fighter", "Gimli")
# Gets: Extra Attack, Darkvision, Dwarven Resilience, etc.
wizard = simple_character_generator(5, "elf", "wizard", "Elrond")
# Gets: Spellcasting, Darkvision, Fey Ancestry, etc.
Combat System
from dnd_5e_core.combat import CombatSystem
combat = CombatSystem(verbose=True)
# Automatic combat decisions:
# - Spellcasters cast spells from back row
# - Fighters use weapons and special attacks
# - Healing spells used on wounded allies
# - Conditions applied automatically
combat.character_turn(character, party, monsters, party)
combat.monster_turn(monster, monsters, party, party, round_num)
Equipment & Magic Items
from dnd_5e_core.equipment import get_magic_item, get_special_weapon
# Magic items
ring = get_magic_item("ring-of-protection") # +1 AC, +1 saves
wand = get_magic_item("wand-of-magic-missiles") # 7 charges
# Magical weapons
flame_tongue = get_special_weapon("flame-tongue") # +1, +2d6 fire
vorpal_sword = get_special_weapon("vorpal-sword") # Legendary
character.equip(flame_tongue)
Treasure Generation
from dnd_5e_core.mechanics import calculate_treasure_hoard
treasure = calculate_treasure_hoard(
encounter_level=5,
difficulty="hard",
cr=5,
include_items=True
)
print(f"Gold: {treasure['gold']} gp")
print(f"Items: {[item.name for item in treasure['items']]}")
print(f"Total value: {treasure['total_value']} gp")
🏗️ Architecture
UI-Agnostic Design - Use with any interface:
# Your game provides UI
import pygame # or tkinter, web framework, etc.
# dnd-5e-core provides game logic
from dnd_5e_core import Character, Monster, CombatSystem
# Game loop
while running:
# Handle input (your code)
action = get_user_input()
# Process game logic (dnd-5e-core)
if action == "attack":
damage = player.attack(monster)
# Render (your code)
render_game_state(player, monster)
🔧 Advanced Usage
Multiclassing
from dnd_5e_core.mechanics.subclass_system import MulticlassCharacter
# Fighter 5 / Wizard 3
gish = MulticlassCharacter("Elric")
for _ in range(5): gish.add_class_level('fighter')
for _ in range(3): gish.add_class_level('wizard')
print(f"Spell slots: {gish.get_spell_slots_multiclass()}")
Encounter Building
from dnd_5e_core.mechanics import select_monsters_by_encounter_table
monsters, difficulty = select_monsters_by_encounter_table(
encounter_level=5,
available_monsters=all_monsters,
allow_pairs=True
)
Extended Monsters
from dnd_5e_core.entities import get_extended_monster_loader
loader = get_extended_monster_loader()
goblins = loader.search_monsters(name_contains="goblin", min_cr=1)
📦 Installation
For Users
pip install dnd-5e-core
For Developers
git clone https://github.com/codingame-team/dnd-5e-core.git
cd dnd-5e-core
pip install -e .[dev]
🧪 Testing
pytest tests/
python tests/verify_package.py
📄 License
MIT License - See LICENSE file for details.
🤝 Contributing
See CONTRIBUTING.md for guidelines.
📦 For Maintainers
Publishing to PyPI:
- Quick Publish Guide - Fast start guide for publishing
- Publication PyPI - Complete publication documentation
- Setup Token: Run
./setup_pypi_token.shto configure your PyPI credentials
🤖 For AI Agents
New! We've created a comprehensive guide specifically for AI agents integrating this package:
- AI Agent Guide - Complete documentation with patterns, error handling, and integration examples
🔗 Related Projects
- DND5e-Test - Examples and demos
- DnD-5th-Edition-API - Complete applications
- DnD5e-Scenarios - 36 D&D scenarios
Metadata
Release files for dnd-5e-core 0.4.5
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| dnd_5e_core-0.4.5.tar.gz | 3.9 MB | Without provenance | Details for dnd_5e_core-0.4.5.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| dnd_5e_core-0.4.5-py3-none-any.whl | Python 3 | none | any | Details for dnd_5e_core-0.4.5-py3-none-any.whl |
Total release size: 10.5 MB
Release files / dnd_5e_core-0.4.5.tar.gz
| Download URL | dnd_5e_core-0.4.5.tar.gz |
|---|---|
| Size | 3.9 MB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
65e64c07e2ae00350c55ae932f1702d6e2cd0f9040e7efe2ec9ec74babd464c8
|
|
BLAKE2b-256 checksum How to use checksums |
f64be95c7cda72bf624bf95959a8f74f653d0f24f6e75247fe15ec92c7ec3491
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.2.0 CPython/3.13.0
|
Release files / dnd_5e_core-0.4.5-py3-none-any.whl
| Download URL | dnd_5e_core-0.4.5-py3-none-any.whl |
|---|---|
| Size | 6.7 MB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
416782817c7cb4a6dc583c6ed4f0aa2a238f95e8e275b20c20fd711231934f35
|
|
BLAKE2b-256 checksum How to use checksums |
93ecdf10d60ca139a61d31ba65fd5a5c3b8392f042fd363365da24d0e32955cb
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.2.0 CPython/3.13.0
|
Security for dnd-5e-core 0.4.5
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.