Phase 3: Split enchantment-effects.ts into category files
Build and Publish Mana Loop Docker Image / build-and-publish (push) Successful in 2m48s

This commit is contained in:
Unknown
2026-04-24 12:56:14 +02:00
parent f8520e15b8
commit c46981d81b
10 changed files with 956 additions and 844 deletions
+69
View File
@@ -0,0 +1,69 @@
// ─── Enchantment Effects Index ─────────────────────────────────────────
// Re-exports everything from category-specific files for backward compatibility
// Import types
import type { EnchantmentEffectCategory, EnchantmentEffectDef } from '../enchantment-types'
// Import all category-specific effect collections
import { SPELL_EFFECTS } from './spell-effects'
import { MANA_EFFECTS } from './mana-effects'
import { COMBAT_EFFECTS } from './combat-effects'
import { ELEMENTAL_EFFECTS } from './elemental-effects'
import { DEFENSE_EFFECTS } from './defense-effects'
import { UTILITY_EFFECTS } from './utility-effects'
import { SPECIAL_EFFECTS } from './special-effects'
// Merge all effects into a single record for backward compatibility
export const ENCHANTMENT_EFFECTS: Record<string, EnchantmentEffectDef> = {
...SPELL_EFFECTS,
...MANA_EFFECTS,
...COMBAT_EFFECTS,
...ELEMENTAL_EFFECTS,
...DEFENSE_EFFECTS,
...UTILITY_EFFECTS,
...SPECIAL_EFFECTS,
}
// ─── Helper Functions ────────────────────────────────────────────────────────
export function getEnchantmentEffect(id: string): EnchantmentEffectDef | undefined {
return ENCHANTMENT_EFFECTS[id];
}
export function getEffectsForEquipment(equipmentCategory: EquipmentCategory): EnchantmentEffectDef[] {
return Object.values(ENCHANTMENT_EFFECTS).filter(effect =>
effect.allowedEquipmentCategories.includes(equipmentCategory)
);
}
export function canApplyEffect(effectId: string, equipmentCategory: EquipmentCategory): boolean {
const effect = ENCHANTMENT_EFFECTS[effectId];
if (!effect) return false;
return effect.allowedEquipmentCategories.includes(equipmentCategory);
}
export function calculateEffectCapacityCost(effectId: string, stacks: number, efficiencyBonus: number = 0): number {
const effect = ENCHANTMENT_EFFECTS[effectId];
if (!effect) return 0;
let totalCost = 0;
for (let i = 0; i < stacks; i++) {
// Each additional stack costs 20% more
const stackMultiplier = 1 + (i * 0.2);
totalCost += effect.baseCapacityCost * stackMultiplier;
}
// Apply efficiency bonus (reduces cost)
return Math.floor(totalCost * (1 - efficiencyBonus));
}
// Re-export category-specific collections for direct access if needed
export {
SPELL_EFFECTS,
MANA_EFFECTS,
COMBAT_EFFECTS,
ELEMENTAL_EFFECTS,
DEFENSE_EFFECTS,
UTILITY_EFFECTS,
SPECIAL_EFFECTS,
}