import { CraftingStationId } from "../definitions/craftingStations.js"; import { ItemId } from "../definitions/items.js"; import { CraftingItemId } from "../definitions/craftingItems.js"; import { MetalItemId } from "../definitions/metalItems.js"; import { LeatherItemId } from "../definitions/leatherItems.js"; import { ClothItemId, wovenClothItemId, rawClothItemId, yarnItemId, CLOTHING_TEMPLATES } from "../definitions/clothItems.js"; import { WIZARD_TEMPLATES } from "../definitions/wizardItems.js"; import { MaterialTier, GatherMaterialId, CLOTH_TIER_ORDER, ClothTier, LeatherTier, tierSmeltSkillLevel, tierCraftSkillLevel } from "../definitions/materialTiers.js"; import { TIER_FAMILY_RECIPES } from "./tierRecipes.js"; import { fishingToolRecipes, fishingCookRecipes } from "../definitions/fishItems.js"; import { staffCraftRecipes, gemCutRecipes } from "../definitions/gemItems.js"; import { jewelryCraftRecipes } from "../definitions/jewelryItems.js"; /** * Craft recipe schema (shared client + server): * * - recipeId: stable string id * - stationId | stationIds: where the recipe appears * - output: { itemId, quantity } * - inputs: [{ itemId, quantity }, ...] * - minSkillLevel: minimum linked station skill (default 1) * - xpMaterial: tier id for duration + XP scaling * - craftGroup / craftGroupLabel: UI groups tier variants behind one material dropdown */ function smelt (tier, recipeId, inputs, outputItemId) { return Object.freeze({ recipeId, stationId: CraftingStationId.furnace, output: { itemId: outputItemId, quantity: 1 }, inputs, minSkillLevel: tierSmeltSkillLevel(tier), skillId: "smithing", xpMaterial: tier }); } function yarnSpinRecipe (clothTier) { return Object.freeze({ recipeId: `yarn-${clothTier}`, craftGroup: "yarn", craftGroupLabel: "Yarn", stationId: CraftingStationId.spinningWheel, output: { itemId: yarnItemId(clothTier), quantity: 1 }, inputs: [{ itemId: rawClothItemId(clothTier), quantity: 1 }], minSkillLevel: tierCraftSkillLevel(clothTier), skillId: "tailoring", xpMaterial: clothTier }); } function clothWeaveRecipe (clothTier) { return Object.freeze({ recipeId: `cloth-${clothTier}`, craftGroup: "cloth", craftGroupLabel: "Cloth", stationId: CraftingStationId.loom, output: { itemId: wovenClothItemId(clothTier), quantity: 1 }, inputs: [{ itemId: yarnItemId(clothTier), quantity: 1 }], minSkillLevel: tierCraftSkillLevel(clothTier), skillId: "tailoring", xpMaterial: clothTier }); } const YARN_SPIN_RECIPES = CLOTH_TIER_ORDER.map((tier) => yarnSpinRecipe(tier)); const CLOTH_WEAVE_RECIPES = CLOTH_TIER_ORDER.map((tier) => clothWeaveRecipe(tier)); /** Tailor templates — client picks material; server resolves inputs/output. */ const TAILOR_TEMPLATE_RECIPES = Object.freeze([ ...Object.values(CLOTHING_TEMPLATES).map((template) => Object.freeze({ recipeId: `tailor-${template.templateId}`, stationId: CraftingStationId.tailorBench, tailorTemplate: template.templateId, output: { itemId: template.outputItemIdForTier(CLOTH_TIER_ORDER[0]), quantity: 1 }, inputs: [], minSkillLevel: template.minSkillLevel ?? 1, skillId: "tailoring" })), ...Object.values(WIZARD_TEMPLATES).map((template) => Object.freeze({ recipeId: template.templateId, stationId: CraftingStationId.tailorBench, tailorTemplate: template.templateId, output: { itemId: template.outputItemIdForTier(CLOTH_TIER_ORDER[0]), quantity: 1 }, inputs: [], minSkillLevel: template.minSkillLevel ?? 1, skillId: "tailoring" })) ]); /** @type {ReadonlyArray} */ export const CRAFT_RECIPES = Object.freeze([ smelt(MaterialTier.bronze, "smelt-bronze", [ { itemId: CraftingItemId.tinOre, quantity: 1 }, { itemId: CraftingItemId.copperOre, quantity: 1 } ], CraftingItemId.bronzeBar), smelt(MaterialTier.iron, "smelt-iron", [ { itemId: MetalItemId.ironOre, quantity: 1 } ], MetalItemId.ironBar), smelt(MaterialTier.steel, "smelt-steel", [ { itemId: MetalItemId.ironOre, quantity: 1 }, { itemId: MetalItemId.coal, quantity: 1 } ], MetalItemId.steelBar), smelt(GatherMaterialId.silver, "smelt-silver", [ { itemId: MetalItemId.silverOre, quantity: 1 } ], MetalItemId.silverBar), smelt(GatherMaterialId.gold, "smelt-gold", [ { itemId: MetalItemId.goldOre, quantity: 1 } ], MetalItemId.goldBar), smelt(GatherMaterialId.electrum, "smelt-electrum", [ { itemId: MetalItemId.goldOre, quantity: 1 }, { itemId: MetalItemId.silverOre, quantity: 1 }, { itemId: MetalItemId.coal, quantity: 3 } ], MetalItemId.electrumBar), smelt(MaterialTier.mithril, "smelt-mithril", [ { itemId: MetalItemId.mithrilOre, quantity: 1 } ], MetalItemId.mithrilBar), smelt(MaterialTier.adamantium, "smelt-adamantium", [ { itemId: MetalItemId.adamantiumOre, quantity: 1 }, { itemId: MetalItemId.coal, quantity: 1 } ], MetalItemId.adamantiumBar), smelt(MaterialTier.orichalcum, "smelt-orichalcum", [ { itemId: MetalItemId.orichalcumOre, quantity: 1 }, { itemId: MetalItemId.coal, quantity: 3 } ], MetalItemId.orichalcumBar), smelt(MaterialTier.dragon, "smelt-dragon", [ { itemId: MetalItemId.dragonOre, quantity: 1 }, { itemId: MetalItemId.coal, quantity: 5 } ], MetalItemId.dragonBar), ...TIER_FAMILY_RECIPES, ...YARN_SPIN_RECIPES, ...CLOTH_WEAVE_RECIPES, ...TAILOR_TEMPLATE_RECIPES, Object.freeze({ recipeId: "smith-steel-stud", stationId: CraftingStationId.anvil, output: { itemId: LeatherItemId.steelStud, quantity: 6 }, inputs: [{ itemId: MetalItemId.steelBar, quantity: 1 }], minSkillLevel: tierCraftSkillLevel(MaterialTier.steel), skillId: "smithing", xpMaterial: MaterialTier.steel }), Object.freeze({ recipeId: "leather-hard", stationId: CraftingStationId.leatherworkingStation, output: { itemId: LeatherItemId.hardLeather, quantity: 1 }, inputs: [ { itemId: LeatherItemId.softLeather, quantity: 1 } ], consumePotionKey: "tanningBrew", minSkillLevel: tierCraftSkillLevel(LeatherTier.hardLeather), skillId: "leatherworking", xpMaterial: LeatherTier.hardLeather }), Object.freeze({ recipeId: "leather-studded", stationId: CraftingStationId.leatherworkingStation, output: { itemId: LeatherItemId.studdedLeather, quantity: 1 }, inputs: [ { itemId: LeatherItemId.hardLeather, quantity: 1 }, { itemId: LeatherItemId.steelStud, quantity: 2 } ], minSkillLevel: tierCraftSkillLevel(LeatherTier.studdedLeather), skillId: "leatherworking", xpMaterial: LeatherTier.studdedLeather }), Object.freeze({ recipeId: "leather-reinforced", stationId: CraftingStationId.leatherworkingStation, output: { itemId: LeatherItemId.reinforcedLeather, quantity: 1 }, inputs: [ { itemId: LeatherItemId.studdedLeather, quantity: 1 }, { itemId: wovenClothItemId(ClothTier.cashmere), quantity: 1 } ], minSkillLevel: tierCraftSkillLevel(LeatherTier.reinforcedLeather), skillId: "leatherworking", xpMaterial: LeatherTier.reinforcedLeather }), Object.freeze({ recipeId: "cook-venison", stationIds: [CraftingStationId.oven, CraftingStationId.fireplace], output: { itemId: CraftingItemId.cookedMeat, quantity: 1 }, inputs: [{ itemId: CraftingItemId.rawMeat, quantity: 1 }], minSkillLevel: 1, skillId: "cooking", burntOutput: { itemId: CraftingItemId.burntMeat, quantity: 1 } }), Object.freeze({ recipeId: "cook-mutton", stationIds: [CraftingStationId.oven, CraftingStationId.fireplace], craftGroup: "cook-mutton", craftGroupLabel: "Mutton", output: { itemId: CraftingItemId.cookedMutton, quantity: 1 }, inputs: [{ itemId: CraftingItemId.rawMutton, quantity: 1 }], minSkillLevel: 1, skillId: "cooking", burntOutput: { itemId: CraftingItemId.burntMutton, quantity: 1 } }), Object.freeze({ recipeId: "cook-goat", stationIds: [CraftingStationId.oven, CraftingStationId.fireplace], craftGroup: "cook-goat", craftGroupLabel: "Goat", output: { itemId: CraftingItemId.cookedGoat, quantity: 1 }, inputs: [{ itemId: CraftingItemId.rawGoat, quantity: 1 }], minSkillLevel: 1, skillId: "cooking", burntOutput: { itemId: CraftingItemId.burntGoat, quantity: 1 } }), Object.freeze({ recipeId: "cook-egg", stationIds: [CraftingStationId.oven], craftGroup: "cook-egg", craftGroupLabel: "Egg", output: { itemId: ItemId.cookedEgg, quantity: 1 }, inputs: [{ itemId: ItemId.egg, quantity: 1 }], minSkillLevel: 1, skillId: "cooking", burntOutput: { itemId: ItemId.burntEgg, quantity: 1 } }), ...fishingToolRecipes(), ...fishingCookRecipes(), ...gemCutRecipes(), ...jewelryCraftRecipes(), ...staffCraftRecipes() ]); const RECIPE_BY_ID = new Map(CRAFT_RECIPES.map((recipe) => [recipe.recipeId, recipe])); export function recipeDefinition (recipeId) { return RECIPE_BY_ID.get(recipeId) ?? null; } export function recipeStationIds (recipe) { if (!recipe) { return []; } if (Array.isArray(recipe.stationIds)) { return recipe.stationIds; } if (recipe.stationId) { return [recipe.stationId]; } return []; } export function recipesForStation (stationId) { return CRAFT_RECIPES.filter((recipe) => recipeStationIds(recipe).includes(stationId)); }