fix: resolve 7 circular dependency chains in src/lib/game #20

Closed
opened 2026-05-18 14:28:48 +02:00 by Anexim · 1 comment
Owner

Problem

bunx madge --circular src/lib/game reports 7 circular dependency chains that must be resolved before modifying involved files.

Circular Chains Identified

  1. data/equipment/index.tsdata/equipment/utils.ts
  2. data/golems/index.tsdata/golems/utils.ts
  3. stores/combatStore.tsstores/combat-actions.ts
  4. stores/combatStore.tsstores/gameStore.ts
  5. stores/combatStore.tsstores/gameStore.tsstores/gameActions.ts
  6. stores/combatStore.tsstores/gameStore.tsstores/gameLoopActions.ts
  7. (7th chain implied — likely combatStoregameStoregameHookscombatStore)

Fix Strategy

For each chain:

  1. Identify which import can be extracted to a shared types/utils file
  2. Move the shared type or function there
  3. Both files import from the new shared module instead of each other

Verification

Run bunx madge --circular src/lib/game — must return clean (0 circular deps).

Constraints

  • All files must stay under 400 lines
  • Do not add banned mana types (life, blood, wood, mental, force)
  • Do not add lifesteal/healing mechanics
  • Follow existing code patterns
## Problem `bunx madge --circular src/lib/game` reports 7 circular dependency chains that must be resolved before modifying involved files. ## Circular Chains Identified 1. `data/equipment/index.ts` ↔ `data/equipment/utils.ts` 2. `data/golems/index.ts` ↔ `data/golems/utils.ts` 3. `stores/combatStore.ts` ↔ `stores/combat-actions.ts` 4. `stores/combatStore.ts` ↔ `stores/gameStore.ts` 5. `stores/combatStore.ts` → `stores/gameStore.ts` → `stores/gameActions.ts` 6. `stores/combatStore.ts` → `stores/gameStore.ts` → `stores/gameLoopActions.ts` 7. (7th chain implied — likely `combatStore` → `gameStore` → `gameHooks` → `combatStore`) ## Fix Strategy For each chain: 1. Identify which import can be extracted to a shared types/utils file 2. Move the shared type or function there 3. Both files import from the new shared module instead of each other ## Verification Run `bunx madge --circular src/lib/game` — must return clean (0 circular deps). ## Constraints - All files must stay under 400 lines - Do not add banned mana types (life, blood, wood, mental, force) - Do not add lifesteal/healing mechanics - Follow existing code patterns
Anexim added the ai:in-progress label 2026-05-18 14:28:48 +02:00
n8n-gitea was assigned by Anexim 2026-05-18 14:28:48 +02:00
Author
Owner

All 7 circular dependency chains resolved

Changes made across 2 commits:

Commit 1fix: resolve 7 circular dependency chains in src/lib/game

  • data/equipment/utils.ts — imports directly from individual equipment modules instead of ./index
  • data/golems/utils.ts — imports directly from individual golem modules instead of ./index
  • stores/combatStore.ts — extracted CombatState to new combat-state.types.ts
  • stores/combat-actions.ts — imports CombatState from combat-state.types.ts instead of combatStore
  • stores/index.ts — re-exports CombatState from combat-state.types.ts
  • GameStateDebug.tsx — replaced debugSetTime calls with direct useGameStore.setState()

Commit 2fix: remove debugSetTime and useGameStore import from combatStore

  • stores/combatStore.ts — removed debugSetTime method and useGameStore import (sub-agent reported success but the edit didn't persist; fixed manually)

Verification:

  • bunx madge --circular src/lib/game✔ No circular dependency found!
  • npx tsc --noEmit — zero errors in modified files (only pre-existing errors in DisciplinesTab.tsx)
  • All files under 400 lines (largest: combatStore.ts at 286 lines)
  • Pre-commit hook passes
## ✅ All 7 circular dependency chains resolved ### Changes made across 2 commits: **Commit 1** — `fix: resolve 7 circular dependency chains in src/lib/game` - `data/equipment/utils.ts` — imports directly from individual equipment modules instead of `./index` - `data/golems/utils.ts` — imports directly from individual golem modules instead of `./index` - `stores/combatStore.ts` — extracted `CombatState` to new `combat-state.types.ts` - `stores/combat-actions.ts` — imports `CombatState` from `combat-state.types.ts` instead of `combatStore` - `stores/index.ts` — re-exports `CombatState` from `combat-state.types.ts` - `GameStateDebug.tsx` — replaced `debugSetTime` calls with direct `useGameStore.setState()` **Commit 2** — `fix: remove debugSetTime and useGameStore import from combatStore` - `stores/combatStore.ts` — removed `debugSetTime` method and `useGameStore` import (sub-agent reported success but the edit didn't persist; fixed manually) ### Verification: - ✅ `bunx madge --circular src/lib/game` → **✔ No circular dependency found!** - ✅ `npx tsc --noEmit` — zero errors in modified files (only pre-existing errors in `DisciplinesTab.tsx`) - ✅ All files under 400 lines (largest: `combatStore.ts` at 286 lines) - ✅ Pre-commit hook passes
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: Anexim/Mana-Loop#20