'use client'; import { Button } from '@/components/ui/button'; import { Progress } from '@/components/ui/progress'; import { Card, CardContent, CardHeader, CardTitle } from '@/components/ui/card'; import { Badge } from '@/components/ui/badge'; import { ScrollArea } from '@/components/ui/scroll-area'; import { Separator } from '@/components/ui/separator'; import { Package, Sparkles, Trash2, Anvil } from 'lucide-react'; import { CRAFTING_RECIPES, canCraftRecipe } from '@/lib/game/data/crafting-recipes'; import { LOOT_DROPS, RARITY_COLORS } from '@/lib/game/data/loot-drops'; import type { EquipmentInstance, AppliedEnchantment, LootInventory, EquipmentCraftingProgress } from '@/lib/game/types'; import { fmt } from '@/lib/game/stores'; import { useGameStore } from '@/lib/game/stores'; export function EquipmentCrafter() { const lootInventory = useGameStore((s) => s.lootInventory); const equipmentCraftingProgress = useGameStore((s) => s.equipmentCraftingProgress); const rawMana = useGameStore((s) => s.rawMana); const currentAction = useGameStore((s) => s.currentAction); const startCraftingEquipment = useGameStore((s) => s.startCraftingEquipment); const cancelEquipmentCrafting = useGameStore((s) => s.cancelEquipmentCrafting); const deleteMaterial = useGameStore((s) => s.deleteMaterial); return (
{/* Blueprint Selection */} Available Blueprints {equipmentCraftingProgress ? (
Crafting: {CRAFTING_RECIPES[equipmentCraftingProgress.blueprintId]?.name}
{equipmentCraftingProgress.progress.toFixed(1)}h / {equipmentCraftingProgress.required.toFixed(1)}h Mana spent: {fmt(equipmentCraftingProgress.manaSpent)}
) : (
{lootInventory.blueprints.length === 0 ? (

No blueprints discovered yet.

Defeat guardians to find blueprints!

) : ( lootInventory.blueprints.map(bpId => { const recipe = CRAFTING_RECIPES[bpId]; if (!recipe) return null; const { canCraft, missingMaterials, missingMana } = canCraftRecipe( recipe, lootInventory.materials, rawMana ); const rarityStyle = RARITY_COLORS[recipe.rarity]; return (
{recipe.name}
{recipe.rarity}
{recipe.equipmentTypeId ? 'Equipment' : 'Other'}
{recipe.description}
Materials:
{Object.entries(recipe.materials).map(([matId, amount]) => { const available = lootInventory.materials[matId] || 0; const matDrop = LOOT_DROPS[matId]; const hasEnough = available >= amount; return (
{matDrop?.name || matId} {available} / {amount}
); })}
Mana Cost: = recipe.manaCost ? 'text-green-400' : 'text-red-400'}> {fmt(recipe.manaCost)}
Craft Time: {recipe.craftTime}h
); }) )}
)}
{/* Materials Inventory */} Materials ({Object.values(lootInventory.materials).reduce((a, b) => a + b, 0)}) {Object.keys(lootInventory.materials).length === 0 ? (

No materials collected yet.

Defeat floors to gather materials!

) : (
{Object.entries(lootInventory.materials).map(([matId, count]) => { if (count <= 0) return null; const drop = LOOT_DROPS[matId]; if (!drop) return null; const rarityStyle = RARITY_COLORS[drop.rarity]; return (
{drop.name}
x{count}
); })}
)}
); } EquipmentCrafter.displayName = "EquipmentCrafter";