Phase 4: Mana Well effects (1st 7)

This commit is contained in:
Refactoring Agent
2026-04-24 16:17:50 +02:00
parent 6e3b867e7d
commit 132a4e6a72
3 changed files with 46 additions and 7 deletions
+25 -3
View File
@@ -298,7 +298,7 @@ function getEffectiveSkillLevel(
}
export function computeMaxMana(
state: Pick<GameState, 'skills' | 'prestigeUpgrades' | 'skillUpgrades' | 'skillTiers' | 'equipmentInstances' | 'equippedInstances'>,
state: Pick<GameState, 'skills' | 'prestigeUpgrades' | 'skillUpgrades' | 'skillTiers' | 'equipmentInstances' | 'equippedInstances' | 'totalManaGathered'>,
effects?: ComputedEffects | UnifiedEffects
): number {
const pu = state.prestigeUpgrades;
@@ -313,10 +313,21 @@ export function computeMaxMana(
}
// Apply effects if available (now includes equipment bonuses)
let maxMana: number;
if (effects) {
return Math.floor((base + effects.maxManaBonus) * effects.maxManaMultiplier);
maxMana = Math.floor((base + effects.maxManaBonus) * effects.maxManaMultiplier);
} else {
maxMana = base;
}
return base;
// MANA_CONDENSE: +1% max mana per 1000 total mana gathered
if (effects && hasSpecial(effects, SPECIAL_EFFECTS.MANA_CONDENSE)) {
const totalGathered = state.totalManaGathered || 0;
const condensesBonus = Math.floor(totalGathered / 1000);
maxMana = Math.floor(maxMana * (1 + condensesBonus * 0.01));
}
return maxMana;
}
export function computeElementMax(
@@ -1695,6 +1706,12 @@ export const useGameStore = create<GameStore>()(
spellsToKeep = learnedSpells.slice(0, state.skills.temporalMemory);
}
// EMERGENCY_RESERVE: Keep 10% mana on new loop
const effects = computeEffects(state.skillUpgrades || {}, state.skillTiers || {});
const hasEmergencyReserve = hasSpecial(effects, SPECIAL_EFFECTS.EMERGENCY_RESERVE);
const maxMana = computeMaxMana(state, effects);
const keepMana = hasEmergencyReserve ? Math.floor(maxMana * 0.10) : 0;
const newState = makeInitial({
loopCount: state.loopCount + 1,
insight: total,
@@ -1704,6 +1721,11 @@ export const useGameStore = create<GameStore>()(
skills: state.skills, // Keep skills through temporal memory for now
});
// Set the kept mana from EMERGENCY_RESERVE
if (keepMana > 0) {
newState.rawMana = keepMana;
}
// Add kept spells
if (spellsToKeep.length > 0) {
spellsToKeep.forEach(spellId => {