BlueGit

timfa questward

Files

questward / shared / definitions / alchemy.js

alchemy.js

alchemy.js 10.3 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 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 minAlchemyLevel: 1,
71 color: Object.freeze({ r: 0.45, g: 0.85, b: 0.75 }),
72 fillLevel: 4,
73 ingredients: Object.freeze([
74 Object.freeze({ key: "mint", quantity: 2 }),
75 Object.freeze({ key: "lavender", quantity: 1 })
76 ]),
77 steps: Object.freeze([
78 Object.freeze({ kind: AlchemyStepKind.insert, itemKey: "mint" }),
79 Object.freeze({ kind: AlchemyStepKind.heat }),
80 Object.freeze({ kind: AlchemyStepKind.stir }),
81 Object.freeze({ kind: AlchemyStepKind.insert, itemKey: "lavender" }),
82 Object.freeze({ kind: AlchemyStepKind.cool })
83 ]),
84 effect: Object.freeze({
85 type: "stamina-regen",
86 amountPerSecond: 1,
87 durationMs: 10_000
88 })
89 }),
90 strengthPotion: Object.freeze({
91 potionKey: "strengthPotion",
92 displayName: "Strength potion",
93 minAlchemyLevel: 1,
94 color: Object.freeze({ r: 0.82, g: 0.32, b: 0.18 }),
95 fillLevel: 4,
96 ingredients: Object.freeze([
97 Object.freeze({ key: "thyme", quantity: 3 }),
98 Object.freeze({ key: "nettle", quantity: 2 })
99 ]),
100 steps: Object.freeze([
101 Object.freeze({ kind: AlchemyStepKind.insert, itemKey: "thyme" }),
102 Object.freeze({ kind: AlchemyStepKind.stir }),
103 Object.freeze({ kind: AlchemyStepKind.insert, itemKey: "nettle" }),
104 Object.freeze({ kind: AlchemyStepKind.heat })
105 ]),
106 effect: Object.freeze({
107 type: "strength-bonus",
108 amount: 5,
109 durationMs: 60_000
110 })
111 }),
112 clarityPotion: Object.freeze({
113 potionKey: "clarityPotion",
114 displayName: "Clarity potion",
115 minAlchemyLevel: 1,
116 color: Object.freeze({ r: 0.55, g: 0.45, b: 0.92 }),
117 fillLevel: 4,
118 ingredients: Object.freeze([
119 Object.freeze({ key: "rosemary", quantity: 1 }),
120 Object.freeze({ key: "chamomile", quantity: 2 })
121 ]),
122 steps: Object.freeze([
123 Object.freeze({ kind: AlchemyStepKind.insert, itemKey: "rosemary" }),
124 Object.freeze({ kind: AlchemyStepKind.cool }),
125 Object.freeze({ kind: AlchemyStepKind.insert, itemKey: "chamomile" }),
126 Object.freeze({ kind: AlchemyStepKind.stir })
127 ]),
128 effect: Object.freeze({
129 type: "mind-bonus",
130 amount: 5,
131 durationMs: 60_000
132 })
133 }),
134 animalFat: Object.freeze({
135 potionKey: "animalFat",
136 displayName: "Bottle of Animal Fat",
137 minAlchemyLevel: 1,
138 color: Object.freeze({ r: 0.92, g: 0.84, b: 0.52 }),
139 fillLevel: 4,
140 ingredients: Object.freeze([
141 Object.freeze({ key: "uncooked-venison", quantity: 1 })
142 ]),
143 steps: Object.freeze([
144 Object.freeze({ kind: AlchemyStepKind.insert, itemKey: "uncooked-venison" }),
145 Object.freeze({ kind: AlchemyStepKind.heat }),
146 Object.freeze({ kind: AlchemyStepKind.stir }),
147 Object.freeze({ kind: AlchemyStepKind.cool })
148 ]),
149 effect: Object.freeze({
150 type: "food-poisoning",
151 amountPerSecond: 1,
152 durationMs: 10_000
153 })
154 }),
155 tanningBrew: Object.freeze({
156 potionKey: "tanningBrew",
157 displayName: "Tanning brew",
158 minAlchemyLevel: 10,
159 color: Object.freeze({ r: 0.45, g: 0.28, b: 0.14 }),
160 fillLevel: 4,
161 /** Solid craft item — not a drinkable potion bottle. */
162 outputItemId: LeatherItemId.tanningBrew,
163 outputQuantity: 1,
164 /** Bottling does not consume empty glass bottles (fat bottle is the vessel). */
165 requiresEmptyBottles: false,
166 ingredients: Object.freeze([
167 Object.freeze({ key: "oak-bark", quantity: 2 }),
168 Object.freeze({ key: "rock-salt", quantity: 1 }),
169 Object.freeze({ potionKey: "animalFat", quantity: 1 })
170 ]),
171 steps: Object.freeze([
172 Object.freeze({ kind: AlchemyStepKind.insert, itemKey: "oak-bark" }),
173 Object.freeze({ kind: AlchemyStepKind.heat }),
174 Object.freeze({ kind: AlchemyStepKind.insert, itemKey: "rock-salt" }),
175 Object.freeze({ kind: AlchemyStepKind.stir }),
176 Object.freeze({ kind: AlchemyStepKind.insert, potionKey: "animalFat" }),
177 Object.freeze({ kind: AlchemyStepKind.cool })
178 ]),
179 effect: null
180 }),
181 ...buildArrowCoatingPotions()
182});
183
184/**
185 * Arrow coatings — one per magic element. Each uses a different wood ash + matching essence,
186 * with a distinct brew sequence so they do not collide with each other.
187 */
188function buildArrowCoatingPotions ()
189{
190 const coats = {};
191 const sequences = [
192 // fire — heat the ash, then fold in essence
193 (ash, essence) => [
194 { kind: AlchemyStepKind.insert, itemKey: ash },
195 { kind: AlchemyStepKind.heat },
196 { kind: AlchemyStepKind.insert, itemKey: essence },
197 { kind: AlchemyStepKind.stir }
198 ],
199 // water — cool ash slurry, essence last
200 (ash, essence) => [
201 { kind: AlchemyStepKind.insert, itemKey: ash },
202 { kind: AlchemyStepKind.cool },
203 { kind: AlchemyStepKind.stir },
204 { kind: AlchemyStepKind.insert, itemKey: essence }
205 ],
206 // air — stir ash, heat essence gently
207 (ash, essence) => [
208 { kind: AlchemyStepKind.insert, itemKey: ash },
209 { kind: AlchemyStepKind.stir },
210 { kind: AlchemyStepKind.insert, itemKey: essence },
211 { kind: AlchemyStepKind.heat }
212 ],
213 // earth — essence first, then ash, heavy heat
214 (ash, essence) => [
215 { kind: AlchemyStepKind.insert, itemKey: essence },
216 { kind: AlchemyStepKind.heat },
217 { kind: AlchemyStepKind.insert, itemKey: ash },
218 { kind: AlchemyStepKind.stir }
219 ],
220 // light — cool essence, warm ash
221 (ash, essence) => [
222 { kind: AlchemyStepKind.insert, itemKey: essence },
223 { kind: AlchemyStepKind.cool },
224 { kind: AlchemyStepKind.insert, itemKey: ash },
225 { kind: AlchemyStepKind.heat }
226 ],
227 // dark — ash and essence together under cool stillness
228 (ash, essence) => [
229 { kind: AlchemyStepKind.insert, itemKey: ash },
230 { kind: AlchemyStepKind.insert, itemKey: essence },
231 { kind: AlchemyStepKind.cool },
232 { kind: AlchemyStepKind.stir }
233 ],
234 // poison — heat essence alone, then ash, cool to set
235 (ash, essence) => [
236 { kind: AlchemyStepKind.insert, itemKey: essence },
237 { kind: AlchemyStepKind.heat },
238 { kind: AlchemyStepKind.stir },
239 { kind: AlchemyStepKind.insert, itemKey: ash },
240 { kind: AlchemyStepKind.cool }
241 ]
242 ];
243 const names = {
244 [MagicElement.fire]: "Fire arrow coating",
245 [MagicElement.water]: "Water arrow coating",
246 [MagicElement.air]: "Air arrow coating",
247 [MagicElement.earth]: "Earth arrow coating",
248 [MagicElement.light]: "Light arrow coating",
249 [MagicElement.dark]: "Dark arrow coating",
250 [MagicElement.poison]: "Poison arrow coating"
251 };
252 MAGIC_ELEMENT_ORDER.forEach((element, index) =>
253 {
254 const wood = ASH_WOOD_FOR_ELEMENT[element];
255 const ashKey = `${wood}-ash`;
256 const essenceKey = `${element}-essence`;
257 const tint = MAGIC_ELEMENT_TINT[element];
258 const potionKey = `${element}ArrowCoating`;
259 coats[potionKey] = Object.freeze({
260 potionKey,
261 displayName: names[element] ?? `${element} arrow coating`,
262 minAlchemyLevel: 5,
263 color: Object.freeze({ r: tint.r, g: tint.g, b: tint.b }),
264 fillLevel: 4,
265 ingredients: Object.freeze([
266 Object.freeze({ key: ashKey, quantity: 1 }),
267 Object.freeze({ key: essenceKey, quantity: 1 })
268 ]),
269 steps: Object.freeze(sequences[index](ashKey, essenceKey).map((s) => Object.freeze(s))),
270 effect: Object.freeze({
271 type: "arrow-coating",
272 element
273 })
274 });
275 });
276 return coats;
277}
278
279/**
280 * Failure (unstable) potions chosen by hashing the step transcript.
281 */
282export const UNSTABLE_POTION_EFFECTS = Object.freeze([
283 Object.freeze({
284 effectKey: "stamina-drain",
285 displayName: "Unstable draught",
286 color: { r: 0.55, g: 0.2, b: 0.35 },
287 fillLevel: 3,
288 effect: Object.freeze({
289 type: "stamina-drain",
290 amountPerSecond: 1,
291 durationMs: 15_000
292 })
293 }),
294 Object.freeze({
295 effectKey: "glow",
296 displayName: "Unstable draught",
297 color: { r: 0.95, g: 0.9, b: 0.45 },
298 fillLevel: 3,
299 effect: Object.freeze({
300 type: "glow",
301 lightRadiusTiles: 2,
302 durationMs: 10_000
303 })
304 }),
305 Object.freeze({
306 effectKey: "shrink",
307 displayName: "Unstable draught",
308 color: { r: 0.7, g: 0.55, b: 0.85 },
309 fillLevel: 2,
310 effect: Object.freeze({
311 type: "shrink",
312 scale: 0.5,
313 durationMs: 30_000
314 })
315 }),
316 Object.freeze({
317 effectKey: "blind",
318 displayName: "Unstable draught",
319 color: { r: 0.12, g: 0.12, b: 0.16 },
320 fillLevel: 3,
321 effect: Object.freeze({
322 type: "blind",
323 durationMs: 20_000
324 })
325 })
326]);
327
328export function alchemyPotionDefinition (potionKey)
329{
330 return ALCHEMY_POTION_DEFINITIONS[potionKey] ?? null;
331}
332
333export function listAlchemyPotions ()
334{
335 return Object.values(ALCHEMY_POTION_DEFINITIONS);
336}