/** Cauldron action / step kinds (authoritative recipe language). */ import { MagicElement, MAGIC_ELEMENT_ORDER, MAGIC_ELEMENT_TINT, ASH_WOOD_FOR_ELEMENT } from "./attackTypes.js"; import { LeatherItemId } from "./leatherItems.js"; export const AlchemyStepKind = Object.freeze({ heat: "heat", cool: "cool", stir: "stir", insert: "insert" }); export const POTION_MAX_STACK = 16; export const POTION_FILL_LEVELS = Object.freeze([1, 2, 3, 4, 5]); export const CAULDRON_SLOT_COUNT = 4; export const DYE_CAULDRON_SLOT_COUNT = 6; /** How many untipped arrows one coating charge can tip. */ export const ARROW_COATING_ARROWS_PER_USE = 10; /** Deterministic cauldron look lines (hashed from the step transcript). */ export const CAULDRON_FLAVOR_LINES = Object.freeze([ "The liquid is bubbling", "The liquid is sizzling", "The liquid is still", "The liquid is murky", "The liquid is swirling", "The liquid is glowing", "The liquid is fuming", "The liquid is boiling" ]); export const CAULDRON_EMPTY_FLAVOR = "The cauldron is empty"; /** * Known successful potions. Ingredient `key` matches item def keys (resolved to itemId at runtime). * A potion may never use more than 4 unique ingredients (one per cauldron slot). * Stage ingredients in the top slots before the first brew step; slots lock until Bottle. * Step `insert` is once per ingredient addition; quantity lives in `ingredients`. */ export const ALCHEMY_POTION_DEFINITIONS = Object.freeze({ lesserHealthTonic: Object.freeze({ potionKey: "lesserHealthTonic", displayName: "Lesser health tonic", description: "Warm red liquid that knits small wounds for a short while.", minAlchemyLevel: 1, color: Object.freeze({ r: 0.95, g: 0.38, b: 0.32 }), fillLevel: 4, ingredients: Object.freeze([ Object.freeze({ key: "thyme", quantity: 1 }), Object.freeze({ key: "mint", quantity: 1 }) ]), steps: Object.freeze([ Object.freeze({ kind: AlchemyStepKind.insert, itemKey: "thyme" }), Object.freeze({ kind: AlchemyStepKind.heat }), Object.freeze({ kind: AlchemyStepKind.insert, itemKey: "mint" }), Object.freeze({ kind: AlchemyStepKind.stir }) ]), effect: Object.freeze({ type: "health-regen", amountPerSecond: 1, durationMs: 10_000 }) }), lesserHasteDraught: Object.freeze({ potionKey: "lesserHasteDraught", displayName: "Lesser haste draught", description: "A cool green sip that steadies the breath and quickens the step.", minAlchemyLevel: 1, color: Object.freeze({ r: 0.45, g: 0.85, b: 0.75 }), fillLevel: 4, ingredients: Object.freeze([ Object.freeze({ key: "mint", quantity: 2 }), Object.freeze({ key: "lavender", quantity: 1 }) ]), steps: Object.freeze([ Object.freeze({ kind: AlchemyStepKind.insert, itemKey: "mint" }), Object.freeze({ kind: AlchemyStepKind.heat }), Object.freeze({ kind: AlchemyStepKind.stir }), Object.freeze({ kind: AlchemyStepKind.insert, itemKey: "lavender" }), Object.freeze({ kind: AlchemyStepKind.cool }) ]), effect: Object.freeze({ type: "stamina-regen", amountPerSecond: 1, durationMs: 10_000 }) }), strengthPotion: Object.freeze({ potionKey: "strengthPotion", displayName: "Strength potion", description: "Thick and fiery — lends a brief surge of muscle.", minAlchemyLevel: 1, color: Object.freeze({ r: 0.82, g: 0.32, b: 0.18 }), fillLevel: 4, ingredients: Object.freeze([ Object.freeze({ key: "thyme", quantity: 3 }), Object.freeze({ key: "nettle", quantity: 2 }) ]), steps: Object.freeze([ Object.freeze({ kind: AlchemyStepKind.insert, itemKey: "thyme" }), Object.freeze({ kind: AlchemyStepKind.stir }), Object.freeze({ kind: AlchemyStepKind.insert, itemKey: "nettle" }), Object.freeze({ kind: AlchemyStepKind.heat }) ]), effect: Object.freeze({ type: "strength-bonus", amount: 5, durationMs: 60_000 }) }), clarityPotion: Object.freeze({ potionKey: "clarityPotion", displayName: "Clarity potion", description: "Pale violet draught that clears the thoughts and steadies the will.", minAlchemyLevel: 1, color: Object.freeze({ r: 0.55, g: 0.45, b: 0.92 }), fillLevel: 4, ingredients: Object.freeze([ Object.freeze({ key: "rosemary", quantity: 1 }), Object.freeze({ key: "chamomile", quantity: 2 }) ]), steps: Object.freeze([ Object.freeze({ kind: AlchemyStepKind.insert, itemKey: "rosemary" }), Object.freeze({ kind: AlchemyStepKind.cool }), Object.freeze({ kind: AlchemyStepKind.insert, itemKey: "chamomile" }), Object.freeze({ kind: AlchemyStepKind.stir }) ]), effect: Object.freeze({ type: "mind-bonus", amount: 5, durationMs: 60_000 }) }), animalFat: Object.freeze({ potionKey: "animalFat", displayName: "Bottle of Animal Fat", description: "Rendered fat sealed in glass. Useful for tanning work — foul if drunk.", minAlchemyLevel: 1, color: Object.freeze({ r: 0.92, g: 0.84, b: 0.52 }), fillLevel: 4, ingredients: Object.freeze([ Object.freeze({ key: "uncooked-venison", quantity: 1 }) ]), steps: Object.freeze([ Object.freeze({ kind: AlchemyStepKind.insert, itemKey: "uncooked-venison" }), Object.freeze({ kind: AlchemyStepKind.heat }), Object.freeze({ kind: AlchemyStepKind.stir }), Object.freeze({ kind: AlchemyStepKind.cool }) ]), effect: Object.freeze({ type: "food-poisoning", amountPerSecond: 1, durationMs: 10_000 }) }), tanningBrew: Object.freeze({ potionKey: "tanningBrew", displayName: "Tanning brew", description: "A dark, bark-bitter liquor for curing hides into leather.", minAlchemyLevel: 10, color: Object.freeze({ r: 0.45, g: 0.28, b: 0.14 }), fillLevel: 4, /** Solid craft item — not a drinkable potion bottle. */ outputItemId: LeatherItemId.tanningBrew, outputQuantity: 1, /** Bottling does not consume empty glass bottles (fat bottle is the vessel). */ requiresEmptyBottles: false, ingredients: Object.freeze([ Object.freeze({ key: "oak-bark", quantity: 2 }), Object.freeze({ key: "rock-salt", quantity: 1 }), Object.freeze({ potionKey: "animalFat", quantity: 1 }) ]), steps: Object.freeze([ Object.freeze({ kind: AlchemyStepKind.insert, itemKey: "oak-bark" }), Object.freeze({ kind: AlchemyStepKind.heat }), Object.freeze({ kind: AlchemyStepKind.insert, itemKey: "rock-salt" }), Object.freeze({ kind: AlchemyStepKind.stir }), Object.freeze({ kind: AlchemyStepKind.insert, potionKey: "animalFat" }), Object.freeze({ kind: AlchemyStepKind.cool }) ]), effect: null }), ...buildArrowCoatingPotions() }); /** * Arrow coatings — one per magic element. Each uses a different wood ash + matching essence, * with a distinct brew sequence so they do not collide with each other. */ function buildArrowCoatingPotions () { const coats = {}; const sequences = [ // fire — heat the ash, then fold in essence (ash, essence) => [ { kind: AlchemyStepKind.insert, itemKey: ash }, { kind: AlchemyStepKind.heat }, { kind: AlchemyStepKind.insert, itemKey: essence }, { kind: AlchemyStepKind.stir } ], // water — cool ash slurry, essence last (ash, essence) => [ { kind: AlchemyStepKind.insert, itemKey: ash }, { kind: AlchemyStepKind.cool }, { kind: AlchemyStepKind.stir }, { kind: AlchemyStepKind.insert, itemKey: essence } ], // air — stir ash, heat essence gently (ash, essence) => [ { kind: AlchemyStepKind.insert, itemKey: ash }, { kind: AlchemyStepKind.stir }, { kind: AlchemyStepKind.insert, itemKey: essence }, { kind: AlchemyStepKind.heat } ], // earth — essence first, then ash, heavy heat (ash, essence) => [ { kind: AlchemyStepKind.insert, itemKey: essence }, { kind: AlchemyStepKind.heat }, { kind: AlchemyStepKind.insert, itemKey: ash }, { kind: AlchemyStepKind.stir } ], // light — cool essence, warm ash (ash, essence) => [ { kind: AlchemyStepKind.insert, itemKey: essence }, { kind: AlchemyStepKind.cool }, { kind: AlchemyStepKind.insert, itemKey: ash }, { kind: AlchemyStepKind.heat } ], // dark — ash and essence together under cool stillness (ash, essence) => [ { kind: AlchemyStepKind.insert, itemKey: ash }, { kind: AlchemyStepKind.insert, itemKey: essence }, { kind: AlchemyStepKind.cool }, { kind: AlchemyStepKind.stir } ], // poison — heat essence alone, then ash, cool to set (ash, essence) => [ { kind: AlchemyStepKind.insert, itemKey: essence }, { kind: AlchemyStepKind.heat }, { kind: AlchemyStepKind.stir }, { kind: AlchemyStepKind.insert, itemKey: ash }, { kind: AlchemyStepKind.cool } ] ]; const names = { [MagicElement.fire]: "Fire arrow coating", [MagicElement.water]: "Water arrow coating", [MagicElement.air]: "Air arrow coating", [MagicElement.earth]: "Earth arrow coating", [MagicElement.light]: "Light arrow coating", [MagicElement.dark]: "Dark arrow coating", [MagicElement.poison]: "Poison arrow coating" }; const descriptions = { [MagicElement.fire]: "Viscous slurry for arrowheads, steeped in living flame.", [MagicElement.water]: "Cool, clinging slurry that carries the pull of deep water.", [MagicElement.air]: "Light slurry that hums faintly, ready for wind-touched shafts.", [MagicElement.earth]: "Heavy slurry thick with grit, for grounding an arrow's bite.", [MagicElement.light]: "Bright slurry that catches the eye, meant for radiant tips.", [MagicElement.dark]: "Shadow-thick slurry that swallows the gleam of steel.", [MagicElement.poison]: "Bitter slurry for arrowheads — venom waits in every drop." }; MAGIC_ELEMENT_ORDER.forEach((element, index) => { const wood = ASH_WOOD_FOR_ELEMENT[element]; const ashKey = `${wood}-ash`; const essenceKey = `${element}-essence`; const tint = MAGIC_ELEMENT_TINT[element]; const potionKey = `${element}ArrowCoating`; coats[potionKey] = Object.freeze({ potionKey, displayName: names[element] ?? `${element} arrow coating`, description: descriptions[element] ?? "A viscous coating for arrowheads.", minAlchemyLevel: 5, color: Object.freeze({ r: tint.r, g: tint.g, b: tint.b }), fillLevel: 4, ingredients: Object.freeze([ Object.freeze({ key: ashKey, quantity: 1 }), Object.freeze({ key: essenceKey, quantity: 1 }) ]), steps: Object.freeze(sequences[index](ashKey, essenceKey).map((s) => Object.freeze(s))), effect: Object.freeze({ type: "arrow-coating", element }) }); }); return coats; } /** * Failure (unstable) potions chosen by hashing the step transcript. */ export const UNSTABLE_POTION_EFFECTS = Object.freeze([ Object.freeze({ effectKey: "stamina-drain", displayName: "Unstable draught", color: { r: 0.55, g: 0.2, b: 0.35 }, fillLevel: 3, effect: Object.freeze({ type: "stamina-drain", amountPerSecond: 1, durationMs: 15_000 }) }), Object.freeze({ effectKey: "glow", displayName: "Unstable draught", color: { r: 0.95, g: 0.9, b: 0.45 }, fillLevel: 3, effect: Object.freeze({ type: "glow", lightRadiusTiles: 2, durationMs: 10_000 }) }), Object.freeze({ effectKey: "shrink", displayName: "Unstable draught", color: { r: 0.7, g: 0.55, b: 0.85 }, fillLevel: 2, effect: Object.freeze({ type: "shrink", scale: 0.5, durationMs: 30_000 }) }), Object.freeze({ effectKey: "blind", displayName: "Unstable draught", color: { r: 0.12, g: 0.12, b: 0.16 }, fillLevel: 3, effect: Object.freeze({ type: "blind", durationMs: 20_000 }) }) ]); export function alchemyPotionDefinition (potionKey) { return ALCHEMY_POTION_DEFINITIONS[potionKey] ?? null; } export function listAlchemyPotions () { return Object.values(ALCHEMY_POTION_DEFINITIONS); }