From c8baea43466b07528604f5e8a2a24128955fd066 Mon Sep 17 00:00:00 2001 From: Refactoring Agent <[email protected]> Date: Sun, 26 Apr 2026 15:42:32 +0200 Subject: [PATCH] Task 2: Crafting - disable Prepare for non-enchanted items, limit Design to owned gear types --- .../game/crafting/EnchantmentDesigner.tsx | 38 ++++++++++++++++++- src/lib/game/crafting-slice.ts | 3 ++ 2 files changed, 40 insertions(+), 1 deletion(-) diff --git a/src/components/game/crafting/EnchantmentDesigner.tsx b/src/components/game/crafting/EnchantmentDesigner.tsx index f30bcec..690d4d2 100644 --- a/src/components/game/crafting/EnchantmentDesigner.tsx +++ b/src/components/game/crafting/EnchantmentDesigner.tsx @@ -11,6 +11,7 @@ import { Wand2, Scroll, Trash2, Plus, Minus } from 'lucide-react'; import { EQUIPMENT_TYPES } from '@/lib/game/data/equipment'; import { ENCHANTMENT_EFFECTS, calculateEffectCapacityCost } from '@/lib/game/data/enchantment-effects'; import { LOOT_DROPS, RARITY_COLORS } from '@/lib/game/data/loot-drops'; +import { CRAFTING_RECIPES } from '@/lib/game/data/crafting-recipes'; import type { EquipmentInstance, EnchantmentDesign, DesignEffect, LootInventory, EquipmentCraftingProgress } from '@/lib/game/types'; import { fmt, type GameStore } from '@/lib/game/store'; @@ -138,6 +139,34 @@ export function EnchantmentDesigner({ ); }; + // Get equipment types that the player has blueprints for + const getOwnedEquipmentTypes = () => { + const ownedBlueprints = store.lootInventory.blueprints || []; + + // Map blueprint IDs to equipment type IDs + const ownedEquipmentTypeIds = new Set(); + for (const blueprintId of ownedBlueprints) { + const recipe = CRAFTING_RECIPES[blueprintId]; + if (recipe) { + ownedEquipmentTypeIds.add(recipe.equipmentTypeId); + } + } + + // Also include the starting equipment types (basicStaff, civilianShirt, civilianShoes) + // These are the types the player starts with, so they should be able to design for them + ownedEquipmentTypeIds.add('basicStaff'); + ownedEquipmentTypeIds.add('civilianShirt'); + ownedEquipmentTypeIds.add('civilianShoes'); + ownedEquipmentTypeIds.add('apprenticeWand'); + ownedEquipmentTypeIds.add('clothHood'); + ownedEquipmentTypeIds.add('civilianGloves'); + ownedEquipmentTypeIds.add('copperRing'); + + return Object.values(EQUIPMENT_TYPES).filter(type => ownedEquipmentTypeIds.has(type.id)); + }; + + const ownedEquipmentTypes = getOwnedEquipmentTypes(); + // Render design stage return (
@@ -162,7 +191,7 @@ export function EnchantmentDesigner({ ) : (
- {Object.values(EQUIPMENT_TYPES).map(type => ( + {ownedEquipmentTypes.map(type => (
))}
+ {ownedEquipmentTypes.length === 0 && ( +
+ No equipment blueprints owned. Craft or find equipment blueprints first. +
+ )} )} @@ -354,3 +388,5 @@ export function EnchantmentDesigner({
); } + +EnchantmentDesigner.displayName = "EnchantmentDesigner"; diff --git a/src/lib/game/crafting-slice.ts b/src/lib/game/crafting-slice.ts index 0fcf802..80f63e0 100755 --- a/src/lib/game/crafting-slice.ts +++ b/src/lib/game/crafting-slice.ts @@ -422,6 +422,9 @@ export function createCraftingSlice( const instance = state.equipmentInstances[equipmentInstanceId]; if (!instance) return false; + // Don't allow preparing enchanted items - they need to be disenchanted first + if (instance.enchantments.length > 0) return false; + const prepTime = calculatePrepTime(instance.totalCapacity); const manaCost = calculatePrepManaCost(instance.totalCapacity);