- 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>
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>
Add createEntityWithId to World for restoring entities with original IDs.
Implement saveEntities/loadEntities to persist NPCs, structures, relationships,
and bonds to SQLite, with proper Map serialization and transient state resets.
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Save/load functions for all four event tables with proper JSON serialization,
chronological ordering, per-entity grouping, and optional field handling.
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Implements saveTiles/loadTiles for round-tripping terrain, decorations,
trunk decorations, resource tiles, obstacles, food and rest positions
via SQLite. Adds saveMetadata/loadMetadata for tick and timestamp.
Includes database.ts (previously only in main worktree).
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
NPCs can now retrieve crafting materials from stockpiles instead of
always gathering raw resources. The industry system checks if a
stockpile has needed materials before falling back to gathering.
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Runs every 100 ticks, checks each NPC for a probability-based eureka
moment scaled by INT and CUR stats. On trigger, sends LLM request with
available materials context, parses/validates the response, registers
the new item + recipe, emits narration, and records a memory event.
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Validates LLM-generated invention JSON: checks inputs exist in
ItemRegistry, rejects name collisions (case-insensitive), validates
categories, and generates snake_case itemIds from names.
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>