From 30eb6b93a8ad9a6db44d1f2a78cb4b921e24ad77 Mon Sep 17 00:00:00 2001 From: zhipu Date: Fri, 27 Mar 2026 18:09:05 +0000 Subject: [PATCH] fix: add missing LootInventory type and lootInventory state - Added LootInventory interface to types.ts with materials and blueprints - Added lootInventory field to GameState interface - Added default lootInventory state to makeInitial() in store.ts - Added lootInventory to persist partialize function - Fixes prerender error: 'Cannot read properties of undefined (reading materials)' --- src/lib/game/store.ts | 8 ++++++++ src/lib/game/types.ts | 9 +++++++++ 2 files changed, 17 insertions(+) diff --git a/src/lib/game/store.ts b/src/lib/game/store.ts index f86f1b8..7e83416 100755 --- a/src/lib/game/store.ts +++ b/src/lib/game/store.ts @@ -504,6 +504,12 @@ function makeInitial(overrides: Partial = {}): GameState { blueprints: {}, + // Loot inventory + lootInventory: { + materials: {}, + blueprints: [], + }, + schedule: [], autoSchedule: false, studyQueue: [], @@ -1707,6 +1713,8 @@ export const useGameStore = create()( designProgress: state.designProgress, preparationProgress: state.preparationProgress, applicationProgress: state.applicationProgress, + // Loot inventory + lootInventory: state.lootInventory, }), } ) diff --git a/src/lib/game/types.ts b/src/lib/game/types.ts index 79b21a6..921dc88 100755 --- a/src/lib/game/types.ts +++ b/src/lib/game/types.ts @@ -252,6 +252,12 @@ export interface BlueprintDef { learned: boolean; } +// Loot inventory for materials and blueprints +export interface LootInventory { + materials: Record; // materialId -> count + blueprints: string[]; // blueprint IDs discovered +} + export type GameAction = 'meditate' | 'climb' | 'study' | 'craft' | 'repair' | 'convert' | 'design' | 'prepare' | 'enchant'; export interface ScheduleBlock { @@ -342,6 +348,9 @@ export interface GameState { // Blueprints blueprints: Record; + // Loot Inventory + lootInventory: LootInventory; + // Schedule schedule: ScheduleBlock[]; autoSchedule: boolean;