Files
ttrpg-initiative-tracker/scripts
david raistrick 94b62dc5ab feat(replay+parser): log order+init, detect unexplained order shifts
replay-combat.js:
- Turn line now dumps order=[Name:init,...] (both, not names only)
- reorderParticipants call fixed: real drag (dragged→before target), correct
  signature (ids not array). Was broken (passed array, func wants ids,
  swallowed by try/catch silent no-op).

analyze-turns.js:
- Parse order=[Name:init,...] from turn lines
- detectOrderShifts: compare order+init between consecutive turns. Flag shifts
  NOT explained by logged reorder, roster change (add/remove), or init change.
  Catches display/rotation divergence (invariant: display===turnOrderIds===nextTurn).
- Report order shifts count + sample. CLEAN requires 0 shifts.

Result: 100-round replay CLEAN (0 skips, 0 doubles, 0 shifts).
Note: shift detector reads turnOrderIds dump. reorder still leaves turnOrderIds
unchanged (BUG-6) — Path A (step 3) aligns display+rotation, then shift
detector catches true divergence.
2026-07-01 15:37:56 -04:00
..

scripts/

Manual demo tool. NOT test.

replay-combat.js

Live backend demo. Drives full combat via ws adapter (same contract as App). Player display live-updates. 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.

See also

  • tests/audit/ — exploratory bug-finders (manual run, non-deterministic)
  • {shared,server,src}/tests/ — jest unit/integration/characterization
  • scratch/ — gitignored throwaway