fix: Elemental Mana Capacity disciplines now increase element capacity
Build and Publish Mana Loop Docker Image / build-and-publish (push) Successful in 1m23s

- Add optional baseMax field to ElementState to track prestige-derived max separately from bonuses
- Add computeElementMaxWithBonuses action to manaStore that computes max = baseMax + per-element bonus
- Apply per-element cap bonuses from disciplines and equipment in game tick (elementCap_* keys)
- Fix resetMana to use correct prestige key (elementalAttune instead of nonexistent elemMax)
- Add store migration (v1->v2) to populate baseMax for existing saved games
- Extract pact ritual processing to pipelines/pact-ritual.ts
- Extract element cap bonus utilities to utils/element-cap-bonus.ts
- Fix inline element types in crafting-fabricator.ts
- Update test fixtures to include baseMax in element literals

Fixes #185
This commit is contained in:
2026-05-28 19:49:47 +02:00
parent 8fef73d233
commit 6355cf308b
11 changed files with 183 additions and 51 deletions
+7 -6
View File
@@ -2,6 +2,7 @@
// Separate file to avoid exceeding the 400-line limit in craftingStore.ts.
import type { EquipmentCraftingProgress } from './types';
import type { ElementState } from './types';
import type { FabricatorRecipe } from './data/fabricator-recipes';
import { FABRICATOR_RECIPES } from './data/fabricator-recipes';
import { useManaStore } from './stores/manaStore';
@@ -26,7 +27,7 @@ export function checkFabricatorCosts(
recipe: FabricatorRecipe,
materials: Record<string, number>,
rawMana: number,
elements: Record<string, { current: number; max: number; unlocked: boolean }>,
elements: Record<string, ElementState>,
): FabricatorCostCheck {
const missingMaterials: Record<string, number> = {};
let canCraft = true;
@@ -52,13 +53,13 @@ export function checkFabricatorCosts(
export interface ManaDeduction {
rawMana: number;
elements: Record<string, { current: number; max: number; unlocked: boolean }>;
elements: Record<string, ElementState>;
}
export function deductFabricatorMana(
recipe: FabricatorRecipe,
rawMana: number,
elements: Record<string, { current: number; max: number; unlocked: boolean }>,
elements: Record<string, ElementState>,
): ManaDeduction | null {
if (recipe.manaType === 'raw') {
if (rawMana < recipe.manaCost) return null;
@@ -84,14 +85,14 @@ export function deductFabricatorMana(
export interface ManaRefund {
rawMana: number;
elements: Record<string, { current: number; max: number; unlocked: boolean }>;
elements: Record<string, ElementState>;
}
export function refundFabricatorMana(
recipe: FabricatorRecipe,
refundAmount: number,
rawMana: number,
elements: Record<string, { current: number; max: number; unlocked: boolean }>,
elements: Record<string, ElementState>,
): ManaRefund {
if (recipe.manaType === 'raw') {
return { rawMana: rawMana + refundAmount, elements };
@@ -149,7 +150,7 @@ export interface CraftMaterialResult {
success: boolean;
newMaterials: Record<string, number>;
newRawMana: number;
newElements: Record<string, { current: number; max: number; unlocked: boolean }>;
newElements: Record<string, ElementState>;
logMessage: string;
}