Refactor large files into modular components
Build and Publish Mana Loop Docker Image / build-and-publish (push) Failing after 1m9s
Build and Publish Mana Loop Docker Image / build-and-publish (push) Failing after 1m9s
- Refactored page.tsx (613→252 lines) with GameOverScreen and LeftPanel extracted - Refactored StatsTab.tsx (584→92 lines) with section components - Refactored SkillsTab.tsx (434→54 lines) with sub-components - Created modular structure for GameContext, LootInventory, and other components - All extracted components organized into feature directories
This commit is contained in:
@@ -0,0 +1,72 @@
|
||||
// ─── Enchantment Application Actions ────────────────────────────────────────
|
||||
|
||||
import type { GameState } from '../types';
|
||||
import * as CraftingApply from '../crafting-apply';
|
||||
|
||||
export function startApplying(
|
||||
equipmentInstanceId: string,
|
||||
designId: string,
|
||||
get: () => GameState,
|
||||
set: (fn: (state: GameState) => Partial<GameState>) => void
|
||||
): boolean {
|
||||
const state = get();
|
||||
const instance = state.equipmentInstances[equipmentInstanceId];
|
||||
const design = state.enchantmentDesigns.find(d => d.id === designId);
|
||||
|
||||
const validation = CraftingApply.canApplyEnchantment(
|
||||
instance,
|
||||
design,
|
||||
state.currentAction
|
||||
);
|
||||
if (!validation.canApply) return false;
|
||||
|
||||
set(() => ({
|
||||
currentAction: 'enchant' as const,
|
||||
applicationProgress: CraftingApply.initializeApplicationProgress(
|
||||
equipmentInstanceId,
|
||||
designId,
|
||||
design!
|
||||
),
|
||||
}));
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
export function pauseApplication(
|
||||
get: () => GameState,
|
||||
set: (fn: (state: GameState) => Partial<GameState>) => void
|
||||
) {
|
||||
set((state) => {
|
||||
if (!state.applicationProgress) return {};
|
||||
return {
|
||||
applicationProgress: {
|
||||
...state.applicationProgress,
|
||||
paused: true,
|
||||
},
|
||||
};
|
||||
});
|
||||
}
|
||||
|
||||
export function resumeApplication(
|
||||
get: () => GameState,
|
||||
set: (fn: (state: GameState) => Partial<GameState>) => void
|
||||
) {
|
||||
set((state) => {
|
||||
if (!state.applicationProgress) return {};
|
||||
return {
|
||||
applicationProgress: {
|
||||
...state.applicationProgress,
|
||||
paused: false,
|
||||
},
|
||||
};
|
||||
});
|
||||
}
|
||||
|
||||
export function cancelApplication(
|
||||
set: (fn: (state: GameState) => Partial<GameState>) => void
|
||||
) {
|
||||
set(() => ({
|
||||
currentAction: 'meditate' as const,
|
||||
applicationProgress: null,
|
||||
}));
|
||||
}
|
||||
Reference in New Issue
Block a user