Wire narration events through the socket layer so clients receive
real-time narration updates. Server emits narration-event on creation,
narration-update when LLM text arrives, and narration-history on connect.
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Removes duplicated local version that had different format.
Also brings backstoryGenerator.ts into the worktree from main.
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Add narrationEmitter system that reads completed interactions from
socialState.lastOutcome and feeds them to the NarrationService. It runs
between socialSystem and relationshipSystem to capture outcomes before
they are cleared. Includes pair deduplication, proposal detection,
priority marking for followed NPCs and high-value relationships, and
personality formatting for LLM prompts.
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Implements NarrationService that manages a rolling buffer of 50 narration events,
generates immediate template fallback text, and queues LLM generation for priority
interactions and proposals (respecting daily limits).
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Define NarrationEvent and NarrationOutcome types in shared package for
social interaction narration. Add generateFallbackNarration() with
randomized templates for each outcome type (positive, negative,
proposal_accepted, proposal_rejected) to provide immediate text when
LLM narration is unavailable.
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Raise requestsPerMinute from 10 to 20 and add requestsPerDay (1000) to
match OpenRouter free-tier limits. The generation queue now tracks daily
usage and resets at midnight, resolving requests with null once the cap
is hit. Both GenerationQueue and LlmService expose isDailyLimitReached().
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Combines config, OpenRouter client, generation queue, and template
rendering into a simple generate(templateName, variables) API. When
disabled (no API key), returns a no-op implementation. Includes
backstory, socialNarration, and innerMonologue prompt templates.
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Reads API key and model from environment variables. LLM is disabled by
default and auto-enables when OPENROUTER_API_KEY is set.
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Replace the 16x16 tileset with LPC Base Assets (32x32 tiles, 1.5x scale).
Uses a 4-layer rendering approach:
- Layer 0: solid grass base (grass.png)
- Layer 1: water transitions (watergrass.png) with LPC autotile edges
- Layer 2: dirt transitions (dirt.png) with LPC autotile edges
- Layer 3: tree canopy decorations (treetop.png)
LPC autotile format: 3x6 grid with inner/outer corners, edges, and fill
tiles. Edge tiles are selected based on 8-neighbor terrain analysis.
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Replace colored-rectangle world rendering with a proper tilemap system
using a 16x16 RPG tileset scaled 3x. Server generates terrain via seeded
procedural generation (river, ponds, dirt patches, tree decorations) and
sends it to clients. Client renders 3-layer Phaser tilemap with
8-neighbor autotiling for water/dirt edges.
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
- Add Math.max(3, ...) to baseline drift in socialSystem to prevent
stats drifting below minimum (was only clamping upward with Math.min)
- Make NpcInfoPanel.updateStats private (only called from updateInfo)
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Positive social outcomes drift sociability and empathy up (+0.05),
negative outcomes drift temperament up (+0.02), capped at 18.
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
High constitution slows hunger/energy decay, low constitution speeds it.
Uses getEffectiveStat helper which defaults to 10 for entities without
stats, preserving backward compatibility.
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Add stats and statModifiers components to spawnNPC, and run
statModifierSystem as the first system in the GameLoop update cycle.
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Adds a method that searches outward from a center position in Manhattan
distance rings to find the nearest walkable tile within a given radius.
Returns null if no walkable tile is found. Includes 5 tests.
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
- Process phase transitions per-pair instead of per-entity to avoid
double-processing (latent bug for future side effects)
- Restore independent outcome rolls per NPC (as designed)
- Let emoji CSS animation finish before removing DOM element, preventing
visual pop when server broadcast timing doesn't align with animation
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>