A comprehensive web-based battle management system for Dungeons & Dragons campaigns. Manage character presets, organize battles, track initiative, handle HP changes, and more - all through an intuitive web interface.
Perfect for Dungeon Masters who want to focus on storytelling instead of spreadsheets. This battle manager handles all the number crunching, initiative tracking, and character management so you can focus on creating memorable adventures.
- ๐ญ Character Preset Management - Create detailed character templates with full D&D 5e stats
- โ๏ธ Battle Organization - Organize encounters with descriptions and visual badges
- ๐ฒ Initiative System - Automatic sorting with manual reordering when needed
- โค๏ธ HP Management - Group damage/healing with real-time health indicators
- ๐พ Data Persistence - SQLite database with JSON export/import for backups
- ๐จ Modern Interface - Clean, responsive design that works on any device
- โก Real-time Updates - No page reloads, everything updates instantly
Want to start using this right now? Follow these simple steps:
The easiest way to get started! Works on Windows, Mac, and Linux.
-
Install Docker
- Download from docker.com
- Follow the installation wizard for your operating system
-
Download the Project
- Click the green "Code" button โ "Download ZIP"
- Extract the ZIP file to a folder (e.g.,
C:\dnd-battle-manageror~/dnd-battle-manager)
-
Start the Application
- Open Command Prompt (Windows) or Terminal (Mac/Linux)
- Navigate to your extracted folder:
cd C:\dnd-battle-manager # Windows cd ~/dnd-battle-manager # Mac/Linux
- Run this single command:
docker-compose up -d
-
Start Playing
- Open your browser to
http://localhost:8080 - That's it! The application is ready to use
- Open your browser to
-
When You're Done
# Stop the application docker-compose down
- Create Characters: Go to "Presets" โ "Add New Preset" โ Fill in your character details
- Start a Battle: Click "New Battle" โ Give it a name and description
- Add Participants: Choose from your presets or create new characters on the fly
- Manage Combat: Track initiative, apply damage/healing, manage turn order
- Save Your Work: Everything is automatically saved, export to JSON for backups
- Full D&D 5e Support: All six ability scores, AC, HP, passive perception
- Skills & Actions: Custom text fields for abilities, spells, and special actions
- Character Types: Distinguish between PCs, NPCs, and enemies
- Quick Creation: Save time with preset templates
- Visual Badges: Color-coded labels (Active Battle, Boss Fight, Random Encounter, etc.)
- Detailed Descriptions: Add context and notes to each encounter
- Easy Navigation: Clean interface to switch between battles and manage multiple encounters
- Initiative Tracking: Automatic sorting with drag-and-drop reordering
- HP Management: Quick damage/heal buttons with group operations
- Real-time Updates: See changes instantly without page refreshes
- Turn Management: Clear visual indicators for current turn and character status
- Dungeon Masters running D&D 5e campaigns
- Players who want to organize their character sheets
- Groups playing online or in-person
- Anyone who loves organized, efficient gameplay
Found a bug or have a great idea? Contributions are welcome!
- Fork the repository on GitHub
- Create your feature branch
- Make your changes
- Submit a pull request
Report issues on the GitHub Issues page.
This project is licensed under the MIT License - free to use, modify, and distribute.
Note
It is not a secret that AI played a significant role in development of this app.
For developers who want to contribute, modify the code, or build from source:
- PHP 8.1 or higher with the following extensions:
pdo_sqlite(for database operations)sqlite3(for SQLite support)
- Web browser with JavaScript ES6+ support
- Git (for cloning the repository)
-
Clone the Repository
git clone https://github.com/xEdziu/DnD-Battle-Manager.git cd DnD-Battle-Manager -
Install PHP (if not already installed)
- Windows: Download from windows.php.net โ Choose "Thread Safe" ZIP
- Mac: Install via Homebrew:
brew install php - Linux: Install via package manager:
sudo apt install php php-sqlite3(Ubuntu/Debian)
Important
Check if you have sqlite extensions enabled!
-
Verify PHP Installation
php --version
-
Set Up the Database
# The SQLite database will be created automatically on first run # Ensure the application has write permissions in the project directory chmod 755 . chmod 777 data/ # If the data directory exists
-
Start Development Server
php -S localhost:8000
-
Access the Application
- Open your browser to
http://localhost:8000 - The database (
data.sqlite) will be created automatically - Default presets will be initialized on first visit
- Open your browser to
# Build and run for development
docker build -t dnd-battle-manager .
docker run -p 8080:80 -v $(pwd):/var/www/html dnd-battle-manager
# Or use docker-compose for development
docker-compose up -d --buildโโโ index.php # Main entry point and router
โโโ dockerfile # Docker configuration
โโโ docker-compose.yml # Docker Compose setup
โโโ .gitignore # Git ignore file
โโโ .dockerignore # Docker ignore file
โโโ config/
โ โโโ config.php # Application configuration
โโโ includes/
โ โโโ database.php # SQLite database management
โ โโโ utils.php # Helper functions and default presets
โ โโโ BadgeManager.php # Battle badge management
โโโ classes/
โ โโโ PresetManager.php # Character preset operations
โ โโโ BattleManager.php # Battle management logic
โ โโโ ParticipantManager.php # Battle participant handling
โโโ handlers/
โ โโโ preset_handler.php # Preset action handling
โ โโโ battle_handler.php # Battle action handling
โ โโโ import_export_handler.php # Data import/export
โโโ api/
โ โโโ battle_api.php # API endpoints for battle operations
โโโ views/
โ โโโ layout/ # Header, footer, navigation templates
โ โโโ battles/ # Battle-related views and components
โ โโโ presets/ # Preset management views
โ โโโ badges/ # Badge management views
โโโ assets/
โ โโโ js/
โ โโโ app.js # Main frontend JavaScript
โ โโโ battle-detail.js # Battle detail page scripts
โ โโโ modules/ # Modular JavaScript components
โโโ data/
โ โโโ .gitkeep # Keep data directory in git
โโโ data.sqlite # SQLite database (auto-created)
โโโ data.json # JSON export/import file (auto-created)
The application uses SQLite with the following main tables:
- presets: Character templates with stats and abilities
- battles: Battle information with names and descriptions
- participants: Characters participating in specific battles
- badges: Visual labels for organizing battles
The application handles these main actions:
POST /?action=create_battle- Create new battlePOST /?action=update_battle_info- Update battle name/descriptionPOST /?action=update_battle_badge- Update battle badgePOST /?action=delete_battle- Remove battlePOST /?action=add_participant- Add character to battlePOST /?action=remove_participant- Remove character from battle
POST /?action=add_preset- Create character presetPOST /?action=edit_preset- Update character presetPOST /?action=delete_preset- Remove character preset
POST /?action=damage- Apply damage to participantsPOST /?action=heal- Heal participantsPOST /?action=update_battle- Update initiative/names (legacy method)
- Go to the "Presets" tab
- Click "Add New Preset"
- Fill in character details (name, stats, abilities)
- Choose character type (PC/NPC/Enemy)
- Save the preset
- Create a new battle with a descriptive name
- Add participants from your presets
- Roll or set initiative values
- Use the battle interface to:
- Track HP changes
- Manage turn order
- Remove defeated characters
- Use the "Export" button to download your data as JSON
- Use the "Import" button to restore from a backup file
- Fork the repository
- Create a feature branch (
git checkout -b feature/amazing-feature) - Commit your changes (
git commit -m 'Add amazing feature') - Push to the branch (
git push origin feature/amazing-feature) - Open a Pull Request
This project is licensed under the MIT License - see the LICENSE file for details.
๐ณ Docker Issues
- Make sure Docker Desktop is running
- Check if port 8080 is already in use:
docker psor tryhttp://localhost:8081 - Restart Docker:
docker-compose down && docker-compose up -d
๐พ Database Connection Errors
- Ensure PHP has SQLite support
- Check file permissions on the project directory
- Verify the application directory is writable
๐ JavaScript Errors
- Check browser console (F12) for specific error messages
- Ensure you're using a modern browser (Chrome 60+, Firefox 55+, Safari 12+)
๐ซ Permission Denied
- On Unix systems:
chmod 755 .andchmod 777 data/ - On Windows: Ensure the folder isn't in a restricted location
๐ Port Already in Use
- For PHP: Change the port:
php -S localhost:8001(or any other port) - For Docker: Edit
docker-compose.ymland change8080:80to8081:80
- Check the Issues page for known problems
- Create a new issue with detailed error information
- Include your PHP version, operating system, and browser details
Built with โค๏ธ for tabletop gaming enthusiasts by xEdziu Assisted by Various AI tools