Phase 8: player view (local/projector) + sync seam

- Player View (/play): read-only projector screen — party HP bars + conditions,
  active-encounter initiative with current turn; enemy HP hidden behind a
  Healthy/Bloodied/Down status band; Fullscreen button
- SyncAdapter seam (src/lib/sync): local-first default via Dexie liveQuery;
  documents where a future networked (WebSocket/CRDT) backend plugs in
- Dashboard + routes get a Player View entry
- Robustness: encountersRepo.mutate() does transactional read-modify-write so
  rapid combat mutations can't overwrite each other (old C19 race); tracker uses it

New player-view e2e. Networked multiplayer backend intentionally deferred.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
This commit is contained in:
2026-06-08 02:07:27 +02:00
parent 1632018ce9
commit 744e91f703
8 changed files with 212 additions and 2 deletions
+13
View File
@@ -164,6 +164,19 @@ export const encountersRepo = {
await db.encounters.put(validated);
},
/**
* Apply a transition by reading the freshest committed state inside a
* transaction, so two rapid mutations can't overwrite each other (the
* read-modify-write race the old app shipped — bug class C19).
*/
async mutate(id: string, fn: (e: Encounter) => Encounter): Promise<void> {
await db.transaction('rw', db.encounters, async () => {
const current = await db.encounters.get(id);
if (!current) return;
await db.encounters.put(encounterSchema.parse({ ...fn(current), updatedAt: now() }));
});
},
async remove(id: string): Promise<void> {
await db.encounters.delete(id);
},