feat(turn): D&D 5e death saves — success/fail tracking

Old model broken: single deathSaves counter, 3=revive. No fails tracked,
successes conflated with fails. DM couldn't model real death save outcomes.

New model (D&D 5e):
- deathSave(enc, id, type, n) — type='success'|'fail', n=1|2|3
- Participant fields: deathSaves (successes), deathFails, isStable, isDying
- 3 successes = stable (0hp unconscious, safe until healed)
- 3 failures = dead (isDying, caller animates removal)
- Toggling same pip = undo that pip
- Returns { patch, log, status } — status: 'stable'|'dead'|'pending'
  isDying back-compat flag kept for App.js removal animation

App.js:
- UI split into green ✓ saves row + red ✕ fails row
- Status badges: Stabilized (emerald) / Dying (red pulse)
- handleDeathSaveChange(participantId, type, saveNumber) — new sig
- makeParticipant init: deathFails + isStable defaults

Data loss: old single-counter participants lose saves (feature didn't work,
no real state to preserve). User confirmed acceptable.

Tests:
- turn.deathsave.test.js: RED-then-GREEN, 3-success stable, 3-fail dead,
  independent tracking, new signature
- Updated 6 callers across characterization/combat/dead-skip/logging/scenario
- Logs UI tests: new title selectors (Success N / Fail N)

243 tests green.
This commit is contained in:
david raistrick
2026-07-04 17:56:14 -04:00
parent f2797595f4
commit 9c90c1500c
10 changed files with 214 additions and 72 deletions
+6 -3
View File
@@ -38,9 +38,12 @@ Backlog of bugs + long-term items. Milestones live in REWORK_PLAN.md.
format for new entries.
- Related: BUG-7 (reorder no undo).
### Death saves: need fails counter
- Current: saves only (`deathSaves` counter, 3 saves = revive). No fails.
- D&D 5e: 3 saves = stable, 3 fails = dead. Track both.
### Death saves: D&D 5e model (FIXED)
- FIXED — separate success/fail tracking. `deathSave(enc, id, type, n)`
type='success'|'fail'. Fields: `deathSaves`, `deathFails`, `isStable`,
`isDying`. 3 success=stable, 3 fail=dead. Returns `{patch, log, status}`.
Old single-counter broken (successes missing, treated saves as fails).
Old data lost (user OK — feature didn't work). UI: green ✓ row + red ✕ row.
### Custom condition field
- Conditions hardcoded list. No way for DM to add custom.