BlueGit

timfa questward

Files

questward / shared / definitions / alchemy.js

alchemy.js

alchemy.js 11.4 KiB Download Raw
1/** Cauldron action / step kinds (authoritative recipe language). */
2import {
3 MagicElement,
4 MAGIC_ELEMENT_ORDER,
5 MAGIC_ELEMENT_TINT,
6 ASH_WOOD_FOR_ELEMENT
7} from "./attackTypes.js";
8
9export const AlchemyStepKind = Object.freeze({
10 heat: "heat",
11 cool: "cool",
12 stir: "stir",
13 insert: "insert"
14});
15
16export const POTION_MAX_STACK = 16;
17export const POTION_FILL_LEVELS = Object.freeze([1, 2, 3, 4, 5]);
18export const CAULDRON_SLOT_COUNT = 4;
19export const DYE_CAULDRON_SLOT_COUNT = 6;
20/** How many untipped arrows one coating charge can tip. */
21export const ARROW_COATING_ARROWS_PER_USE = 10;
22
23/** Deterministic cauldron look lines (hashed from the step transcript). */
24export const CAULDRON_FLAVOR_LINES = Object.freeze([
25 "The liquid is bubbling",
26 "The liquid is sizzling",
27 "The liquid is still",
28 "The liquid is murky",
29 "The liquid is swirling",
30 "The liquid is glowing",
31 "The liquid is fuming",
32 "The liquid is boiling"
33]);
34
35export const CAULDRON_EMPTY_FLAVOR = "The cauldron is empty";
36
37/**
38 * Known successful potions. Ingredient `key` matches item def keys (resolved to itemId at runtime).
39 * A potion may never use more than 4 unique ingredients (one per cauldron slot).
40 * Stage ingredients in the top slots before the first brew step; slots lock until Bottle.
41 * Step `insert` is once per ingredient addition; quantity lives in `ingredients`.
42 */
43export const ALCHEMY_POTION_DEFINITIONS = Object.freeze({
44 lesserHealthTonic: Object.freeze({
45 potionKey: "lesserHealthTonic",
46 displayName: "Lesser health tonic",
47 description: "Warm red liquid that knits small wounds for a short while.",
48 minAlchemyLevel: 1,
49 color: Object.freeze({ r: 0.95, g: 0.38, b: 0.32 }),
50 fillLevel: 4,
51 ingredients: Object.freeze([
52 Object.freeze({ key: "thyme", quantity: 1 }),
53 Object.freeze({ key: "mint", quantity: 1 })
54 ]),
55 steps: Object.freeze([
56 Object.freeze({ kind: AlchemyStepKind.insert, itemKey: "thyme" }),
57 Object.freeze({ kind: AlchemyStepKind.heat }),
58 Object.freeze({ kind: AlchemyStepKind.insert, itemKey: "mint" }),
59 Object.freeze({ kind: AlchemyStepKind.stir })
60 ]),
61 effect: Object.freeze({
62 type: "health-regen",
63 amountPerSecond: 1,
64 durationMs: 10_000
65 })
66 }),
67 lesserHasteDraught: Object.freeze({
68 potionKey: "lesserHasteDraught",
69 displayName: "Lesser haste draught",
70 description: "A cool green sip that steadies the breath and quickens the step.",
71 minAlchemyLevel: 1,
72 color: Object.freeze({ r: 0.45, g: 0.85, b: 0.75 }),
73 fillLevel: 4,
74 ingredients: Object.freeze([
75 Object.freeze({ key: "mint", quantity: 2 }),
76 Object.freeze({ key: "lavender", quantity: 1 })
77 ]),
78 steps: Object.freeze([
79 Object.freeze({ kind: AlchemyStepKind.insert, itemKey: "mint" }),
80 Object.freeze({ kind: AlchemyStepKind.heat }),
81 Object.freeze({ kind: AlchemyStepKind.stir }),
82 Object.freeze({ kind: AlchemyStepKind.insert, itemKey: "lavender" }),
83 Object.freeze({ kind: AlchemyStepKind.cool })
84 ]),
85 effect: Object.freeze({
86 type: "stamina-regen",
87 amountPerSecond: 1,
88 durationMs: 10_000
89 })
90 }),
91 strengthPotion: Object.freeze({
92 potionKey: "strengthPotion",
93 displayName: "Strength potion",
94 description: "Thick and fiery — lends a brief surge of muscle.",
95 minAlchemyLevel: 1,
96 color: Object.freeze({ r: 0.82, g: 0.32, b: 0.18 }),
97 fillLevel: 4,
98 ingredients: Object.freeze([
99 Object.freeze({ key: "thyme", quantity: 3 }),
100 Object.freeze({ key: "nettle", quantity: 2 })
101 ]),
102 steps: Object.freeze([
103 Object.freeze({ kind: AlchemyStepKind.insert, itemKey: "thyme" }),
104 Object.freeze({ kind: AlchemyStepKind.stir }),
105 Object.freeze({ kind: AlchemyStepKind.insert, itemKey: "nettle" }),
106 Object.freeze({ kind: AlchemyStepKind.heat })
107 ]),
108 effect: Object.freeze({
109 type: "strength-bonus",
110 amount: 5,
111 durationMs: 60_000
112 })
113 }),
114 clarityPotion: Object.freeze({
115 potionKey: "clarityPotion",
116 displayName: "Clarity potion",
117 description: "Pale violet draught that clears the thoughts and steadies the will.",
118 minAlchemyLevel: 1,
119 color: Object.freeze({ r: 0.55, g: 0.45, b: 0.92 }),
120 fillLevel: 4,
121 ingredients: Object.freeze([
122 Object.freeze({ key: "rosemary", quantity: 1 }),
123 Object.freeze({ key: "chamomile", quantity: 2 })
124 ]),
125 steps: Object.freeze([
126 Object.freeze({ kind: AlchemyStepKind.insert, itemKey: "rosemary" }),
127 Object.freeze({ kind: AlchemyStepKind.cool }),
128 Object.freeze({ kind: AlchemyStepKind.insert, itemKey: "chamomile" }),
129 Object.freeze({ kind: AlchemyStepKind.stir })
130 ]),
131 effect: Object.freeze({
132 type: "mind-bonus",
133 amount: 5,
134 durationMs: 60_000
135 })
136 }),
137 animalFat: Object.freeze({
138 potionKey: "animalFat",
139 displayName: "Bottle of Animal Fat",
140 description: "Rendered fat sealed in glass. Useful for tanning work — foul if drunk.",
141 minAlchemyLevel: 1,
142 color: Object.freeze({ r: 0.92, g: 0.84, b: 0.52 }),
143 fillLevel: 4,
144 ingredients: Object.freeze([
145 Object.freeze({ key: "uncooked-venison", quantity: 1 })
146 ]),
147 steps: Object.freeze([
148 Object.freeze({ kind: AlchemyStepKind.insert, itemKey: "uncooked-venison" }),
149 Object.freeze({ kind: AlchemyStepKind.heat }),
150 Object.freeze({ kind: AlchemyStepKind.stir }),
151 Object.freeze({ kind: AlchemyStepKind.cool })
152 ]),
153 effect: Object.freeze({
154 type: "food-poisoning",
155 amountPerSecond: 1,
156 durationMs: 10_000
157 })
158 }),
159 tanningBrew: Object.freeze({
160 potionKey: "tanningBrew",
161 displayName: "Tanning brew",
162 description: "A dark, bark-bitter liquor for curing hides. Foul if drunk.",
163 minAlchemyLevel: 10,
164 color: Object.freeze({ r: 0.45, g: 0.28, b: 0.14 }),
165 fillLevel: 4,
166 /** Fat bottle is the vessel — bottling does not consume empty glass bottles. */
167 requiresEmptyBottles: false,
168 ingredients: Object.freeze([
169 Object.freeze({ key: "oak-bark", quantity: 2 }),
170 Object.freeze({ key: "rock-salt", quantity: 1 }),
171 Object.freeze({ potionKey: "animalFat", quantity: 1 })
172 ]),
173 steps: Object.freeze([
174 Object.freeze({ kind: AlchemyStepKind.insert, itemKey: "oak-bark" }),
175 Object.freeze({ kind: AlchemyStepKind.heat }),
176 Object.freeze({ kind: AlchemyStepKind.insert, itemKey: "rock-salt" }),
177 Object.freeze({ kind: AlchemyStepKind.stir }),
178 Object.freeze({ kind: AlchemyStepKind.insert, potionKey: "animalFat" }),
179 Object.freeze({ kind: AlchemyStepKind.cool })
180 ]),
181 effect: Object.freeze({
182 type: "food-poisoning",
183 amountPerSecond: 1,
184 durationMs: 10_000
185 })
186 }),
187 ...buildArrowCoatingPotions()
188});
189
190/**
191 * Arrow coatings — one per magic element. Each uses a different wood ash + matching essence,
192 * with a distinct brew sequence so they do not collide with each other.
193 */
194function buildArrowCoatingPotions ()
195{
196 const coats = {};
197 const sequences = [
198 // fire — heat the ash, then fold in essence
199 (ash, essence) => [
200 { kind: AlchemyStepKind.insert, itemKey: ash },
201 { kind: AlchemyStepKind.heat },
202 { kind: AlchemyStepKind.insert, itemKey: essence },
203 { kind: AlchemyStepKind.stir }
204 ],
205 // water — cool ash slurry, essence last
206 (ash, essence) => [
207 { kind: AlchemyStepKind.insert, itemKey: ash },
208 { kind: AlchemyStepKind.cool },
209 { kind: AlchemyStepKind.stir },
210 { kind: AlchemyStepKind.insert, itemKey: essence }
211 ],
212 // air — stir ash, heat essence gently
213 (ash, essence) => [
214 { kind: AlchemyStepKind.insert, itemKey: ash },
215 { kind: AlchemyStepKind.stir },
216 { kind: AlchemyStepKind.insert, itemKey: essence },
217 { kind: AlchemyStepKind.heat }
218 ],
219 // earth — essence first, then ash, heavy heat
220 (ash, essence) => [
221 { kind: AlchemyStepKind.insert, itemKey: essence },
222 { kind: AlchemyStepKind.heat },
223 { kind: AlchemyStepKind.insert, itemKey: ash },
224 { kind: AlchemyStepKind.stir }
225 ],
226 // light — cool essence, warm ash
227 (ash, essence) => [
228 { kind: AlchemyStepKind.insert, itemKey: essence },
229 { kind: AlchemyStepKind.cool },
230 { kind: AlchemyStepKind.insert, itemKey: ash },
231 { kind: AlchemyStepKind.heat }
232 ],
233 // dark — ash and essence together under cool stillness
234 (ash, essence) => [
235 { kind: AlchemyStepKind.insert, itemKey: ash },
236 { kind: AlchemyStepKind.insert, itemKey: essence },
237 { kind: AlchemyStepKind.cool },
238 { kind: AlchemyStepKind.stir }
239 ],
240 // poison — heat essence alone, then ash, cool to set
241 (ash, essence) => [
242 { kind: AlchemyStepKind.insert, itemKey: essence },
243 { kind: AlchemyStepKind.heat },
244 { kind: AlchemyStepKind.stir },
245 { kind: AlchemyStepKind.insert, itemKey: ash },
246 { kind: AlchemyStepKind.cool }
247 ]
248 ];
249 const names = {
250 [MagicElement.fire]: "Fire arrow coating",
251 [MagicElement.water]: "Water arrow coating",
252 [MagicElement.air]: "Air arrow coating",
253 [MagicElement.earth]: "Earth arrow coating",
254 [MagicElement.light]: "Light arrow coating",
255 [MagicElement.dark]: "Dark arrow coating",
256 [MagicElement.poison]: "Poison arrow coating"
257 };
258 const descriptions = {
259 [MagicElement.fire]: "Viscous slurry for arrowheads, steeped in living flame.",
260 [MagicElement.water]: "Cool, clinging slurry that carries the pull of deep water.",
261 [MagicElement.air]: "Light slurry that hums faintly, ready for wind-touched shafts.",
262 [MagicElement.earth]: "Heavy slurry thick with grit, for grounding an arrow's bite.",
263 [MagicElement.light]: "Bright slurry that catches the eye, meant for radiant tips.",
264 [MagicElement.dark]: "Shadow-thick slurry that swallows the gleam of steel.",
265 [MagicElement.poison]: "Bitter slurry for arrowheads — venom waits in every drop."
266 };
267 MAGIC_ELEMENT_ORDER.forEach((element, index) =>
268 {
269 const wood = ASH_WOOD_FOR_ELEMENT[element];
270 const ashKey = `${wood}-ash`;
271 const essenceKey = `${element}-essence`;
272 const tint = MAGIC_ELEMENT_TINT[element];
273 const potionKey = `${element}ArrowCoating`;
274 coats[potionKey] = Object.freeze({
275 potionKey,
276 displayName: names[element] ?? `${element} arrow coating`,
277 description: descriptions[element] ?? "A viscous coating for arrowheads.",
278 minAlchemyLevel: 5,
279 color: Object.freeze({ r: tint.r, g: tint.g, b: tint.b }),
280 fillLevel: 4,
281 ingredients: Object.freeze([
282 Object.freeze({ key: ashKey, quantity: 1 }),
283 Object.freeze({ key: essenceKey, quantity: 1 })
284 ]),
285 steps: Object.freeze(sequences[index](ashKey, essenceKey).map((s) => Object.freeze(s))),
286 effect: Object.freeze({
287 type: "arrow-coating",
288 element
289 })
290 });
291 });
292 return coats;
293}
294
295/**
296 * Failure (unstable) potions chosen by hashing the step transcript.
297 */
298export const UNSTABLE_POTION_EFFECTS = Object.freeze([
299 Object.freeze({
300 effectKey: "stamina-drain",
301 displayName: "Unstable draught",
302 color: { r: 0.55, g: 0.2, b: 0.35 },
303 fillLevel: 3,
304 effect: Object.freeze({
305 type: "stamina-drain",
306 amountPerSecond: 1,
307 durationMs: 15_000
308 })
309 }),
310 Object.freeze({
311 effectKey: "glow",
312 displayName: "Unstable draught",
313 color: { r: 0.95, g: 0.9, b: 0.45 },
314 fillLevel: 3,
315 effect: Object.freeze({
316 type: "glow",
317 lightRadiusTiles: 2,
318 durationMs: 10_000
319 })
320 }),
321 Object.freeze({
322 effectKey: "shrink",
323 displayName: "Unstable draught",
324 color: { r: 0.7, g: 0.55, b: 0.85 },
325 fillLevel: 2,
326 effect: Object.freeze({
327 type: "shrink",
328 scale: 0.5,
329 durationMs: 30_000
330 })
331 }),
332 Object.freeze({
333 effectKey: "blind",
334 displayName: "Unstable draught",
335 color: { r: 0.12, g: 0.12, b: 0.16 },
336 fillLevel: 3,
337 effect: Object.freeze({
338 type: "blind",
339 durationMs: 20_000
340 })
341 })
342]);
343
344export function alchemyPotionDefinition (potionKey)
345{
346 return ALCHEMY_POTION_DEFINITIONS[potionKey] ?? null;
347}
348
349export function listAlchemyPotions ()
350{
351 return Object.values(ALCHEMY_POTION_DEFINITIONS);
352}