Architecture Overview
System Architecture
The Commander rules engine is organized into several interconnected modules that work together to provide a complete implementation of the Commander format:
-
Game State Management
- Core state tracking and game flow coordination
- Central resource for game metadata and state
- Integration point for all other systems
-
Player Management
- Player data structures and tracking
- Life total management (starting at 40)
- Commander damage tracking
-
Command Zone Management
- Special zone for Commander cards
- Commander casting and tax implementation
- Zone transition rules
-
Turn Structure & Phases
- Complete turn sequence implementation
- Priority passing in multiplayer context
- Phase-based effects and triggers
-
Combat System
- Multiplayer combat implementation
- Commander damage tracking
- Attack declaration and blocking in multiplayer
-
Priority & Stack
- Priority passing algorithms for multiplayer
- Stack implementation for spells and abilities
- Resolution mechanics in complex scenarios
-
State-Based Actions
- Game state checks including commander damage threshold (21)
- Format-specific state checks
- Automatic game actions
-
Special Commander Rules
- Color identity validation
- Commander zone movement replacement effects
- Partner and Background mechanics
-
Multiplayer Politics
- Voting mechanics
- Deal-making systems
- Multiplayer-specific card effects
Integration with Bevy ECS
The Commander implementation leverages Bevy ECS (Entity Component System) for game state management:
#![allow(unused)] fn main() { // Game state as a Bevy resource #[derive(Resource)] pub struct CommanderGameState { // Game state fields } // Player as an entity with components #[derive(Component)] pub struct CommanderPlayer { // Player data } // Systems for game logic fn process_commander_damage( mut game_state: ResMut<CommanderGameState>, query: Query<(&CommanderPlayer, &CommanderDamage)>, ) { // Implementation } }
The architecture allows for clean separation of concerns while maintaining the complex relationships between different aspects of the Commander format.