Skip to content

refactor: extract HuntersPath.tsx monolith (6,555 → 3,975 lines)#34

Merged
JesseRWeigel merged 5 commits intomainfrom
refactor/extract-monolith
Mar 17, 2026
Merged

refactor: extract HuntersPath.tsx monolith (6,555 → 3,975 lines)#34
JesseRWeigel merged 5 commits intomainfrom
refactor/extract-monolith

Conversation

@JesseRWeigel
Copy link
Owner

Summary

Major refactor of the 6,555-line monolithic HuntersPath.tsx into modular, testable pieces. 40% reduction (3,975 lines remaining).

Extracted Modules

Types & Constants (Phase 1):

  • lib/game/types.ts — 15 game interfaces
  • lib/game/constants/ — prestige, UI, story, combat messages, monsters
  • components/game/ui/ — Card, Btn, Bar, BarMini, CombatBar, DamageNumber

Custom Hooks (Phases 2-4):

Hook Lines Responsibility
useAudio 95 Sound/music state, audioManager sync
useSaveSystem 480 Save/load/export/import, autosave, recovery
useGameTime 50 Game clock, day advance
useTraining 80 Training activities, work
useShop 90 Buy potions, equipment
useEquipment 120 Equip/unequip items
useItemUsage 130 Potion/rune/key usage
useRebirth 70 Rebirth, prestige upgrades
useCombatEngine 621 Combat tick loop, gates, auto-dungeon
useDailyQuests 241 Quest tracking, completion, penalties
useLevelUp 210 Level gain, celebration, story events
useSpiritBinding 240 Binding sequence, phases

Verification

  • All 215 tests pass across 13 test files
  • Production build succeeds
  • Manually tested: tutorial, login reward, gate entry, boss intro, combat, victory, loot, story events, stat allocation, achievements, inventory

Closes #11

Test plan

  • All 215 tests pass
  • Production build succeeds
  • Manual testing via Playwright: full combat loop works
  • CI passes on this PR

🤖 Generated with Claude Code

JesseRWeigel and others added 4 commits March 16, 2026 19:51
Phase 1 of HuntersPath.tsx refactor (6,555 → 5,965 lines):

- Extract 15 interfaces to lib/game/types.ts
- Extract constants to lib/game/constants/:
  - prestige.ts, ui.ts, story.ts, combatMessages.ts, monsters.ts
- Extract 6 UI components to components/game/ui/:
  - Card, Btn, Bar, BarMini, CombatBar, DamageNumber

All 215 tests pass. No logic changes.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Phase 2 of HuntersPath.tsx refactor (5,965 → 5,466 lines):

- useAudio: sound/music state, audioManager sync, first-interaction
  ambient start, volume/toggle controls
- useSaveSystem: save/load/export/import, autosave, visibility-change
  save, offline gains, corruption recovery, spirit migration

All 215 tests pass. No logic changes.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Phase 3 of HuntersPath.tsx refactor (5,466 → 5,029 lines):

- useGameTime: game time advance, passive EXP on new day
- useTraining: physical/mental/meditation training, work
- useShop: buy potions, buy equipment upgrades
- useEquipment: equip/unequip items
- useItemUsage: use potions, runes, dungeon keys
- useRebirth: rebirth handler, prestige upgrade purchase

All 215 tests pass. No logic changes.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Phase 4 of HuntersPath.tsx refactor (5,029 → 3,975 lines):

- useCombatEngine: combat tick loop, gate selection, auto-dungeon,
  boss intro, combat result handling (621 lines)
- useDailyQuests: quest progress, completion, penalties, reset (241 lines)
- useLevelUp: level gain, celebration modal, story events, stat
  allocation feedback (210 lines)
- useSpiritBinding: binding sequence, phases, try binding (240 lines)

40% total reduction from original 6,555 lines. All 215 tests pass.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
@JesseRWeigel JesseRWeigel merged commit 961eadb into main Mar 17, 2026
1 of 2 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Refactor HuntersPath.tsx monolith (5,292 lines)

1 participant