refactor: consolidate duplicate functions (calculateDesignTime, calculateDesignCapacityCost, generateSwarmEnemies)
Build and Publish Mana Loop Docker Image / build-and-publish (push) Successful in 1m21s
Build and Publish Mana Loop Docker Image / build-and-publish (push) Successful in 1m21s
This commit is contained in:
@@ -1,9 +1,8 @@
|
||||
// ─── Crafting Helper Utilities ─────────────────────────────────────────────────
|
||||
// Instance/ID generation and helper functions
|
||||
|
||||
import type { EquipmentInstance, EnchantmentDesign, DesignEffect } from './types';
|
||||
import type { EquipmentInstance, EnchantmentDesign } from './types';
|
||||
import { EQUIPMENT_TYPES, type EquipmentCategory, type EquipmentSlot } from './data/equipment';
|
||||
import { ENCHANTMENT_EFFECTS, calculateEffectCapacityCost } from './data/enchantment-effects';
|
||||
import { CRAFTING_RECIPES, canCraftRecipe, type CraftingRecipe } from './data/crafting-recipes';
|
||||
|
||||
// ─── Instance/ID Generation ──────────────────────────────────────────────────
|
||||
@@ -29,10 +28,6 @@ export function getEquipmentType(typeId: string) {
|
||||
|
||||
// ─── Capacity Calculation Helpers ────────────────────────────────────────────
|
||||
|
||||
export function calculateDesignCapacityCost(effects: DesignEffect[], efficiencyBonus: number = 0): number {
|
||||
return effects.reduce((total, eff) => total + calculateEffectCapacityCost(eff.effectId, eff.stacks, efficiencyBonus), 0);
|
||||
}
|
||||
|
||||
export function getAvailableCapacity(instance: EquipmentInstance): number {
|
||||
return instance.totalCapacity - instance.usedCapacity;
|
||||
}
|
||||
@@ -43,17 +38,6 @@ export function designFitsInEquipment(design: EnchantmentDesign, instance: Equip
|
||||
|
||||
// ─── Time Calculation Helpers ────────────────────────────────────────────────
|
||||
|
||||
export function calculateDesignTime(effects: DesignEffect[]): number {
|
||||
let time = 1;
|
||||
for (const eff of effects) {
|
||||
const effectDef = ENCHANTMENT_EFFECTS[eff.effectId];
|
||||
if (effectDef) {
|
||||
time += 0.5 * eff.stacks;
|
||||
}
|
||||
}
|
||||
return time;
|
||||
}
|
||||
|
||||
export function calculatePrepTime(equipmentCapacity: number): number {
|
||||
return 2 + Math.floor(equipmentCapacity / 50);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user