import { CraftingStationId } from "../definitions/craftingStations.js"; import { ItemId } from "../definitions/items.js"; /** * Craft recipe schema (shared client + server): * * - recipeId: stable string id * - stationId | stationIds: where the recipe appears (use stationIds for oven + campfire) * - output: { itemId, quantity } * - inputs: [{ itemId, quantity }, ...] * - minSkillLevel: minimum linked station skill (default 1) * - burnChanceOven / burnChanceFireplace: cooking-only, 0–1 when skill is below min (TBD) */ /** @type {ReadonlyArray} */ export const CRAFT_RECIPES = Object.freeze([ // UI/dev placeholder — replace with real bench recipes. Object.freeze({ recipeId: "dev-stick-from-paper", stationId: CraftingStationId.craftingBench, output: { itemId: ItemId.stick, quantity: 1 }, inputs: [{ itemId: ItemId.paper, quantity: 2 }], minSkillLevel: 1 }), // --- Furnace (smelt ore → bars) --- // { recipeId: "smelt-bronze", stationId: CraftingStationId.furnace, ... }, // --- Spinning wheel (wool → thread) --- // { recipeId: "spin-thread", stationId: CraftingStationId.spinningWheel, ... }, // --- Loom (cloth garments) --- // { recipeId: "weave-cloth-shirt", stationId: CraftingStationId.loom, ... }, // --- Anvil (bars → metal items) --- // { recipeId: "smith-bronze-sword", stationId: CraftingStationId.anvil, ... }, // --- Leatherworking station --- // { recipeId: "craft-leather-body", stationId: CraftingStationId.leatherworkingStation, ... }, // --- Crafting bench (arrows, etc.) --- // { recipeId: "fletch-arrow", stationId: CraftingStationId.craftingBench, // output: { itemId: CraftingItemId.arrow, quantity: 1 }, // inputs: [{ itemId: CraftingItemId.arrowTip, quantity: 1 }, ...] }, // --- Cooking (oven + campfire share recipes via stationIds) --- // { recipeId: "cook-meat", stationIds: [CraftingStationId.oven, CraftingStationId.fireplace], // output: { itemId: CraftingItemId.cookedMeat, quantity: 1 }, // inputs: [{ itemId: CraftingItemId.rawMeat, quantity: 1 }], // minSkillLevel: 1, burnChanceOven: 0.1, burnChanceFireplace: 0.25 } ]); 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)); }