0eabd604b0
Build and Publish Mana Loop Docker Image / build-and-publish (push) Has been cancelled
- Change Dockerfile to use development build (better error messages)
- Add || {} fallbacks to all Object.values() calls accessing state
- Fixes "Cannot convert undefined or null to object" browser error during SSR/hydration
- Verified TypeScript compilation and Next.js build successful
Files modified:
- Dockerfile
- src/app/page.tsx
- src/components/game/tabs/StatsTab.tsx
- src/components/game/StatsTab/LoopStatsSection.tsx
- src/components/game/StatsTab/ElementStatsSection.tsx
- src/components/game/tabs/AttunementsTab.tsx
- src/components/game/tabs/GolemancyTab.tsx
- src/lib/game/effects.ts
- src/lib/game/utils/combat-utils.ts
- src/lib/game/crafting-loot.ts
- src/components/game/LootInventory/LootInventoryDisplay.tsx
- src/components/game/LootInventory/index.tsx
- src/components/game/crafting/EnchantmentDesigner/utils.ts
57 lines
1.9 KiB
TypeScript
57 lines
1.9 KiB
TypeScript
// ─── Computed Getters ──────────────────────────────────────────────────────
|
|
|
|
import type { GameState } from '../types';
|
|
import { ENCHANTMENT_EFFECTS } from '../data/enchantment-effects';
|
|
|
|
export function getEquipmentSpells(get: () => GameState): string[] {
|
|
const state = get();
|
|
const spells: string[] = [];
|
|
|
|
for (const instanceId of Object.values(state.equippedInstances || {})) {
|
|
if (!instanceId) continue;
|
|
const instance = state.equipmentInstances[instanceId];
|
|
if (!instance) continue;
|
|
|
|
for (const ench of instance.enchantments) {
|
|
const effectDef = ENCHANTMENT_EFFECTS[ench.effectId];
|
|
if (effectDef?.effect.type === 'spell' && effectDef.effect.spellId) {
|
|
spells.push(effectDef.effect.spellId);
|
|
}
|
|
}
|
|
}
|
|
|
|
return [...new Set(spells)];
|
|
}
|
|
|
|
export function getEquipmentEffects(get: () => GameState): Record<string, number> {
|
|
const state = get();
|
|
const effects: Record<string, number> = {};
|
|
|
|
for (const instanceId of Object.values(state.equippedInstances || {})) {
|
|
if (!instanceId) continue;
|
|
const instance = state.equipmentInstances[instanceId];
|
|
if (!instance) continue;
|
|
|
|
for (const ench of instance.enchantments) {
|
|
const effectDef = ENCHANTMENT_EFFECTS[ench.effectId];
|
|
if (!effectDef) continue;
|
|
|
|
if (effectDef.effect.type === 'bonus' && effectDef.effect.stat && effectDef.effect.value) {
|
|
effects[effectDef.effect.stat] = (effects[effectDef.effect.stat] || 0) + effectDef.effect.value * ench.stacks;
|
|
}
|
|
}
|
|
}
|
|
|
|
return effects;
|
|
}
|
|
|
|
export function getAvailableCapacity(
|
|
instanceId: string,
|
|
get: () => GameState
|
|
): number {
|
|
const state = get();
|
|
const instance = state.equipmentInstances[instanceId];
|
|
if (!instance) return 0;
|
|
return instance.totalCapacity - instance.usedCapacity;
|
|
}
|