import { SkillId } from "./skills.js"; import { WOOD_TIER_ORDER } from "./materialTiers.js"; /** 1-based rank in wood tier order (pine = 1 … elder = 7). */ export function woodTierRank (woodTier) { const idx = WOOD_TIER_ORDER.indexOf(woodTier); return idx >= 0 ? idx + 1 : 1; } /** Placeable or fixed world stations that gate recipes (blocks / ground objects later). */ export const CraftingStationId = Object.freeze({ furnace: "furnace", spinningWheel: "spinning-wheel", loom: "loom", anvil: "anvil", jeweleringStation: "jewelering-station", leatherworkingStation: "leatherworking-station", craftingBench: "crafting-bench", woodworkingBench: "woodworking-bench", tailorBench: "tailor-bench", oven: "oven", fireplace: "fireplace" }); /** Legacy fixed duration; prefer {@link campfireDurationMs}. */ export const FIREPLACE_DURATION_MS = 10 * 60 * 1000; /** Base duration per wood-tier rank (3 minutes × rank). */ export const CAMPFIRE_DURATION_PER_RANK_MS = 3 * 60_000; /** Burn chance when cooking on an oven (0–1). */ export const COOK_BURN_CHANCE_OVEN = 0.10; /** Burn chance when cooking on a campfire (0–1). */ export const COOK_BURN_CHANCE_CAMPFIRE = 0.35; /** * Campfire lifetime from the wood tier used to light it. * @param {string|number} woodTierOrRank wood tier id or 1-based rank */ export function campfireDurationMs (woodTierOrRank) { const rank = typeof woodTierOrRank === "number" ? Math.max(1, woodTierOrRank | 0) : Math.max(1, woodTierRank(woodTierOrRank)); return CAMPFIRE_DURATION_PER_RANK_MS * rank; } /** * Firestarting difficulty for a wood log tier: max((rank - 1) * 10, 1). */ export function firestartingDifficulty (woodTier) { const rank = woodTierRank(woodTier); return Math.max((rank - 1) * 10, 1); } /** Fixed craft action duration at any station (ms). */ export const CRAFT_DURATION_MS = 2000; export const CRAFTING_STATION_DEFINITIONS = Object.freeze({ [CraftingStationId.furnace]: Object.freeze({ stationId: CraftingStationId.furnace, displayName: "Furnace", skillId: SkillId.smithing, description: "Smelt gathered ore into metal bars." }), [CraftingStationId.spinningWheel]: Object.freeze({ stationId: CraftingStationId.spinningWheel, displayName: "Spinning wheel", skillId: SkillId.tailoring, description: "Spin raw fibre into yarn." }), [CraftingStationId.loom]: Object.freeze({ stationId: CraftingStationId.loom, displayName: "Loom", skillId: SkillId.tailoring, description: "Weave yarn into cloth." }), [CraftingStationId.tailorBench]: Object.freeze({ stationId: CraftingStationId.tailorBench, displayName: "Tailor's bench", skillId: SkillId.tailoring, description: "Sew garments from yarn or cloth; dyes may colour the cloth." }), [CraftingStationId.anvil]: Object.freeze({ stationId: CraftingStationId.anvil, displayName: "Anvil", skillId: SkillId.smithing, description: "Smith metal items from bars." }), [CraftingStationId.jeweleringStation]: Object.freeze({ stationId: CraftingStationId.jeweleringStation, displayName: "Jewelering station", skillId: SkillId.jewelering, description: "Cut gemstones and set precious metal jewellery." }), [CraftingStationId.leatherworkingStation]: Object.freeze({ stationId: CraftingStationId.leatherworkingStation, displayName: "Leatherworking station", skillId: SkillId.leatherworking, description: "Craft leather armour and goods." }), [CraftingStationId.craftingBench]: Object.freeze({ stationId: CraftingStationId.craftingBench, displayName: "Crafting bench", skillId: SkillId.crafting, description: "Fit handles to tool heads and finish assembled goods." }), [CraftingStationId.woodworkingBench]: Object.freeze({ stationId: CraftingStationId.woodworkingBench, displayName: "Woodworking bench", skillId: SkillId.crafting, description: "Shape logs into handles and other wood components." }), [CraftingStationId.oven]: Object.freeze({ stationId: CraftingStationId.oven, displayName: "Oven", skillId: SkillId.cooking, description: "Cook raw meat over steady heat." }), [CraftingStationId.fireplace]: Object.freeze({ stationId: CraftingStationId.fireplace, displayName: "Campfire", skillId: SkillId.cooking, description: "An open fire for cooking on the road; food scorches more easily here.", portable: true, maxPerTile: 1, durationMs: FIREPLACE_DURATION_MS }) }); export function craftingStationDefinition (stationId) { return CRAFTING_STATION_DEFINITIONS[stationId] ?? null; }