Commit Graph
2 Commits
Author SHA1 Message Date
robertandClaude Fable 5 ea17c5e26e fix: end combat failing when character sync enabled
Character writeback in endEncounter wrote to a bare campaigns/{id} path,
which the firebase adapter passes straight to the SDK — the update hit a
nonexistent top-level doc, threw, and aborted the whole end-combat action
(round never reset, combat stayed running).

- endEncounter now uses ctx.campaignPath (full artifacts/... path from
  App.js), falling back to the bare path for server/test adapters
- writeback failures no longer block ending combat
- regression tests: campaignPath routing, writeback-failure resilience,
  and participants never cleared on end

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
2026-07-31 16:30:00 -04:00
david raistrick fd03ae48c8 Character writeback on encounter end
Campaign-level toggle (CharacterManager, live flip). When ON, ending an
encounter writes each character participant's current HP, Max HP, and AC back
to the campaign roster so they carry into the next encounter.

- shared: buildCharacterParticipant uses defaultCurrentHp (fallback maxHp)
- endEncounter: syncs maxHp/ac/currentHp to campaign players if syncCharacters,
  snapshots old values into undo payload for restore. Works retroactive
  (ctx.campaignId fallback for encounters lacking campaignId field).
- New encounters store campaignId field.
- Undo end-encounter restores character values client-side.
- CharacterManager: styled sync toggle (checkbox badge), stat badges in list
  (HP/Current HP/AC/Init), edit box supports Current HP field.

Tests: 5 writeback cases (off/on/skip monsters/undo snapshot/missing char).
2026-07-08 16:33:21 -04:00