fix: resolve mana conversion, Spire/Grimoire tab errors, and legacy store references
Build and Publish Mana Loop Docker Image / build-and-publish (push) Successful in 1m33s
Build and Publish Mana Loop Docker Image / build-and-publish (push) Successful in 1m33s
- Fix mana conversion to deduct from regen instead of mana pool (resolves player stuck at 1 mana below cap) - Fix Spire Tab error by removing unused legacy import (store-modules/enemy-utils) - Fix Grimoire Tab error by adding Array.isArray check for effects.map - Move utility functions from legacy store-modules to utils/ to eliminate legacy dependencies - Add regression test for mana conversion fix - Update SpellsTab.tsx imports to use utils instead of legacy stores
This commit is contained in:
@@ -143,15 +143,26 @@ export const useGameStore = create<GameCoordinatorStore>()(
|
||||
meditateTicks = 0;
|
||||
}
|
||||
|
||||
// Calculate effective regen with incursion and meditation
|
||||
const effectiveRegen = baseRegen * (1 - incursionStrength) * meditationMultiplier;
|
||||
// Calculate total attunement conversion per tick (to subtract from regen)
|
||||
const attunementState = useAttunementStore.getState();
|
||||
let totalConversionPerTick = 0;
|
||||
Object.entries(attunementState.attunements).forEach(([id, state]) => {
|
||||
if (!state.active) return;
|
||||
const def = ATTUNEMENTS_DEF[id];
|
||||
if (!def || def.conversionRate <= 0 || !def.primaryManaType) return;
|
||||
|
||||
const scaledRate = getAttunementConversionRate(id, state.level || 1);
|
||||
totalConversionPerTick += scaledRate * HOURS_PER_TICK;
|
||||
});
|
||||
|
||||
// Mana regeneration
|
||||
// Calculate effective regen with incursion, meditation, and attunement conversion
|
||||
const effectiveRegen = Math.max(0, baseRegen * (1 - incursionStrength) * meditationMultiplier - totalConversionPerTick);
|
||||
|
||||
// Mana regeneration (now includes attunement conversion deduction)
|
||||
let rawMana = Math.min(manaState.rawMana + effectiveRegen * HOURS_PER_TICK, maxMana);
|
||||
let elements = { ...manaState.elements };
|
||||
|
||||
// Apply attunement conversion (raw mana to primary mana types)
|
||||
const attunementState = useAttunementStore.getState();
|
||||
// Apply attunement conversion (add to primary mana types)
|
||||
Object.entries(attunementState.attunements).forEach(([id, state]) => {
|
||||
if (!state.active) return;
|
||||
const def = ATTUNEMENTS_DEF[id];
|
||||
@@ -160,17 +171,11 @@ export const useGameStore = create<GameCoordinatorStore>()(
|
||||
const scaledRate = getAttunementConversionRate(id, state.level || 1);
|
||||
const conversionThisTick = scaledRate * HOURS_PER_TICK; // per tick
|
||||
|
||||
// Cap conversion to available raw mana
|
||||
const actualConversion = Math.min(conversionThisTick, rawMana);
|
||||
|
||||
// Subtract from raw mana
|
||||
rawMana = Math.max(0, rawMana - actualConversion);
|
||||
|
||||
// Add to primary mana type
|
||||
// Add to primary mana type (cost already deducted from regen)
|
||||
if (elements[def.primaryManaType]) {
|
||||
elements[def.primaryManaType].current = Math.min(
|
||||
elements[def.primaryManaType].max,
|
||||
elements[def.primaryManaType].current + actualConversion
|
||||
elements[def.primaryManaType].current + conversionThisTick
|
||||
);
|
||||
}
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user