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.
scripts/
Manual tools. NOT unit tests. Math.random, non-deterministic.
Used to FIND bugs. Unit tests (in */tests/) LOCK them.
replay-combat.js
Drives full combat through live backend via ws adapter (same contract as App). Player display live-updates. Use to watch UI react to state changes.
# start backend + frontend first (see docs/DEVELOPMENT.md)
node scripts/replay-combat.js [rounds] [delayMs]
# defaults: 100 rounds, 200ms/step
Coverage per round: damage, heal, all 22 conditions, toggleActive, removeParticipant, addParticipant (reinforcements), updateParticipant, pause/resume, reorderParticipants, endEncounter. Revives dead each round to sustain full round count.
audit-rotation.js
Pure turn.js simulation of replay op sequence. Detects rotation violations (skip/dupe per round). Pinpointed BUG-1 (addParticipant + pause corrupts).
node scripts/audit-rotation.js
Bisect: comment/uncomment op blocks to isolate triggering combo.
audit-state.js
Expanded invariant bug-finder. 9 check classes per round:
- rotation integrity
- HP bounds
- isActive consistency
- turnOrder no dup ids
- turnOrder ids all active
- currentTurn valid + active
- deathSave range + reset on revive
- removeParticipant orphans
- undo support
node scripts/audit-state.js [rounds] # default 100
See TODO.md for bugs found.