Thank you for your interest in contributing!
- Fork and clone the repository
- Create a virtual environment:
python -m venv venv source venv/bin/activate # or `venv\Scripts\activate` on Windows
- Install in development mode:
pip install -e .[dev]
- Follow PEP 8 style guide
- Use type hints for all function signatures
- Write docstrings for all public functions/classes (Google style)
- Keep UI logic OUT of this package (this is core logic only)
- Add tests for new features
from typing import List, Optional
from dnd_5e_core.entities import Character, Monster
def attack(attacker: Character, defender: Monster, action_index: int = 0) -> int:
"""
Perform an attack from attacker to defender.
Args:
attacker: The character performing the attack
defender: The target monster
action_index: Index of action to use (default: 0)
Returns:
Total damage dealt to defender
Raises:
ValueError: If action_index is invalid
"""
passRun tests before submitting:
pytest tests/ -vCheck coverage:
pytest tests/ --cov=dnd_5e_core --cov-report=html- Create feature branch:
git checkout -b feature/my-feature - Implement feature with tests
- Ensure all tests pass
- Run linting:
black dnd_5e_core/andflake8 dnd_5e_core/ - Update documentation if needed
- Submit pull request
dnd_5e_core/
├── entities/ # Monster, Character, Sprite
├── races/ # Race, SubRace, Trait, Language
├── classes/ # ClassType, Proficiency
├── equipment/ # Weapon, Armor, Potion, Inventory
├── spells/ # Spell, SpellCaster, SpellSlots
├── combat/ # Action, SpecialAbility, Condition, CombatSystem
├── abilities/ # Abilities, SavingThrow, Skill
├── mechanics/ # Dice, CR, XP, LevelUp
├── data/ # API loader, serialization
└── utils/ # Helpers, constants
- Create a feature branch
- Make your changes
- Add/update tests
- Run tests and linting
- Update CHANGELOG.md
- Submit pull request with clear description
Please update CHANGELOG.md for every release. This repository follows the "Keep a Changelog" format. The CI will enforce that the changelog contains an entry for the version declared in pyproject.toml before merging/publishing.
What to do before publishing:
- Bump the version in
pyproject.toml,setup.py(if used), anddnd_5e_core/__init__.pyto the same value. - Add a section in
CHANGELOG.mdfor the new version using the format below. - Commit the changes and open a PR. The GitHub Actions workflow
.github/workflows/check-changelog.ymlwill verify the changelog entry automatically.
Example changelog entry (copy/paste):
## [0.4.2] - 2026-01-22
### Added
- Short description of the change.
### Fixed
- Short description of the fix.
If the release contains no notable changes, add a short note under the version header (e.g. "No notable changes").
Local checks you can run:
# Verify the changelog contains an entry for the current version
python3 scripts/check_changelog.py
# Build and test locally before publishing
./build_package.sh --clean --buildNotes:
- The scripts
build_package.shandpublish_final.shalso run the changelog check and will fail if the changelog does not contain the expected version header. - The CI workflow will block merges to
mainif the changelog check fails; please ensure your PR updates the changelog accordingly.
Be respectful and inclusive. We welcome contributions from everyone.
Open an issue for discussion before starting major changes.