8a7ddaae27
Build and Publish Mana Loop Docker Image / build-and-publish (push) Successful in 1m19s
- CombatState: split into CombatState (data) + CombatActions + CombatStore - PrestigeState: split into PrestigeState (data) + PrestigeActions + PrestigeStore - ManaState: split into ManaState (data) + ManaActions + ManaStore - GameState: deprecated, removed from barrel exports - crafting-actions: updated to use CraftingState instead of GameState - combat-utils/mana-utils: replaced Pick<GameState,...> with focused interfaces - DisciplineCardProps: split into Definition + Runtime + Callbacks - stores/index.ts: now exports both State and Actions types
57 lines
1.9 KiB
TypeScript
57 lines
1.9 KiB
TypeScript
// ─── Computed Getters ──────────────────────────────────────────────────────
|
|
|
|
import type { CraftingState } from '../stores/craftingStore.types';
|
|
import { ENCHANTMENT_EFFECTS } from '../data/enchantment-effects';
|
|
|
|
export function getEquipmentSpells(get: () => CraftingState): 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: () => CraftingState): 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: () => CraftingState
|
|
): number {
|
|
const state = get();
|
|
const instance = state.equipmentInstances[instanceId];
|
|
if (!instance) return 0;
|
|
return instance.totalCapacity - instance.usedCapacity;
|
|
}
|