BlueGit

timfa questward

Files

questward / shared / definitions / herbs.js

herbs.js

herbs.js 7.6 KiB Download Raw
1import { spriteImageName } from "./tileSprites.js";
2import { ItemCategory } from "./itemCategories.js";
3
4/**
5 * Folklore herb catalog for Herbalism nodes + alchemy ingredients.
6 * Fantasy associations live in docs/FEATURES.md (not code) for later potion design.
7 *
8 * Tier spread (24 herbs): 2 / 3 / 3 / 4 / 4 / 4 / 4 for tiers 1–7.
9 */
10
11export const HerbId = Object.freeze({
12 mint: "mint",
13 garlic: "garlic",
14 thyme: "thyme",
15 sage: "sage",
16 rosemary: "rosemary",
17 lavender: "lavender",
18 chamomile: "chamomile",
19 nettle: "nettle",
20 yarrow: "yarrow",
21 juniper: "juniper",
22 elder: "elder",
23 rue: "rue",
24 valerian: "valerian",
25 mugwort: "mugwort",
26 wormwood: "wormwood",
27 stJohnsWort: "st-johns-wort",
28 hawthorn: "hawthorn",
29 foxglove: "foxglove",
30 mistletoe: "mistletoe",
31 datura: "datura",
32 belladonna: "belladonna",
33 henbane: "henbane",
34 mandrake: "mandrake",
35 aconite: "aconite"
36});
37
38/** Numeric item IDs (160–183). Keys are camelCase for `ItemId` spread. */
39export const HerbItemId = Object.freeze({
40 mint: 160,
41 garlic: 161,
42 thyme: 162,
43 sage: 163,
44 rosemary: 164,
45 lavender: 165,
46 chamomile: 166,
47 nettle: 167,
48 yarrow: 168,
49 juniper: 169,
50 elder: 170,
51 rue: 171,
52 valerian: 172,
53 mugwort: 173,
54 wormwood: 174,
55 stJohnsWort: 175,
56 hawthorn: 176,
57 foxglove: 177,
58 mistletoe: 178,
59 datura: 179,
60 belladonna: 180,
61 henbane: 181,
62 mandrake: 182,
63 aconite: 183
64});
65
66/** Map herbId string → ItemId number. */
67const HERB_ITEM_ID_BY_KEY = Object.freeze({
68 [HerbId.mint]: HerbItemId.mint,
69 [HerbId.garlic]: HerbItemId.garlic,
70 [HerbId.thyme]: HerbItemId.thyme,
71 [HerbId.sage]: HerbItemId.sage,
72 [HerbId.rosemary]: HerbItemId.rosemary,
73 [HerbId.lavender]: HerbItemId.lavender,
74 [HerbId.chamomile]: HerbItemId.chamomile,
75 [HerbId.nettle]: HerbItemId.nettle,
76 [HerbId.yarrow]: HerbItemId.yarrow,
77 [HerbId.juniper]: HerbItemId.juniper,
78 [HerbId.elder]: HerbItemId.elder,
79 [HerbId.rue]: HerbItemId.rue,
80 [HerbId.valerian]: HerbItemId.valerian,
81 [HerbId.mugwort]: HerbItemId.mugwort,
82 [HerbId.wormwood]: HerbItemId.wormwood,
83 [HerbId.stJohnsWort]: HerbItemId.stJohnsWort,
84 [HerbId.hawthorn]: HerbItemId.hawthorn,
85 [HerbId.foxglove]: HerbItemId.foxglove,
86 [HerbId.mistletoe]: HerbItemId.mistletoe,
87 [HerbId.datura]: HerbItemId.datura,
88 [HerbId.belladonna]: HerbItemId.belladonna,
89 [HerbId.henbane]: HerbItemId.henbane,
90 [HerbId.mandrake]: HerbItemId.mandrake,
91 [HerbId.aconite]: HerbItemId.aconite
92});
93
94/**
95 * Gather skill gates by herb tier (aligned with mining: ceil(equipGate/2)).
96 * Tier 1→1, 2→5, 3→10, 4→18, 5→25, 6→35, 7→45.
97 */
98export const HERB_GATHER_SKILL_LEVEL = Object.freeze({
99 1: 1,
100 2: 5,
101 3: 10,
102 4: 18,
103 5: 25,
104 6: 35,
105 7: 45
106});
107
108const DEFAULT_STACK = 99;
109
110function herb (
111 herbId,
112 tier,
113 displayName,
114 description,
115 { seedValue = 2 } = {}
116)
117{
118 const itemId = HERB_ITEM_ID_BY_KEY[herbId];
119 return Object.freeze({
120 herbId,
121 itemId,
122 key: herbId,
123 tier,
124 displayName,
125 description,
126 seedValue,
127 stackable: true,
128 maxStackSize: DEFAULT_STACK,
129 uniqueInstance: false,
130 category: ItemCategory.ingredient,
131 herb: true,
132 /** Shared folder `assets/herbs/<key>.png` — catalog registers block + item. */
133 iconKey: "herbs",
134 defaultState: herbId,
135 sprite: spriteImageName("item", "herbs", herbId)
136 });
137}
138
139export const HERB_DEFINITIONS = Object.freeze({
140 // Tier 1 — kitchen & common garden
141 [HerbId.mint]: herb(
142 HerbId.mint,
143 1,
144 "Mint",
145 "Cool green leaves that freshen the breath and settle a heavy stomach."
146 ),
147 [HerbId.garlic]: herb(
148 HerbId.garlic,
149 1,
150 "Garlic",
151 "Pungent bulbs prized in kitchens and hung in doorways against unwelcome guests."
152 ),
153 // Tier 2 — household remedies
154 [HerbId.thyme]: herb(
155 HerbId.thyme,
156 2,
157 "Thyme",
158 "A hardy herb of the hills, used to clear the chest and steel the nerves."
159 ),
160 [HerbId.sage]: herb(
161 HerbId.sage,
162 2,
163 "Sage",
164 "Silvery leaves long trusted as a general cure and a mark of a clear mind."
165 ),
166 [HerbId.rosemary]: herb(
167 HerbId.rosemary,
168 2,
169 "Rosemary",
170 "Needle-leafed sprigs that sharpen memory and are said to ward off ill spirits."
171 ),
172 // Tier 3 — calming & common wild
173 [HerbId.lavender]: herb(
174 HerbId.lavender,
175 3,
176 "Lavender",
177 "Fragrant purple spikes laid under pillows and pressed into wound wraps."
178 ),
179 [HerbId.chamomile]: herb(
180 HerbId.chamomile,
181 3,
182 "Chamomile",
183 "Daisy-like blooms brewed for restless bellies and quiet evenings."
184 ),
185 [HerbId.nettle]: herb(
186 HerbId.nettle,
187 3,
188 "Nettle",
189 "Stinging greens that nourish when cooked and toughen those who handle them."
190 ),
191 // Tier 4 — battle & boundary herbs
192 [HerbId.yarrow]: herb(
193 HerbId.yarrow,
194 4,
195 "Yarrow",
196 "Feathery battlefield herb bound into bandages to stop a soldier's bleeding."
197 ),
198 [HerbId.juniper]: herb(
199 HerbId.juniper,
200 4,
201 "Juniper",
202 "Dark berries whose smoke is burned to purify rooms and drive out sickness."
203 ),
204 [HerbId.elder]: herb(
205 HerbId.elder,
206 4,
207 "Elder",
208 "Blossom and berry of a tree whispered to house spirits of its own."
209 ),
210 [HerbId.rue]: herb(
211 HerbId.rue,
212 4,
213 "Rue",
214 "Bitter leaves carried against curses and the stare of the evil eye."
215 ),
216 // Tier 5 — dream & bitter medicine
217 [HerbId.valerian]: herb(
218 HerbId.valerian,
219 5,
220 "Valerian",
221 "Earthy roots that pull the weary towards deep, untroubled sleep."
222 ),
223 [HerbId.mugwort]: herb(
224 HerbId.mugwort,
225 5,
226 "Mugwort",
227 "Roadside herb of dreamers, travellers, and those who seek visions."
228 ),
229 [HerbId.wormwood]: herb(
230 HerbId.wormwood,
231 5,
232 "Wormwood",
233 "A bitter grey-green plant used against parasites and haunted moods."
234 ),
235 [HerbId.stJohnsWort]: herb(
236 HerbId.stJohnsWort,
237 5,
238 "St. John's wort",
239 "Sunny yellow blooms carried as a charm against demons and dark hours."
240 ),
241 // Tier 6 — fey & perilous
242 [HerbId.hawthorn]: herb(
243 HerbId.hawthorn,
244 6,
245 "Hawthorn",
246 "Thorny blossom of sacred hedges and places best left undisturbed."
247 ),
248 [HerbId.foxglove]: herb(
249 HerbId.foxglove,
250 6,
251 "Foxglove",
252 "Tall bells said to be fairy gloves — beautiful, and deadly if mishandled."
253 ),
254 [HerbId.mistletoe]: herb(
255 HerbId.mistletoe,
256 6,
257 "Mistletoe",
258 "Pale berries of the oak-parasite, gathered for rites of life and fertility."
259 ),
260 [HerbId.datura]: herb(
261 HerbId.datura,
262 6,
263 "Datura",
264 "Trumpet flowers that open the mind to visions — and to madness."
265 ),
266 // Tier 7 — witches' garden
267 [HerbId.belladonna]: herb(
268 HerbId.belladonna,
269 7,
270 "Belladonna",
271 "Glossy black berries of the nightshade, linked to witch-flight and poison."
272 ),
273 [HerbId.henbane]: herb(
274 HerbId.henbane,
275 7,
276 "Henbane",
277 "Sickly nightshade that dulls the senses and invites strange trances."
278 ),
279 [HerbId.mandrake]: herb(
280 HerbId.mandrake,
281 7,
282 "Mandrake",
283 "A man-shaped root said to scream when torn from the earth."
284 ),
285 [HerbId.aconite]: herb(
286 HerbId.aconite,
287 7,
288 "Aconite",
289 "Monkshood — also called wolfsbane — a lethal flower of curses and beasts."
290 )
291});
292
293export const HERB_ORDER = Object.freeze(Object.keys(HERB_DEFINITIONS));
294
295export function herbDefinition (herbId)
296{
297 return HERB_DEFINITIONS[herbId] ?? null;
298}
299
300export function herbDefinitionByItemId (itemId)
301{
302 const id = itemId | 0;
303 for (const def of Object.values(HERB_DEFINITIONS))
304 {
305 if (def.itemId === id)
306 { return def; }
307 }
308 return null;
309}
310
311export function isHerbId (value)
312{
313 return !!HERB_DEFINITIONS[value];
314}
315
316export function herbGatherSkillLevel (tier)
317{
318 return HERB_GATHER_SKILL_LEVEL[tier | 0] ?? HERB_GATHER_SKILL_LEVEL[1];
319}
320
321export function herbBlockState (herbId)
322{
323 return isHerbId(herbId) ? herbId : HerbId.mint;
324}
325
326/** Item definition stubs merged into ITEM_DEFINITIONS. */
327export const HERB_ITEM_DEFINITIONS = Object.freeze(
328 Object.fromEntries(
329 Object.values(HERB_DEFINITIONS).map((def) => [def.itemId, def])
330 )
331);