'use client'; import { Button } from '@/components/ui/button'; import { Badge } from '@/components/ui/badge'; import { Separator } from '@/components/ui/separator'; import { LOOT_DROPS, LOOT_RARITY_COLORS } from '@/lib/game/data/loot-drops'; import { canCraftRecipe } from '@/lib/game/data/fabricator-recipes'; import { MANA_TYPE_LABELS } from '@/lib/game/data/fabricator-recipe-types'; import type { FabricatorRecipe } from '@/lib/game/data/fabricator-recipes'; import { DebugName } from '@/components/game/debug/debug-context'; import { getCraftingCostReduction, applyCostReduction } from '@/lib/game/crafting-fabricator'; interface MaterialRecipeCardProps { recipe: FabricatorRecipe; materials: Record; rawMana: number; elementalMana: Record; onCraft: (recipe: FabricatorRecipe) => void; costReduction?: number; } export function MaterialRecipeCard({ recipe, materials, rawMana, elementalMana, onCraft, costReduction = 0, }: MaterialRecipeCardProps) { const pool = recipe.manaType === 'raw' ? rawMana : (elementalMana[recipe.manaType]?.current ?? 0); const { canCraft } = canCraftRecipe(recipe, materials, pool, recipe.manaType, costReduction); const resultDrop = recipe.resultMaterial ? LOOT_DROPS[recipe.resultMaterial] : null; const resultRarity = resultDrop ? LOOT_RARITY_COLORS[resultDrop.rarity] : null; return (
{recipe.name}
{recipe.rarity}
{recipe.resultAmount}x Output
{recipe.description}
{Object.keys(recipe.materials).length > 0 && ( <>
Input Materials:
{Object.entries(recipe.materials).map(([matId, rawAmount]) => { const reducedAmount = applyCostReduction(rawAmount, costReduction); const available = materials[matId] || 0; const matDrop = LOOT_DROPS[matId]; const hasEnough = available >= reducedAmount; return (
{matDrop?.name ?? matId} {available} / {reducedAmount} {costReduction > 0 && rawAmount !== reducedAmount && ( (was {rawAmount}) )}
); })} )} {recipe.manaCost > 0 && (
{MANA_TYPE_LABELS[recipe.manaType]?.split(' ')[1] ?? recipe.manaType} Mana: = recipe.manaCost ? 'text-green-400' : 'text-red-400'}> {pool} / {recipe.manaCost}
)}
Produces: {recipe.resultAmount}x {resultDrop?.name ?? recipe.resultMaterial}
); }