An open-source, interface-driven combat engine for RPGs compatible with D&D 5e SRD mechanics. Built with extensibility, testability, and AI-assisted development in mind.
- Interface-First Architecture: Maximum extensibility through comprehensive interfaces
- SRD 5.1 Compliant: Fully compatible with D&D 5e mechanics while respecting IP
- Test-Driven Development: Minimum 80% code coverage with TDD methodology
- AI-Friendly: Optimized for pair programming with AI assistants
Tip
Check out the Project Roadmap to see our progress and architectural decisions.
- Core D20 Mechanics:
- Ability Scores (STR, DEX, CON, INT, WIS, CHA)
- Modifiers calculated automatically (
(Score - 10) / 2) - Dice Rolling (Standard notation like
1d20+5, Advantage/Disadvantage)
- Creature Management:
- Composition-based architecture (
ICreature,IAbilityScores,IHitPoints) - Serialization: Memento pattern support for saving/loading creature state (JSON compatible)
- Composition-based architecture (
- Action System:
- Command-based Actions (
IAction,AttackAction) - Combat Stats (AC, Initiative, Speed)
- Damage and Healing logic
- Command-based Actions (
- Turn Management:
- Cyclic Initiative system
- Tie-breaking using Dexterity score
- Cyclic Initiative system
- Tie-breaking using Dexterity score
- Round tracking
- Health & Survival:
- Death Saving Throws (Success/Failure tracking, Stabilization)
- Damage Types & Resistances (Resistance, Vulnerability, Immunity logic)
- Ability Checks & Saving Throws
- Spellcasting System:
- Spell Slots & Preparation (Wizard/Sorcerer style support)
- Spell Resolution (Attack Rolls, Saving Throws, Damage)
- Spell Resolution (Attack Rolls, Saving Throws, Damage)
- Content Import (JSON support for Spells)
- Open5e Integration: Direct API access to SRD Spells and Monsters
- Magic Items:
- Attunement System (Max 3 items)
- Passive Bonuses (Features/Conditions applied automatically)
- Item Types (Weapons, Armor, Rings, Wondrous Items)
- Extensible Design:
- Interface-driven architecture
- Dependency Injection friendly
- Result pattern for robust error handling without exceptions
- โ Reproducible Testing: Seed-based dice rolling for deterministic tests
Note
See PLANNED.md for our future feature roadmap, including Content Systems and Advanced Magic.
- .NET 8.0 SDK or higher
- Any IDE that supports C# (Visual Studio, VS Code, Rider, etc.)
# Clone the repository
git clone https://github.com/yourusername/OpenCombatEngine.git
cd OpenCombatEngine
# Build the solution
dotnet build
# Run tests
dotnet test
# Run with coverage
dotnet test --collect:"XPlat Code Coverage"using OpenCombatEngine.Core.Interfaces.Dice;
using OpenCombatEngine.Implementation.Dice;
// Create a dice roller
IDiceRoller roller = new StandardDiceRoller();
// Roll some dice
var result = roller.Roll("3d6+2");
if (result.IsSuccess)
{
Console.WriteLine($"Rolled: {result.Value.Total}");
Console.WriteLine($"Individual rolls: [{string.Join(", ", result.Value.IndividualRolls)}]");
}
// Roll with advantage
var advantage = roller.RollWithAdvantage("1d20+5");
Console.WriteLine($"Advantage result: {advantage.Value}");We include a CLI demo project that showcases the Event System and Reaction System in action.
dotnet run --project src/OpenCombatEngine.Demo/OpenCombatEngine.Demo.csprojOpenCombatEngine/
โโโ src/
โ โโโ OpenCombatEngine.Core/ # Interfaces and contracts only
โ โโโ OpenCombatEngine.Implementation/ # Concrete implementations
โ โโโ OpenCombatEngine.Content/ # Content import system
โโโ tests/
โ โโโ OpenCombatEngine.Core.Tests/ # Comprehensive unit tests
โโโ docs/
โ โโโ architecture/ # Architecture decisions
โ โโโ implementation/ # Implementation details
โโโ examples/
โ โโโ DiceRollerDemo.cs # Usage examples
โโโ .ai/
โโโ project-context.md # AI assistant context
- Interface-First Design: Every feature starts as an interface
- Separation of Concerns: Core interfaces, implementations, and content are separate
- Immutable Data: DTOs and value objects are immutable
- No Exceptions in Public APIs: Result pattern for error handling
- Comprehensive Documentation: XML docs on every public member
- Result Pattern: Safe error handling without exceptions
- Enum Sentinels: Every enum has Unspecified=0 and LastValue for validation
- Test-Driven Development: Tests written before implementation
- Builder Pattern: For complex object construction in tests
This project follows strict coding standards. See .ai/project-context.md for complete details.
- Mandatory XML documentation on ALL public members
- Specific enum patterns with validation sentinels
- Underscore prefix for private fields
- Result pattern for all public APIs
- Minimum 80% test coverage
We welcome contributions! Please ensure:
- All code follows the standards in .ai/project-context.md
- Tests are written BEFORE implementation (TDD)
- All tests pass
- Code coverage remains โฅ80%
- No compiler warnings
- Fork the repository
- Create a feature branch (
feature/add-amazing-feature) - Write tests for your feature
- Implement the feature
- Ensure all tests pass
- Submit a Pull Request
This project is optimized for AI pair programming. If using an AI assistant:
โ See AI Development Guide to get started
We support Antigravity, Cursor, Claude, GPT-4, and GitHub Copilot with comprehensive context files.
- Code License: MIT License
- Game Mechanics: OGL 1.0a compliant
- Content: SRD 5.1 only - no proprietary D&D content
- Trademarks: No use of Wizards of the Coast trademarks
- This project uses game mechanics from the SRD 5.1
- No proprietary monster names (Beholder, Mind Flayer, etc.)
- No copyrighted spell descriptions (mechanics only)
- No setting-specific content (Forgotten Realms, etc.)
For important legal disclaimers, see LEGAL.md.
- API Documentation - Coming soon
- Architecture Decisions
- Implementation Details
- Content Import Formats - Coming soon
- AI Prompt History - Complete development conversations with AI assistants
- Demonstrates AI-assisted development methodology
- Shows design decision evolution
- Useful for contributors using AI tools
See ROADMAP.md for the detailed project roadmap and task history.
# Build
dotnet build
dotnet build --configuration Release
# Test
dotnet test
dotnet test --collect:"XPlat Code Coverage"
dotnet test --filter "FullyQualifiedName~DiceRollerTests"
# Package
dotnet pack --configuration ReleaseThis project adheres to a Code of Conduct. By participating, you are expected to uphold this code.
- Issues - Bug reports and feature requests
- Discussions - General discussions
- Wiki - Community documentation
- James Duane Plotts - Project Lead & Architecture
This project is licensed under the MIT License - see the LICENSE file for details.
Game mechanics are used under the Open Gaming License v1.0a - see docs/legal/OGL.txt for details.
- Wizards of the Coast for the SRD 5.1
- The open-source rpg gaming community
- Contributors to 5e.tools and Open5e for format inspiration
- The .NET and C# communities
Built with โค๏ธ for the rpg gaming community