Files
Mana-Loop/docs/task7/ctx_page.md
T
Refactoring Agent 03815f27ee
Build and Publish Mana Loop Docker Image / build-and-publish (push) Failing after 5m57s
feat: add prestige system and skill upgrades with comprehensive documentation
2026-05-01 15:18:09 +02:00

3.5 KiB
Raw Blame History

Context: src/app/page.tsx

Total Line Count

492 lines

Top-Level Exports

1. ManaLoopGame (default export)

  • Line Range: 45485
  • 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: 4243
  • Description: A simple loading placeholder component shown while lazy-loaded tab components are being fetched.

3. canCastSpell (inline helper)

  • Line Range: 141144
  • Description: A closure defined inside ManaLoopGame that 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/store
  • ActivityLogEntry@/lib/game/types
  • getActiveEquipmentSpells, getTotalDPS@/lib/game/computed-stats
  • ELEMENTS, GUARDIANS, SPELLS_DEF, PRESTIGE_DEF, getStudySpeedMultiplier, getStudyCostMultiplier@/lib/game/constants
  • getUnifiedEffects, hasSpecial, SPECIAL_EFFECTS@/lib/game/effects
  • DebugName@/lib/game/debug-context

From @/components/

  • Button@/components/ui/button
  • Tabs, TabsContent, TabsList, TabsTrigger@/components/ui/tabs
  • Card, CardContent, CardHeader, CardTitle@/components/ui/card
  • Badge@/components/ui/badge
  • ScrollArea@/components/ui/scroll-area
  • RotateCcw, Mountain, ChevronDownlucide-react (icon pack)
  • TooltipProvider@/components/ui/tooltip
  • ActionButtons, 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):

  1. 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.

  2. canCastSpell — Although currently nested inside ManaLoopGame, it is a pure function of (spellId, store) (it reads SPELLS_DEF and canAffordSpellCost). 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).
  • 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.