742a992d59
Build and Publish Mana Loop Docker Image / build-and-publish (push) Successful in 1m34s
- Fix computeDisciplineEffects() to not require GameState parameter - Fix getUnifiedEffects() to accept proper partial state type - Replace upgradeEffects as any with proper UnifiedEffects type - Replace explicit : any annotations with proper types (ComputedEffects, DesignProgress, SpellDef, etc.) - Fix activity-log.ts eventType casting - Fix crafting-design.ts computedEffects and designProgress types - Fix page.tsx grimoire spell rendering with proper SpellDef property names - Fix StatsTab ManaStatsSection with proper ManaStatsEffects interface - Remove unused imports (useDisciplineStore from page.tsx, LeftPanel.tsx) Remaining: 1 as any in craftingStore.ts (pre-existing CraftingStore/GameState architectural mismatch)
114 lines
3.4 KiB
TypeScript
114 lines
3.4 KiB
TypeScript
// ─── Enchantment Design Actions ────────────────────────────────────────────
|
|
|
|
import type { GameState, EnchantmentDesign, DesignEffect, DesignProgress } from '../types';
|
|
import * as CraftingUtils from '../crafting-utils';
|
|
import * as CraftingDesign from '../crafting-design';
|
|
import { computeEffects } from '../effects/upgrade-effects';
|
|
import { hasSpecial, SPECIAL_EFFECTS } from '../effects/special-effects';
|
|
|
|
export function startDesigningEnchantment(
|
|
name: string,
|
|
equipmentTypeId: string,
|
|
effects: DesignEffect[],
|
|
get: () => GameState,
|
|
set: (fn: (state: GameState) => Partial<GameState>) => void
|
|
): boolean {
|
|
const state = get();
|
|
const enchantingLevel = state.skills.enchanting || 0;
|
|
const validation = CraftingDesign.validateDesignEffects(
|
|
effects,
|
|
equipmentTypeId,
|
|
enchantingLevel
|
|
);
|
|
if (!validation.valid) return false;
|
|
|
|
const equipType = CraftingUtils.getEquipmentType(equipmentTypeId);
|
|
if (!equipType) return false;
|
|
|
|
const efficiencyBonus = ((state.skillUpgrades || {})['efficientEnchant'] || [])?.length * 0.05 || 0;
|
|
const totalCapacityCost = CraftingDesign.calculateDesignCapacityCost(effects, efficiencyBonus);
|
|
|
|
if (totalCapacityCost > equipType.baseCapacity) {
|
|
return false;
|
|
}
|
|
|
|
const computedEffects = computeEffects(state.skillUpgrades || {}, state.skillTiers || {});
|
|
const hasEnchantMastery = hasSpecial(computedEffects, SPECIAL_EFFECTS.ENCHANT_MASTERY);
|
|
|
|
let updates: Partial<GameState> = {};
|
|
|
|
if (!state.designProgress) {
|
|
updates = {
|
|
currentAction: 'design' as const,
|
|
designProgress: {
|
|
designId: CraftingUtils.generateDesignId(),
|
|
progress: 0,
|
|
required: CraftingDesign.calculateDesignTime(effects),
|
|
name,
|
|
equipmentType: equipmentTypeId,
|
|
effects,
|
|
},
|
|
};
|
|
} else if (hasEnchantMastery && !state.designProgress2) {
|
|
updates = {
|
|
designProgress2: {
|
|
designId: CraftingUtils.generateDesignId(),
|
|
progress: 0,
|
|
required: CraftingDesign.calculateDesignTime(effects),
|
|
name,
|
|
equipmentType: equipmentTypeId,
|
|
effects,
|
|
},
|
|
};
|
|
} else {
|
|
return false;
|
|
}
|
|
|
|
set(() => updates);
|
|
return true;
|
|
}
|
|
|
|
export function cancelDesign(
|
|
get: () => GameState,
|
|
set: (fn: (state: GameState) => Partial<GameState>) => void
|
|
) {
|
|
const state = get();
|
|
if (state.designProgress2 && !state.designProgress) {
|
|
set(() => ({ designProgress2: null }));
|
|
} else {
|
|
set(() => ({
|
|
currentAction: 'meditate' as const,
|
|
designProgress: null,
|
|
}));
|
|
}
|
|
}
|
|
|
|
export function saveDesign(
|
|
design: EnchantmentDesign,
|
|
get: () => GameState,
|
|
set: (fn: (state: GameState) => Partial<GameState>) => void
|
|
) {
|
|
const state = get();
|
|
if (state.designProgress2 && state.designProgress2.designId === design.id) {
|
|
set((state) => ({
|
|
enchantmentDesigns: [...state.enchantmentDesigns, design],
|
|
designProgress2: null,
|
|
}));
|
|
} else {
|
|
set((state) => ({
|
|
enchantmentDesigns: [...state.enchantmentDesigns, design],
|
|
designProgress: null,
|
|
currentAction: 'meditate' as const,
|
|
}));
|
|
}
|
|
}
|
|
|
|
export function deleteDesign(
|
|
designId: string,
|
|
set: (fn: (state: GameState) => Partial<GameState>) => void
|
|
) {
|
|
set((state) => ({
|
|
enchantmentDesigns: state.enchantmentDesigns.filter(d => d.id !== designId),
|
|
}));
|
|
}
|