refactor: resolve structural inconsistencies and dead code
Build and Publish Mana Loop Docker Image / build-and-publish (push) Failing after 55s
Build and Publish Mana Loop Docker Image / build-and-publish (push) Failing after 55s
- Fix broken barrel exports in components/game/index.ts - Remove skill system from stores (gameStore, gameActions, gameLoopActions, gameHooks, craftingStore, combat) - Remove skill system from components (page.tsx, LeftPanel, StatsTab, SpellsTab, EnchantmentDesigner, EnchantmentPreparer, GameContext/Provider) - Delete dead code: stats/ directory, attunements/ directory, layout/ Header+TabBar, shared/ StudyProgress+UpgradeDialog duplicates, effects.ts.fix, study-slice.ts, navigation-slice.ts - Delete legacy store/ and store-modules/ directories, redirect remaining callers - Merge root formatting.ts into utils/formatting.ts - Move effects files (dynamic-compute, upgrade-effects, special-effects, upgrade-effects.types) into effects/ directory - Move debug-context.tsx into components/game/debug/ - Create tabs/index.ts barrel for tab components - Fix page.tsx lazy imports to use tabs barrel - Fix all broken import paths across codebase - Remove SKILLS_DEF and skill-evolution references - Trim store.ts to under 400 lines by removing dead skill actions
This commit is contained in:
@@ -0,0 +1,125 @@
|
||||
// ─── Dynamic Computations ──────────────────────────────────────────────────
|
||||
// Dynamic computation functions that depend on special effects
|
||||
|
||||
import type { ComputedEffects } from './upgrade-effects.types';
|
||||
import { SPECIAL_EFFECTS, hasSpecial } from './special-effects';
|
||||
|
||||
/**
|
||||
* Compute regen with special effects that depend on dynamic values
|
||||
*/
|
||||
export function computeDynamicRegen(
|
||||
effects: ComputedEffects,
|
||||
baseRegen: number,
|
||||
maxMana: number,
|
||||
currentMana: number,
|
||||
incursionStrength: number
|
||||
): number {
|
||||
let regen = baseRegen;
|
||||
|
||||
// Mana Cascade: +0.1 regen per 100 max mana
|
||||
if (hasSpecial(effects, SPECIAL_EFFECTS.MANA_CASCADE)) {
|
||||
regen += Math.floor(maxMana / 100) * 0.1;
|
||||
}
|
||||
|
||||
// Mana Waterfall: +0.25 regen per 100 max mana (upgraded cascade)
|
||||
if (hasSpecial(effects, SPECIAL_EFFECTS.MANA_WATERFALL)) {
|
||||
regen += Math.floor(maxMana / 100) * 0.25;
|
||||
}
|
||||
|
||||
// Mana Torrent: +50% regen when above 75% mana
|
||||
if (hasSpecial(effects, SPECIAL_EFFECTS.MANA_TORRENT) && currentMana > maxMana * 0.75) {
|
||||
regen *= 1.5;
|
||||
}
|
||||
|
||||
// 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;
|
||||
}
|
||||
|
||||
// Deep Reserve: +0.5 regen per 100 max mana
|
||||
if (hasSpecial(effects, SPECIAL_EFFECTS.DEEP_RESERVE)) {
|
||||
regen += Math.floor(maxMana / 100) * 0.5;
|
||||
}
|
||||
|
||||
// Mana Core: 0.5% of max mana added as regen
|
||||
if (hasSpecial(effects, SPECIAL_EFFECTS.MANA_CORE)) {
|
||||
regen += maxMana * 0.005;
|
||||
}
|
||||
|
||||
// Mana Tide: Regen pulses ±50% (sinusoidal based on time)
|
||||
if (hasSpecial(effects, SPECIAL_EFFECTS.MANA_TIDE)) {
|
||||
const pulseFactor = 0.5 + 0.5 * Math.sin(Date.now() / 10000);
|
||||
regen *= (0.5 + pulseFactor * 0.5);
|
||||
}
|
||||
|
||||
// Eternal Flow: Regen immune to ALL penalties
|
||||
if (hasSpecial(effects, SPECIAL_EFFECTS.ETERNAL_FLOW)) {
|
||||
return regen * effects.regenMultiplier;
|
||||
}
|
||||
|
||||
// Steady Stream: Regen immune to incursion
|
||||
if (hasSpecial(effects, SPECIAL_EFFECTS.STEADY_STREAM)) {
|
||||
return regen * effects.regenMultiplier;
|
||||
}
|
||||
|
||||
// Apply incursion penalty
|
||||
regen *= (1 - incursionStrength);
|
||||
|
||||
return regen * effects.regenMultiplier;
|
||||
}
|
||||
|
||||
/**
|
||||
* Compute click mana with special effects
|
||||
*/
|
||||
export function computeDynamicClickMana(
|
||||
effects: ComputedEffects,
|
||||
baseClickMana: number
|
||||
): number {
|
||||
let clickMana = baseClickMana;
|
||||
|
||||
// Mana Echo: 10% chance to gain double mana from clicks
|
||||
// Note: The chance is handled in the click handler, this just returns the base
|
||||
// The click handler should check hasSpecial and apply the 10% chance
|
||||
|
||||
// Mana Genesis: Generate 1% of max mana per hour passively
|
||||
// This is handled in the game loop (store.ts), not here
|
||||
|
||||
// Mana Heart: +10% max mana per loop (permanent)
|
||||
// This is applied during loop reset in store.ts
|
||||
|
||||
return Math.floor((clickMana + effects.clickManaBonus) * effects.clickManaMultiplier);
|
||||
}
|
||||
|
||||
/**
|
||||
* Compute damage with special effects
|
||||
*/
|
||||
export function computeDynamicDamage(
|
||||
effects: ComputedEffects,
|
||||
baseDamage: number,
|
||||
floorHPPct: number,
|
||||
currentMana: number,
|
||||
maxMana: number
|
||||
): number {
|
||||
let damage = baseDamage * effects.baseDamageMultiplier;
|
||||
|
||||
// Overpower: +50% damage when mana above 80%
|
||||
if (hasSpecial(effects, SPECIAL_EFFECTS.OVERPOWER) && currentMana >= maxMana * 0.8) {
|
||||
damage *= 1.5;
|
||||
}
|
||||
|
||||
// Berserker: +50% damage when below 50% mana
|
||||
if (hasSpecial(effects, SPECIAL_EFFECTS.BERSERKER) && currentMana < maxMana * 0.5) {
|
||||
damage *= 1.5;
|
||||
}
|
||||
|
||||
// Combo Master: Every 5th attack deals 3x damage
|
||||
// Note: The hit counter is tracked in game state, this just returns the multiplier
|
||||
// The combat handler should check hasSpecial and the hit count
|
||||
|
||||
return damage + effects.baseDamageBonus;
|
||||
}
|
||||
Reference in New Issue
Block a user