'use client'; import { ATTUNEMENTS_DEF, ATTUNEMENT_SLOT_NAMES, getTotalAttunementRegen, getAvailableSkillCategories, getAttunementXPForLevel, MAX_ATTUNEMENT_LEVEL, getAttunementConversionRate } from '@/lib/game/data/attunements'; import { ELEMENTS } from '@/lib/game/constants'; import type { GameStore, AttunementState } from '@/lib/game/types'; import { Card, CardContent, CardHeader, CardTitle } from '@/components/ui/card'; import { Badge } from '@/components/ui/badge'; import { Button } from '@/components/ui/button'; import { Progress } from '@/components/ui/progress'; import { Lock, Sparkles, TrendingUp } from 'lucide-react'; export interface AttunementsTabProps { store: GameStore; } export function AttunementsTab({ store }: AttunementsTabProps) { const attunements = store.attunements || {}; // Get active attunements const activeAttunements = Object.entries(attunements) .filter(([, state]) => state.active) .map(([id]) => ATTUNEMENTS_DEF[id]) .filter(Boolean); // Calculate total regen from attunements const totalAttunementRegen = getTotalAttunementRegen(attunements); // Get available skill categories const availableCategories = getAvailableSkillCategories(attunements); return (
{/* Overview Card */} Your Attunements

Attunements are magical bonds tied to specific body locations. Each attunement grants unique capabilities, mana regeneration, and access to specialized skills. Level them up to increase their power.

+{totalAttunementRegen.toFixed(1)} raw mana/hr {activeAttunements.length} active attunement{activeAttunements.length !== 1 ? 's' : ''}
{/* Attunement Slots */}
{Object.entries(ATTUNEMENTS_DEF).map(([id, def]) => { const state = attunements[id]; const isActive = state?.active; const isUnlocked = state?.active || def.unlocked; const level = state?.level || 1; const xp = state?.experience || 0; const xpNeeded = getAttunementXPForLevel(level + 1); const xpProgress = xpNeeded > 0 ? (xp / xpNeeded) * 100 : 100; const isMaxLevel = level >= MAX_ATTUNEMENT_LEVEL; // Get primary mana element info const primaryElem = def.primaryManaType ? ELEMENTS[def.primaryManaType] : null; // Get current mana for this attunement's type const currentMana = def.primaryManaType ? store.elements[def.primaryManaType]?.current || 0 : 0; const maxMana = def.primaryManaType ? store.elements[def.primaryManaType]?.max || 50 : 50; // Calculate level-scaled stats const levelMult = Math.pow(1.5, level - 1); const scaledRegen = def.rawManaRegen * levelMult; const scaledConversion = getAttunementConversionRate(id, level); return (
{def.icon}
{def.name}
{ATTUNEMENT_SLOT_NAMES[def.slot]}
{!isUnlocked && ( )} {isActive && ( Lv.{level} )}

{def.desc}

{/* Mana Type */}
Primary Mana {primaryElem ? ( {primaryElem.sym} {primaryElem.name} ) : ( From Pacts )}
{/* Mana bar (only for attunements with primary type) */} {primaryElem && isActive && (
{currentMana.toFixed(1)} /{maxMana}
)}
{/* Stats with level scaling */}
Raw Regen
+{scaledRegen.toFixed(2)}/hr {level > 1 && ({((levelMult - 1) * 100).toFixed(0)}% bonus)}
Conversion
{scaledConversion > 0 ? `${scaledConversion.toFixed(2)}/hr` : '—'} {level > 1 && scaledConversion > 0 && ({((levelMult - 1) * 100).toFixed(0)}% bonus)}
{/* XP Progress Bar */} {isUnlocked && state && !isMaxLevel && (
XP Progress {xp} / {xpNeeded}
{isMaxLevel ? 'Max Level' : `${xpNeeded - xp} XP to Level ${level + 1}`}
)} {/* Max Level Indicator */} {isMaxLevel && (
✨ MAX LEVEL ✨
)} {/* Capabilities */}
Capabilities
{def.capabilities.map(cap => ( {cap === 'enchanting' && '✨ Enchanting'} {cap === 'disenchanting' && '🔄 Disenchant'} {cap === 'pacts' && '🤝 Pacts'} {cap === 'guardianPowers' && '💜 Guardian Powers'} {cap === 'elementalMastery' && '🌟 Elem. Mastery'} {cap === 'golemCrafting' && '🗿 Golems'} {cap === 'gearCrafting' && '⚒️ Gear'} {cap === 'earthShaping' && '⛰️ Earth Shaping'} {!['enchanting', 'disenchanting', 'pacts', 'guardianPowers', 'elementalMastery', 'golemCrafting', 'gearCrafting', 'earthShaping'].includes(cap) && cap} ))}
{/* Unlock condition for locked attunements */} {!isUnlocked && def.unlockCondition && (
🔒 {def.unlockCondition}
)}
); })}
{/* Available Skills Summary */} Available Skill Categories

Your attunements grant access to specialized skill categories:

{availableCategories.map(cat => { const attunement = Object.values(ATTUNEMENTS_DEF).find(a => a.skillCategories.includes(cat) && attunements[a.id]?.active ); return ( {cat === 'mana' && '💧 Mana'} {cat === 'study' && '📚 Study'} {cat === 'research' && '🔮 Research'} {cat === 'ascension' && '⭐ Ascension'} {cat === 'enchant' && '✨ Enchanting'} {cat === 'effectResearch' && '🔬 Effect Research'} {cat === 'invocation' && '💜 Invocation'} {cat === 'pact' && '🤝 Pact Mastery'} {cat === 'fabrication' && '⚒️ Fabrication'} {cat === 'golemancy' && '🗿 Golemancy'} {!['mana', 'study', 'research', 'ascension', 'enchant', 'effectResearch', 'invocation', 'pact', 'fabrication', 'golemancy'].includes(cat) && cat} ); })}
); }