- Map combat HUD on the editor (Round, current combatant, Prev/Next turn) that
drives the active encounter via encountersRepo.mutate(nextTurn/previousTurn).
- The current combatant's linked token glows (MapCanvas activeTokenId).
- Token edit modal gains a "Combat HP" control (−5/−1/+1/+5) for combatant-linked
tokens, writing damage/heal back to the tracker (applyDamage/applyHealing +
logEvent + updateCombatant) — HP now syncs both ways between map and combat.
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
- src/lib/map/vision.ts (pure, tested): blockingSegments (walls + closed doors),
segment intersection, computeVisibleCells (raycast viewer→cell-centre, sight radius).
- BattleMap += dynamicVision + sightRadiusFeet (Dexie v12, backfilled).
- MapEditor: new "Walls" tool (draw wall polylines; click a door to open/close),
a "Vision" toggle (auto-enables fog and reveals from the party), sight-radius field,
and "Reveal from party". Moving a PC token accumulates revealed cells via LoS when
Vision is on. Doors/walls render for the GM (amber=closed, green=open).
- Networked players need no new protocol: revealed cells already travel in the snapshot.
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
- character.portrait + mapToken.image (data URLs, Dexie v10, additive).
- src/lib/img/resize.ts: center-crop + downscale helper (160px tokens / 256px
portraits) keeping IndexedDB + wire payloads small.
- Portrait uploader on the character sheet; token icon uploader in the map token
modal (falls back to the linked character's portrait). Palette PC entries show
the portrait thumbnail.
- Tokens render the image clipped to the circle (HP ring + condition badge on top).
- Realtime: generalized the image channel to many images (map bg + token/portrait
icons), deduped by content and resent on reconnect. Player tokens/party carry an
imageId resolved from the session image cache; party panel shows portraits.
- Also: fix the encounter-picker dropdown text being clipped (drop fixed height).
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
- PWA registerType autoUpdate + skipWaiting/clientsClaim/cleanupOutdatedCaches so
a fresh deploy reaches browsers without a manual hard-reload (the old 'prompt'
served the stale cached bundle, hiding shipped fixes like the polygon outline).
- MapCanvas: always mount the outer container so the ResizeObserver binds even when
the map image arrives late over WebSocket — fixes the networked player view
showing the map at 100% instead of fit ("3x magnified").
- TokenPalette: encounter picker for planned AND active encounters (was active-only),
with per-encounter "+ All" and counts.
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Render the map on a single viewport-sized canvas with a camera transform at
devicePixelRatio (image, fog, drawings, overlay) and draw the grid as crisp 1px
device-space lines — instead of CSS-scaling a natural-resolution bitmap, which
blurred the grid/fog/text at any zoom. Tokens now position in screen space so
their labels stay sharp too. Add live tool feedback via a 'hover' phase: polygon
shows its outline + vertices + rubber-band + fill preview, the brush shows its
footprint, and circle/square AoE preview under the cursor.
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Render maps at natural resolution inside a CSS-transform world layer (zoom,
pan, fit-to-view) instead of shrinking to maxWidth — large maps are now usable.
Pure viewport math in src/lib/map/viewport.ts (unit-tested). New TokenPalette
places party PCs / active-encounter combatants / blanks in one click with dup
detection; tokens gain optional combatantId (Dexie v9) for live encounter HP.
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
- Pure geometry library src/lib/map/* (grid, distance 5e/pf2e/euclid, AoE
circle/cone/line/square, polygon rasterize + point-in-polygon, brush, fog set
algebra, player projection) with unit tests.
- Schema: map tokens gain size/kind/characterId/hp/conditions/gmOnly; maps gain
drawings/gridUnit(feet)/gridType/fogVersion + point/drawing sub-schemas. Dexie v8
additive migration; mapsRepo.get + transactional mutate.
- Editor split into a shared MapCanvas renderer + MapEditor tool state machine:
fog via brush/rectangle/polygon (+ size, reveal-all/hide-all), measurement
(system-aware distance in feet), AoE templates (circle/cone/line/square preview),
drawing annotations (freehand/line/arrow/rect/circle/text, GM-only), pings, and
richer tokens (NxN size, character link with live HP ring, condition dots, edit popover).
- Player-facing projection: toPlayerProjection strips GM-only content; PlayerMapView
renders it read-only with opaque fog; uiStore.activeMapId + 'Show to players'; the
player view now shows the live battle map. enemyStatus extracted to
src/lib/combat/playerProjection.ts (reused, and for Phase 18).
9 geometry unit tests; maps e2e covers upload→token→reveal-all→player projection.
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>