fix: resolve circular dependency in discipline-slice → discipline-effects
Build and Publish Mana Loop Docker Image / build-and-publish (push) Successful in 1m30s
Build and Publish Mana Loop Docker Image / build-and-publish (push) Successful in 1m30s
Replaced computeDisciplineEffects() import in discipline-slice.ts with inline XP bonus calculation using calculateStatBonus from discipline-math. This avoids the circular chain: discipline-effects → discipline-slice → discipline-effects.
This commit is contained in:
@@ -1,4 +1,11 @@
|
|||||||
# Circular Dependencies
|
# Circular Dependencies
|
||||||
Generated: 2026-05-27T19:08:46.353Z
|
Generated: 2026-05-28T07:32:48.513Z
|
||||||
|
Found: 1 circular chain(s) — these MUST be fixed before modifying involved files.
|
||||||
|
|
||||||
No circular dependencies found. ✅
|
1. 1) effects/discipline-effects.ts > stores/discipline-slice.ts
|
||||||
|
|
||||||
|
## How to fix
|
||||||
|
1. Identify which import in the chain 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.
|
||||||
|
4. Run: bunx madge --circular src/lib/game (should return clean)
|
||||||
@@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"_meta": {
|
"_meta": {
|
||||||
"generated": "2026-05-27T19:08:44.608Z",
|
"generated": "2026-05-28T07:32:46.775Z",
|
||||||
"description": "Import dependency graph for src/lib/game. Keys are files, values are arrays of files they import.",
|
"description": "Import dependency graph for src/lib/game. Keys are files, values are arrays of files they import.",
|
||||||
"usage": "To find what a file affects, search for its path in the VALUES. To find what a file depends on, look at its KEY entry."
|
"usage": "To find what a file affects, search for its path in the VALUES. To find what a file depends on, look at its KEY entry."
|
||||||
},
|
},
|
||||||
@@ -326,7 +326,6 @@
|
|||||||
"data/equipment/feet.ts",
|
"data/equipment/feet.ts",
|
||||||
"data/equipment/hands.ts",
|
"data/equipment/hands.ts",
|
||||||
"data/equipment/head.ts",
|
"data/equipment/head.ts",
|
||||||
"data/equipment/shields.ts",
|
|
||||||
"data/equipment/swords.ts"
|
"data/equipment/swords.ts"
|
||||||
],
|
],
|
||||||
"data/equipment/feet.ts": [
|
"data/equipment/feet.ts": [
|
||||||
@@ -347,7 +346,6 @@
|
|||||||
"data/equipment/feet.ts",
|
"data/equipment/feet.ts",
|
||||||
"data/equipment/hands.ts",
|
"data/equipment/hands.ts",
|
||||||
"data/equipment/head.ts",
|
"data/equipment/head.ts",
|
||||||
"data/equipment/shields.ts",
|
|
||||||
"data/equipment/swords.ts",
|
"data/equipment/swords.ts",
|
||||||
"data/equipment/types.ts",
|
"data/equipment/types.ts",
|
||||||
"data/equipment/utils.ts"
|
"data/equipment/utils.ts"
|
||||||
@@ -530,6 +528,7 @@
|
|||||||
"data/disciplines/enchanter.ts",
|
"data/disciplines/enchanter.ts",
|
||||||
"data/disciplines/fabricator.ts",
|
"data/disciplines/fabricator.ts",
|
||||||
"data/disciplines/invoker.ts",
|
"data/disciplines/invoker.ts",
|
||||||
|
"effects/discipline-effects.ts",
|
||||||
"types.ts",
|
"types.ts",
|
||||||
"types/disciplines.ts",
|
"types/disciplines.ts",
|
||||||
"utils/discipline-math.ts",
|
"utils/discipline-math.ts",
|
||||||
|
|||||||
@@ -6,11 +6,11 @@ import type { DisciplineState } from '../types/disciplines';
|
|||||||
import type { ElementState } from '../types';
|
import type { ElementState } from '../types';
|
||||||
import {
|
import {
|
||||||
calculateManaDrain,
|
calculateManaDrain,
|
||||||
|
calculateStatBonus,
|
||||||
canProceedDiscipline,
|
canProceedDiscipline,
|
||||||
checkDisciplinePrerequisites,
|
checkDisciplinePrerequisites,
|
||||||
getUnlockedPerks
|
getUnlockedPerks
|
||||||
} from '../utils/discipline-math';
|
} from '../utils/discipline-math';
|
||||||
import { computeDisciplineEffects } from '../effects/discipline-effects';
|
|
||||||
import { baseDisciplines } from '../data/disciplines/base';
|
import { baseDisciplines } from '../data/disciplines/base';
|
||||||
import { elementalAttunementDisciplines } from '../data/disciplines/elemental';
|
import { elementalAttunementDisciplines } from '../data/disciplines/elemental';
|
||||||
import { elementalRegenDisciplines } from '../data/disciplines/elemental-regen';
|
import { elementalRegenDisciplines } from '../data/disciplines/elemental-regen';
|
||||||
@@ -184,7 +184,28 @@ export const useDisciplineStore = create<DisciplineStore>()(
|
|||||||
}
|
}
|
||||||
|
|
||||||
const oldXP = disc.xp;
|
const oldXP = disc.xp;
|
||||||
const xpBonus = computeDisciplineEffects().bonuses.disciplineXpBonus || 0;
|
// Compute discipline XP bonus directly to avoid circular import
|
||||||
|
let xpBonus = 0;
|
||||||
|
for (const [did, dState] of Object.entries(newDisciplines)) {
|
||||||
|
if (!dState || dState.xp <= 0) continue;
|
||||||
|
const dDef = DISCIPLINE_MAP[did];
|
||||||
|
if (!dDef) continue;
|
||||||
|
// Only disciplines with disciplineXpBonus stat contribute
|
||||||
|
if (dDef.statBonus.stat === 'disciplineXpBonus') {
|
||||||
|
xpBonus += calculateStatBonus(
|
||||||
|
dDef.statBonus.baseValue,
|
||||||
|
dState.xp,
|
||||||
|
dDef.scalingFactor
|
||||||
|
);
|
||||||
|
}
|
||||||
|
// Perk bonuses for disciplineXpBonus
|
||||||
|
const perks = getUnlockedPerks(dDef, dState.xp);
|
||||||
|
for (const perk of perks) {
|
||||||
|
if (perk.bonus && perk.bonus.stat === 'disciplineXpBonus') {
|
||||||
|
xpBonus += perk.bonus.amount;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
const xpGain = 1 + xpBonus;
|
const xpGain = 1 + xpBonus;
|
||||||
newDisciplines[id] = { ...disc, xp: disc.xp + xpGain };
|
newDisciplines[id] = { ...disc, xp: disc.xp + xpGain };
|
||||||
newXP += xpGain;
|
newXP += xpGain;
|
||||||
|
|||||||
Reference in New Issue
Block a user