import { spriteImageName } from "./tileSprites.js"; import { ItemCategory } from "./itemCategories.js"; /** * Folklore herb catalog for Herbalism nodes + alchemy ingredients. * Fantasy associations live in docs/FEATURES.md (not code) for later potion design. * * Tier spread (24 herbs): 2 / 3 / 3 / 4 / 4 / 4 / 4 for tiers 1–7. */ export const HerbId = Object.freeze({ mint: "mint", garlic: "garlic", thyme: "thyme", sage: "sage", rosemary: "rosemary", lavender: "lavender", chamomile: "chamomile", nettle: "nettle", yarrow: "yarrow", juniper: "juniper", elder: "elder", rue: "rue", valerian: "valerian", mugwort: "mugwort", wormwood: "wormwood", stJohnsWort: "st-johns-wort", hawthorn: "hawthorn", foxglove: "foxglove", mistletoe: "mistletoe", datura: "datura", belladonna: "belladonna", henbane: "henbane", mandrake: "mandrake", aconite: "aconite" }); /** Numeric item IDs (160–183). Keys are camelCase for `ItemId` spread. */ export const HerbItemId = Object.freeze({ mint: 160, garlic: 161, thyme: 162, sage: 163, rosemary: 164, lavender: 165, chamomile: 166, nettle: 167, yarrow: 168, juniper: 169, elder: 170, rue: 171, valerian: 172, mugwort: 173, wormwood: 174, stJohnsWort: 175, hawthorn: 176, foxglove: 177, mistletoe: 178, datura: 179, belladonna: 180, henbane: 181, mandrake: 182, aconite: 183 }); /** Map herbId string → ItemId number. */ const HERB_ITEM_ID_BY_KEY = Object.freeze({ [HerbId.mint]: HerbItemId.mint, [HerbId.garlic]: HerbItemId.garlic, [HerbId.thyme]: HerbItemId.thyme, [HerbId.sage]: HerbItemId.sage, [HerbId.rosemary]: HerbItemId.rosemary, [HerbId.lavender]: HerbItemId.lavender, [HerbId.chamomile]: HerbItemId.chamomile, [HerbId.nettle]: HerbItemId.nettle, [HerbId.yarrow]: HerbItemId.yarrow, [HerbId.juniper]: HerbItemId.juniper, [HerbId.elder]: HerbItemId.elder, [HerbId.rue]: HerbItemId.rue, [HerbId.valerian]: HerbItemId.valerian, [HerbId.mugwort]: HerbItemId.mugwort, [HerbId.wormwood]: HerbItemId.wormwood, [HerbId.stJohnsWort]: HerbItemId.stJohnsWort, [HerbId.hawthorn]: HerbItemId.hawthorn, [HerbId.foxglove]: HerbItemId.foxglove, [HerbId.mistletoe]: HerbItemId.mistletoe, [HerbId.datura]: HerbItemId.datura, [HerbId.belladonna]: HerbItemId.belladonna, [HerbId.henbane]: HerbItemId.henbane, [HerbId.mandrake]: HerbItemId.mandrake, [HerbId.aconite]: HerbItemId.aconite }); /** * Gather skill gates by herb tier (aligned with mining: ceil(equipGate/2)). * Tier 1→1, 2→5, 3→10, 4→18, 5→25, 6→35, 7→45. */ export const HERB_GATHER_SKILL_LEVEL = Object.freeze({ 1: 1, 2: 5, 3: 10, 4: 18, 5: 25, 6: 35, 7: 45 }); const DEFAULT_STACK = 99; function herb ( herbId, tier, displayName, description, { seedValue = 2 } = {} ) { const itemId = HERB_ITEM_ID_BY_KEY[herbId]; return Object.freeze({ herbId, itemId, key: herbId, tier, displayName, description, seedValue, stackable: true, maxStackSize: DEFAULT_STACK, uniqueInstance: false, category: ItemCategory.ingredient, herb: true, /** Shared folder `assets/herbs/.png` — catalog registers block + item. */ iconKey: "herbs", defaultState: herbId, sprite: spriteImageName("item", "herbs", herbId) }); } export const HERB_DEFINITIONS = Object.freeze({ // Tier 1 — kitchen & common garden [HerbId.mint]: herb( HerbId.mint, 1, "Mint", "Cool green leaves that freshen the breath and settle a heavy stomach." ), [HerbId.garlic]: herb( HerbId.garlic, 1, "Garlic", "Pungent bulbs prized in kitchens and hung in doorways against unwelcome guests." ), // Tier 2 — household remedies [HerbId.thyme]: herb( HerbId.thyme, 2, "Thyme", "A hardy herb of the hills, used to clear the chest and steel the nerves." ), [HerbId.sage]: herb( HerbId.sage, 2, "Sage", "Silvery leaves long trusted as a general cure and a mark of a clear mind." ), [HerbId.rosemary]: herb( HerbId.rosemary, 2, "Rosemary", "Needle-leafed sprigs that sharpen memory and are said to ward off ill spirits." ), // Tier 3 — calming & common wild [HerbId.lavender]: herb( HerbId.lavender, 3, "Lavender", "Fragrant purple spikes laid under pillows and pressed into wound wraps." ), [HerbId.chamomile]: herb( HerbId.chamomile, 3, "Chamomile", "Daisy-like blooms brewed for restless bellies and quiet evenings." ), [HerbId.nettle]: herb( HerbId.nettle, 3, "Nettle", "Stinging greens that nourish when cooked and toughen those who handle them." ), // Tier 4 — battle & boundary herbs [HerbId.yarrow]: herb( HerbId.yarrow, 4, "Yarrow", "Feathery battlefield herb bound into bandages to stop a soldier's bleeding." ), [HerbId.juniper]: herb( HerbId.juniper, 4, "Juniper", "Dark berries whose smoke is burned to purify rooms and drive out sickness." ), [HerbId.elder]: herb( HerbId.elder, 4, "Elder", "Blossom and berry of a tree whispered to house spirits of its own." ), [HerbId.rue]: herb( HerbId.rue, 4, "Rue", "Bitter leaves carried against curses and the stare of the evil eye." ), // Tier 5 — dream & bitter medicine [HerbId.valerian]: herb( HerbId.valerian, 5, "Valerian", "Earthy roots that pull the weary towards deep, untroubled sleep." ), [HerbId.mugwort]: herb( HerbId.mugwort, 5, "Mugwort", "Roadside herb of dreamers, travellers, and those who seek visions." ), [HerbId.wormwood]: herb( HerbId.wormwood, 5, "Wormwood", "A bitter grey-green plant used against parasites and haunted moods." ), [HerbId.stJohnsWort]: herb( HerbId.stJohnsWort, 5, "St. John's wort", "Sunny yellow blooms carried as a charm against demons and dark hours." ), // Tier 6 — fey & perilous [HerbId.hawthorn]: herb( HerbId.hawthorn, 6, "Hawthorn", "Thorny blossom of sacred hedges and places best left undisturbed." ), [HerbId.foxglove]: herb( HerbId.foxglove, 6, "Foxglove", "Tall bells said to be fairy gloves — beautiful, and deadly if mishandled." ), [HerbId.mistletoe]: herb( HerbId.mistletoe, 6, "Mistletoe", "Pale berries of the oak-parasite, gathered for rites of life and fertility." ), [HerbId.datura]: herb( HerbId.datura, 6, "Datura", "Trumpet flowers that open the mind to visions — and to madness." ), // Tier 7 — witches' garden [HerbId.belladonna]: herb( HerbId.belladonna, 7, "Belladonna", "Glossy black berries of the nightshade, linked to witch-flight and poison." ), [HerbId.henbane]: herb( HerbId.henbane, 7, "Henbane", "Sickly nightshade that dulls the senses and invites strange trances." ), [HerbId.mandrake]: herb( HerbId.mandrake, 7, "Mandrake", "A man-shaped root said to scream when torn from the earth." ), [HerbId.aconite]: herb( HerbId.aconite, 7, "Aconite", "Monkshood — also called wolfsbane — a lethal flower of curses and beasts." ) }); export const HERB_ORDER = Object.freeze(Object.keys(HERB_DEFINITIONS)); export function herbDefinition (herbId) { return HERB_DEFINITIONS[herbId] ?? null; } export function herbDefinitionByItemId (itemId) { const id = itemId | 0; for (const def of Object.values(HERB_DEFINITIONS)) { if (def.itemId === id) { return def; } } return null; } export function isHerbId (value) { return !!HERB_DEFINITIONS[value]; } export function herbGatherSkillLevel (tier) { return HERB_GATHER_SKILL_LEVEL[tier | 0] ?? HERB_GATHER_SKILL_LEVEL[1]; } export function herbBlockState (herbId) { return isHerbId(herbId) ? herbId : HerbId.mint; } /** Item definition stubs merged into ITEM_DEFINITIONS. */ export const HERB_ITEM_DEFINITIONS = Object.freeze( Object.fromEntries( Object.values(HERB_DEFINITIONS).map((def) => [def.itemId, def]) ) );