4.3 KiB
Combat State Implementation Status
This document compares the CombatState.spec.js requirements with the current implementation.
Summary
Status: ✅ Core functionality implemented, some spec requirements differ from implementation
Test Coverage: All CoAs are tested (193 tests passing)
Implementation vs Specification
✅ Implemented and Tested
TurnSystem CoAs
-
CoA 1: Initiative Roll ✅
- Spec: Sort by Speed stat (Highest First)
- Implementation: Uses chargeMeter-based system (speed * 5 for initial charge)
- Status: Functional but uses different algorithm (charge-based vs direct speed sorting)
- Test: ✅ Passing
-
CoA 2: Turn Start Hygiene - AP Reset ✅
- Spec: Reset currentAP to baseAP when turn begins
- Implementation: Units get full AP (10) when charge reaches 100
- Status: ✅ Implemented
- Test: ✅ Passing
-
CoA 2: Turn Start Hygiene - Status Effects ⚠️
- Spec: Status effects (DoTs) must tick
- Implementation: Not yet implemented
- Status: ⚠️ Gap documented in tests
- Test: ⚠️ Placeholder test documents gap
-
CoA 2: Turn Start Hygiene - Cooldowns ⚠️
- Spec: Cooldowns must decrement
- Implementation: Not yet implemented
- Status: ⚠️ Gap documented in tests
- Test: ⚠️ Placeholder test documents gap
-
CoA 3: Cycling ✅
- Spec: endTurn() moves to next unit, increments round when queue empty
- Implementation: ✅ endTurn() advances queue, round tracking exists but doesn't increment
- Status: ✅ Functional (round increment needs implementation)
- Test: ✅ Passing
MovementSystem CoAs
-
CoA 1: Validation ✅
- Spec: Fail if blocked/occupied, no path, insufficient AP
- Implementation: ✅ All validations implemented
- Status: ✅ Fully implemented
- Tests: ✅ All passing
-
CoA 2: Execution ✅
- Spec: Update position, grid, deduct AP
- Implementation: ✅ All requirements met
- Status: ✅ Fully implemented
- Tests: ✅ All passing
-
CoA 3: Path Snapping ⚠️
- Spec: Move to furthest reachable tile if target unreachable (optional QoL)
- Implementation: Not implemented
- Status: ⚠️ Optional feature - gap documented
- Test: ⚠️ Placeholder test documents gap
⚠️ Interface Differences
The current CombatState interface differs from the spec:
| Spec Requirement | Current Implementation | Status |
|---|---|---|
phase: CombatPhase |
Not present | ⚠️ Gap |
isActive: boolean |
Not present | ⚠️ Gap |
activeUnitId: string | null |
activeUnit: UnitStatus | null |
⚠️ Different structure |
turnQueue: string[] |
turnQueue: QueueEntry[] |
⚠️ Different structure |
round: number |
roundNumber: number |
✅ Similar (different name) |
Note: The current implementation uses a richer structure (objects instead of IDs) which may be more useful for the UI, but doesn't match the spec exactly.
Architecture Differences
Spec Suggests:
- Separate
TurnSystem.jsclass - Separate
MovementSystem.jsclass - Event dispatching (combat-start, turn-start, turn-end)
Current Implementation:
- Logic integrated into
GameLoop.js - No separate system classes
- State managed via
GameStateManager
Recommendations
High Priority
- ✅ Status Effect Ticking: Implement DoT processing on turn start
- ✅ Cooldown Decrementing: Implement cooldown reduction on turn start
- ⚠️ Round Incrementing: Implement round counter increment when queue cycles
Medium Priority
- ⚠️ Phase Tracking: Add
phaseproperty to CombatState (if needed for future features) - ⚠️ isActive Flag: Add
isActiveboolean (if needed for state management)
Low Priority (Optional)
- ⚠️ Path Snapping: Implement QoL feature for partial movement
- ⚠️ System Refactoring: Consider extracting TurnSystem and MovementSystem if architecture benefits
Test Coverage
- Total Tests: 193 passing
- CoA Coverage: 100% (all CoAs have tests)
- Code Coverage: 92.13%
All implemented features are fully tested. Gaps are documented with placeholder tests.