a8e88cf0f0
Audit bug: pause fired turn%12, no resume in same iter. nextTurn then called on paused encounter → threw 'Encounter not running'. Throw is correct feature behavior (nextTurn refuses when paused); audit misuse. Fix: togglePause twice (pause+resume) in one iteration, plus guard 'advance-while-paused' check before nextTurn call. Result: 6 audit artifacts → 0 violations / 100 rounds. Confirms BUG-1 resolved as side effect of BUG-2 dup-id fix. Replay verify: 10 rounds, 103 turns, no skip/dupe. TODO: BUG-1 + BUG-2 marked RESOLVED/FIXED.
63 lines
3.0 KiB
Markdown
63 lines
3.0 KiB
Markdown
# TODO
|
|
|
|
## M4 — Initiative skip bug + dead-participant handling
|
|
|
|
### Dead participants must NOT be skipped in turn order
|
|
- Current: dead (HP=0) → `isActive=false` → removed from turn order → skipped
|
|
- WRONG. Dead participants still occupy initiative slot.
|
|
- PCs (unconscious): death saves still resolve on their turn
|
|
- Monsters/NPCs: may still have reaction/reaction-like considerations
|
|
- Saw this problem in game Saturday.
|
|
- Fix: keep dead participants in turnOrderIds; their turn still comes up.
|
|
Damage/death-save UI already gated on HP=0 so row buttons stay usable.
|
|
- Affects: `shared/turn.js` `nextTurn` (filters `isActive`), `applyHpChange`
|
|
(sets isActive=false on death), `computeTurnOrderAfterRemoval`.
|
|
- Characterization tests (`src/tests/Combat.characterization.test.js`) lock CURRENT
|
|
(buggy) behavior — those tests must be UPDATED to desired behavior, not
|
|
preserved. Red desired-test first, then fix.
|
|
|
|
### JUMP_TURN_TO(participantId) manual turn override
|
|
- DM clicks participant → cursor jumps → that participant's turn now.
|
|
- Future NEXT_TURN continues from jumped position.
|
|
- UI button: "Make This Turn"
|
|
- Backend action: new endpoint or via generic doc patch.
|
|
|
|
## Confirmed bugs (tests written, NOT fixed)
|
|
|
|
### BUG-1: addParticipant + pause/resume corrupts turn rotation
|
|
- **RESOLVED** as side effect of BUG-2 fix (dup-id rejection broke chain).
|
|
- Audit: 0 violations / 100 rounds after BUG-2 fix.
|
|
- Replay: 10 rounds clean, no skip/dupe.
|
|
- Audit: 128 violations / 100 rounds, 4 symptom faces.
|
|
- Symptom chain (one bug family):
|
|
1. pause blocks nextTurn advance → totalTurns stays frozen (e.g. 120)
|
|
2. addParticipant re-adds same `r${totalTurns}` id (BUG-2: no dedup)
|
|
3. togglePause resume rebuilds turnOrderIds → dup id appears x2
|
|
4. nextTurn gets stuck on dup id → rotation breaks
|
|
5. eventually nextTurn throws 'Encounter not running'
|
|
- Symptom counts (audit-state.js, 100 rounds):
|
|
62x turnOrder-no-dup, 52x rotation-dupes, 14x nextTurn-throws
|
|
- Repro in replay round 10+: current stuck on one participant forever,
|
|
nextTurn returns same id, round never advances.
|
|
- Clean minimal repro (shared/tests/turn.pause-add.test.js) PASSES = combo
|
|
needs more state than single add+pause. Audit authoritative repro.
|
|
- Clean subsystems (zero violations): HP bounds, isActive, deathSave
|
|
range, conditions, removeParticipant orphans.
|
|
- Real repro = `node scripts/audit-state.js` (or audit-rotation.js).
|
|
|
|
### BUG-2: addParticipant allows duplicate id
|
|
- **FIXED** (commit: addParticipant throws on dup id).
|
|
- Test: `shared/tests/turn.characterization.test.js` 'addParticipant rejects
|
|
duplicate id' — GREEN.
|
|
|
|
## Pipeline
|
|
- [ ] Red test: dead participant still in turnOrderIds, turn still advances to them
|
|
- [ ] Fix `shared/turn.js`: don't drop dead from turn order
|
|
- [ ] Update characterization tests to desired (not preserved) behavior
|
|
(src/tests/Combat.characterization.test.js, etc)
|
|
- [ ] JUMP_TURN_TO red test
|
|
- [ ] JUMP_TURN_TO impl (shared + UI button)
|
|
- [ ] M5 docker-compose
|
|
- [ ] M6 undo rework (transactional events table)
|
|
- [ ] M7 Playwright E2E
|