Fix LeftPanel.tsx to use modular stores instead of legacy useGameStore
Build and Publish Mana Loop Docker Image / build-and-publish (push) Successful in 1m22s
Build and Publish Mana Loop Docker Image / build-and-publish (push) Successful in 1m22s
- Added useCraftingStore import for crafting progress fields - Changed spireMode/enterSpireMode to useCombatStore - Changed currentStudyTarget to useSkillStore - Changed crafting progress fields to useCraftingStore - Added useCraftingStore export to stores/index.ts - Kept useGameStore only for gatherMana, day, hour
This commit is contained in:
@@ -7,7 +7,7 @@ import { ManaDisplay } from '@/components/game';
|
|||||||
import { ActionButtons } from '@/components/game';
|
import { ActionButtons } from '@/components/game';
|
||||||
import { CalendarDisplay } from '@/components/game';
|
import { CalendarDisplay } from '@/components/game';
|
||||||
import { DebugName } from '@/lib/game/debug-context';
|
import { DebugName } from '@/lib/game/debug-context';
|
||||||
import { useGameStore, useManaStore, useSkillStore, useCombatStore } from '@/lib/game/stores';
|
import { useGameStore, useManaStore, useSkillStore, useCombatStore, useCraftingStore } from '@/lib/game/stores';
|
||||||
import { getUnifiedEffects } from '@/lib/game/effects';
|
import { getUnifiedEffects } from '@/lib/game/effects';
|
||||||
import { computeMaxMana, computeClickMana, getMeditationBonus } from '@/lib/game/stores';
|
import { computeMaxMana, computeClickMana, getMeditationBonus } from '@/lib/game/stores';
|
||||||
|
|
||||||
@@ -24,18 +24,21 @@ export function LeftPanel() {
|
|||||||
const skillUpgrades = useSkillStore((s) => s.skillUpgrades);
|
const skillUpgrades = useSkillStore((s) => s.skillUpgrades);
|
||||||
|
|
||||||
const gatherMana = useGameStore((s) => s.gatherMana);
|
const gatherMana = useGameStore((s) => s.gatherMana);
|
||||||
const spireMode = useGameStore((s) => s.spireMode);
|
|
||||||
const currentAction = useCombatStore((s) => s.currentAction);
|
|
||||||
const currentStudyTarget = useGameStore((s) => s.currentStudyTarget);
|
|
||||||
const designProgress = useGameStore((s) => s.designProgress);
|
|
||||||
const designProgress2 = useGameStore((s) => s.designProgress2);
|
|
||||||
const preparationProgress = useGameStore((s) => s.preparationProgress);
|
|
||||||
const applicationProgress = useGameStore((s) => s.applicationProgress);
|
|
||||||
const equipmentCraftingProgress = useGameStore((s) => s.equipmentCraftingProgress);
|
|
||||||
const enterSpireMode = useGameStore((s) => s.enterSpireMode);
|
|
||||||
const day = useGameStore((s) => s.day);
|
const day = useGameStore((s) => s.day);
|
||||||
const hour = useGameStore((s) => s.hour);
|
const hour = useGameStore((s) => s.hour);
|
||||||
|
|
||||||
|
const spireMode = useCombatStore((s) => s.spireMode);
|
||||||
|
const enterSpireMode = useCombatStore((s) => s.enterSpireMode);
|
||||||
|
const currentAction = useCombatStore((s) => s.currentAction);
|
||||||
|
|
||||||
|
const currentStudyTarget = useSkillStore((s) => s.currentStudyTarget);
|
||||||
|
|
||||||
|
const designProgress = useCraftingStore((s) => s.designProgress);
|
||||||
|
const designProgress2 = useCraftingStore((s) => s.designProgress2);
|
||||||
|
const preparationProgress = useCraftingStore((s) => s.preparationProgress);
|
||||||
|
const applicationProgress = useCraftingStore((s) => s.applicationProgress);
|
||||||
|
const equipmentCraftingProgress = useCraftingStore((s) => s.equipmentCraftingProgress);
|
||||||
|
|
||||||
const handleGatherStart = () => {
|
const handleGatherStart = () => {
|
||||||
setIsGathering(true);
|
setIsGathering(true);
|
||||||
gatherMana();
|
gatherMana();
|
||||||
|
|||||||
@@ -1,13 +1,12 @@
|
|||||||
'use client';
|
'use client';
|
||||||
|
|
||||||
import { EquipmentSlot } from '@/lib/game/data/equipment';
|
import { EquipmentSlot } from '@/lib/game/data/equipment';
|
||||||
import type { GameStore } from '@/lib/game/types';
|
// GameStore import removed - not used
|
||||||
import { ActionButton } from '@/components/ui/action-button';
|
import { ActionButton } from '@/components/ui/action-button';
|
||||||
import { Tooltip, TooltipContent, TooltipProvider, TooltipTrigger } from '@/components/ui/tooltip';
|
import { Tooltip, TooltipContent, TooltipProvider, TooltipTrigger } from '@/components/ui/tooltip';
|
||||||
import { X } from 'lucide-react';
|
import { X } from 'lucide-react';
|
||||||
|
|
||||||
interface EquipmentControlsProps {
|
interface EquipmentControlsProps {
|
||||||
store: GameStore;
|
|
||||||
onUnequip: (slot: EquipmentSlot) => void;
|
onUnequip: (slot: EquipmentSlot) => void;
|
||||||
onDelete: (instanceId: string, name: string) => void;
|
onDelete: (instanceId: string, name: string) => void;
|
||||||
selectedSlot: EquipmentSlot | null;
|
selectedSlot: EquipmentSlot | null;
|
||||||
@@ -17,7 +16,6 @@ interface EquipmentControlsProps {
|
|||||||
}
|
}
|
||||||
|
|
||||||
export function EquipmentControls({
|
export function EquipmentControls({
|
||||||
store,
|
|
||||||
onUnequip,
|
onUnequip,
|
||||||
onDelete,
|
onDelete,
|
||||||
selectedSlot,
|
selectedSlot,
|
||||||
|
|||||||
@@ -3,7 +3,7 @@
|
|||||||
import { useState } from 'react';
|
import { useState } from 'react';
|
||||||
import { EquipmentSlot } from '@/lib/game/data/equipment';
|
import { EquipmentSlot } from '@/lib/game/data/equipment';
|
||||||
import { EQUIPMENT_TYPES } from '@/lib/game/data/equipment';
|
import { EQUIPMENT_TYPES } from '@/lib/game/data/equipment';
|
||||||
import type { GameStore, EquipmentInstance } from '@/lib/game/types';
|
import type { EquipmentInstance } from '@/lib/game/types';
|
||||||
import { GameCard } from '@/components/ui/game-card';
|
import { GameCard } from '@/components/ui/game-card';
|
||||||
import { Badge } from '@/components/ui/badge';
|
import { Badge } from '@/components/ui/badge';
|
||||||
import { Button } from '@/components/ui/button';
|
import { Button } from '@/components/ui/button';
|
||||||
@@ -17,7 +17,6 @@ import {
|
|||||||
import { EnchantmentsPanel } from './EnchantmentsPanel';
|
import { EnchantmentsPanel } from './EnchantmentsPanel';
|
||||||
|
|
||||||
interface EquipmentInventoryProps {
|
interface EquipmentInventoryProps {
|
||||||
store: GameStore;
|
|
||||||
unequippedItems: EquipmentInstance[];
|
unequippedItems: EquipmentInstance[];
|
||||||
onEquip: (instanceId: string, slot: EquipmentSlot) => void;
|
onEquip: (instanceId: string, slot: EquipmentSlot) => void;
|
||||||
onDelete: (instanceId: string, name: string) => void;
|
onDelete: (instanceId: string, name: string) => void;
|
||||||
@@ -27,7 +26,6 @@ interface EquipmentInventoryProps {
|
|||||||
}
|
}
|
||||||
|
|
||||||
export function EquipmentInventory({
|
export function EquipmentInventory({
|
||||||
store,
|
|
||||||
unequippedItems,
|
unequippedItems,
|
||||||
onEquip,
|
onEquip,
|
||||||
onDelete,
|
onDelete,
|
||||||
|
|||||||
@@ -1,8 +1,8 @@
|
|||||||
'use client';
|
'use client';
|
||||||
|
|
||||||
import { EquipmentSlot } from '@/lib/game/data/equipment';
|
import { EquipmentSlot } from '@/lib/game/data/equipment';
|
||||||
import { SLOT_NAMES } from '@/lib/game/data/equipment';
|
import { SLOT_NAMES, EQUIPMENT_TYPES } from '@/lib/game/data/equipment';
|
||||||
import type { GameStore, EquipmentInstance } from '@/lib/game/types';
|
import type { EquipmentInstance } from '@/lib/game/types';
|
||||||
import { GameCard } from '@/components/ui/game-card';
|
import { GameCard } from '@/components/ui/game-card';
|
||||||
import { Badge } from '@/components/ui/badge';
|
import { Badge } from '@/components/ui/badge';
|
||||||
import { AlertCircle, Sword, Shield, HardHat, Shirt, Hand, Footprints, Gem } from 'lucide-react';
|
import { AlertCircle, Sword, Shield, HardHat, Shirt, Hand, Footprints, Gem } from 'lucide-react';
|
||||||
@@ -23,7 +23,8 @@ const SLOT_ICONS: Record<EquipmentSlot, React.ElementType> = {
|
|||||||
};
|
};
|
||||||
|
|
||||||
interface EquipmentSlotGridProps {
|
interface EquipmentSlotGridProps {
|
||||||
store: GameStore;
|
equippedInstances: Record<string, string | null>;
|
||||||
|
equipmentInstances: Record<string, EquipmentInstance>;
|
||||||
selectedSlot: EquipmentSlot | null;
|
selectedSlot: EquipmentSlot | null;
|
||||||
onSlotClick: (slot: EquipmentSlot) => void;
|
onSlotClick: (slot: EquipmentSlot) => void;
|
||||||
onUnequip: (slot: EquipmentSlot) => void;
|
onUnequip: (slot: EquipmentSlot) => void;
|
||||||
@@ -32,7 +33,8 @@ interface EquipmentSlotGridProps {
|
|||||||
}
|
}
|
||||||
|
|
||||||
export function EquipmentSlotGrid({
|
export function EquipmentSlotGrid({
|
||||||
store,
|
equippedInstances,
|
||||||
|
equipmentInstances,
|
||||||
selectedSlot,
|
selectedSlot,
|
||||||
onSlotClick,
|
onSlotClick,
|
||||||
onUnequip,
|
onUnequip,
|
||||||
@@ -40,9 +42,9 @@ export function EquipmentSlotGrid({
|
|||||||
SLOT_GROUPS,
|
SLOT_GROUPS,
|
||||||
}: EquipmentSlotGridProps) {
|
}: EquipmentSlotGridProps) {
|
||||||
const renderSlot = (slot: EquipmentSlot) => {
|
const renderSlot = (slot: EquipmentSlot) => {
|
||||||
const instanceId = store.equippedInstances[slot];
|
const instanceId = equippedInstances[slot];
|
||||||
const instance = instanceId ? store.equipmentInstances[instanceId] : null;
|
const instance = instanceId ? equipmentInstances[instanceId] : null;
|
||||||
const equipmentType = instance ? (store as any).EQUIPMENT_TYPES?.[instance.typeId] : null;
|
const equipmentType = instance ? EQUIPMENT_TYPES?.[instance.typeId] : null;
|
||||||
const blocked = isSlotBlocked(slot);
|
const blocked = isSlotBlocked(slot);
|
||||||
const isEmpty = !instance;
|
const isEmpty = !instance;
|
||||||
const SlotIcon = SLOT_ICONS[slot];
|
const SlotIcon = SLOT_ICONS[slot];
|
||||||
|
|||||||
@@ -15,6 +15,7 @@ import {
|
|||||||
import { Button } from '@/components/ui/button';
|
import { Button } from '@/components/ui/button';
|
||||||
import { Card, CardContent, CardHeader, CardTitle } from '@/components/ui/card';
|
import { Card, CardContent, CardHeader, CardTitle } from '@/components/ui/card';
|
||||||
import { Badge } from '@/components/ui/badge';
|
import { Badge } from '@/components/ui/badge';
|
||||||
|
import { ScrollArea } from '@/components/ui/scroll-area';
|
||||||
import { fmt } from '@/lib/game/stores';
|
import { fmt } from '@/lib/game/stores';
|
||||||
|
|
||||||
export function PrestigeTab() {
|
export function PrestigeTab() {
|
||||||
@@ -51,7 +52,7 @@ export function PrestigeTab() {
|
|||||||
const effect = upgradeEffects ? upgradeEffects.specials.has(id) : false;
|
const effect = upgradeEffects ? upgradeEffects.specials.has(id) : false;
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<Card key={id} className={effect ? "border-[var(--color-success)]/50 bg-[var(--color-success)]/10" : "bg-gray-900/80 border-gray-700">
|
<Card key={id} className={effect ? "border-[var(--color-success)]/50 bg-[var(--color-success)]/10" : "bg-gray-900/80 border-gray-700"}>
|
||||||
<CardHeader>
|
<CardHeader>
|
||||||
<CardTitle className="text-sm flex items-center gap-2">
|
<CardTitle className="text-sm flex items-center gap-2">
|
||||||
<span>{def.name}</span>
|
<span>{def.name}</span>
|
||||||
|
|||||||
@@ -20,6 +20,9 @@ export interface CombatState {
|
|||||||
currentAction: GameAction;
|
currentAction: GameAction;
|
||||||
castProgress: number;
|
castProgress: number;
|
||||||
|
|
||||||
|
// Spire mode
|
||||||
|
spireMode: boolean;
|
||||||
|
|
||||||
// Spells
|
// Spells
|
||||||
spells: Record<string, SpellState>;
|
spells: Record<string, SpellState>;
|
||||||
|
|
||||||
@@ -37,6 +40,9 @@ export interface CombatState {
|
|||||||
learnSpell: (spellId: string) => void;
|
learnSpell: (spellId: string) => void;
|
||||||
setSpellState: (spellId: string, state: Partial<SpellState>) => void;
|
setSpellState: (spellId: string, state: Partial<SpellState>) => void;
|
||||||
|
|
||||||
|
// Spire mode
|
||||||
|
enterSpireMode: () => void;
|
||||||
|
|
||||||
// Combat tick
|
// Combat tick
|
||||||
processCombatTick: (
|
processCombatTick: (
|
||||||
skills: Record<string, number>,
|
skills: Record<string, number>,
|
||||||
@@ -62,6 +68,7 @@ export const useCombatStore = create<CombatState>()(
|
|||||||
activeSpell: 'manaBolt',
|
activeSpell: 'manaBolt',
|
||||||
currentAction: 'meditate',
|
currentAction: 'meditate',
|
||||||
castProgress: 0,
|
castProgress: 0,
|
||||||
|
spireMode: false,
|
||||||
spells: {
|
spells: {
|
||||||
manaBolt: { learned: true, level: 1, studyProgress: 0 },
|
manaBolt: { learned: true, level: 1, studyProgress: 0 },
|
||||||
},
|
},
|
||||||
@@ -112,6 +119,10 @@ export const useCombatStore = create<CombatState>()(
|
|||||||
set({ castProgress: progress });
|
set({ castProgress: progress });
|
||||||
},
|
},
|
||||||
|
|
||||||
|
enterSpireMode: () => {
|
||||||
|
set({ spireMode: true });
|
||||||
|
},
|
||||||
|
|
||||||
learnSpell: (spellId: string) => {
|
learnSpell: (spellId: string) => {
|
||||||
set((state) => ({
|
set((state) => ({
|
||||||
spells: {
|
spells: {
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
// ─── Store Index ──────────────────────────────────────────────────────────────
|
// ─── Store Index ──────────────────────────────────────────
|
||||||
// Exports all stores and re-exports commonly used utilities
|
// Exports all stores and re-exports commonly used utilities
|
||||||
|
|
||||||
// Stores
|
// Stores
|
||||||
@@ -17,6 +17,9 @@ export type { SkillState } from './skillStore';
|
|||||||
export { useCombatStore, makeInitialSpells } from './combatStore';
|
export { useCombatStore, makeInitialSpells } from './combatStore';
|
||||||
export type { CombatState } from './combatStore';
|
export type { CombatState } from './combatStore';
|
||||||
|
|
||||||
|
export { useCraftingStore } from './craftingStore';
|
||||||
|
export type { CraftingState, CraftingActions } from './craftingStore';
|
||||||
|
|
||||||
export { useGameStore } from './gameStore';
|
export { useGameStore } from './gameStore';
|
||||||
export { useGameLoop } from './gameHooks';
|
export { useGameLoop } from './gameHooks';
|
||||||
export type { GameCoordinatorState, GameCoordinatorStore } from './gameStore';
|
export type { GameCoordinatorState, GameCoordinatorStore } from './gameStore';
|
||||||
@@ -31,16 +34,14 @@ export {
|
|||||||
computeRegen,
|
computeRegen,
|
||||||
computeEffectiveRegen,
|
computeEffectiveRegen,
|
||||||
computeClickMana,
|
computeClickMana,
|
||||||
getElementalBonus,
|
getMeditationBonus,
|
||||||
getBoonBonuses,
|
getBoonBonuses,
|
||||||
calcDamage,
|
calcDamage,
|
||||||
calcInsight,
|
calcInsight,
|
||||||
getMeditationBonus,
|
|
||||||
getIncursionStrength,
|
getIncursionStrength,
|
||||||
canAffordSpellCost,
|
canAffordSpellCost,
|
||||||
deductSpellCost,
|
deductSpellCost,
|
||||||
} from '../utils';
|
} from '../utils';
|
||||||
|
|
||||||
export { computeElementMax } from '../store-modules/computed-stats';
|
export { computeElementMax } from '../store-modules/computed-stats';
|
||||||
|
|
||||||
export { getStudySpeedMultiplier, getStudyCostMultiplier } from '../constants';
|
export { getStudySpeedMultiplier, getStudyCostMultiplier } from '../constants';
|
||||||
|
|||||||
Reference in New Issue
Block a user