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";
8import { LeatherItemId } from "./leatherItems.js";
9
10export const AlchemyStepKind = Object.freeze({
11 heat: "heat",
12 cool: "cool",
13 stir: "stir",
14 insert: "insert"
15});
16
17export const POTION_MAX_STACK = 16;
18export const POTION_FILL_LEVELS = Object.freeze([1, 2, 3, 4, 5]);
19export const CAULDRON_SLOT_COUNT = 4;
20export const DYE_CAULDRON_SLOT_COUNT = 6;
21/** How many untipped arrows one coating charge can tip. */
22export const ARROW_COATING_ARROWS_PER_USE = 10;
23
24/** Deterministic cauldron look lines (hashed from the step transcript). */
25export const CAULDRON_FLAVOR_LINES = Object.freeze([
26 "The liquid is bubbling",
27 "The liquid is sizzling",
28 "The liquid is still",
29 "The liquid is murky",
30 "The liquid is swirling",
31 "The liquid is glowing",
32 "The liquid is fuming",
33 "The liquid is boiling"
34]);
35
36export const CAULDRON_EMPTY_FLAVOR = "The cauldron is empty";
37
38/**
39 * Known successful potions. Ingredient `key` matches item def keys (resolved to itemId at runtime).
40 * A potion may never use more than 4 unique ingredients (one per cauldron slot).
41 * Stage ingredients in the top slots before the first brew step; slots lock until Bottle.
42 * Step `insert` is once per ingredient addition; quantity lives in `ingredients`.
43 */
44export const ALCHEMY_POTION_DEFINITIONS = Object.freeze({
45 lesserHealthTonic: Object.freeze({
46 potionKey: "lesserHealthTonic",
47 displayName: "Lesser health tonic",
48 description: "Warm red liquid that knits small wounds for a short while.",
49 minAlchemyLevel: 1,
50 color: Object.freeze({ r: 0.95, g: 0.38, b: 0.32 }),
51 fillLevel: 4,
52 ingredients: Object.freeze([
53 Object.freeze({ key: "thyme", quantity: 1 }),
54 Object.freeze({ key: "mint", quantity: 1 })
55 ]),
56 steps: Object.freeze([
57 Object.freeze({ kind: AlchemyStepKind.insert, itemKey: "thyme" }),
58 Object.freeze({ kind: AlchemyStepKind.heat }),
59 Object.freeze({ kind: AlchemyStepKind.insert, itemKey: "mint" }),
60 Object.freeze({ kind: AlchemyStepKind.stir })
61 ]),
62 effect: Object.freeze({
63 type: "health-regen",
64 amountPerSecond: 1,
65 durationMs: 10_000
66 })
67 }),
68 lesserHasteDraught: Object.freeze({
69 potionKey: "lesserHasteDraught",
70 displayName: "Lesser haste draught",
71 description: "A cool green sip that steadies the breath and quickens the step.",
72 minAlchemyLevel: 1,
73 color: Object.freeze({ r: 0.45, g: 0.85, b: 0.75 }),
74 fillLevel: 4,
75 ingredients: Object.freeze([
76 Object.freeze({ key: "mint", quantity: 2 }),
77 Object.freeze({ key: "lavender", quantity: 1 })
78 ]),
79 steps: Object.freeze([
80 Object.freeze({ kind: AlchemyStepKind.insert, itemKey: "mint" }),
81 Object.freeze({ kind: AlchemyStepKind.heat }),
82 Object.freeze({ kind: AlchemyStepKind.stir }),
83 Object.freeze({ kind: AlchemyStepKind.insert, itemKey: "lavender" }),
84 Object.freeze({ kind: AlchemyStepKind.cool })
85 ]),
86 effect: Object.freeze({
87 type: "stamina-regen",
88 amountPerSecond: 1,
89 durationMs: 10_000
90 })
91 }),
92 strengthPotion: Object.freeze({
93 potionKey: "strengthPotion",
94 displayName: "Strength potion",
95 description: "Thick and fiery — lends a brief surge of muscle.",
96 minAlchemyLevel: 1,
97 color: Object.freeze({ r: 0.82, g: 0.32, b: 0.18 }),
98 fillLevel: 4,
99 ingredients: Object.freeze([
100 Object.freeze({ key: "thyme", quantity: 3 }),
101 Object.freeze({ key: "nettle", quantity: 2 })
102 ]),
103 steps: Object.freeze([
104 Object.freeze({ kind: AlchemyStepKind.insert, itemKey: "thyme" }),
105 Object.freeze({ kind: AlchemyStepKind.stir }),
106 Object.freeze({ kind: AlchemyStepKind.insert, itemKey: "nettle" }),
107 Object.freeze({ kind: AlchemyStepKind.heat })
108 ]),
109 effect: Object.freeze({
110 type: "strength-bonus",
111 amount: 5,
112 durationMs: 60_000
113 })
114 }),
115 clarityPotion: Object.freeze({
116 potionKey: "clarityPotion",
117 displayName: "Clarity potion",
118 description: "Pale violet draught that clears the thoughts and steadies the will.",
119 minAlchemyLevel: 1,
120 color: Object.freeze({ r: 0.55, g: 0.45, b: 0.92 }),
121 fillLevel: 4,
122 ingredients: Object.freeze([
123 Object.freeze({ key: "rosemary", quantity: 1 }),
124 Object.freeze({ key: "chamomile", quantity: 2 })
125 ]),
126 steps: Object.freeze([
127 Object.freeze({ kind: AlchemyStepKind.insert, itemKey: "rosemary" }),
128 Object.freeze({ kind: AlchemyStepKind.cool }),
129 Object.freeze({ kind: AlchemyStepKind.insert, itemKey: "chamomile" }),
130 Object.freeze({ kind: AlchemyStepKind.stir })
131 ]),
132 effect: Object.freeze({
133 type: "mind-bonus",
134 amount: 5,
135 durationMs: 60_000
136 })
137 }),
138 animalFat: Object.freeze({
139 potionKey: "animalFat",
140 displayName: "Bottle of Animal Fat",
141 description: "Rendered fat sealed in glass. Useful for tanning work — foul if drunk.",
142 minAlchemyLevel: 1,
143 color: Object.freeze({ r: 0.92, g: 0.84, b: 0.52 }),
144 fillLevel: 4,
145 ingredients: Object.freeze([
146 Object.freeze({ key: "uncooked-venison", quantity: 1 })
147 ]),
148 steps: Object.freeze([
149 Object.freeze({ kind: AlchemyStepKind.insert, itemKey: "uncooked-venison" }),
150 Object.freeze({ kind: AlchemyStepKind.heat }),
151 Object.freeze({ kind: AlchemyStepKind.stir }),
152 Object.freeze({ kind: AlchemyStepKind.cool })
153 ]),
154 effect: Object.freeze({
155 type: "food-poisoning",
156 amountPerSecond: 1,
157 durationMs: 10_000
158 })
159 }),
160 tanningBrew: Object.freeze({
161 potionKey: "tanningBrew",
162 displayName: "Tanning brew",
163 description: "A dark, bark-bitter liquor for curing hides into leather.",
164 minAlchemyLevel: 10,
165 color: Object.freeze({ r: 0.45, g: 0.28, b: 0.14 }),
166 fillLevel: 4,
167 /** Solid craft item — not a drinkable potion bottle. */
168 outputItemId: LeatherItemId.tanningBrew,
169 outputQuantity: 1,
170 /** Bottling does not consume empty glass bottles (fat bottle is the vessel). */
171 requiresEmptyBottles: false,
172 ingredients: Object.freeze([
173 Object.freeze({ key: "oak-bark", quantity: 2 }),
174 Object.freeze({ key: "rock-salt", quantity: 1 }),
175 Object.freeze({ potionKey: "animalFat", quantity: 1 })
176 ]),
177 steps: Object.freeze([
178 Object.freeze({ kind: AlchemyStepKind.insert, itemKey: "oak-bark" }),
179 Object.freeze({ kind: AlchemyStepKind.heat }),
180 Object.freeze({ kind: AlchemyStepKind.insert, itemKey: "rock-salt" }),
181 Object.freeze({ kind: AlchemyStepKind.stir }),
182 Object.freeze({ kind: AlchemyStepKind.insert, potionKey: "animalFat" }),
183 Object.freeze({ kind: AlchemyStepKind.cool })
184 ]),
185 effect: null
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}