Commit Graph

330 Commits

Author SHA1 Message Date
root b347ada878 feat: add D (Desires) tab to NPC info panel
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-03-10 01:34:46 +00:00
root 176ca88983 docs: NPC panel cleanup implementation plan
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-03-10 01:32:53 +00:00
root b28046c5f2 docs: NPC panel cleanup design — desires tab, thought name stripping
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-03-10 01:32:14 +00:00
root 034f799431 feat: multi-tile trees with treesnstone tileset and trunk bridging
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>
2026-03-10 01:22:47 +00:00
root c2b22aab4e feat: NPC desire system — motivation layer for emergent behavior
Adds 0-3 personal desires per NPC that drive crafting priorities,
influence invention, and create emergent stories. Hybrid LLM approach:
traits generated at spawn + event-driven updates.

Key components:
- Desire types (material/social/shelter/comfort/community/creative)
- Fulfillment checking system (7 criteria types, runs every 100 ticks)
- Desire generator system (periodic + event-driven LLM generation)
- Combined backstory+desires LLM generation at spawn
- Industry system scores recipes by desire match
- Desires passed into invention prompts
- Persistence, wire protocol, and client display
- All LLM templates reframed from medieval to frontier settlement

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-03-10 00:16:00 +00:00
root a8f27a869d fix: emit desire_fulfilled events, populate LLM context, fix category scoring
- 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>
2026-03-10 00:14:35 +00:00
root 7a16872bb9 feat: display NPC desires in info panel
Shows category-colored diamond bullets for active desires and
placeholder slots in the Status tab, between backstory and thoughts.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-03-10 00:07:14 +00:00
root f3591e68d7 feat: industrySystem scores recipes by desire match
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>
2026-03-10 00:07:09 +00:00
root c548d0ac05 test: add desire lifecycle integration test
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-03-10 00:04:30 +00:00
root 7ef9636307 feat: wire desire systems into GameLoop and spawner
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-03-10 00:02:40 +00:00
root 733cdfb20f feat: send desires to client via state serializer
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-03-10 00:00:20 +00:00
root a63ff776de feat: persist desires component in entity serializer
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-03-09 23:59:47 +00:00
root cf5558ce0f feat: pass NPC desires into invention prompts
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-03-09 23:59:29 +00:00
root 808ffc06c6 feat: add desire generator system for periodic and event-driven desire creation
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>
2026-03-09 23:55:29 +00:00
root 5835206171 feat: add combined backstory + desires LLM generator
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>
2026-03-09 23:50:51 +00:00
root 979a318651 refactor: reframe LLM templates from medieval to frontier settlement
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-03-09 23:47:21 +00:00
root f94a6363aa feat: add desire fulfillment system with criteria checks
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>
2026-03-09 23:44:46 +00:00
root d3706c90b8 feat: add desireConfig with tuning values
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-03-09 23:42:04 +00:00
root 57e8b3a98a feat: add Desire types to shared
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-03-09 23:41:07 +00:00
root dfd2b9e6e4 docs: add NPC desire system implementation plan
14 bite-sized tasks covering types, config, fulfillment system,
template overhaul, backstory+desires generator, desire generator
system, industry scoring, invention integration, persistence,
client display, and integration testing.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-03-09 23:37:15 +00:00
root ac9c881610 docs: add NPC desire system design
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>
2026-03-09 23:31:50 +00:00
root ee7f22c2c3 feat: ensure default stockpiles on load, use full stat names in backstory prompts
- 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>
2026-03-09 22:05:14 +00:00
root 1da03c46f3 refactor: extract findNearestStockpile helper in npcBrainSystem
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>
2026-03-09 21:55:26 +00:00
root a84b93bfd3 feat: gatheringSystem uses carry capacity for dropoff decision
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-03-09 21:52:15 +00:00
root 18b011fbf5 fix: preserve dropoff goal in npcBrainSystem and add carry capacity priority
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-03-09 21:50:48 +00:00
root a9c1cd55d6 feat: add getCarryCapacity stat helper
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-03-09 21:49:29 +00:00
root 1bfb9c581c feat: add getTotalItemCount inventory helper
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-03-09 21:48:46 +00:00
root 7a15a3257a docs: carry capacity and dropoff implementation plan
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-03-09 21:47:27 +00:00
root d66db04832 docs: carry capacity and dropoff priority design
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>
2026-03-09 21:46:10 +00:00
root 219f02d7d6 test: add integration test for stat-driven invention prompt
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-03-09 20:37:25 +00:00
root 36fdf1b3c1 fix: prevent race condition with global pendingItemIds set
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>
2026-03-09 20:36:02 +00:00
root 0851cea047 feat: track token usage from OpenRouter API responses
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>
2026-03-09 20:33:16 +00:00
root 6a3f9dd614 feat: stat-driven invention selection via revised LLM prompt
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>
2026-03-09 20:29:04 +00:00
root b8b2a870fa feat: parse reasoning field from invention LLM response
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-03-09 20:26:56 +00:00
root 28cd79a5c7 fix: re-register inventions into registries on save load
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>
2026-03-09 20:21:32 +00:00
root 31d45338ec docs: add invention refinements implementation plan
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>
2026-03-09 20:18:26 +00:00
root bc0e1154b5 docs: add invention system refinements design
Covers duplicate fix (load bug), name normalization, stat-driven
invention selection, race condition guard, and token usage tracking.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-03-09 20:15:34 +00:00
root 45ecad89bb fix: store tooltip cleanup functions and call on destroy
Prevents orphaned tooltip divs when panels are torn down while
a tooltip is visible.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-03-09 19:31:58 +00:00
root 3ae0d55f72 fix: prevent orphaned tooltip divs on rapid mouse re-entry
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-03-09 19:29:15 +00:00
root ad80d63763 feat: add hover tooltips to NPC info panel tabs and stat abbreviations
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-03-09 19:28:30 +00:00
root 57be76443c feat: add hover tooltips to left panel tabs
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-03-09 19:27:28 +00:00
root 9165758e67 feat: add tooltip utility for hover labels
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-03-09 19:26:38 +00:00
root fe7bc56c28 docs: add tooltip hover implementation plan
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-03-09 19:24:17 +00:00
root e9d8e5f533 docs: add tooltip hover design for UI abbreviations
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-03-09 19:23:17 +00:00
root 34aca29082 fix: sleep emoji, invention history race condition, and gathering stuck state
- 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>
2026-03-09 18:57:50 +00:00
root 3294879bab fix: address code review findings for sleep system
- Fix NpcInfoPanel activity label: rest→sleep (functional bug)
- Remove unnecessary array spread in mapGenerator reserved set
- Remove unused SLEEP_NIGHT_END constant

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-03-09 18:02:04 +00:00
root b67d491b9d feat: update thought system to recognize sleeping NPCs
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>
2026-03-09 17:59:03 +00:00
root 65ee23c5be refactor: remove rest POIs from map generation, persistence, and client rendering
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-03-09 17:58:02 +00:00
root b76ce16cba feat(server): protect sleeping NPCs from social interactions (empathy < 7 exception)
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>
2026-03-09 17:55:13 +00:00
root 812e30a222 feat(server): implement sleep-in-place behavior in npcBrainSystem with day/night awareness
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-03-09 17:52:46 +00:00