Task 2: Crafting - disable Prepare for non-enchanted items, limit Design to owned gear types
This commit is contained in:
@@ -11,6 +11,7 @@ import { Wand2, Scroll, Trash2, Plus, Minus } from 'lucide-react';
|
|||||||
import { EQUIPMENT_TYPES } from '@/lib/game/data/equipment';
|
import { EQUIPMENT_TYPES } from '@/lib/game/data/equipment';
|
||||||
import { ENCHANTMENT_EFFECTS, calculateEffectCapacityCost } from '@/lib/game/data/enchantment-effects';
|
import { ENCHANTMENT_EFFECTS, calculateEffectCapacityCost } from '@/lib/game/data/enchantment-effects';
|
||||||
import { LOOT_DROPS, RARITY_COLORS } from '@/lib/game/data/loot-drops';
|
import { LOOT_DROPS, RARITY_COLORS } from '@/lib/game/data/loot-drops';
|
||||||
|
import { CRAFTING_RECIPES } from '@/lib/game/data/crafting-recipes';
|
||||||
import type { EquipmentInstance, EnchantmentDesign, DesignEffect, LootInventory, EquipmentCraftingProgress } from '@/lib/game/types';
|
import type { EquipmentInstance, EnchantmentDesign, DesignEffect, LootInventory, EquipmentCraftingProgress } from '@/lib/game/types';
|
||||||
import { fmt, type GameStore } from '@/lib/game/store';
|
import { fmt, type GameStore } from '@/lib/game/store';
|
||||||
|
|
||||||
@@ -138,6 +139,34 @@ export function EnchantmentDesigner({
|
|||||||
);
|
);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
// Get equipment types that the player has blueprints for
|
||||||
|
const getOwnedEquipmentTypes = () => {
|
||||||
|
const ownedBlueprints = store.lootInventory.blueprints || [];
|
||||||
|
|
||||||
|
// Map blueprint IDs to equipment type IDs
|
||||||
|
const ownedEquipmentTypeIds = new Set<string>();
|
||||||
|
for (const blueprintId of ownedBlueprints) {
|
||||||
|
const recipe = CRAFTING_RECIPES[blueprintId];
|
||||||
|
if (recipe) {
|
||||||
|
ownedEquipmentTypeIds.add(recipe.equipmentTypeId);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Also include the starting equipment types (basicStaff, civilianShirt, civilianShoes)
|
||||||
|
// These are the types the player starts with, so they should be able to design for them
|
||||||
|
ownedEquipmentTypeIds.add('basicStaff');
|
||||||
|
ownedEquipmentTypeIds.add('civilianShirt');
|
||||||
|
ownedEquipmentTypeIds.add('civilianShoes');
|
||||||
|
ownedEquipmentTypeIds.add('apprenticeWand');
|
||||||
|
ownedEquipmentTypeIds.add('clothHood');
|
||||||
|
ownedEquipmentTypeIds.add('civilianGloves');
|
||||||
|
ownedEquipmentTypeIds.add('copperRing');
|
||||||
|
|
||||||
|
return Object.values(EQUIPMENT_TYPES).filter(type => ownedEquipmentTypeIds.has(type.id));
|
||||||
|
};
|
||||||
|
|
||||||
|
const ownedEquipmentTypes = getOwnedEquipmentTypes();
|
||||||
|
|
||||||
// Render design stage
|
// Render design stage
|
||||||
return (
|
return (
|
||||||
<div className="grid grid-cols-1 lg:grid-cols-2 gap-4">
|
<div className="grid grid-cols-1 lg:grid-cols-2 gap-4">
|
||||||
@@ -162,7 +191,7 @@ export function EnchantmentDesigner({
|
|||||||
) : (
|
) : (
|
||||||
<ScrollArea className="h-64">
|
<ScrollArea className="h-64">
|
||||||
<div className="grid grid-cols-2 gap-2">
|
<div className="grid grid-cols-2 gap-2">
|
||||||
{Object.values(EQUIPMENT_TYPES).map(type => (
|
{ownedEquipmentTypes.map(type => (
|
||||||
<div
|
<div
|
||||||
key={type.id}
|
key={type.id}
|
||||||
className={`p-2 rounded border cursor-pointer transition-all ${
|
className={`p-2 rounded border cursor-pointer transition-all ${
|
||||||
@@ -177,6 +206,11 @@ export function EnchantmentDesigner({
|
|||||||
</div>
|
</div>
|
||||||
))}
|
))}
|
||||||
</div>
|
</div>
|
||||||
|
{ownedEquipmentTypes.length === 0 && (
|
||||||
|
<div className="text-center text-gray-400 py-4 text-sm">
|
||||||
|
No equipment blueprints owned. Craft or find equipment blueprints first.
|
||||||
|
</div>
|
||||||
|
)}
|
||||||
</ScrollArea>
|
</ScrollArea>
|
||||||
)}
|
)}
|
||||||
</CardContent>
|
</CardContent>
|
||||||
@@ -354,3 +388,5 @@ export function EnchantmentDesigner({
|
|||||||
</div>
|
</div>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
EnchantmentDesigner.displayName = "EnchantmentDesigner";
|
||||||
|
|||||||
@@ -422,6 +422,9 @@ export function createCraftingSlice(
|
|||||||
const instance = state.equipmentInstances[equipmentInstanceId];
|
const instance = state.equipmentInstances[equipmentInstanceId];
|
||||||
if (!instance) return false;
|
if (!instance) return false;
|
||||||
|
|
||||||
|
// Don't allow preparing enchanted items - they need to be disenchanted first
|
||||||
|
if (instance.enchantments.length > 0) return false;
|
||||||
|
|
||||||
const prepTime = calculatePrepTime(instance.totalCapacity);
|
const prepTime = calculatePrepTime(instance.totalCapacity);
|
||||||
const manaCost = calculatePrepManaCost(instance.totalCapacity);
|
const manaCost = calculatePrepManaCost(instance.totalCapacity);
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user