848 lines
25 KiB
Plaintext
848 lines
25 KiB
Plaintext
// Data-driven, player-facing craft recipes.
|
|
//
|
|
// Ingredient names intentionally match the first column of the craft CSVs.
|
|
// 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 restoration-main = csv("/data/src/craft/restoration_main.csv")
|
|
#let restoration-sides = csv("/data/src/craft/restoration_sides.csv")
|
|
#let restoration-seasonings = csv("/data/src/craft/restoration_seasoning.csv")
|
|
#let alchemy-solvents = csv("/data/src/craft/alchemy_solvants.csv")
|
|
#let alchemy-reagents = csv("/data/src/craft/alchemy_reagents.csv")
|
|
#let alchemy-transmutations = csv("/data/src/craft/alchemy_transmutations.csv")
|
|
#let forge-materials = csv("/data/src/craft/forge_materials.csv")
|
|
#let forge-finishings = csv("/data/src/craft/forge_finishing.csv")
|
|
#let brewery-ferments = csv("/data/src/craft/brewry_ferments.csv")
|
|
#let brewery-methods = csv("/data/src/craft/brewry_methods.csv")
|
|
#let brewery-main-effects = csv("/data/src/craft/brewry_main_effects.csv")
|
|
#let brewery-secondary-effects = csv("/data/src/craft/brewry_secondary_effects.csv")
|
|
#let brewery-finishings = csv("/data/src/craft/brewry_finishing.csv")
|
|
#let recipe-catalog = yaml("/data/config/recipes.yaml")
|
|
#let forge-modifiers = yaml("/data/config/forge_modifiers.yaml")
|
|
|
|
#let number(value) = if type(value) == int or type(value) == float {
|
|
value
|
|
} else {
|
|
// Craft CSVs 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 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,
|
|
stat-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,
|
|
stat-modifiers: stat-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,
|
|
[Dégâts #item.damage, dégâts par réussite #item.p_damage, réussites max #item.rmax, brise-armure #item.armor_break, protection #item.protection, intégrité #item.integrity.],
|
|
)
|
|
|
|
#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 target-name = if target == "Weapons" { "weapon" } else { "armor" }
|
|
let modifiers = forge-modifiers.materials.at(name, default: (:)).at(
|
|
target-name,
|
|
default: (:),
|
|
)
|
|
component(
|
|
row.at(0),
|
|
"Matériau",
|
|
row.at(1),
|
|
row.at(2),
|
|
row.at(3),
|
|
0,
|
|
row.at(effect-index),
|
|
stat-modifiers: modifiers,
|
|
)
|
|
}
|
|
|
|
#let forge-finishing-component(name, stage) = {
|
|
let row = find-ingredient(forge-finishings, name, stage)
|
|
let modifiers = forge-modifiers.finishings.at(name, default: (:))
|
|
component(
|
|
row.at(0),
|
|
stage,
|
|
row.at(2),
|
|
row.at(4),
|
|
0,
|
|
0,
|
|
row.at(5),
|
|
finishing: row.at(3),
|
|
stat-modifiers: modifiers,
|
|
)
|
|
}
|
|
|
|
#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",
|
|
)
|
|
|
|
// 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)
|
|
}
|
|
}
|
|
}
|
|
// Fer improves each material effect which already increases weapon damage.
|
|
if equipment.apply_category == "Weapons" and "Fer" in materials {
|
|
let boosted-materials = result.components.filter(item => (
|
|
item.stage == "Matériau"
|
|
and item.stat-modifiers.at("damage", default: 0) > 0
|
|
)).len()
|
|
stats.insert("damage", stats.damage + boosted-materials)
|
|
}
|
|
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_integrite: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 material-rows = ()
|
|
for item in material-items {
|
|
let modifiers = item.stat-modifiers
|
|
// Fer amplifies every material which directly increases weapon damage.
|
|
if item.name == "Fer" and material-items.any(other => (
|
|
other.name != "Fer" and other.stat-modifiers.at("damage", default: 0) > 0
|
|
)) {
|
|
modifiers.insert("damage", modifiers.at("damage", default: 0) + 1)
|
|
}
|
|
material-rows.push((name: item.name, stats: modifiers, delta: true))
|
|
}
|
|
|
|
let rows = (
|
|
(name: "Base", stats: base, delta: false),
|
|
..material-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)
|
|
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.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)
|
|
}
|
|
}
|