'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, LOOT_RARITY_COLORS } from '@/lib/game/data/loot-drops'; import type { LootInventory } from '@/lib/game/types'; import { fmt } from '@/lib/game/stores'; import { useCraftingStore, useCombatStore, useManaStore } from '@/lib/game/stores'; // ─── Crafting Progress ─────────────────────────────────────────────────────── function CraftingProgress({ progress }: { progress: { blueprintId: string; progress: number; required: number; manaSpent: number } }) { const recipe = CRAFTING_RECIPES[progress.blueprintId]; const cancelEquipmentCrafting = useCraftingStore((s) => s.cancelEquipmentCrafting); return (
Crafting: {recipe?.name}
{progress.progress.toFixed(1)}h / {progress.required.toFixed(1)}h Mana spent: {fmt(progress.manaSpent)}
); } // ─── Blueprint Card ─────────────────────────────────────────────────────────── function BlueprintCard({ bpId, lootInventory, rawMana, isCrafting, startCraftingEquipment, currentAction }: { bpId: string; lootInventory: LootInventory; rawMana: number; isCrafting: boolean; startCraftingEquipment: (id: string) => void; currentAction: string | null; }) { const recipe = CRAFTING_RECIPES[bpId]; if (!recipe) return null; const { canCraft, missingMaterials } = canCraftRecipe(recipe, lootInventory.materials, rawMana); const rarityStyle = LOOT_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
); } // ─── Blueprint List ─────────────────────────────────────────────────────────── function BlueprintList({ lootInventory, rawMana, startCraftingEquipment, currentAction }: { lootInventory: LootInventory; rawMana: number; startCraftingEquipment: (id: string) => void; currentAction: string | null }) { if (lootInventory.blueprints.length === 0) { return (

No blueprints discovered yet.

Defeat guardians to find blueprints!

); } return (
{lootInventory.blueprints.map(bpId => ( ))}
); } // ─── Material Card ──────────────────────────────────────────────────────────── function MaterialCard({ matId, count, deleteMaterial }: { matId: string; count: number; deleteMaterial: (id: string, count: number) => void }) { const drop = LOOT_DROPS[matId]; if (!drop) return null; const rarityStyle = LOOT_RARITY_COLORS[drop.rarity]; return (
{drop.name}
x{count}
); } // ─── Materials Inventory ───────────────────────────────────────────────────── function MaterialsInventory({ materials, deleteMaterial }: { materials: Record; deleteMaterial: (id: string, count: number) => void }) { const totalCount = Object.values(materials).reduce((a, b) => a + b, 0); return ( Materials ({totalCount}) {Object.keys(materials).length === 0 ? (

No materials collected yet.

Defeat floors to gather materials!

) : (
{Object.entries(materials).map(([matId, count]) => { if (count <= 0) return null; return ; })}
)}
); } // ─── Main Component ─────────────────────────────────────────────────────────── export function EquipmentCrafter() { const lootInventory = useCraftingStore((s) => s.lootInventory); const equipmentCraftingProgress = useCraftingStore((s) => s.equipmentCraftingProgress); const startCraftingEquipment = useCraftingStore((s) => s.startCraftingEquipment); const deleteMaterial = useCraftingStore((s) => s.deleteMaterial); const rawMana = useManaStore((s) => s.rawMana); const currentAction = useCombatStore((s) => s.currentAction); return (
Available Blueprints {equipmentCraftingProgress ? ( ) : ( )}
); } EquipmentCrafter.displayName = 'EquipmentCrafter';