# Issue #97: Initiative and Combat Round Tracker ## Summary Add an initiative and combat round tracking system to the Combat tab. This includes rolling initiative using the character's Reaction + Intuition + configurable initiative dice, tracking combat rounds, initiative passes, displaying the current initiative score, and showing action economy reminders per pass. ## Implementation Plan ### Step 1: Create CombatTracker model class **File**: `sharedUI/src/commonMain/kotlin/org/shahondin1624/model/charactermodel/CombatTracker.kt` Create a data class (NOT serialized, as combat state is transient/session-only) holding: - `initiativeScore: Int` - Current initiative score (after rolling) - `initiativeDice: Int` - Number of initiative dice (default 1, can be increased by augmentations) - `currentRound: Int` - Current combat round (starts at 1) - `currentPass: Int` - Current initiative pass (starts at 1) - `isInCombat: Boolean` - Whether combat is active - `actionsUsed: Set` - Actions used this pass Create an `ActionType` enum: `FreeAction`, `SimpleAction1`, `SimpleAction2`, `ComplexAction` - In SR5e: each pass you get 1 Free Action + either 2 Simple Actions OR 1 Complex Action Helper functions: - `rollInitiative(reactionPlusIntuition: Int, dice: Int): CombatTracker` - rolls initiative dice, sets score - `nextPass(): CombatTracker` - advances to next pass (reduces initiative by 10), or to next round if score <= 0 - `nextRound(): CombatTracker` - increments round, resets pass to 1 (requires re-rolling initiative) - `resetCombat(): CombatTracker` - resets everything - `useAction(action: ActionType): CombatTracker` - marks action as used - `resetActions(): CombatTracker` - clears used actions for new pass - `hasMultiplePasses(): Boolean` - initiative > 10 means extra passes - `passesRemaining(): Int` - how many initiative passes the character gets this round ### Step 2: Add CombatTrackerPanel UI composable **File**: `sharedUI/src/commonMain/kotlin/org/shahondin1624/lib/components/charactermodel/CombatTrackerPanel.kt` Create the UI panel with: - **Initiative section**: "Roll Initiative" button, configurable initiative dice count (1-5), display current initiative score - **Round tracker**: Display "Round X / Pass Y", increment/reset buttons - **Action economy**: Show available actions per pass (Free, Simple x2 OR Complex), toggle buttons to mark used - Use existing Card/Panel pattern from other panels (DamageMonitorPanel, etc.) ### Step 3: Add test tags for combat tracker **File**: Update `TestTags.kt` with new constants for combat tracker elements. ### Step 4: Add string resources **File**: Update `strings.xml` with all combat tracker labels. ### Step 5: Integrate CombatTrackerPanel into CombatContent **File**: Update `CharacterSheetPage.kt` to add the CombatTrackerPanel above the existing DamageMonitorPanel in the Combat tab. The CombatTracker state will be managed as `remember` state in the CombatContent composable (not persisted) since combat is a session-only activity. ### Step 6: Add unit tests **File**: `sharedUI/src/commonTest/kotlin/org/shahondin1624/CombatTrackerTest.kt` Test: - Initiative rolling produces valid scores - Round counter increments correctly - Pass tracking works (initiative - 10 per pass) - Action economy tracking - Reset functionality ## Acceptance Criteria Checklist 1. [ ] Roll initiative button that uses character's initiative attributes + dice 2. [ ] Combat round counter with increment/reset 3. [ ] Initiative pass tracking for multiple passes 4. [ ] Current initiative score displayed during combat 5. [ ] Action economy reminder per pass