// Data-driven, player-facing craft recipes. // // Ingredient names intentionally match the first column of the craft TSVs. // This keeps cookbook recipes readable while leaving the source tables as the // single source of truth for costs, difficulty, toxicity, and effects. #import "core/macros.typ" as macros #import "theme/variables.typ": theme #import "theme/symbols.typ" as symbols #import "/chapters/craft/forge-data.typ": equipments #let ddlvl = macros.ddlvl #let craft-data(source) = csv(source, delimiter: "\t") #let restoration-main = craft-data("/data/src/craft/restoration_main.tsv") #let restoration-sides = craft-data("/data/src/craft/restoration_sides.tsv") #let restoration-seasonings = craft-data("/data/src/craft/restoration_seasoning.tsv") #let alchemy-solvents = craft-data("/data/src/craft/alchemy_solvants.tsv") #let alchemy-reagents = craft-data("/data/src/craft/alchemy_reagents.tsv") #let alchemy-transmutations = craft-data("/data/src/craft/alchemy_transmutations.tsv") #let forge-materials = craft-data("/data/src/craft/forge_materials.tsv") #let forge-finishings = craft-data("/data/src/craft/forge_finishing.tsv") #let brewery-ferments = craft-data("/data/src/craft/brewry_ferments.tsv") #let brewery-methods = craft-data("/data/src/craft/brewry_methods.tsv") #let brewery-main-effects = craft-data("/data/src/craft/brewry_main_effects.tsv") #let brewery-secondary-effects = craft-data("/data/src/craft/brewry_secondary_effects.tsv") #let brewery-finishings = craft-data("/data/src/craft/brewry_finishing.tsv") #let recipe-catalog = yaml("/data/config/recipes.yaml") #let number(value) = if type(value) == int or type(value) == float { value } else { // Craft TSVs store values as renderable calls such as `#ddlvl(-2)`. // Re-evaluate those calls with numeric stand-ins so recipes can total them. eval( value.replace("#", ""), mode: "code", scope: ( ddlvl: (n, ..args) => n, toxlvl: (n, ..args) => n, winelvl: (n, ..args) => n, timelvl: (n, ..args) => n, ), ) } #let typed-number(value, kind) = if value == "" { 0 } else { eval( value.replace("#", "").replace(regex("\\)\\s+"), ") + "), mode: "code", scope: ( ddlvl: (n, ..args) => if kind == "difficulty" { n } else { 0 }, toxlvl: (n, ..args) => if kind == "toxicity" { n } else { 0 }, winelvl: (n, ..args) => if kind == "wine" { n } else { 0 }, timelvl: (n, ..args) => if kind == "time" { n } else { 0 }, ), ) } #let markup(value) = if type(value) != str { value } else if value == "" { [] } else { eval(value, mode: "markup", scope: macros.bigscope) } #let forge-change-fields = ( damage: ("damage",), physical_damage: ("damage",), elemental_damage: ("damage",), p_damage: ("p_damage",), damage_p: ("p_damage",), rmax: ("rmax",), armor_break: ("armor_break",), armor_pierce: ("armor_pierce",), protection: ("protection",), integrity: ("integrity",), precision: ("precision",), dodge: ("dodge",), parry: ("parry",), dodge_parry: ("dodge", "parry"), speed: ("speed",), stealth: ("stealth",), range: ("range",), torque: ("torque_two_handed", "torque_one_handed"), agility: ("agility_bonus",), force: (), charisma: (), willpower: (), camouflage: (), aerial_speed: (), ) #let explicit-forge-changes(effect) = effect.matches(regex( "#change\\(\"?([a-z_]+)\"?,\\s*\"?([+-][0-9]+)\"?(?:,\\s*of_type:\\s*\\[[^]]+\\])?\\)", )).map(found => ( kind: found.captures.at(0), delta: int(found.captures.at(1)), )) #let forge-drawback-reductions(effect) = effect.matches(regex( "#drawback-reduction\\(\\(([^)]*)\\),\\s*\"?([1-9][0-9]*)\"?\\)", )).map(found => { let amount = int(found.captures.at(1)) found.captures.at(0).matches(regex("\"?([a-z_]+)\"?")).map(kind => ( kind: kind.captures.first(), delta: amount, )) }).flatten() #let forge-bonus-reductions(effect) = effect.matches(regex( "#bonus-reduction\\(\\(([^)]*)\\),\\s*\"?(-?[1-9][0-9]*)\"?\\)", )).map(found => { let amount = calc.abs(int(found.captures.at(1))) found.captures.at(0).matches(regex("\"?([a-z_]+)\"?")).map(kind => ( kind: kind.captures.first(), delta: amount, )) }).flatten() #let forge-changes(effect) = explicit-forge-changes(effect) #let forge-stat-modifiers(effect) = { let result = (:) for change in forge-changes(effect) { let kind = change.kind if kind not in forge-change-fields { panic("Unknown forge change kind `" + kind + "`") } for field in forge-change-fields.at(kind) { result.insert(field, result.at(field, default: 0) + change.delta) } } result } #let forge-alloy-modifiers(effect) = effect.matches(regex( "#alloy-material\\(kind:\\s*\"([a-z_]+)\",\\s*effect:\\s*\"([+x][0-9]+)\"\\)", )).map(found => ( kind: found.captures.at(0), effect: found.captures.at(1), )) #let find-ingredient(data, ingredient, stage) = { let matches = data.slice(1).filter(row => row.first() == ingredient) if matches.len() == 0 { panic("Unknown " + stage + " ingredient: " + ingredient) } matches.first() } #let component( name, stage, tier, cost, difficulty, toxicity, effect, satiety: 0, finishing: 0, detail: none, show-in-effects: true, stat-modifiers: (:), forge-changes: (), drawback-reductions: (), bonus-reductions: (), alloy-modifiers: (), wine: 0, wine-cost: 0, preparation-time: 0, fermentation-time: 0, ) = ( name: name, stage: stage, tier: number(tier), cost: number(cost), difficulty: number(difficulty), toxicity: number(toxicity), satiety: number(satiety), finishing: number(finishing), effect: markup(effect), detail: detail, show-in-effects: show-in-effects, stat-modifiers: stat-modifiers, forge-changes: forge-changes, drawback-reductions: drawback-reductions, bonus-reductions: bonus-reductions, alloy-modifiers: alloy-modifiers, wine: wine, wine-cost: wine-cost, preparation-time: preparation-time, fermentation-time: fermentation-time, ) #let restoration-component(name, stage) = { if stage == "Principal" { let row = find-ingredient(restoration-main, name, stage) component( row.at(0), stage, row.at(2), row.at(3), row.at(4), row.at(5), row.at(7), satiety: row.at(6), detail: row.at(1), ) } else if stage == "Accompagnement" { let row = find-ingredient(restoration-sides, name, stage) component( row.at(0), stage, row.at(1), row.at(2), row.at(3), row.at(4), row.at(6), satiety: row.at(5), ) } else { let row = find-ingredient(restoration-seasonings, name, stage) component( row.at(0), stage, row.at(1), row.at(3), 0, row.at(4), row.at(5), finishing: row.at(2), ) } } #let alchemy-component(name, stage) = { if stage == "Solvant" { let row = find-ingredient(alchemy-solvents, name, stage) component(row.at(0), stage, row.at(1), row.at(2), row.at(3), row.at(4), row.at(5)) } else if stage == "Réagent" { let row = find-ingredient(alchemy-reagents, name, stage) component( row.at(0), stage, row.at(2), row.at(3), row.at(4), row.at(5), row.at(7), detail: [#row.at(1) — #row.at(6)], ) } else { let row = find-ingredient(alchemy-transmutations, name, stage) component( row.at(0), stage, row.at(1), row.at(3), 0, 0, row.at(5), finishing: row.at(2), detail: [Production : #row.at(4)], ) } } #let brewery-ferment-component(name, stage) = { let row = find-ingredient(brewery-ferments, name, stage) let preparation = typed-number(row.at(5), "time") let fermentation = typed-number(row.at(6), "time") component( row.at(0), stage, row.at(1), row.at(2), row.at(4), row.at(3), [Préparation #macros.timelvl(preparation) ; fermentation #macros.timelvl(fermentation).], preparation-time: preparation, fermentation-time: fermentation, ) } #let brewery-method-component(name, stage) = { let row = find-ingredient(brewery-methods, name, stage) let wine = typed-number(row.at(2), "wine") let time = typed-number(row.at(3), "time") component( row.at(0), stage, 0, 0, row.at(1), typed-number(row.at(4), "toxicity"), [Produit #macros.winelvl(wine) en #macros.timelvl(time).], wine: wine, preparation-time: if stage == "Préparation" { time } else { 0 }, fermentation-time: if stage == "Fermentation" { time } else { 0 }, ) } #let brewery-effect-component(name, stage) = { let data = if stage == "Effet principal" { brewery-main-effects } else { brewery-secondary-effects } let row = find-ingredient(data, name, stage) component( row.at(0), stage, row.at(1), 0, 0, typed-number(row.at(3), "toxicity"), row.at(2), wine-cost: typed-number(row.at(3), "wine"), ) } #let brewery-finishing-component(name, stage) = { let row = find-ingredient(brewery-finishings, name, stage) component( row.at(0), stage, row.at(1), row.at(3), 0, row.at(4), row.at(5), finishing: row.at(2), ) } #let find-equipment(shape, nature) = { let matches = equipments.filter(item => ( item.shape_name == shape and (item.nature_name == nature or item.nature_category == nature) )) if matches.len() == 0 { panic("Unknown forge equipment: " + shape + " + " + nature) } matches.first() } #let forge-display-name(item) = { let feminine = item.shape_name in ("Épée", "Hache", "Arbalète", "Armure") let plural = item.shape_name == "Griffes" let adjective = if feminine or plural { ( Light: "légère", Medium: "moyenne", Heavy: "lourde", SuperHeavy: "super-lourde", ).at(item.nature_category) + if plural { "s" } else { "" } } else { ( Light: "léger", Medium: "moyen", Heavy: "lourd", SuperHeavy: "super-lourd", ).at(item.nature_category) } item.shape_name + " " + adjective } #let forge-base-component(item) = component( forge-display-name(item), "Base", item.tier, item.cost, item.difficulty, 0, if item.special.len() == 0 { [] } else { item.special.map(markup).join([, ]) + [.] }, show-in-effects: item.special.len() > 0, ) #let forge-material-component(name, target) = { let row = find-ingredient(forge-materials, name, "Matériau") let effect-index = if target == "Weapons" { 4 } else { 5 } let raw-effect = row.at(effect-index) component( row.at(0), "Matériau", row.at(1), row.at(2), row.at(3), 0, raw-effect, stat-modifiers: forge-stat-modifiers(raw-effect), forge-changes: forge-changes(raw-effect), drawback-reductions: forge-drawback-reductions(raw-effect), bonus-reductions: forge-bonus-reductions(raw-effect), alloy-modifiers: forge-alloy-modifiers(raw-effect), ) } #let forge-finishing-component(name, stage) = { let row = find-ingredient(forge-finishings, name, stage) let raw-effect = row.at(5) component( row.at(0), stage, row.at(2), row.at(4), 0, 0, raw-effect, finishing: row.at(3), stat-modifiers: forge-stat-modifiers(raw-effect), forge-changes: forge-changes(raw-effect), drawback-reductions: forge-drawback-reductions(raw-effect), bonus-reductions: forge-bonus-reductions(raw-effect), ) } #let assemble(craft, stages) = { let components = stages.map(stage => stage.ingredients.map( name => (stage.load)(name, stage.name), )).flatten() if components.len() == 0 { panic("A recipe needs at least one ingredient") } let tier = 0 let cost = 0 let difficulty = 0 let toxicity = 0 let satiety = 0 let finishing = 0 for item in components { tier = calc.max(tier, item.tier) cost += item.cost difficulty += item.difficulty toxicity += item.toxicity satiety += item.satiety finishing += item.finishing } ( craft: craft, stages: stages, components: components, tier: tier, cost: cost, difficulty: difficulty, toxicity: toxicity, satiety: satiety, finishing: finishing, ) } // Build the calculated restoration data without rendering it. #let restoration(main: (), sides: (), seasonings: ()) = assemble( "Restauration", ( (name: "Principal", ingredients: main, load: restoration-component), (name: "Accompagnement", ingredients: sides, load: restoration-component), (name: "Assaisonnement", ingredients: seasonings, load: restoration-component), ), ) // Build the calculated alchemy data without rendering it. #let alchemy(solvents: (), reagents: (), transmutations: ()) = assemble( "Alchimie", ( (name: "Solvant", ingredients: solvents, load: alchemy-component), (name: "Réagent", ingredients: reagents, load: alchemy-component), (name: "Transmutation", ingredients: transmutations, load: alchemy-component), ), ) #let brewery( ferments: (), preparation, fermentation, main-effect, secondary-effects: (), finishings: (), ) = { if ferments.len() == 0 { panic("A brewery recipe needs at least one ferment") } if not preparation.starts-with("Préparation ") { panic("Brewery preparation must name a Préparation method: " + preparation) } if not fermentation.starts-with("Fermentation ") { panic("Brewery fermentation must name a Fermentation method: " + fermentation) } let result = assemble( "Brasserie", ( (name: "Ferment", ingredients: ferments, load: brewery-ferment-component), (name: "Préparation", ingredients: (preparation,), load: brewery-method-component), (name: "Fermentation", ingredients: (fermentation,), load: brewery-method-component), (name: "Effet principal", ingredients: (main-effect,), load: brewery-effect-component), (name: "Effet secondaire", ingredients: secondary-effects, load: brewery-effect-component), (name: "Finition", ingredients: finishings, load: brewery-finishing-component), ), ) let wine = result.components.map(item => item.wine).sum() let wine-cost = result.components.map(item => item.wine-cost).sum() if wine-cost > wine { panic("Brewery recipe overspends its titrage (" + str(wine-cost) + " used, " + str(wine) + " available)") } result.insert("wine", wine) result.insert("wine-cost", wine-cost) result.insert("preparation-time", result.components.map(item => item.preparation-time).sum()) result.insert("fermentation-time", result.components.map(item => item.fermentation-time).sum()) result } #let forge-stat-fields = ( "damage", "p_damage", "rmax", "armor_break", "armor_pierce", "antimaterial", "protection", "integrity", "dodge", "parry", "speed", "stealth", "precision", "agility_bonus", "range", "action_cost", "torque_two_handed", "torque_one_handed", "reload_cost", ) #let forge-alloy-field(kind) = if kind.ends-with("damage") { "damage" } else { kind } #let forge-alloy-matches(alloy-kind, change-kind) = ( alloy-kind == change-kind or (alloy-kind == "damage" and change-kind.ends-with("damage")) ) // Forge bases come from weapons.db; materials and finishings remain CSV-backed. #let forge(shape, nature, materials: (), finishings: ()) = { let equipment = find-equipment(shape, nature) let result = assemble( "Forge", ( ( name: "Base", ingredients: (forge-display-name(equipment),), load: (..args) => forge-base-component(equipment), ), ( name: "Matériau", ingredients: materials, load: (name, ..args) => forge-material-component(name, equipment.apply_category), ), ( name: "Finition", ingredients: finishings, load: forge-finishing-component, ), ), ) let stats = (:) for field in forge-stat-fields { stats.insert(field, equipment.at(field, default: none)) } for item in result.components { for (field, delta) in item.stat-modifiers { let current = stats.at(field, default: none) if current != none and current != "null" { stats.insert(field, current + delta) } } for reduction in item.drawback-reductions { for field in forge-change-fields.at(reduction.kind) { let current = stats.at(field, default: none) if current != none and current != "null" and current < 0 { stats.insert(field, current + calc.min(reduction.delta, -current)) } } } for reduction in item.bonus-reductions { for field in forge-change-fields.at(reduction.kind) { let current = stats.at(field, default: none) if current != none and current != "null" and current > 0 { stats.insert(field, current - calc.min(reduction.delta, current)) } } } } // Alloy macros amplify matching positive changes declared by materials. for source in result.components.filter(item => item.stage == "Matériau") { for alloy in source.alloy-modifiers { if alloy.kind == "protection" or alloy.kind.ends-with("damage") { let field = forge-alloy-field(alloy.kind) for target in result.components.filter(item => item.stage == "Matériau") { for change in target.forge-changes.filter(change => ( change.delta > 0 and forge-alloy-matches(alloy.kind, change.kind) )) { let bonus = if alloy.effect.starts-with("x") { change.delta * (int(alloy.effect.slice(1)) - 1) } else { int(alloy.effect.slice(1)) } stats.insert(field, stats.at(field) + bonus) } } } } } result.insert("equipment", equipment) result.insert("stats", stats) result } #let metric(label, value) = block( width: 100%, inset: (x: 3.5pt, y: 3pt), fill: theme.parchment-light, stroke: 0.4pt + theme.border, radius: 2pt, )[ #text(size: 6.2pt, fill: theme.muted)[#label]\ #text(size: 7.8pt, weight: "bold")[#value] ] #let forge-stat-labels = ( ("damage", "Dég."), ("p_damage", "+/réuss."), ("rmax", [@rl_rmax:short]), ("armor_break", [@rl_arbreak:short]), ("armor_pierce", "Perce"), ("antimaterial", "Anti-mat."), ("protection", [@rl_protection:short]), ("integrity", [@rl_integrity:short]), ("dodge", "Esq."), ("parry", "Par."), ("speed", "Vit."), ("stealth", "Disc."), ("precision", [@rl_precision:short]), ("agility_bonus", "Agi."), ("range", "Portée"), ("action_cost", "A"), ("torque_two_handed", [@ca_torque:short 2]), ("torque_one_handed", [@ca_torque:short 1]), ("reload_cost", [@rl_reload:short]), ) #let shown-stat(value) = if value == none or value == "null" { [—] } else { value } #let signed-stat(value) = if value > 0 { "+" + str(value) } else { str(value) } #let forge-stat-header(body) = { show box: it => symbols.try-re-colorize(it, theme.muted) text(size: 5.5pt, weight: "semibold", fill: theme.muted, body) } #let forge-stat-summary(stats, delta: false) = { let visible = forge-stat-labels.filter(pair => { let value = stats.at(pair.at(0), default: none) value != none and value != "null" and value != 0 }) if visible.len() == 0 { [—] } else { for (index, pair) in visible.enumerate() { let value = stats.at(pair.at(0)) if index > 0 { h(0.55em) } text(size: 5.7pt, fill: theme.muted)[#pair.at(1)] h(0.2em) text(size: 6.7pt, weight: "bold")[ #if delta and type(value) != str { signed-stat(value) } else { value } ] } } } #let forge-stat-line(ingredients) = { let base = (:) for field in forge-stat-fields { base.insert(field, ingredients.equipment.at(field, default: none)) } let material-items = ingredients.components.filter(item => item.stage == "Matériau") let row-state = base let material-rows = () for item in material-items { let modifiers = item.stat-modifiers for (field, delta) in item.stat-modifiers { let current = row-state.at(field, default: none) if current != none and current != "null" { row-state.insert(field, current + delta) } } for reduction in item.drawback-reductions { for field in forge-change-fields.at(reduction.kind) { let current = row-state.at(field, default: none) if current != none and current != "null" and current < 0 { let applied = calc.min(reduction.delta, -current) modifiers.insert(field, modifiers.at(field, default: 0) + applied) row-state.insert(field, current + applied) } } } for reduction in item.bonus-reductions { for field in forge-change-fields.at(reduction.kind) { let current = row-state.at(field, default: none) if current != none and current != "null" and current > 0 { let applied = calc.min(reduction.delta, current) modifiers.insert(field, modifiers.at(field, default: 0) - applied) row-state.insert(field, current - applied) } } } // Attribute alloy amplification to the alloy's own row. for alloy in item.alloy-modifiers { if alloy.kind == "protection" or alloy.kind.ends-with("damage") { let field = forge-alloy-field(alloy.kind) for target in material-items { for change in target.forge-changes.filter(change => ( change.delta > 0 and forge-alloy-matches(alloy.kind, change.kind) )) { let bonus = if alloy.effect.starts-with("x") { change.delta * (int(alloy.effect.slice(1)) - 1) } else { int(alloy.effect.slice(1)) } modifiers.insert(field, modifiers.at(field, default: 0) + bonus) } } } } material-rows.push((name: item.name, stats: modifiers, delta: true)) } let finishing-rows = () for item in ingredients.components.filter(item => item.stage == "Finition") { let modifiers = item.stat-modifiers for (field, delta) in item.stat-modifiers { let current = row-state.at(field, default: none) if current != none and current != "null" { row-state.insert(field, current + delta) } } for reduction in item.drawback-reductions { for field in forge-change-fields.at(reduction.kind) { let current = row-state.at(field, default: none) if current != none and current != "null" and current < 0 { let applied = calc.min(reduction.delta, -current) modifiers.insert(field, modifiers.at(field, default: 0) + applied) row-state.insert(field, current + applied) } } } for reduction in item.bonus-reductions { for field in forge-change-fields.at(reduction.kind) { let current = row-state.at(field, default: none) if current != none and current != "null" and current > 0 { let applied = calc.min(reduction.delta, current) modifiers.insert(field, modifiers.at(field, default: 0) - applied) row-state.insert(field, current - applied) } } } if modifiers.values().any(value => value != 0) { finishing-rows.push((name: item.name, stats: modifiers, delta: true)) } } let rows = ( (name: "Base", stats: base, delta: false), ..material-rows, ..finishing-rows, (name: "Final", stats: ingredients.stats, delta: false), ) let damage-visible = rows.any(row => ( row.stats.at("damage", default: 0) != 0 or row.stats.at("p_damage", default: 0) != 0 )) let visible-fields = forge-stat-labels.filter(pair => { let field = pair.at(0) if field == "damage" or field == "p_damage" { damage-visible } else if field == "action_cost" { rows.any(row => { let value = row.stats.at(field, default: none) value != none and value != "null" and value > 1 }) } else { rows.any(row => { let value = row.stats.at(pair.at(0), default: none) value != none and value != "null" and value != 0 }) } }) let shown-cell(value, field, delta: false) = if ( field == "damage" or field == "p_damage" ) { let numeric = if value == none or value == "null" { 0 } else { value } let shown = if delta or field == "p_damage" { signed-stat(numeric) } else { str(numeric) } if field == "damage" { shown + "/" } else { shown } } else if ( value == none or value == "null" or value == 0 ) { [] } else if delta and type(value) != str { signed-stat(value) } else if ( field in ("parry", "dodge", "integrity", "speed", "stealth", "precision") and type(value) != str and value > 0 ) { "+" + str(value) } else { value } let paired-stat(value, delta: false) = { let numeric = if value == none or value == "null" { 0 } else { value } if numeric >= 0 { "+" + str(numeric) } else { str(numeric) } } let row-cells(row) = { let is-final = row.name == "Final" let row-fill = if is-final { theme.ink } else { theme.ink.transparentize(28%) } let row-weight = if is-final { "bold" } else { "regular" } let cells = ( text( size: 6.1pt, weight: if is-final { "bold" } else { "semibold" }, fill: if is-final { theme.heading } else { theme.dark-gold.transparentize(30%) }, )[#row.name], ) for pair in visible-fields { let field = pair.at(0) if field == "damage" { let damage = row.stats.at("damage", default: 0) let per-success = row.stats.at("p_damage", default: 0) if row.delta and damage == 0 and per-success == 0 { cells.push(table.cell(colspan: 2)[]) } else { let left = if row.delta { paired-stat(damage, delta: true) } else { str(damage) } cells.push(table.cell(colspan: 2, align: right + horizon)[ #text(size: 6.1pt, weight: row-weight, fill: row-fill)[#left/#paired-stat(per-success)] ]) } } else if field != "p_damage" { cells.push(text(size: 6.1pt, weight: row-weight, fill: row-fill)[ #shown-cell( row.stats.at(field, default: none), field, delta: row.delta, ) ]) } } cells } let header-cells = () for pair in visible-fields { let field = pair.at(0) if field == "damage" { header-cells.push(table.cell(colspan: 2, align: center)[ #forge-stat-header([Dég.]) ]) } else if field != "p_damage" { header-cells.push(forge-stat-header(pair.at(1))) } } align(center)[ #box( inset: (x: 4pt, y: 3.5pt), fill: theme.parchment-dark, stroke: 0.45pt + theme.border, radius: 3pt, )[ #table( columns: (auto,) + visible-fields.map(_ => auto), align: (left + horizon,) + visible-fields.map(_ => right + horizon), column-gutter: 3pt, stroke: none, fill: none, inset: (x: 2pt, y: 1.5pt), table.header( [ ], ..header-cells, ), ..rows.map(row-cells).flatten(), ) ] ] } #let ingredient-name(item) = text( size: 6.6pt, weight: "semibold", fill: theme.heading.transparentize(20%), )[ #item.name ] #let ingredient-effect(item) = text(size: 6.4pt)[ #if item.detail != none { text(size: 5.7pt, fill: theme.muted.transparentize(15%))[(#item.detail)] h(0.35em) } #item.effect ] #let step-pill(step) = box( inset: (x: 3pt, y: 1pt), fill: theme.parchment-light.transparentize(28%), stroke: 0.25pt + theme.border.transparentize(60%), radius: 7pt, )[ #text(size: 5.5pt, fill: theme.muted)[#step] ] // Render any calculated craft data as a complete cookbook card. #let render-recipe(name, ingredients, flavor: none) = { let craft = ingredients.craft let metrics = if craft == "Forge" { ( ([Maîtrise], ingredients.tier), ([Coût], ddlvl(ingredients.cost)), ([Difficulté], ddlvl(ingredients.difficulty)), ([Finition], if ingredients.finishing == 0 { [—] } else { ddlvl(ingredients.finishing) }), ) } else if craft == "Brasserie" { ( ([Maîtrise], ingredients.tier), ([Coût], ddlvl(ingredients.cost)), ([Difficulté], ddlvl(ingredients.difficulty)), ([Toxicité], macros.toxlvl(ingredients.toxicity)), ([Titrage], [#macros.winelvl(ingredients.wine-cost) / #macros.winelvl(ingredients.wine)]), ([Arrangement], if ingredients.finishing == 0 { [—] } else { ddlvl(ingredients.finishing) }), ) } else { ( ([Maîtrise], ingredients.tier), ([Coût], ddlvl(ingredients.cost)), ([Difficulté], ddlvl(ingredients.difficulty)), ([Toxicité], ddlvl(ingredients.toxicity)), ([Satiété], if ingredients.satiety == 0 { [—] } else { ddlvl(ingredients.satiety) }), ([Finition], if ingredients.finishing == 0 { [—] } else { ddlvl(ingredients.finishing) }), ) } block( width: 100%, breakable: false, above: 6pt, below: 6pt, fill: theme.parchment, stroke: 0.75pt + theme.gold, inset: 8.5pt, radius: 4pt, )[ #text(size: 6.2pt, weight: "bold", tracking: 0.08em, fill: theme.dark-gold)[#craft] #h(0.65em) #text(size: 12.5pt, weight: "bold", fill: theme.heading)[#name] #if flavor != none { linebreak() v(2.5pt) text(size: 7.6pt, style: "italic", fill: theme.muted)[#flavor] } #v(5pt) #grid( columns: metrics.len(), gutter: 3pt, ..metrics.map(pair => metric(pair.at(0), pair.at(1))), ) #if craft == "Forge" { v(4pt) forge-stat-line(ingredients) } else if craft == "Brasserie" { v(3pt) align(center)[ #text(size: 6.4pt, fill: theme.muted)[ Préparation : #macros.timelvl(ingredients.preparation-time) jours #h(1.2em) Fermentation : #macros.timelvl(ingredients.fermentation-time) semaines ] ] } #v(5pt) #text(size: 6.6pt, weight: "bold", fill: theme.dark-gold)[Ingrédients et effets] #v(-1pt) #pad(left: 6pt)[ #table( columns: (auto, auto, 1fr), align: (left + horizon, left + horizon, left + horizon), column-gutter: 3pt, stroke: none, inset: (x: 1pt, y: 1.5pt), ..ingredients.components.filter(item => item.show-in-effects).map(item => ( ingredient-name(item), step-pill(item.stage), ingredient-effect(item), )).flatten(), ) ] ] } #let restoration-recipe( name, flavor: none, main: (), sides: (), seasonings: (), ) = render-recipe( name, restoration( main: main, sides: sides, seasonings: seasonings, ), flavor: flavor, ) #let alchemy-recipe( name, flavor: none, solvents: (), reagents: (), transmutations: (), ) = render-recipe( name, alchemy( solvents: solvents, reagents: reagents, transmutations: transmutations, ), flavor: flavor, ) #let forge-recipe( name, shape, nature, flavor: none, materials: (), finishings: (), ) = render-recipe( name, forge( shape, nature, materials: materials, finishings: finishings, ), flavor: flavor, ) #let brewery-recipe( name, preparation, fermentation, main-effect, flavor: none, ferments: (), secondary-effects: (), finishings: (), ) = render-recipe( name, brewery( preparation, fermentation, main-effect, ferments: ferments, secondary-effects: secondary-effects, finishings: finishings, ), flavor: flavor, ) // Render a catalog entry from data/config/recipes.yaml. This is the public // authoring API used by books and chapters: `#recipe("restoration", "name")`. #let recipe(module, recipe-name) = { if module not in recipe-catalog { panic("Unknown recipe module: " + module) } let recipes = recipe-catalog.at(module) if recipe-name not in recipes { panic("Unknown recipe in " + module + ": " + recipe-name) } let entry = recipes.at(recipe-name) let flavor = entry.at("flavor", default: none) if module == "restoration" { restoration-recipe( entry.name, flavor: flavor, main: entry.at("main", default: ()), sides: entry.at("sides", default: ()), seasonings: entry.at("seasonings", default: ()), ) } else if module == "alchemy" { alchemy-recipe( entry.name, flavor: flavor, solvents: entry.at("solvents", default: ()), reagents: entry.at("reagents", default: ()), transmutations: entry.at("transmutations", default: ()), ) } else if module == "forge" { let base = entry.at("base") forge-recipe( entry.name, base.shape, base.nature, flavor: flavor, materials: entry.at("materials", default: ()), finishings: entry.at("finishings", default: ()), ) } else if module == "brewery" { brewery-recipe( entry.name, entry.at("preparation"), entry.at("fermentation"), entry.at("main-effect"), flavor: flavor, ferments: entry.at("ferments", default: ()), secondary-effects: entry.at("secondary-effects", default: ()), finishings: entry.at("finishings", default: ()), ) } else { panic("Recipe module has no constructor: " + module) } }