Fix 3 bugs: equip crash, enchantment not processing, spire spell casting
Build and Publish Mana Loop Docker Image / build-and-publish (push) Successful in 1m43s

Bug 1: EquipmentTab handleEquip was passing useCombatStore to equipItem()
which needs the crafting store (has equipmentInstances/equippedInstances).
Fixed by using useCraftingStore instead.

Bug 2: processCraftingTick() from crafting-slice.ts was never called in the
game tick loop. Added call in tick-logic.ts when currentAction is
'design'/'prepare'/'enchant'/'craft' so enchantment progress advances.

Bug 3: equipmentSpellStates was initialized as [] and never populated from
equipped items. Added logic in tick-logic.ts to build equipmentSpellStates
from active equipment spells when climbing (currentAction === 'climb').
This commit is contained in:
2026-05-11 12:07:12 +02:00
parent ae0bf3e38d
commit f6bf049f91
5 changed files with 874 additions and 4 deletions
+2 -1
View File
@@ -26,6 +26,7 @@ import { ConfirmDialog } from '@/components/game/ConfirmDialog';
import { DebugName } from '@/lib/game/debug-context';
import { equipItem, unequipItem, deleteEquipmentInstance } from '@/lib/game/crafting-actions';
import { useCombatStore, useCraftingStore } from '@/lib/game/stores';
import type { GameState } from '@/lib/game/types';
// Rarity color mappings using design system tokens
export const RARITY_BORDER_COLORS: Record<string, string> = {
@@ -151,7 +152,7 @@ export function EquipmentTab() {
// Equip an item to a slot
const handleEquip = (instanceId: string, slot: EquipmentSlot) => {
const instance = equipmentInstances[instanceId];
equipItem(instanceId, slot, useCombatStore.getState, (fn) => useCombatStore.setState(fn));
equipItem(instanceId, slot, useCraftingStore.getState as () => GameState, (fn) => useCraftingStore.setState(fn as any));
setSelectedSlot(null);
showToast('success', 'Item Equipped', `${instance?.name || 'Item'} equipped to ${SLOT_NAMES[slot]}`);
};
+31
View File
@@ -16,6 +16,8 @@ import { GOLEMS_DEF, isGolemUnlocked, getGolemDamage } from '../data/golems';
import { SPELLS_DEF, ELEMENTS } from '../constants';
import { canAffordSpellCost, deductSpellCost, calcDamage } from './computed-stats';
import { getFloorElement, getFloorMaxHP } from '../utils/floor-utils';
import { processCraftingTick } from '../crafting-slice';
import { getActiveEquipmentSpells } from '../utils/combat-utils';
interface TickParams {
state: GameState;
@@ -219,6 +221,34 @@ export function processTick({ state, set, get }: TickParams): void {
comboHitCount = comboHitCount || 0;
floorHitCount = floorHitCount || 0;
// Build equipment spell states from equipped items (Bug #3 fix)
let equipmentSpellStates = state.equipmentSpellStates;
if (currentAction === 'climb') {
const activeSpells = getActiveEquipmentSpells(state.equippedInstances, state.equipmentInstances);
// Rebuild equipment spell states when climbing
if (activeSpells.length > 0) {
equipmentSpellStates = activeSpells.map(s => {
const existing = state.equipmentSpellStates.find(es => es.spellId === s.spellId && es.sourceEquipment === s.equipmentId);
return existing || { spellId: s.spellId, sourceEquipment: s.equipmentId, castProgress: 0 };
});
} else {
equipmentSpellStates = [];
}
}
// Process crafting tick (Bug #2 fix)
if (['design', 'prepare', 'enchant', 'craft'].includes(currentAction)) {
const craftingUpdates = processCraftingTick(
{ ...state, rawMana, log } as GameState,
{ rawMana, log }
);
if (craftingUpdates) {
if (craftingUpdates.rawMana !== undefined) rawMana = craftingUpdates.rawMana;
if (craftingUpdates.log) log = craftingUpdates.log;
if (craftingUpdates.currentAction) currentAction = craftingUpdates.currentAction;
}
}
// Update state
set({
day, hour, rawMana, elements, meditateTicks,
@@ -226,5 +256,6 @@ export function processTick({ state, set, get }: TickParams): void {
parallelStudyTarget, currentFloor, floorHP, floorMaxHP, maxFloorReached, signedPacts, castProgress, currentRoom,
comboHitCount, floorHitCount, activityLog, totalManaGathered,
conversionDrains, flowSurgeEndTime, incursionStrength,
equipmentSpellStates,
});
}