BlueGit

timfa questward

Files

questward / shared / definitions / craftingStations.js

craftingStations.js

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