Phase 4: Element special effects (4)

This commit is contained in:
Refactoring Agent
2026-04-25 09:19:15 +02:00
parent 0f0b800e60
commit 8d1d328c3f
+46 -1
View File
@@ -880,6 +880,23 @@ export const useGameStore = create<GameStore>()(
if (state.currentAction === 'meditate') {
meditateTicks++;
meditationMultiplier = getMeditationBonus(meditateTicks, state.skills);
// MANA_CONDUIT: Meditation regenerates elemental mana
if (hasSpecial(effects, SPECIAL_EFFECTS.MANA_CONDUIT)) {
const elementalRegenPerTick = 0.1 * HOURS_PER_TICK; // 0.1 elemental mana per hour of meditation
elements = { ...state.elements };
Object.keys(elements).forEach(elemId => {
if (elements[elemId]?.unlocked) {
elements[elemId] = {
...elements[elemId],
current: Math.min(
elements[elemId].current + elementalRegenPerTick,
elements[elemId].max
)
};
}
});
}
} else {
meditateTicks = 0;
}
@@ -1165,6 +1182,21 @@ export const useGameStore = create<GameStore>()(
elements = afterCost.elements;
totalManaGathered += spellDef.cost.amount;
// ELEMENTAL_RESONANCE: Using element spells restores 1 of that element
if (hasSpecial(effects, SPECIAL_EFFECTS.ELEMENTAL_RESONANCE) && spellDef.cost.element) {
const elemId = spellDef.cost.element;
if (elements[elemId]?.unlocked) {
elements = {
...elements,
[elemId]: {
...elements[elemId],
current: Math.min(elements[elemId].current + 1, elements[elemId].max)
}
};
log = [`🔄 Elemental Resonance! +1 ${ELEMENTS[elemId]?.name || elemId} mana!`, ...log.slice(0, 49)];
}
}
// Calculate damage
let baseDmg = calcDamage(state, spellId, floorElement);
@@ -1243,6 +1275,15 @@ export const useGameStore = create<GameStore>()(
log = [`🔥 Berserker! +50% damage!`, ...log.slice(0, 49)];
}
// EXOTIC_MASTERY: +20% damage with exotic elements
if (hasSpecial(effects, SPECIAL_EFFECTS.EXOTIC_MASTERY) && spellDef.elem) {
const elemDef = ELEMENTS[spellDef.elem];
if (elemDef?.cat === 'exotic') {
dmg *= 1.2;
log = [`🌟 Exotic Mastery! +20% damage!`, ...log.slice(0, 49)];
}
}
// Spell echo - chance to cast again
const echoChance = (skills.spellEcho || 0) * 0.1;
if (Math.random() < echoChance) {
@@ -1764,11 +1805,15 @@ export const useGameStore = create<GameStore>()(
const cost = 500;
if (state.rawMana < cost) return;
// ELEMENTAL_AFFINITY: New elements start with 10 capacity
const effects = getUnifiedEffects(state.skillUpgrades, state.skillTiers);
const newElementMax = hasSpecial(effects, SPECIAL_EFFECTS.ELEMENTAL_AFFINITY) ? 10 : 0;
set({
rawMana: state.rawMana - cost,
elements: {
...state.elements,
[element]: { ...state.elements[element], unlocked: true },
[element]: { ...state.elements[element], unlocked: true, max: newElementMax },
},
log: [`${ELEMENTS[element].name} affinity unlocked!`, ...state.log.slice(0, 49)],
});