BlueGit

timfa questward

Files

questward / shared / definitions / alchemy.js

alchemy.js

alchemy.js 8.6 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 minAlchemyLevel: 1,
48 color: Object.freeze({ r: 0.95, g: 0.38, b: 0.32 }),
49 fillLevel: 4,
50 ingredients: Object.freeze([
51 Object.freeze({ key: "thyme", quantity: 1 }),
52 Object.freeze({ key: "mint", quantity: 1 })
53 ]),
54 steps: Object.freeze([
55 Object.freeze({ kind: AlchemyStepKind.insert, itemKey: "thyme" }),
56 Object.freeze({ kind: AlchemyStepKind.heat }),
57 Object.freeze({ kind: AlchemyStepKind.insert, itemKey: "mint" }),
58 Object.freeze({ kind: AlchemyStepKind.stir })
59 ]),
60 effect: Object.freeze({
61 type: "health-regen",
62 amountPerSecond: 1,
63 durationMs: 10_000
64 })
65 }),
66 lesserHasteDraught: Object.freeze({
67 potionKey: "lesserHasteDraught",
68 displayName: "Lesser haste draught",
69 minAlchemyLevel: 1,
70 color: Object.freeze({ r: 0.45, g: 0.85, b: 0.75 }),
71 fillLevel: 4,
72 ingredients: Object.freeze([
73 Object.freeze({ key: "mint", quantity: 2 }),
74 Object.freeze({ key: "lavender", quantity: 1 })
75 ]),
76 steps: Object.freeze([
77 Object.freeze({ kind: AlchemyStepKind.insert, itemKey: "mint" }),
78 Object.freeze({ kind: AlchemyStepKind.heat }),
79 Object.freeze({ kind: AlchemyStepKind.stir }),
80 Object.freeze({ kind: AlchemyStepKind.insert, itemKey: "lavender" }),
81 Object.freeze({ kind: AlchemyStepKind.cool })
82 ]),
83 effect: Object.freeze({
84 type: "stamina-regen",
85 amountPerSecond: 1,
86 durationMs: 10_000
87 })
88 }),
89 strengthPotion: Object.freeze({
90 potionKey: "strengthPotion",
91 displayName: "Strength potion",
92 minAlchemyLevel: 1,
93 color: Object.freeze({ r: 0.82, g: 0.32, b: 0.18 }),
94 fillLevel: 4,
95 ingredients: Object.freeze([
96 Object.freeze({ key: "thyme", quantity: 3 }),
97 Object.freeze({ key: "nettle", quantity: 2 })
98 ]),
99 steps: Object.freeze([
100 Object.freeze({ kind: AlchemyStepKind.insert, itemKey: "thyme" }),
101 Object.freeze({ kind: AlchemyStepKind.stir }),
102 Object.freeze({ kind: AlchemyStepKind.insert, itemKey: "nettle" }),
103 Object.freeze({ kind: AlchemyStepKind.heat })
104 ]),
105 effect: Object.freeze({
106 type: "strength-bonus",
107 amount: 5,
108 durationMs: 60_000
109 })
110 }),
111 clarityPotion: Object.freeze({
112 potionKey: "clarityPotion",
113 displayName: "Clarity potion",
114 minAlchemyLevel: 1,
115 color: Object.freeze({ r: 0.55, g: 0.45, b: 0.92 }),
116 fillLevel: 4,
117 ingredients: Object.freeze([
118 Object.freeze({ key: "rosemary", quantity: 1 }),
119 Object.freeze({ key: "chamomile", quantity: 2 })
120 ]),
121 steps: Object.freeze([
122 Object.freeze({ kind: AlchemyStepKind.insert, itemKey: "rosemary" }),
123 Object.freeze({ kind: AlchemyStepKind.cool }),
124 Object.freeze({ kind: AlchemyStepKind.insert, itemKey: "chamomile" }),
125 Object.freeze({ kind: AlchemyStepKind.stir })
126 ]),
127 effect: Object.freeze({
128 type: "mind-bonus",
129 amount: 5,
130 durationMs: 60_000
131 })
132 }),
133 ...buildArrowCoatingPotions()
134});
135
136/**
137 * Arrow coatings — one per magic element. Each uses a different wood ash + matching essence,
138 * with a distinct brew sequence so they do not collide with each other.
139 */
140function buildArrowCoatingPotions ()
141{
142 const coats = {};
143 const sequences = [
144 // fire — heat the ash, then fold in essence
145 (ash, essence) => [
146 { kind: AlchemyStepKind.insert, itemKey: ash },
147 { kind: AlchemyStepKind.heat },
148 { kind: AlchemyStepKind.insert, itemKey: essence },
149 { kind: AlchemyStepKind.stir }
150 ],
151 // water — cool ash slurry, essence last
152 (ash, essence) => [
153 { kind: AlchemyStepKind.insert, itemKey: ash },
154 { kind: AlchemyStepKind.cool },
155 { kind: AlchemyStepKind.stir },
156 { kind: AlchemyStepKind.insert, itemKey: essence }
157 ],
158 // air — stir ash, heat essence gently
159 (ash, essence) => [
160 { kind: AlchemyStepKind.insert, itemKey: ash },
161 { kind: AlchemyStepKind.stir },
162 { kind: AlchemyStepKind.insert, itemKey: essence },
163 { kind: AlchemyStepKind.heat }
164 ],
165 // earth — essence first, then ash, heavy heat
166 (ash, essence) => [
167 { kind: AlchemyStepKind.insert, itemKey: essence },
168 { kind: AlchemyStepKind.heat },
169 { kind: AlchemyStepKind.insert, itemKey: ash },
170 { kind: AlchemyStepKind.stir }
171 ],
172 // light — cool essence, warm ash
173 (ash, essence) => [
174 { kind: AlchemyStepKind.insert, itemKey: essence },
175 { kind: AlchemyStepKind.cool },
176 { kind: AlchemyStepKind.insert, itemKey: ash },
177 { kind: AlchemyStepKind.heat }
178 ],
179 // dark — ash and essence together under cool stillness
180 (ash, essence) => [
181 { kind: AlchemyStepKind.insert, itemKey: ash },
182 { kind: AlchemyStepKind.insert, itemKey: essence },
183 { kind: AlchemyStepKind.cool },
184 { kind: AlchemyStepKind.stir }
185 ],
186 // poison — heat essence alone, then ash, cool to set
187 (ash, essence) => [
188 { kind: AlchemyStepKind.insert, itemKey: essence },
189 { kind: AlchemyStepKind.heat },
190 { kind: AlchemyStepKind.stir },
191 { kind: AlchemyStepKind.insert, itemKey: ash },
192 { kind: AlchemyStepKind.cool }
193 ]
194 ];
195 const names = {
196 [MagicElement.fire]: "Fire arrow coating",
197 [MagicElement.water]: "Water arrow coating",
198 [MagicElement.air]: "Air arrow coating",
199 [MagicElement.earth]: "Earth arrow coating",
200 [MagicElement.light]: "Light arrow coating",
201 [MagicElement.dark]: "Dark arrow coating",
202 [MagicElement.poison]: "Poison arrow coating"
203 };
204 MAGIC_ELEMENT_ORDER.forEach((element, index) =>
205 {
206 const wood = ASH_WOOD_FOR_ELEMENT[element];
207 const ashKey = `${wood}-ash`;
208 const essenceKey = `${element}-essence`;
209 const tint = MAGIC_ELEMENT_TINT[element];
210 const potionKey = `${element}ArrowCoating`;
211 coats[potionKey] = Object.freeze({
212 potionKey,
213 displayName: names[element] ?? `${element} arrow coating`,
214 minAlchemyLevel: 5,
215 color: Object.freeze({ r: tint.r, g: tint.g, b: tint.b }),
216 fillLevel: 4,
217 ingredients: Object.freeze([
218 Object.freeze({ key: ashKey, quantity: 1 }),
219 Object.freeze({ key: essenceKey, quantity: 1 })
220 ]),
221 steps: Object.freeze(sequences[index](ashKey, essenceKey).map((s) => Object.freeze(s))),
222 effect: Object.freeze({
223 type: "arrow-coating",
224 element
225 })
226 });
227 });
228 return coats;
229}
230
231/**
232 * Failure (unstable) potions chosen by hashing the step transcript.
233 */
234export const UNSTABLE_POTION_EFFECTS = Object.freeze([
235 Object.freeze({
236 effectKey: "stamina-drain",
237 displayName: "Unstable draught",
238 color: { r: 0.55, g: 0.2, b: 0.35 },
239 fillLevel: 3,
240 effect: Object.freeze({
241 type: "stamina-drain",
242 amountPerSecond: 1,
243 durationMs: 15_000
244 })
245 }),
246 Object.freeze({
247 effectKey: "glow",
248 displayName: "Unstable draught",
249 color: { r: 0.95, g: 0.9, b: 0.45 },
250 fillLevel: 3,
251 effect: Object.freeze({
252 type: "glow",
253 lightRadiusTiles: 2,
254 durationMs: 10_000
255 })
256 }),
257 Object.freeze({
258 effectKey: "shrink",
259 displayName: "Unstable draught",
260 color: { r: 0.7, g: 0.55, b: 0.85 },
261 fillLevel: 2,
262 effect: Object.freeze({
263 type: "shrink",
264 scale: 0.5,
265 durationMs: 30_000
266 })
267 }),
268 Object.freeze({
269 effectKey: "blind",
270 displayName: "Unstable draught",
271 color: { r: 0.12, g: 0.12, b: 0.16 },
272 fillLevel: 3,
273 effect: Object.freeze({
274 type: "blind",
275 durationMs: 20_000
276 })
277 })
278]);
279
280export function alchemyPotionDefinition (potionKey)
281{
282 return ALCHEMY_POTION_DEFINITIONS[potionKey] ?? null;
283}
284
285export function listAlchemyPotions ()
286{
287 return Object.values(ALCHEMY_POTION_DEFINITIONS);
288}