fix: Elemental Mana Capacity disciplines now increase element capacity
Build and Publish Mana Loop Docker Image / build-and-publish (push) Successful in 1m23s
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:
@@ -0,0 +1,38 @@
|
||||
// ─── Element Capacity Bonus Utilities ─────────────────────────────────────────
|
||||
// Extracts and merges per-element capacity bonuses from discipline and equipment
|
||||
// effects for application during the game tick.
|
||||
|
||||
/**
|
||||
* Extract elementCap_* bonuses from a bonus record.
|
||||
* Returns a map of element name → bonus amount.
|
||||
*/
|
||||
export function extractElementCapBonuses(
|
||||
bonuses: Record<string, number>
|
||||
): Record<string, number> {
|
||||
const result: Record<string, number> = {};
|
||||
for (const [key, value] of Object.entries(bonuses)) {
|
||||
if (key.startsWith('elementCap_') && value > 0) {
|
||||
const element = key.replace('elementCap_', '');
|
||||
result[element] = (result[element] || 0) + value;
|
||||
}
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
/**
|
||||
* Merge elementCap_* bonuses from discipline and equipment effects
|
||||
* into a single per-element bonus map.
|
||||
*/
|
||||
export function mergePerElementCapBonuses(
|
||||
disciplineBonuses: Record<string, number>,
|
||||
equipmentBonuses: Record<string, number>,
|
||||
): Record<string, number> {
|
||||
const merged: Record<string, number> = {};
|
||||
for (const [element, value] of Object.entries(extractElementCapBonuses(disciplineBonuses))) {
|
||||
merged[element] = (merged[element] || 0) + value;
|
||||
}
|
||||
for (const [element, value] of Object.entries(extractElementCapBonuses(equipmentBonuses))) {
|
||||
merged[element] = (merged[element] || 0) + value;
|
||||
}
|
||||
return merged;
|
||||
}
|
||||
Reference in New Issue
Block a user