BlueGit

timfa questward

Files

questward / shared / definitions / materialTiers.js

materialTiers.js

materialTiers.js 18.1 KiB Download Raw
1/**
2 * Metal materials (and coal) — name, tint, rank, and skill gates.
3 * Equip min level is the tier gate; mining = half (ceil), smelting = 75% (ceil).
4 */
5export const MaterialTier = Object.freeze({
6 bronze: "bronze",
7 iron: "iron",
8 steel: "steel",
9 mithril: "mithril",
10 adamantium: "adamantium",
11 orichalcum: "orichalcum",
12 dragon: "dragon"
13});
14
15/**
16 * Wood materials — same ranks / skill gates as metals (gather with axe later).
17 * Matching metal: pine↔bronze … elder↔dragon.
18 */
19export const WoodTier = Object.freeze({
20 pine: "pine",
21 birch: "birch",
22 oak: "oak",
23 ebony: "ebony",
24 lignum: "lignum",
25 heartwood: "heartwood",
26 elder: "elder"
27});
28
29/**
30 * Cloth / fibre tiers (tailoring). Gathering methods vary (plant / shear / drop);
31 * ranks and equip gates match metal / wood.
32 */
33export const ClothTier = Object.freeze({
34 cotton: "cotton",
35 wool: "wool",
36 linen: "linen",
37 cashmere: "cashmere",
38 silk: "silk",
39 fairySilk: "fairySilk",
40 dragonweave: "dragonweave"
41});
42
43/** Ordered low → high (metal smithing / tools). */
44export const MATERIAL_TIER_ORDER = Object.freeze([
45 MaterialTier.bronze,
46 MaterialTier.iron,
47 MaterialTier.steel,
48 MaterialTier.mithril,
49 MaterialTier.adamantium,
50 MaterialTier.orichalcum,
51 MaterialTier.dragon
52]);
53
54/** Ordered low → high (woodcutting / woodcraft). */
55export const WOOD_TIER_ORDER = Object.freeze([
56 WoodTier.pine,
57 WoodTier.birch,
58 WoodTier.oak,
59 WoodTier.ebony,
60 WoodTier.lignum,
61 WoodTier.heartwood,
62 WoodTier.elder
63]);
64
65/** Ordered low → high (tailoring). */
66export const CLOTH_TIER_ORDER = Object.freeze([
67 ClothTier.cotton,
68 ClothTier.wool,
69 ClothTier.linen,
70 ClothTier.cashmere,
71 ClothTier.silk,
72 ClothTier.fairySilk,
73 ClothTier.dragonweave
74]);
75
76/**
77 * Leather tiers (leatherworking). Rank gates mirror cloth/metal families.
78 */
79export const LeatherTier = Object.freeze({
80 softLeather: "softLeather",
81 hardLeather: "hardLeather",
82 studdedLeather: "studdedLeather",
83 reinforcedLeather: "reinforcedLeather",
84 scaledLeather: "scaledLeather",
85 wyvernHide: "wyvernHide",
86 dragonhide: "dragonhide"
87});
88
89/** Ordered low → high (leatherworking). */
90export const LEATHER_TIER_ORDER = Object.freeze([
91 LeatherTier.softLeather,
92 LeatherTier.hardLeather,
93 LeatherTier.studdedLeather,
94 LeatherTier.reinforcedLeather,
95 LeatherTier.scaledLeather,
96 LeatherTier.wyvernHide,
97 LeatherTier.dragonhide
98]);
99
100export const LEATHER_DISPLAY_NAME = Object.freeze({
101 [LeatherTier.softLeather]: "Soft leather",
102 [LeatherTier.hardLeather]: "Hard leather",
103 [LeatherTier.studdedLeather]: "Studded leather",
104 [LeatherTier.reinforcedLeather]: "Reinforced leather",
105 [LeatherTier.scaledLeather]: "Scaled leather",
106 [LeatherTier.wyvernHide]: "Wyvern hide",
107 [LeatherTier.dragonhide]: "Dragonhide"
108});
109
110/**
111 * Gemstone materials — mined for staves and jewellery.
112 * Ranks / equip gates match metal / wood (tourmaline↔pine/bronze … jadeite↔elder/dragon).
113 */
114export const GemTier = Object.freeze({
115 tourmaline: "tourmaline",
116 alexandrite: "alexandrite",
117 opal: "opal",
118 diamond: "diamond",
119 emerald: "emerald",
120 ruby: "ruby",
121 jadeite: "jadeite"
122});
123
124/** Ordered low → high (gem mining / jewellery). */
125export const GEM_TIER_ORDER = Object.freeze([
126 GemTier.tourmaline,
127 GemTier.alexandrite,
128 GemTier.opal,
129 GemTier.diamond,
130 GemTier.emerald,
131 GemTier.ruby,
132 GemTier.jadeite
133]);
134
135/**
136 * Gatherable ores / fuels that are not always 1:1 with a gear tier.
137 * Tin + copper smelt into bronze; coal fuels steel. Gold and silver have ore +
138 * bars but no tools (jewelry / future recipes). Mine/smelt timing uses
139 * {@link associatedBarTier}. Gemstones map onto the matching metal gate.
140 */
141export const GatherMaterialId = Object.freeze({
142 ...MaterialTier,
143 ...GemTier,
144 tin: "tin",
145 copper: "copper",
146 coal: "coal",
147 silver: "silver",
148 gold: "gold"
149});
150
151/** Minimum relevant skill level required to equip tools/gear of this tier. */
152export const TIER_MIN_SKILL_LEVEL = Object.freeze({
153 [MaterialTier.bronze]: 1,
154 [MaterialTier.iron]: 10,
155 [MaterialTier.steel]: 20,
156 [MaterialTier.mithril]: 35,
157 [MaterialTier.adamantium]: 50,
158 [MaterialTier.orichalcum]: 70,
159 [MaterialTier.dragon]: 90,
160 [GatherMaterialId.silver]: 10,
161 [GatherMaterialId.gold]: 20,
162 [GemTier.tourmaline]: 1,
163 [GemTier.alexandrite]: 10,
164 [GemTier.opal]: 20,
165 [GemTier.diamond]: 35,
166 [GemTier.emerald]: 50,
167 [GemTier.ruby]: 70,
168 [GemTier.jadeite]: 90,
169 [WoodTier.pine]: 1,
170 [WoodTier.birch]: 10,
171 [WoodTier.oak]: 20,
172 [WoodTier.ebony]: 35,
173 [WoodTier.lignum]: 50,
174 [WoodTier.heartwood]: 70,
175 [WoodTier.elder]: 90,
176 [ClothTier.cotton]: 1,
177 [ClothTier.wool]: 10,
178 [ClothTier.linen]: 20,
179 [ClothTier.cashmere]: 35,
180 [ClothTier.silk]: 50,
181 [ClothTier.fairySilk]: 70,
182 [ClothTier.dragonweave]: 90,
183 [LeatherTier.softLeather]: 1,
184 [LeatherTier.hardLeather]: 10,
185 [LeatherTier.studdedLeather]: 20,
186 [LeatherTier.reinforcedLeather]: 35,
187 [LeatherTier.scaledLeather]: 50,
188 [LeatherTier.wyvernHide]: 70,
189 [LeatherTier.dragonhide]: 90
190});
191
192/** Rank used for mining duration and relative power (1 = bronze/pine … 7 = dragon/elder). */
193export const TIER_RANK = Object.freeze({
194 [MaterialTier.bronze]: 1,
195 [MaterialTier.iron]: 2,
196 [MaterialTier.steel]: 3,
197 [MaterialTier.mithril]: 4,
198 [MaterialTier.adamantium]: 5,
199 [MaterialTier.orichalcum]: 6,
200 [MaterialTier.dragon]: 7,
201 [GatherMaterialId.silver]: 2,
202 [GatherMaterialId.gold]: 3,
203 [GemTier.tourmaline]: 1,
204 [GemTier.alexandrite]: 2,
205 [GemTier.opal]: 3,
206 [GemTier.diamond]: 4,
207 [GemTier.emerald]: 5,
208 [GemTier.ruby]: 6,
209 [GemTier.jadeite]: 7,
210 [WoodTier.pine]: 1,
211 [WoodTier.birch]: 2,
212 [WoodTier.oak]: 3,
213 [WoodTier.ebony]: 4,
214 [WoodTier.lignum]: 5,
215 [WoodTier.heartwood]: 6,
216 [WoodTier.elder]: 7,
217 [ClothTier.cotton]: 1,
218 [ClothTier.wool]: 2,
219 [ClothTier.linen]: 3,
220 [ClothTier.cashmere]: 4,
221 [ClothTier.silk]: 5,
222 [ClothTier.fairySilk]: 6,
223 [ClothTier.dragonweave]: 7,
224 [LeatherTier.softLeather]: 1,
225 [LeatherTier.hardLeather]: 2,
226 [LeatherTier.studdedLeather]: 3,
227 [LeatherTier.reinforcedLeather]: 4,
228 [LeatherTier.scaledLeather]: 5,
229 [LeatherTier.wyvernHide]: 6,
230 [LeatherTier.dragonhide]: 7
231});
232
233/** Stat bonus granted by tier for the equipment's bonus category. */
234export const TIER_STAT_BONUS = Object.freeze({
235 [MaterialTier.bronze]: 1,
236 [MaterialTier.iron]: 2,
237 [MaterialTier.steel]: 4,
238 [MaterialTier.mithril]: 6,
239 [MaterialTier.adamantium]: 8,
240 [MaterialTier.orichalcum]: 10,
241 [MaterialTier.dragon]: 12,
242 [WoodTier.pine]: 1,
243 [WoodTier.birch]: 2,
244 [WoodTier.oak]: 4,
245 [WoodTier.ebony]: 6,
246 [WoodTier.lignum]: 8,
247 [WoodTier.heartwood]: 10,
248 [WoodTier.elder]: 12,
249 [ClothTier.cotton]: 1,
250 [ClothTier.wool]: 2,
251 [ClothTier.linen]: 4,
252 [ClothTier.cashmere]: 6,
253 [ClothTier.silk]: 8,
254 [ClothTier.fairySilk]: 10,
255 [ClothTier.dragonweave]: 12,
256 [LeatherTier.softLeather]: 1,
257 [LeatherTier.hardLeather]: 2,
258 [LeatherTier.studdedLeather]: 4,
259 [LeatherTier.reinforcedLeather]: 6,
260 [LeatherTier.scaledLeather]: 8,
261 [LeatherTier.wyvernHide]: 10,
262 [LeatherTier.dragonhide]: 12
263});
264
265/** Display names for UI / editor. */
266export const MATERIAL_DISPLAY_NAME = Object.freeze({
267 [MaterialTier.bronze]: "Bronze",
268 [MaterialTier.iron]: "Iron",
269 [MaterialTier.steel]: "Steel",
270 [MaterialTier.mithril]: "Mithril",
271 [MaterialTier.adamantium]: "Adamantium",
272 [MaterialTier.orichalcum]: "Orichalcum",
273 [MaterialTier.dragon]: "Dragon",
274 [GatherMaterialId.tin]: "Tin",
275 [GatherMaterialId.copper]: "Copper",
276 [GatherMaterialId.coal]: "Coal",
277 [GatherMaterialId.silver]: "Silver",
278 [GatherMaterialId.gold]: "Gold",
279 [GemTier.tourmaline]: "Tourmaline",
280 [GemTier.alexandrite]: "Alexandrite",
281 [GemTier.opal]: "Opal",
282 [GemTier.diamond]: "Diamond",
283 [GemTier.emerald]: "Emerald",
284 [GemTier.ruby]: "Ruby",
285 [GemTier.jadeite]: "Jadeite",
286 [WoodTier.pine]: "Pine",
287 [WoodTier.birch]: "Birch",
288 [WoodTier.oak]: "Oak",
289 [WoodTier.ebony]: "Ebony",
290 [WoodTier.lignum]: "Lignum",
291 [WoodTier.heartwood]: "Heartwood",
292 [WoodTier.elder]: "Elder"
293});
294
295export const CLOTH_DISPLAY_NAME = Object.freeze({
296 [ClothTier.cotton]: "Cotton",
297 [ClothTier.wool]: "Wool",
298 [ClothTier.linen]: "Linen",
299 [ClothTier.cashmere]: "Cashmere",
300 [ClothTier.silk]: "Silk",
301 [ClothTier.fairySilk]: "Fairy silk",
302 [ClothTier.dragonweave]: "Dragonweave"
303});
304
305/**
306 * Author tint swatches via {@link rgb} (0–255) so editors can offer a colour picker.
307 * Also accepts `0xRRGGBB` / `"#RRGGBB"`; all forms become 0–1 RGB at module load.
308 * Steel is slightly darker than iron; silver is bright gray; gold is yellow;
309 * orichalcum is coppery; dragon is red.
310 */
311export function rgb (r, g, b)
312{
313 return Object.freeze({
314 r: clampByte(r) / 255,
315 g: clampByte(g) / 255,
316 b: clampByte(b) / 255
317 });
318}
319
320function clampByte (n)
321{
322 return Math.min(255, Math.max(0, Math.round(Number(n) || 0)));
323}
324
325export const MATERIAL_TINT_HEX = Object.freeze({
326 [MaterialTier.bronze]: rgb(184, 122, 71),
327 [MaterialTier.iron]: rgb(158, 163, 173),
328 [MaterialTier.steel]: rgb(75, 76, 80),
329 [MaterialTier.mithril]: rgb(3, 120, 255),
330 [MaterialTier.adamantium]: rgb(108, 202, 132),
331 [MaterialTier.orichalcum]: rgb(230, 140, 31),
332 [MaterialTier.dragon]: rgb(228, 19, 15),
333 [GatherMaterialId.tin]: rgb(221, 221, 221),
334 [GatherMaterialId.copper]: rgb(255, 94, 0),
335 [GatherMaterialId.coal]: rgb(45, 45, 48),
336 [GatherMaterialId.silver]: rgb(214, 220, 230),
337 [GatherMaterialId.gold]: rgb(255, 200, 0),
338 [GemTier.tourmaline]: rgb(200, 55, 120),
339 [GemTier.alexandrite]: rgb(120, 70, 180),
340 [GemTier.opal]: rgb(230, 210, 220),
341 [GemTier.diamond]: rgb(200, 235, 255),
342 [GemTier.emerald]: rgb(35, 165, 95),
343 [GemTier.ruby]: rgb(190, 25, 45),
344 [GemTier.jadeite]: rgb(55, 145, 105),
345 [WoodTier.pine]: rgb(199, 158, 97),
346 [WoodTier.birch]: rgb(224, 209, 173),
347 [WoodTier.oak]: rgb(158, 107, 61),
348 [WoodTier.ebony]: rgb(56, 41, 51),
349 [WoodTier.lignum]: rgb(107, 97, 56),
350 [WoodTier.heartwood]: rgb(184, 71, 56),
351 [WoodTier.elder]: rgb(184, 189, 199),
352 [ClothTier.cotton]: rgb(245, 240, 230),
353 [ClothTier.wool]: rgb(220, 210, 195),
354 [ClothTier.linen]: rgb(200, 185, 140),
355 [ClothTier.cashmere]: rgb(210, 175, 150),
356 [ClothTier.silk]: rgb(230, 220, 240),
357 [ClothTier.fairySilk]: rgb(180, 230, 255),
358 [ClothTier.dragonweave]: rgb(200, 60, 50),
359 [LeatherTier.softLeather]: rgb(210, 180, 140),
360 [LeatherTier.hardLeather]: rgb(140, 90, 50),
361 [LeatherTier.studdedLeather]: rgb(110, 70, 40),
362 [LeatherTier.reinforcedLeather]: rgb(120, 100, 85),
363 [LeatherTier.scaledLeather]: rgb(150, 70, 55),
364 [LeatherTier.wyvernHide]: rgb(70, 85, 75),
365 [LeatherTier.dragonhide]: rgb(180, 40, 35)
366});
367
368/**
369 * Optional ore-only tint overrides (boulders + ore items).
370 * Missing entries fall back to {@link MATERIAL_TINT_HEX}.
371 */
372export const MATERIAL_ORE_TINT_HEX = Object.freeze({
373 [MaterialTier.iron]: rgb(210, 118, 48),
374 [GatherMaterialId.copper]: rgb(81, 153, 105)
375});
376
377/**
378 * Normalize tint authoring forms to frozen 0–1 `{ r, g, b }`:
379 * - number `0xRRGGBB`
380 * - string `"#RGB"` / `"#RRGGBB"` / `"rgb(r,g,b)"`
381 * - object from {@link rgb}
382 */
383export function hexToRgb01 (hex)
384{
385 if (hex && typeof hex === "object" && "r" in hex && "g" in hex && "b" in hex)
386 {
387 return Object.freeze({
388 r: clamp01Channel(hex.r),
389 g: clamp01Channel(hex.g),
390 b: clamp01Channel(hex.b)
391 });
392 }
393 if (typeof hex === "number" && Number.isFinite(hex))
394 {
395 const value = hex >>> 0;
396 return Object.freeze({
397 r: ((value >> 16) & 255) / 255,
398 g: ((value >> 8) & 255) / 255,
399 b: (value & 255) / 255
400 });
401 }
402 const text = String(hex ?? "").trim();
403 const rgbMatch = /^rgba?\(\s*([0-9.]+)\s*,\s*([0-9.]+)\s*,\s*([0-9.]+)/i.exec(text);
404 if (rgbMatch)
405 { return rgb(rgbMatch[1], rgbMatch[2], rgbMatch[3]); }
406 const raw = text.replace(/^#/, "");
407 const full = raw.length === 3
408 ? raw.split("").map((ch) => ch + ch).join("")
409 : raw;
410 if (!/^[0-9a-fA-F]{6}$/.test(full))
411 { return Object.freeze({ r: 0.7, g: 0.7, b: 0.7 }); }
412 const value = Number.parseInt(full, 16);
413 return Object.freeze({
414 r: ((value >> 16) & 255) / 255,
415 g: ((value >> 8) & 255) / 255,
416 b: (value & 255) / 255
417 });
418}
419
420function clamp01Channel (n)
421{
422 const value = Number(n);
423 if (!Number.isFinite(value))
424 { return 0; }
425 if (value > 1)
426 { return clampByte(value) / 255; }
427 return Math.min(1, Math.max(0, value));
428}
429
430/** 0–1 RGB map derived from {@link MATERIAL_TINT_HEX}. */
431export const MATERIAL_TINT_COLOR = Object.freeze(
432 Object.fromEntries(
433 Object.entries(MATERIAL_TINT_HEX).map(([id, hex]) => [id, hexToRgb01(hex)])
434 )
435);
436
437/** 0–1 RGB map derived from {@link MATERIAL_ORE_TINT_HEX}. */
438export const MATERIAL_ORE_TINT_COLOR = Object.freeze(
439 Object.fromEntries(
440 Object.entries(MATERIAL_ORE_TINT_HEX).map(([id, hex]) => [id, hexToRgb01(hex)])
441 )
442);
443
444/** Wood tier that matches a metal tier's rank (for tool hafts). */
445export const WOOD_TIER_FOR_METAL = Object.freeze({
446 [MaterialTier.bronze]: WoodTier.pine,
447 [MaterialTier.iron]: WoodTier.birch,
448 [MaterialTier.steel]: WoodTier.oak,
449 [MaterialTier.mithril]: WoodTier.ebony,
450 [MaterialTier.adamantium]: WoodTier.lignum,
451 [MaterialTier.orichalcum]: WoodTier.heartwood,
452 [MaterialTier.dragon]: WoodTier.elder
453});
454
455export const METAL_TIER_FOR_WOOD = Object.freeze(Object.fromEntries(
456 Object.entries(WOOD_TIER_FOR_METAL).map(([metal, wood]) => [wood, metal])
457));
458
459/**
460 * Bar tier that drives mine/smelt duration and gates for a gatherable.
461 * Tin/copper → bronze; coal → steel; gold/silver and gear metals map to themselves.
462 */
463export function associatedBarTier (materialId)
464{
465 if (materialId === GatherMaterialId.tin || materialId === GatherMaterialId.copper)
466 { return MaterialTier.bronze; }
467 if (materialId === GatherMaterialId.coal)
468 { return MaterialTier.steel; }
469 const gemIdx = GEM_TIER_ORDER.indexOf(materialId);
470 if (gemIdx >= 0)
471 { return MATERIAL_TIER_ORDER[gemIdx] ?? MaterialTier.bronze; }
472 return materialId;
473}
474
475export function materialDisplayName (materialId)
476{
477 return MATERIAL_DISPLAY_NAME[materialId] ?? materialId;
478}
479
480/**
481 * Tint for a material. When `ore` is true, prefer {@link MATERIAL_ORE_TINT_COLOR}
482 * if defined for that material; otherwise the normal material tint.
483 */
484export function materialTintColor (materialId, { ore = false } = {})
485{
486 if (ore)
487 {
488 const oreTint = MATERIAL_ORE_TINT_COLOR[materialId];
489 if (oreTint)
490 { return oreTint; }
491 }
492 return MATERIAL_TINT_COLOR[materialId] ?? MATERIAL_TINT_COLOR[MaterialTier.bronze];
493}
494
495export function tierStatBonus (tier)
496{
497 return TIER_STAT_BONUS[tier] ?? TIER_STAT_BONUS[MaterialTier.bronze];
498}
499
500/** Alias for equipment combat boosts derived from material tier. */
501export const statBoostPerTier = tierStatBonus;
502
503export function tierMinSkillLevel (tier)
504{
505 return TIER_MIN_SKILL_LEVEL[tier] ?? TIER_MIN_SKILL_LEVEL[MaterialTier.bronze];
506}
507
508export function tierRank (tier)
509{
510 return TIER_RANK[associatedBarTier(tier)] ?? TIER_RANK[tier] ?? 1;
511}
512
513/** Mining / woodcutting skill required (half of equip gate, ceil). */
514export function tierMineSkillLevel (tier)
515{
516 return Math.max(1, Math.ceil(tierMinSkillLevel(associatedBarTier(tier)) / 2));
517}
518
519/** Smithing / woodcraft skill required to process this material (75% of equip gate, ceil). */
520export function tierSmeltSkillLevel (tier)
521{
522 return Math.max(1, Math.ceil(tierMinSkillLevel(associatedBarTier(tier)) * 0.75));
523}
524
525/** Alias for woodworking / general craft gates (same curve as smelting). */
526export function tierCraftSkillLevel (tier)
527{
528 return tierSmeltSkillLevel(tier);
529}
530
531export function woodTierForMetal (metalTier)
532{
533 return WOOD_TIER_FOR_METAL[metalTier] ?? WoodTier.pine;
534}
535
536/** Matching wood tier for a gemstone (tourmaline↔pine … jadeite↔elder). */
537export function woodTierForGem (gemTier)
538{
539 const idx = GEM_TIER_ORDER.indexOf(gemTier);
540 return WOOD_TIER_ORDER[idx >= 0 ? idx : 0] ?? WoodTier.pine;
541}
542
543/** Matching gemstone for a wood tier. */
544export function gemTierForWood (woodTier)
545{
546 const idx = WOOD_TIER_ORDER.indexOf(woodTier);
547 return GEM_TIER_ORDER[idx >= 0 ? idx : 0] ?? GemTier.tourmaline;
548}
549
550export function isGemstoneMaterial (materialId)
551{
552 return GEM_TIER_ORDER.includes(materialId);
553}
554
555/** Matching cloth tier for a wood tier (pine↔cotton, birch↔wool, …). */
556export function clothTierForWood (woodTier)
557{
558 const idx = WOOD_TIER_ORDER.indexOf(woodTier);
559 return CLOTH_TIER_ORDER[idx >= 0 ? idx : 0] ?? ClothTier.cotton;
560}
561
562export function metalTierForWood (woodTier)
563{
564 return METAL_TIER_FOR_WOOD[woodTier] ?? MaterialTier.bronze;
565}
566
567/**
568 * Mining action duration in ms.
569 * (resourceRank * 8s) − (toolRank * 3s), floored at 0.5s.
570 * Tin/copper/coal use their associated bar's rank.
571 */
572export function miningDurationMs (resourceMaterialId, toolTier)
573{
574 const resourceRank = tierRank(resourceMaterialId);
575 const toolRank = tierRank(toolTier);
576 const seconds = Math.max(0.5, resourceRank * 8 - toolRank * 3);
577 return Math.round(seconds * 1000);
578}
579
580/** After a successful mine, nodes stay exhausted for 10s × associated bar rank. */
581export function oreExhaustDurationMs (materialId)
582{
583 return Math.max(1, tierRank(materialId)) * 10_000;
584}
585
586/** Base craft duration per bar rank (bronze = 2s, iron = 4s, …). */
587export const SMELT_DURATION_PER_RANK_MS = 2000;
588
589/**
590 * Furnace smelt duration from the output bar's associated tier rank.
591 * Tin/copper/coal map to bronze/steel so ingredient timing matches that bar.
592 */
593export function smeltingDurationMs (barOrMaterialId)
594{
595 return Math.max(1, tierRank(barOrMaterialId)) * SMELT_DURATION_PER_RANK_MS;
596}
597
598/** Visual / interact state while an ore boulder is depleted (plain rock). */
599export const EXHAUSTED_ORE_BOULDER_STATE = "boulder";
600
601/**
602 * Materials that have an ore boulder node.
603 * Bronze has no ore (tin + copper); steel has no ore (iron + coal).
604 * Gold and silver are precious only (ore + bars, no tools).
605 */
606export const ORE_BEARING_MATERIALS = Object.freeze([
607 GatherMaterialId.tin,
608 GatherMaterialId.copper,
609 MaterialTier.iron,
610 GatherMaterialId.silver,
611 GatherMaterialId.gold,
612 MaterialTier.mithril,
613 MaterialTier.adamantium,
614 MaterialTier.orichalcum,
615 MaterialTier.dragon,
616 GatherMaterialId.coal,
617 ...GEM_TIER_ORDER
618]);
619
620/** Boulder visual state for a gatherable ore (editor / world). */
621export function oreBoulderState (materialId)
622{
623 if (materialId === GatherMaterialId.coal)
624 { return "coal"; }
625 return `${materialId}-ore`;
626}
627
628export function materialFromOreBoulderState (state)
629{
630 if (!state || state === "boulder")
631 { return null; }
632 if (state === "coal")
633 { return GatherMaterialId.coal; }
634 if (state.endsWith("-ore"))
635 {
636 const id = state.slice(0, -"-ore".length);
637 if (ORE_BEARING_MATERIALS.includes(id))
638 { return id; }
639 }
640 return null;
641}
642
643export function isOreBoulderState (state)
644{
645 return materialFromOreBoulderState(state) != null;
646}