56 lines
3.5 KiB
Markdown
56 lines
3.5 KiB
Markdown
# 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 `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`, `ChevronDown` — `lucide-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).
|
||
|
||
### 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.
|