fix: resolve all Priority 5 CRASH/BLOCKER issues (#51-#57)
Build and Publish Mana Loop Docker Image / build-and-publish (push) Successful in 1m19s

- #51: Fix broken import path @/types/disciplines → @/lib/game/types/disciplines
- #52: Fix canProceedDiscipline() called with wrong arguments in discipline-slice.ts
- #53: Add local useState for activeAttunement tab filtering in DisciplinesTab
- #54: Make canProceedDiscipline() defensive when gameState is undefined
- #57: Remove stale CraftingTab export from game/index.ts
- Refactored DisciplineCard to use Zustand selector subscriptions properly
- Added DisciplinePerk type import to discipline-math.ts
This commit is contained in:
2026-05-18 17:51:06 +02:00
parent 92238e4dd8
commit ff3a268358
6 changed files with 169 additions and 213 deletions
+2 -1
View File
@@ -58,7 +58,8 @@ export const useDisciplineStore = create<DisciplineStore>()(
return d && !d.paused;
}).length;
if (nonPaused >= s.concurrentLimit) return s;
if (!canProceedDiscipline(id, gameState)) return s;
const discState = s.disciplines[id];
if (!canProceedDiscipline(def, discState, gameState)) return s;
const existing = s.disciplines[id] || { id, xp: 0, paused: false };
return {
+10 -6
View File
@@ -1,7 +1,7 @@
// ─── Discipline Math Utilities ────────────────────────────────────────────────
// Continuous scaling formulas for Active Disciplines
import type { DisciplineState, DisciplineDefinition } from '../types/disciplines';
import type { DisciplineState, DisciplineDefinition, DisciplinePerk } from '../types/disciplines';
/**
* Calculate continuous stat bonus from discipline XP
@@ -64,21 +64,25 @@ export function canActivateDiscipline(
*/
export function canProceedDiscipline(
discipline: DisciplineDefinition,
disciplineState: DisciplineState,
gameState: { elements?: Record<string, any>; rawMana?: number }
disciplineState: DisciplineState | undefined,
gameState?: { elements?: Record<string, any>; rawMana?: number }
): boolean {
if (!disciplineState) return true;
if (disciplineState.paused) return false;
// If no game state provided, allow activation (optimistic)
if (!gameState) return true;
const drain = calculateManaDrain(
discipline.drainBase,
disciplineState.xp,
discipline.difficultyFactor
);
if (discipline.manaType === 'raw') {
return (gameState.rawMana || 0) >= drain;
}
const element = gameState.elements?.[discipline.manaType];
return element && element.current >= drain;
}