refactor: eliminate as any type casts across 18 source files
Build and Publish Mana Loop Docker Image / build-and-publish (push) Successful in 1m34s
Build and Publish Mana Loop Docker Image / build-and-publish (push) Successful in 1m34s
- Fix computeDisciplineEffects() to not require GameState parameter - Fix getUnifiedEffects() to accept proper partial state type - Replace upgradeEffects as any with proper UnifiedEffects type - Replace explicit : any annotations with proper types (ComputedEffects, DesignProgress, SpellDef, etc.) - Fix activity-log.ts eventType casting - Fix crafting-design.ts computedEffects and designProgress types - Fix page.tsx grimoire spell rendering with proper SpellDef property names - Fix StatsTab ManaStatsSection with proper ManaStatsEffects interface - Remove unused imports (useDisciplineStore from page.tsx, LeftPanel.tsx) Remaining: 1 as any in craftingStore.ts (pre-existing CraftingStore/GameState architectural mismatch)
This commit is contained in:
@@ -1,11 +1,12 @@
|
||||
// ─── Crafting Design System ─────────────────────────────────────────────────
|
||||
// Design system functions: calculateDesignTime, capacity cost, XP, etc.
|
||||
|
||||
import type { EnchantmentDesign, DesignEffect, AppliedEnchantment } from './types';
|
||||
import type { EnchantmentDesign, DesignEffect, AppliedEnchantment, DesignProgress } from './types';
|
||||
import type { EquipmentInstance } from './types';
|
||||
import type { ComputedEffects } from './effects/upgrade-effects.types';
|
||||
import { calculateEnchantingXP } from './data/attunements';
|
||||
import { ENCHANTMENT_EFFECTS, calculateEffectCapacityCost } from './data/enchantment-effects';
|
||||
import { hasSpecial, SPECIAL_EFFECTS } from './effects/special-effects';
|
||||
import { computeEffects } from './effects/upgrade-effects';
|
||||
import { EQUIPMENT_TYPES, type EquipmentCategory } from './data/equipment';
|
||||
|
||||
// ─── Design Creation & Calculation ──────────────────────────────────────────
|
||||
@@ -110,7 +111,7 @@ export function calculateDesignTime(effects: DesignEffect[]): number {
|
||||
export function getDesignTimeWithHaste(
|
||||
effects: DesignEffect[],
|
||||
isRepeatDesign: boolean,
|
||||
computedEffects: any
|
||||
computedEffects: ComputedEffects
|
||||
): number {
|
||||
let time = calculateDesignTime(effects);
|
||||
if (isRepeatDesign && hasSpecial(computedEffects, SPECIAL_EFFECTS.HASTY_ENCHANTER)) {
|
||||
@@ -131,7 +132,7 @@ export interface DesignProgressUpdate {
|
||||
export function calculateDesignProgress(
|
||||
currentProgress: number,
|
||||
required: number,
|
||||
computedEffects: any,
|
||||
computedEffects: ComputedEffects,
|
||||
isRepeatDesign: boolean
|
||||
): DesignProgressUpdate {
|
||||
let progress = currentProgress + 0.04;
|
||||
@@ -152,15 +153,15 @@ export function calculateDesignProgress(
|
||||
export function calculateSecondDesignProgress(
|
||||
currentProgress: number,
|
||||
required: number,
|
||||
computedEffects: any,
|
||||
computedEffects: ComputedEffects,
|
||||
isRepeatDesign: boolean
|
||||
): DesignProgressUpdate {
|
||||
return calculateDesignProgress(currentProgress, required, computedEffects, isRepeatDesign);
|
||||
}
|
||||
|
||||
export function isSecondDesignSlotAvailable(
|
||||
designProgress: any,
|
||||
designProgress2: any,
|
||||
designProgress: DesignProgress | null,
|
||||
designProgress2: DesignProgress | null,
|
||||
hasEnchantMastery: boolean
|
||||
): boolean {
|
||||
if (!designProgress && !designProgress2) return true;
|
||||
@@ -208,18 +209,11 @@ export function filterDesignsByEquipment(
|
||||
if (!equipment) return [];
|
||||
return designs.map(design => ({
|
||||
design,
|
||||
fitsInEquipment: designFitsInEquipment(design, {
|
||||
...equipment,
|
||||
enchantments: [],
|
||||
rarity: 'common',
|
||||
quality: 100,
|
||||
typeId: '',
|
||||
name: '',
|
||||
} as any),
|
||||
fitsInEquipment: designFitsInEquipment(design, equipment),
|
||||
availableCapacity: equipment.totalCapacity - equipment.usedCapacity,
|
||||
}));
|
||||
}
|
||||
|
||||
function designFitsInEquipment(design: EnchantmentDesign, instance: any): boolean {
|
||||
function designFitsInEquipment(design: EnchantmentDesign, instance: { usedCapacity: number; totalCapacity: number }): boolean {
|
||||
return (instance.usedCapacity || 0) + design.totalCapacityUsed <= instance.totalCapacity;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user