- Wire npcBrainSystem to RuntimeConstants (was using hardcoded shared imports)
- Add auth gating on admin-update-constant and admin-reset-defaults sockets
- Unsubscribe from previous tab's data sources on left-panel tab switch
- Use per-key debounce timers in AdminPanel to avoid dropped changes
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Replace direct constant imports with rc.get() calls in needsDecaySystem,
socialSystem, statModifierSystem, movementSystem, gatheringSystem,
craftingSystem, buildingSystem, and SocketServer. All system functions
now accept a RuntimeConstants parameter, enabling live-tuning of game
constants via the admin panel.
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Replace direct constant imports (TICK_RATE, BROADCAST_EVERY_N_TICKS,
ENERGY_DECAY_PER_TICK, DAY_NIGHT_RATIO) with RuntimeConstants lookups.
Add LogService for autosave logging and tick overrun detection.
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Backstories stored as raw JSON (containing desires) are now parsed
on deserialization to extract just the backstory text.
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Replace single-tile tree rendering with 6 multi-tile tree variants using
the treesnstone.png tileset. Each tree is 3 tiles wide with canopy tiles
on the decorations layer (above characters) and ground/shadow tiles on
the trunkDecorations layer (below characters). Add trunk bridge tiles
(tile 41) behind transparent canopy areas to connect canopy to ground
visually, fixing floating canopy appearance.
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
- desireFulfillmentSystem records memory events when desires are fulfilled
- desireGeneratorSystem populates recentEvents and recentInventions template vars
- industrySystem own_item_category scoring now checks recipe output category
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Adds scoreCraftableRecipes helper that scores recipes based on NPC
desires (priority * 10 for own_item match). Falls back to first
available when no desires match.
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Factory-function system that generates new desires via LLM based on
periodic stat-based probability checks and external event triggers.
Tracks pending entities to prevent duplicate in-flight requests.
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Add backstoryAndDesires and desireGeneration templates. Rewrite
backstoryGenerator with getWorldContext, validateDesire, and
generateBackstoryAndDesires helpers while keeping legacy generateBackstory
for backward compatibility. Add comprehensive tests (22 cases).
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Checks NPC desires against world state every 100 ticks and removes
fulfilled ones. Supports own_item, own_item_category, structure_exists,
relationship_tier, recipe_exists criteria. building_exists and custom
always return false (deferred).
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
- Add ensureDefaultStockpiles() to handle saves from before stockpile spawning
- Switch backstory prompt stat formatting from abbreviations (STR, DEX) to
full names (strength, dexterity) for better LLM comprehension
- Add prior design/plan docs for LLM fallback and NPC sleep system
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Deduplicates stockpile-finding logic that was repeated in the dropoff
preservation block and the target selection block.
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Two NPCs could invent the same item if both LLM requests
returned before either registered. The pendingItemIds set
blocks the second registration.
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Captures prompt_tokens and completion_tokens from API response.
Stores in 100-entry ring buffer, logs per-call summary. Adds
tokenUsage() accessor to LlmService interface.
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Prompt now includes full 10-stat block with readable names and
scale context. Instructs LLM to consider 3 ideas and pick the
best match for the NPC's personality. Known items list includes
both seed and invented items for better duplicate prevention.
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Inventions loaded from DB were only added to the timeline, not
the item/recipe registries. This allowed duplicate inventions
after server restarts since the validation check was empty.
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
- Add persistent 💤 emoji over sleeping NPCs (tracks sprite position)
- Buffer history events (inventions, narration, stockpile) in SocketClient
to fix race condition where data arrived before GameScene handlers registered
- Fix NPCs getting stuck on 'gather' goal: tree trunks are both obstacles
and resource tiles, so pathfinding always failed. Now findNearestResource
returns adjacent walkable tiles for non-walkable resources, and
gatheringSystem checks adjacent tiles. Added wander fallback when
pathfinding to any gather target fails.
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Skip sleeping NPCs in the thought generation loop and update
describeState to output 'sleeping' when currentGoal is 'sleep'.
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Sleeping NPCs are now shielded from social interaction initiation unless
the approaching NPC has low empathy (< 7, i.e. rude). Sleeping NPCs also
cannot initiate social interactions themselves.
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Add null checks for relationship components before processing
social outcomes to prevent crashes when entities lack relationships.
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
The LlmService interface no longer exposes isDailyLimitReached — model
switching is handled internally. Remove all checks in thoughtSystem,
inventionSystem, narrationService, and thoughtGenerator. Update mocks
in test files to match the new interface and remove obsolete daily-limit
test cases.
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>