/** Cauldron action / step kinds (authoritative recipe language). */ import { MagicElement, MAGIC_ELEMENT_ORDER, MAGIC_ELEMENT_TINT, ASH_WOOD_FOR_ELEMENT } from "./attackTypes.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", 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", 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", 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", 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 }) }), ...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" }; 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`, 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); }