fix: migrate equipment and enchantment state to modular stores, fix EnchantmentDesigner
Build and Publish Mana Loop Docker Image / build-and-publish (push) Successful in 1m24s

This commit is contained in:
Refactoring Agent
2026-05-05 13:25:19 +02:00
parent 221d3e4b41
commit 3db7e07302
14 changed files with 246 additions and 60 deletions
@@ -22,7 +22,8 @@ import {
addEffectToDesign,
removeEffectFromDesign,
} from './EnchantmentDesigner/utils';
import { useGameStore } from '@/lib/game/stores';
import { useCraftingStore } from '@/lib/game/stores';
import { useSkillStore } from '@/lib/game/stores';
export function EnchantmentDesigner({
selectedEquipmentType,
@@ -34,16 +35,21 @@ export function EnchantmentDesigner({
selectedDesign,
setSelectedDesign,
}: EnchantmentDesignerProps) {
const enchantmentDesigns = useGameStore((s) => s.enchantmentDesigns);
const designProgress = useGameStore((s) => s.designProgress);
const startDesigningEnchantment = useGameStore((s) => s.startDesigningEnchantment);
const cancelDesign = useGameStore((s) => s.cancelDesign);
const deleteDesign = useGameStore((s) => s.deleteDesign);
const unlockedEffects = useGameStore((s) => s.unlockedEffects);
const skills = useGameStore((s) => s.skills);
// Crafting store selectors
const enchantmentDesigns = useCraftingStore((s) => s.enchantmentDesigns);
const designProgress = useCraftingStore((s) => s.designProgress);
const startDesigningEnchantment = useCraftingStore((s) => s.startDesigningEnchantment);
const cancelDesign = useCraftingStore((s) => s.cancelDesign);
const deleteDesign = useCraftingStore((s) => s.deleteDesign);
const unlockedEffects = useCraftingStore((s) => s.unlockedEffects);
const equipmentInstances = useCraftingStore((s) => s.equipmentInstances);
const enchantingLevel = skills.enchanting || 0;
const efficiencyBonus = (skills.efficientEnchant || 0) * 0.05;
// Skill store selectors
const skills = useSkillStore((s) => s.skills);
const skillUpgrades = useSkillStore((s) => s.skillUpgrades);
const enchantingLevel = skills?.enchanting || 0;
const efficiencyBonus = (skillUpgrades?.['efficientEnchant'] || []).length * 0.05 || 0;
// Calculate total capacity cost for current design
const designCapacityCost = calculateDesignCapacityCost(selectedEffects, efficiencyBonus);
@@ -84,7 +90,7 @@ export function EnchantmentDesigner({
const incompatibleEffects = getIncompatibleEffects(selectedEquipmentType, unlockedEffects);
// Get equipment types that the player actually owns (has instances of)
const ownedEquipmentTypes = getOwnedEquipmentTypes(useGameStore.getState());
const ownedEquipmentTypes = getOwnedEquipmentTypes(equipmentInstances);
// Get the reason why an effect is incompatible
const getIncompatibilityReasonWrapper = (effect: { id: string; name: string; description: string; allowedEquipmentCategories: any[] }) => {