fix: lootInventory, prestige, golemancy, attunementStore export, debug components
Build and Publish Mana Loop Docker Image / build-and-publish (push) Successful in 1m21s

This commit is contained in:
Refactoring Agent
2026-05-05 15:00:22 +02:00
parent f0532c1673
commit ed616738fd
10 changed files with 171 additions and 68 deletions
+25
View File
@@ -7,6 +7,7 @@ import { SPELLS_DEF, GUARDIANS, HOURS_PER_TICK } from '../constants';
import type { GameAction, SpellState } from '../types';
import { getFloorMaxHP, getFloorElement, calcDamage, canAffordSpellCost, deductSpellCost } from '../utils';
import { usePrestigeStore } from './prestigeStore';
import { useGameStore } from './gameStore';
export interface CombatState {
// Floor state
@@ -56,6 +57,11 @@ export interface CombatState {
// Reset
resetCombat: (startFloor: number, spellsToKeep?: string[]) => void;
// Debug helpers
debugSetFloor: (floor: number) => void;
resetFloorHP: () => void;
debugSetTime: (day: number, hour: number) => void;
}
export const useCombatStore = create<CombatState>()(
@@ -244,6 +250,25 @@ export const useCombatStore = create<CombatState>()(
spells: startSpells,
});
},
// Debug helpers
debugSetFloor: (floor: number) => {
set({
currentFloor: floor,
floorHP: getFloorMaxHP(floor),
floorMaxHP: getFloorMaxHP(floor),
});
},
resetFloorHP: () => {
set((state) => ({
floorHP: state.floorMaxHP,
}));
},
debugSetTime: (day: number, hour: number) => {
useGameStore.setState({ day, hour });
},
}),
{
name: 'mana-loop-combat',
+55
View File
@@ -37,6 +37,11 @@ export interface CraftingState {
equipmentInstances: Record<string, EquipmentInstance>;
// Equipped instances (slot -> instanceId or null)
equippedInstances: Record<string, string | null>;
// Loot inventory
lootInventory: {
materials: Record<string, number>;
blueprints: string[];
};
}
export interface CraftingActions {
@@ -68,6 +73,10 @@ export interface CraftingActions {
// Enchantment preparation actions
startPreparing: (equipmentInstanceId: string) => boolean;
cancelPreparation: () => void;
// Loot inventory actions
deleteMaterial: (materialId: string, amount: number) => void;
deleteEquipmentInstance: (instanceId: string) => void;
}
export type CraftingStore = CraftingState & CraftingActions;
@@ -85,6 +94,10 @@ export const useCraftingStore = create<CraftingStore>()(
unlockedEffects: [],
equipmentInstances: {},
equippedInstances: {},
lootInventory: {
materials: {},
blueprints: [],
},
// Actions
setDesignProgress: (progress) => set({ designProgress: progress }),
@@ -221,6 +234,47 @@ export const useCraftingStore = create<CraftingStore>()(
PreparationActions.cancelPreparation(set);
useGameStore.setState({ currentAction: 'meditate' });
},
// Loot inventory actions
deleteMaterial: (materialId: string, amount: number) => {
set((state) => {
const newMaterials = { ...state.lootInventory.materials };
const currentAmount = newMaterials[materialId] || 0;
const newAmount = Math.max(0, currentAmount - amount);
if (newAmount <= 0) {
delete newMaterials[materialId];
} else {
newMaterials[materialId] = newAmount;
}
return {
lootInventory: {
...state.lootInventory,
materials: newMaterials,
},
};
});
},
deleteEquipmentInstance: (instanceId: string) => {
set((state) => {
let newEquipped = { ...state.equippedInstances };
for (const [slot, id] of Object.entries(newEquipped)) {
if (id === instanceId) {
newEquipped[slot as any] = null;
}
}
const newInstances = { ...state.equipmentInstances };
delete newInstances[instanceId];
return {
equippedInstances: newEquipped,
equipmentInstances: newInstances,
};
});
},
}),
{
name: 'mana-loop-crafting',
@@ -234,6 +288,7 @@ export const useCraftingStore = create<CraftingStore>()(
unlockedEffects: state.unlockedEffects,
equipmentInstances: state.equipmentInstances,
equippedInstances: state.equippedInstances,
lootInventory: state.lootInventory,
}),
}
)
+25
View File
@@ -26,6 +26,12 @@ export interface PrestigeState {
// Guardian pacts
defeatedGuardians: number[];
signedPacts: number[];
signedPactDetails: Record<number, {
floor: number;
guardianId: string;
signedAt: { day: number; hour: number };
skillLevels: Record<string, number>;
}>;
pactRitualFloor: number | null;
pactRitualProgress: number;
@@ -73,6 +79,12 @@ const initialState = {
memories: [] as Memory[],
defeatedGuardians: [] as number[],
signedPacts: [] as number[],
signedPactDetails: {} as Record<number, {
floor: number;
guardianId: string;
signedAt: { day: number; hour: number };
skillLevels: Record<string, number>;
}>,
pactRitualFloor: null as number | null,
pactRitualProgress: 0,
};
@@ -249,6 +261,19 @@ export const usePrestigeStore = create<PrestigeState>()(
resetPrestige: () => {
set(initialState);
},
// Debug helpers
debugSetSignedPacts: (pacts: number[]) => {
set({ signedPacts: pacts });
},
debugSetPactDetails: (details: Record<number, {
floor: number;
guardianId: string;
signedAt: { day: number; hour: number };
skillLevels: Record<string, number>;
}>) => {
set({ signedPactDetails: details });
},
}),
{
name: 'mana-loop-prestige',