Motivation layer giving NPCs personal desires (0-3 per NPC) that
drive crafting priorities, influence invention, and create emergent
stories. Hybrid LLM approach: traits at spawn + event-driven updates.
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>
NPCs never drop off gathered resources due to missing continue
statement in npcBrainSystem. Design adds strength-based carry
capacity and fixes dropoff goal priority.
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>
8 tasks covering: load-time re-registration fix, reasoning field
parsing, revised LLM prompt, full stat passthrough, token usage
tracking, race condition guard, and integration tests.
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 missing Vite client type declarations, fix canvas-to-HTMLImageElement
cast in CharacterCompositor, and use proper Stats/StatName types in
NpcInfoPanel instead of loose Record<string, number>.
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>
Fix vertical line artifacts in nighttime overlay by using a single
rectangle for full night and a base+sweep approach for transitions.
Increase night darkness from 0.3 to 0.45 for more distinct nighttime.
Add a time indicator bar at top-center showing day/night progress
with sun/moon icons matching the EarthBound-inspired UI style.
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>
Add RateLimitInfo interface and CompletionResult type union so callers
can distinguish 429 rate limits from other errors. Includes isRateLimited
type guard and per-request model override in CompletionRequest.
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Verifies complete save → close → reopen → load cycle with NPCs,
relationships, bonds, structures, and all event types (narration,
memory, stockpile, invention).
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Wire SaveManager into game startup/shutdown: constructor now checks for
existing save file and loads or creates new world accordingly. Add
autosave every 30s, final save on stop, and graceful shutdown signals.
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>