'use client'; import { Button } from '@/components/ui/button'; import { Card, CardContent, CardHeader, CardTitle } from '@/components/ui/card'; import { ELEMENTS } from '@/lib/game/constants'; interface LabTabProps { store: { rawMana: number; elements: Record; skills: Record; craftComposite: (target: string) => void; }; } export function LabTab({ store }: LabTabProps) { // Render elemental mana grid const renderElementsGrid = () => (
{Object.entries(store.elements) .filter(([, state]) => state.unlocked) .map(([id, state]) => { const def = ELEMENTS[id]; return (
{def?.sym}
{def?.name}
{state.current}/{state.max}
); })}
); // Render composite crafting const renderCompositeCrafting = () => { const compositeElements = Object.entries(ELEMENTS) .filter(([, def]) => def.recipe) .filter(([id]) => store.elements[id]?.unlocked); if (compositeElements.length === 0) return null; return ( Composite Crafting
{compositeElements.map(([id, def]) => { const recipe = def.recipe || []; const canCraft = recipe.every(r => (store.elements[r]?.current || 0) >= 1); const craftBonus = 1 + (store.skills.elemCrafting || 0) * 0.25; const output = Math.floor(craftBonus); return (
{def.sym} {def.name} ({recipe.map(r => ELEMENTS[r]?.sym).join(' + ')})
); })}
); }; // Check if there are any unlocked elements const hasUnlockedElements = Object.values(store.elements).some(e => e.unlocked); if (!hasUnlockedElements) { return (
No elemental mana available. Elements are unlocked through gameplay.
); } return (
{/* Elemental Mana Display */} Elemental Mana {renderElementsGrid()} {/* Composite Crafting */} {renderCompositeCrafting()}
); }