Combat Phases
Overview
The Combat Phase in Commander follows the standard Magic: The Gathering combat sequence, with special considerations for the multiplayer nature of the format. This document provides an overview of the combat phase structure and links to detailed implementation documentation for each step.
Combat Phase Sequence
The Combat Phase consists of five distinct steps:
- Beginning of Combat Step - The phase begins and "at beginning of combat" triggered abilities go on the stack
- Declare Attackers Step - The active player declares attackers and "when attacks" triggered abilities go on the stack
- Declare Blockers Step - Each defending player declares blockers and "when blocks/blocked" triggered abilities go on the stack
- Combat Damage Step - Combat damage is assigned and dealt, and "when deals damage" triggered abilities go on the stack
- End of Combat Step - The phase ends and "at end of combat" triggered abilities go on the stack
Implementation Architecture
Combat phases are implemented using a combination of phase-specific systems and a shared combat state:
#![allow(unused)] fn main() { #[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)] pub enum CombatStep { Beginning, DeclareAttackers, DeclareBlockers, FirstStrike, CombatDamage, End, } // Systems for handling different combat steps pub fn beginning_of_combat_system( mut combat_system: ResMut<CombatSystem>, turn_manager: Res<TurnManager>, mut commands: Commands, // Other system parameters ) { // Implementation } pub fn declare_attackers_system( mut combat_system: ResMut<CombatSystem>, turn_manager: Res<TurnManager>, // Other system parameters ) { // Implementation } // And so on for other combat steps }
Detailed Phase Documentation
Each combat step has its own specialized implementation with unique rules and edge cases:
- Beginning of Combat - Initialization of combat and "beginning of combat" triggers
- Declare Attackers - Attack declaration, restrictions, and requirements
- Declare Blockers - Block declaration, restrictions, and requirements
- Combat Damage - Damage assignment, ordering, and resolution
- End of Combat - Combat cleanup and "end of combat" triggers
Combat Phase Transitions
The transition between combat steps is managed by the TurnManager
, which ensures that:
- Each step is processed in the correct order
- Priority is passed to all players in turn order during each step
- The stack is emptied before proceeding to the next step
- Any special effects that modify the combat phase flow are properly handled
Integration with Turn Structure
The combat phase is integrated into the overall turn structure via the TurnManager
:
#![allow(unused)] fn main() { impl TurnManager { pub fn advance_phase(&mut self) -> Result<Phase, TurnError> { self.current_phase = match self.current_phase { // Other phases... Phase::Combat(CombatStep::Beginning) => Phase::Combat(CombatStep::DeclareAttackers), Phase::Combat(CombatStep::DeclareAttackers) => Phase::Combat(CombatStep::DeclareBlockers), Phase::Combat(CombatStep::DeclareBlockers) => { if self.has_first_strike_creatures() { Phase::Combat(CombatStep::FirstStrike) } else { Phase::Combat(CombatStep::CombatDamage) } }, Phase::Combat(CombatStep::FirstStrike) => Phase::Combat(CombatStep::CombatDamage), Phase::Combat(CombatStep::CombatDamage) => Phase::Combat(CombatStep::End), Phase::Combat(CombatStep::End) => Phase::Postcombat(PostcombatStep::Main), // Other phases... }; // Further implementation } } }