diff --git a/src/lib/game/store.ts b/src/lib/game/store.ts index 2fadbcd..6205335 100755 --- a/src/lib/game/store.ts +++ b/src/lib/game/store.ts @@ -298,7 +298,7 @@ function getEffectiveSkillLevel( } export function computeMaxMana( - state: Pick, + state: Pick, 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()( 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()( 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 => { diff --git a/src/lib/game/store/manaSlice.ts b/src/lib/game/store/manaSlice.ts index bd6a419..ac5c1d2 100755 --- a/src/lib/game/store/manaSlice.ts +++ b/src/lib/game/store/manaSlice.ts @@ -5,7 +5,7 @@ import type { StateCreator } from 'zustand'; import type { GameState, ElementState, SpellCost } from '../types'; import { ELEMENTS, MANA_PER_ELEMENT, BASE_UNLOCKED_ELEMENTS } from '../constants'; import { computeMaxMana, computeElementMax, computeClickMana, canAffordSpellCost, getMeditationBonus } from './computed'; -import { computeEffects } from '../upgrade-effects'; +import { computeEffects, hasSpecial, SPECIAL_EFFECTS } from '../upgrade-effects'; export interface ManaSlice { // State @@ -67,6 +67,11 @@ export const createManaSlice = ( const effects = computeEffects(state.skillUpgrades || {}, state.skillTiers || {}); const max = computeMaxMana(state, effects); + // Mana Conversion: Convert 5% of max mana to click bonus + if (hasSpecial(effects, SPECIAL_EFFECTS.MANA_CONVERSION)) { + cm += Math.floor(max * 0.05); + } + // Mana Echo: 10% chance to gain double mana from clicks const hasManaEcho = effects.specials?.has('MANA_ECHO') ?? false; if (hasManaEcho && Math.random() < 0.1) { diff --git a/src/lib/game/upgrade-effects.ts b/src/lib/game/upgrade-effects.ts index 0b6ee2c..f7b12d1 100755 --- a/src/lib/game/upgrade-effects.ts +++ b/src/lib/game/upgrade-effects.ts @@ -72,7 +72,8 @@ export const SPECIAL_EFFECTS = { ETERNAL_FLOW: 'eternalFlow', // Regen immune to all penalties // Mana Well special effects - DESPERATE_WELLS: 'desperateWells', // +50% regen when below 25% mana + DESPAIR_WELLS: 'despairWells', // +50% regen when below 25% mana (task name) + DESPERATE_WELLS: 'desperateWells', // +50% regen when below 25% mana (legacy name) MANA_ECHO: 'manaEcho', // 10% chance double mana from clicks EMERGENCY_RESERVE: 'emergencyReserve', // Keep 10% mana on new loop MANA_THRESHOLD: 'manaThreshold', // +30% max mana, -10% regen trade-off @@ -309,6 +310,12 @@ export function computeEffects( } } + // MANA_THRESHOLD: +30% max mana, -10% regen trade-off + if (hasSpecial(effects, SPECIAL_EFFECTS.MANA_THRESHOLD)) { + effects.maxManaMultiplier *= 1.30; + effects.regenMultiplier *= 0.90; + } + return effects; } @@ -346,11 +353,16 @@ export function computeDynamicRegen( regen *= 1.5; } - // Desperate Wells: +50% regen when below 25% mana - if (hasSpecial(effects, SPECIAL_EFFECTS.DESPERATE_WELLS) && currentMana < maxMana * 0.25) { + // Desperate Wells / Despair Wells: +50% regen when below 25% mana + if ((hasSpecial(effects, SPECIAL_EFFECTS.DESPERATE_WELLS) || hasSpecial(effects, SPECIAL_EFFECTS.DESPAIR_WELLS)) && currentMana < maxMana * 0.25) { regen *= 1.5; } + // Panic Reserve: +100% regen when below 10% mana + if (hasSpecial(effects, SPECIAL_EFFECTS.PANIC_RESERVE) && currentMana < maxMana * 0.1) { + regen *= 2.0; + } + // Eternal Flow: Regen immune to ALL penalties (stronger than Steady Stream) if (hasSpecial(effects, SPECIAL_EFFECTS.ETERNAL_FLOW)) { return regen * effects.regenMultiplier;