3.5 KiB
3.5 KiB
Context: src/app/page.tsx
Total Line Count
492 lines
Top-Level Exports
1. ManaLoopGame (default export)
- Line Range: 45–485
- Description: The main game component that renders the entire Mana Loop UI, manages tab state, gathering, spire mode, and orchestrates all game systems via the Zustand store.
2. TabLoadingFallback
- Line Range: 42–43
- Description: A simple loading placeholder component shown while lazy-loaded tab components are being fetched.
3. canCastSpell (inline helper)
- Line Range: 141–144
- Description: A closure defined inside
ManaLoopGamethat checks whether a given spell can be afforded with current mana and element resources.
Imports from Other Files in the Repo (relative paths)
From @/lib/game/
useGameStore,useGameLoop,fmt,getFloorElement,computeMaxMana,computeRegen,computeClickMana,getMeditationBonus,getIncursionStrength,canAffordSpellCost—@/lib/game/storeActivityLogEntry—@/lib/game/typesgetActiveEquipmentSpells,getTotalDPS—@/lib/game/computed-statsELEMENTS,GUARDIANS,SPELLS_DEF,PRESTIGE_DEF,getStudySpeedMultiplier,getStudyCostMultiplier—@/lib/game/constantsgetUnifiedEffects,hasSpecial,SPECIAL_EFFECTS—@/lib/game/effectsDebugName—@/lib/game/debug-context
From @/components/
Button—@/components/ui/buttonTabs,TabsContent,TabsList,TabsTrigger—@/components/ui/tabsCard,CardContent,CardHeader,CardTitle—@/components/ui/cardBadge—@/components/ui/badgeScrollArea—@/components/ui/scroll-areaRotateCcw,Mountain,ChevronDown—lucide-react(icon pack)TooltipProvider—@/components/ui/tooltipActionButtons,CalendarDisplay,ManaDisplay,TimeDisplay—@/components/game- Lazy-loaded tab components (all from
@/components/game/tabs):SpireTab,SkillsTab,SpellsTab,LabTab,StatsTab,EquipmentTab,AttunementsTab,DebugTab,LootTab,AchievementsTab,GolemancyTab,CraftingTab
Assessment: Which exports are safest to extract to a new file
Safest to extract (stand-alone, reusable, low coupling):
-
TabLoadingFallback— A presentational component with zero dependencies on game state or side-effects. It could be moved to a shared UI file (e.g.,components/ui/loading.tsx) with no behavioral impact. -
canCastSpell— Although currently nested insideManaLoopGame, it is a pure function of(spellId, store)(it readsSPELLS_DEFandcanAffordSpellCost). It could be lifted to@/lib/game/spells.ts(or similar) and exported as a named helper. This would reduce closure complexity and make it easily testable.
Moderate safety (would require small refactors but are useful to share):
- None identified beyond the above two — the only other export is the default
ManaLoopGame, which is intentionally top-level and orchestrates too many concerns to extract as-is. Splitting it would require significant decomposition (e.g., extracting subcomponents, custom hooks, and game-logic helpers).
Not recommended to extract as-is:
ManaLoopGame— It is the root page component for/and tightly integrates routing-lite behavior (spire mode vs normal tabs), game-loop effects, state selectors, and presentation. Extracting it would require first breaking it into smaller pieces (state hooks, subcomponents) rather than moving it wholesale.