Consolidate disenchanting into CraftingTab Prepare step (Bug 8)
Build and Publish Mana Loop Docker Image / build-and-publish (push) Successful in 3m32s
Build and Publish Mana Loop Docker Image / build-and-publish (push) Successful in 3m32s
- Add 'tags' field to EquipmentInstance type - Modify Prepare step to show warning and different button text when item has enchantments - Consolidate disenchanting into Prepare step (remove separate disenchant UI) - After successful preparation, item receives 'Ready for Enchantment' tag - Modify Apply step to only allow applying enchantments to items tagged 'Ready for Enchantment' - Update subtask_6_progress.md and todo.md to mark Sub-Task 6 as completed
This commit is contained in:
@@ -422,8 +422,8 @@ export function createCraftingSlice(
|
||||
const instance = state.equipmentInstances[equipmentInstanceId];
|
||||
if (!instance) return false;
|
||||
|
||||
// Don't allow preparing enchanted items - they need to be disenchanted first
|
||||
if (instance.enchantments.length > 0) return false;
|
||||
// Don't allow preparing an item that's already prepared
|
||||
if (instance.tags?.includes('Ready for Enchantment')) return false;
|
||||
|
||||
const prepTime = calculatePrepTime(instance.totalCapacity);
|
||||
const manaCost = calculatePrepManaCost(instance.totalCapacity);
|
||||
@@ -459,6 +459,11 @@ export function createCraftingSlice(
|
||||
|
||||
if (!instance || !design) return false;
|
||||
|
||||
// Check if equipment is ready for enchantment
|
||||
if (!instance.tags?.includes('Ready for Enchantment')) {
|
||||
return false;
|
||||
}
|
||||
|
||||
// Check capacity
|
||||
if (instance.usedCapacity + design.totalCapacityUsed > instance.totalCapacity) {
|
||||
return false;
|
||||
@@ -818,12 +823,35 @@ export function processCraftingTick(
|
||||
const manaCostPaid = prep.manaCostPaid + manaCost;
|
||||
|
||||
if (progress >= prep.required) {
|
||||
// Preparation complete - clear enchantments, add tag, and recover some mana
|
||||
const instance = state.equipmentInstances[prep.equipmentInstanceId];
|
||||
let totalRecovered = 0;
|
||||
|
||||
if (instance) {
|
||||
// Calculate mana recovery from disenchanting
|
||||
const disenchantLevel = (state.skills as Record<string, number>).disenchanting || 0;
|
||||
const recoveryRate = 0.1 + disenchantLevel * 0.2; // 10% base + 20% per level
|
||||
for (const ench of instance.enchantments) {
|
||||
totalRecovered += Math.floor(ench.actualCost * recoveryRate);
|
||||
}
|
||||
}
|
||||
|
||||
updates = {
|
||||
...updates,
|
||||
rawMana: rawMana - manaCost,
|
||||
rawMana: rawMana - manaCost + totalRecovered,
|
||||
preparationProgress: null,
|
||||
currentAction: 'meditate',
|
||||
log: ['✅ Equipment prepared for enchanting!', ...log],
|
||||
equipmentInstances: instance ? {
|
||||
...state.equipmentInstances,
|
||||
[instance.instanceId]: {
|
||||
...instance,
|
||||
enchantments: [],
|
||||
usedCapacity: 0,
|
||||
rarity: 'common',
|
||||
tags: [...(instance.tags || []), 'Ready for Enchantment'],
|
||||
},
|
||||
} : state.equipmentInstances,
|
||||
log: [`✅ Equipment prepared for enchanting! Recovered ${totalRecovered} mana.`, ...log],
|
||||
};
|
||||
} else {
|
||||
updates = {
|
||||
|
||||
Reference in New Issue
Block a user