Fix crafting tab crash, update attunement XP system
Some checks failed
Build and Publish Mana Loop Docker Image / build-and-publish (push) Failing after 33s
Some checks failed
Build and Publish Mana Loop Docker Image / build-and-publish (push) Failing after 33s
- Add missing EquipmentCraftingProgress interface to types.ts - Fix CraftingTab to accept store prop like other tabs - Update attunement XP calculation: 1 XP per 10 capacity used (min 1) - Change XP requirements: 1000 for lv2, 2500 for lv3, doubling thereafter - Grant Enchanter XP when enchantments are applied - Add equipmentCraftingProgress to GameState and persist config
This commit is contained in:
@@ -1,11 +1,12 @@
|
||||
// ─── Crafting Store Slice ─────────────────────────────────────────────────────────
|
||||
// Handles equipment and enchantment system: design, prepare, apply stages
|
||||
|
||||
import type { GameState, EquipmentInstance, AppliedEnchantment, EnchantmentDesign, DesignEffect, EquipmentSlot, EquipmentCraftingProgress, LootInventory } from './types';
|
||||
import type { GameState, EquipmentInstance, AppliedEnchantment, EnchantmentDesign, DesignEffect, EquipmentSlot, EquipmentCraftingProgress, LootInventory, AttunementState } from './types';
|
||||
import { EQUIPMENT_TYPES, type EquipmentCategory } from './data/equipment';
|
||||
import { ENCHANTMENT_EFFECTS, calculateEffectCapacityCost } from './data/enchantment-effects';
|
||||
import { CRAFTING_RECIPES, canCraftRecipe, type CraftingRecipe } from './data/crafting-recipes';
|
||||
import { SPELLS_DEF } from './constants';
|
||||
import { calculateEnchantingXP, getAttunementXPForLevel, MAX_ATTUNEMENT_LEVEL } from './data/attunements';
|
||||
|
||||
// ─── Helper Functions ─────────────────────────────────────────────────────────
|
||||
|
||||
@@ -687,11 +688,42 @@ export function processCraftingTick(
|
||||
actualCost: eff.capacityCost,
|
||||
}));
|
||||
|
||||
// Calculate and grant attunement XP to enchanter
|
||||
const xpGained = calculateEnchantingXP(design.totalCapacityUsed);
|
||||
let newAttunements = state.attunements;
|
||||
|
||||
if (state.attunements.enchanter?.active && xpGained > 0) {
|
||||
const enchanterState = state.attunements.enchanter;
|
||||
let newXP = enchanterState.experience + xpGained;
|
||||
let newLevel = enchanterState.level;
|
||||
|
||||
// Check for level ups
|
||||
while (newLevel < MAX_ATTUNEMENT_LEVEL) {
|
||||
const xpNeeded = getAttunementXPForLevel(newLevel + 1);
|
||||
if (newXP >= xpNeeded) {
|
||||
newXP -= xpNeeded;
|
||||
newLevel++;
|
||||
} else {
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
newAttunements = {
|
||||
...state.attunements,
|
||||
enchanter: {
|
||||
...enchanterState,
|
||||
level: newLevel,
|
||||
experience: newXP,
|
||||
},
|
||||
};
|
||||
}
|
||||
|
||||
updates = {
|
||||
...updates,
|
||||
rawMana: rawMana - manaCost,
|
||||
applicationProgress: null,
|
||||
currentAction: 'meditate',
|
||||
attunements: newAttunements,
|
||||
equipmentInstances: {
|
||||
...state.equipmentInstances,
|
||||
[app.equipmentInstanceId]: {
|
||||
@@ -700,7 +732,7 @@ export function processCraftingTick(
|
||||
usedCapacity: instance.usedCapacity + design.totalCapacityUsed,
|
||||
},
|
||||
},
|
||||
log: [`✨ Enchantment "${design.name}" applied to ${instance.name}!`, ...log],
|
||||
log: [`✨ Enchantment "${design.name}" applied to ${instance.name}! (+${xpGained} Enchanter XP)`, ...log],
|
||||
};
|
||||
}
|
||||
} else {
|
||||
|
||||
Reference in New Issue
Block a user