BlueGit

timfa questward

Files

questward / shared / definitions / craftingStations.js

craftingStations.js

craftingStations.js 4.1 KiB Download Raw
1import { SkillId } from "./skills.js";
2import { WOOD_TIER_ORDER } from "./materialTiers.js";
3
4/** 1-based rank in wood tier order (pine = 1 … elder = 7). */
5export function woodTierRank (woodTier)
6{
7 const idx = WOOD_TIER_ORDER.indexOf(woodTier);
8 return idx >= 0 ? idx + 1 : 1;
9}
10
11/** Placeable or fixed world stations that gate recipes (blocks / ground objects later). */
12export const CraftingStationId = Object.freeze({
13 furnace: "furnace",
14 spinningWheel: "spinning-wheel",
15 loom: "loom",
16 anvil: "anvil",
17 leatherworkingStation: "leatherworking-station",
18 craftingBench: "crafting-bench",
19 woodworkingBench: "woodworking-bench",
20 tailorBench: "tailor-bench",
21 oven: "oven",
22 fireplace: "fireplace"
23});
24
25/** Legacy fixed duration; prefer {@link campfireDurationMs}. */
26export const FIREPLACE_DURATION_MS = 10 * 60 * 1000;
27
28/** Base duration per wood-tier rank (3 minutes × rank). */
29export const CAMPFIRE_DURATION_PER_RANK_MS = 3 * 60_000;
30
31/** Burn chance when cooking on an oven (0–1). */
32export const COOK_BURN_CHANCE_OVEN = 0.10;
33
34/** Burn chance when cooking on a campfire (0–1). */
35export const COOK_BURN_CHANCE_CAMPFIRE = 0.35;
36
37/**
38 * Campfire lifetime from the wood tier used to light it.
39 * @param {string|number} woodTierOrRank wood tier id or 1-based rank
40 */
41export function campfireDurationMs (woodTierOrRank)
42{
43 const rank = typeof woodTierOrRank === "number"
44 ? Math.max(1, woodTierOrRank | 0)
45 : Math.max(1, woodTierRank(woodTierOrRank));
46 return CAMPFIRE_DURATION_PER_RANK_MS * rank;
47}
48
49/**
50 * Firestarting difficulty for a wood log tier: max((rank - 1) * 10, 1).
51 */
52export function firestartingDifficulty (woodTier)
53{
54 const rank = woodTierRank(woodTier);
55 return Math.max((rank - 1) * 10, 1);
56}
57
58/** Fixed craft action duration at any station (ms). */
59export const CRAFT_DURATION_MS = 2000;
60
61export const CRAFTING_STATION_DEFINITIONS = Object.freeze({
62 [CraftingStationId.furnace]: Object.freeze({
63 stationId: CraftingStationId.furnace,
64 displayName: "Furnace",
65 skillId: SkillId.smithing,
66 description: "Smelt gathered ore into metal bars."
67 }),
68 [CraftingStationId.spinningWheel]: Object.freeze({
69 stationId: CraftingStationId.spinningWheel,
70 displayName: "Spinning wheel",
71 skillId: SkillId.tailoring,
72 description: "Spin raw fibre into yarn."
73 }),
74 [CraftingStationId.loom]: Object.freeze({
75 stationId: CraftingStationId.loom,
76 displayName: "Loom",
77 skillId: SkillId.tailoring,
78 description: "Weave yarn into cloth."
79 }),
80 [CraftingStationId.tailorBench]: Object.freeze({
81 stationId: CraftingStationId.tailorBench,
82 displayName: "Tailor's bench",
83 skillId: SkillId.tailoring,
84 description: "Sew garments from yarn or cloth; dyes may colour the cloth."
85 }),
86 [CraftingStationId.anvil]: Object.freeze({
87 stationId: CraftingStationId.anvil,
88 displayName: "Anvil",
89 skillId: SkillId.smithing,
90 description: "Smith metal items from bars."
91 }),
92 [CraftingStationId.leatherworkingStation]: Object.freeze({
93 stationId: CraftingStationId.leatherworkingStation,
94 displayName: "Leatherworking station",
95 skillId: SkillId.leatherworking,
96 description: "Craft leather armour and goods."
97 }),
98 [CraftingStationId.craftingBench]: Object.freeze({
99 stationId: CraftingStationId.craftingBench,
100 displayName: "Crafting bench",
101 skillId: SkillId.crafting,
102 description: "Fit handles to tool heads and finish assembled goods."
103 }),
104 [CraftingStationId.woodworkingBench]: Object.freeze({
105 stationId: CraftingStationId.woodworkingBench,
106 displayName: "Woodworking bench",
107 skillId: SkillId.crafting,
108 description: "Shape logs into handles and other wood components."
109 }),
110 [CraftingStationId.oven]: Object.freeze({
111 stationId: CraftingStationId.oven,
112 displayName: "Oven",
113 skillId: SkillId.cooking,
114 description: "Cook raw meat over steady heat."
115 }),
116 [CraftingStationId.fireplace]: Object.freeze({
117 stationId: CraftingStationId.fireplace,
118 displayName: "Campfire",
119 skillId: SkillId.cooking,
120 description: "An open fire for cooking on the road; food scorches more easily here.",
121 portable: true,
122 maxPerTile: 1,
123 durationMs: FIREPLACE_DURATION_MS
124 })
125});
126
127export function craftingStationDefinition (stationId)
128{
129 return CRAFTING_STATION_DEFINITIONS[stationId] ?? null;
130}