340 lines
12 KiB
Plaintext
340 lines
12 KiB
Plaintext
// Data-driven master-handbook creature sheet.
|
|
//
|
|
// The renderer deliberately accepts plain Typst dictionaries. This keeps the
|
|
// presentation independent from the database/export format that will replace
|
|
// the mock record later.
|
|
|
|
#import "../theme/variables.typ": theme
|
|
#import "../core/macros.typ" as macros
|
|
#import "../generation/glossary.typ": glossary
|
|
#import "@preview/glossarium:0.5.10": gls
|
|
|
|
#let label-fill = (
|
|
ATK: rgb("#c95f5f"), MVT: rgb("#658db5"), DEF: rgb("#73a16f"),
|
|
PAS: rgb("#a9c89c"), REV: rgb("#73a16f"), CLM: rgb("#496b4a"),
|
|
TRA: rgb("#d79555"), ASE: rgb("#c95f5f"), STA: rgb("#f7f5ef"),
|
|
CMB: rgb("#c95f5f"), FLR: rgb("#c95f5f"), GRB: rgb("#c95f5f"),
|
|
MXU: rgb("#c95f5f"), ADF: rgb("#c95f5f"), BYP: rgb("#873b3b"),
|
|
TBU: rgb("#873b3b"), TBZ: rgb("#873b3b"), TSH: rgb("#873b3b"),
|
|
CLV: rgb("#c95f5f"), AOE: rgb("#c95f5f"), WID: rgb("#c95f5f"),
|
|
WIP: rgb("#873b3b"), SZO: rgb("#f7f5ef"), SIT: rgb("#f7f5ef"),
|
|
SRG: rgb("#8d6799"), HRG: rgb("#8d6799"), BAD: rgb("#d79555"),
|
|
BIS: rgb("#873b3b"),
|
|
)
|
|
|
|
#let present(value) = value != none and value != "" and value != ()
|
|
#let cell(value, size: none) = if size == none { [#value] } else { text(size: size, value) }
|
|
#let threshold(value) = [
|
|
$#value.base$
|
|
#text(weight: "light", size: 0.6em)[$(#value.modifier)$]
|
|
]
|
|
#let protection(value) = $#value.base [#value.armor]$
|
|
#let small-value(value) = text(weight: "light", size: 0.6em, $#value$)
|
|
#let resistance(value) = {
|
|
if value == "++" { $++$ }
|
|
else if value == "+" { $+$ }
|
|
else if value == "--" { $--$ }
|
|
else if value == "-" { $-$ }
|
|
else { $ $ }
|
|
}
|
|
#let element-icon(path, height: 0.75em, baseline: 1.1pt) = box(
|
|
height: height,
|
|
baseline: baseline,
|
|
inset: 0pt,
|
|
image(path),
|
|
)
|
|
|
|
#let rich-text(value) = {
|
|
if type(value) == str {
|
|
let entries = (:)
|
|
for entry in glossary { entries.insert(entry.key, entry) }
|
|
let db-gls(key, short: false) = {
|
|
let entry = entries.at(key, default: none)
|
|
if entry == none {
|
|
"@" + key
|
|
} else if short {
|
|
gls(key, display: entry.short, link: false)
|
|
} else {
|
|
gls(key, link: false)
|
|
}
|
|
}
|
|
let references-to-calls(source) = {
|
|
let found = source.match(regex("@([A-Za-z][A-Za-z0-9_]*)(:short)?"))
|
|
if found == none { return source }
|
|
let key = found.captures.first()
|
|
let short = found.captures.at(1, default: none) != none
|
|
(
|
|
source.slice(0, found.start)
|
|
+ "#db-gls(\""
|
|
+ key
|
|
+ "\""
|
|
+ (if short { ", short: true)" } else { ")" })
|
|
+ references-to-calls(source.slice(found.end))
|
|
)
|
|
}
|
|
let markup = references-to-calls(value)
|
|
eval(
|
|
markup,
|
|
mode: "markup",
|
|
scope: macros.bigscope + (db-gls: db-gls),
|
|
)
|
|
} else {
|
|
value
|
|
}
|
|
}
|
|
#let section-title(title) = block(
|
|
width: 100%,
|
|
inset: (x: 5pt, y: 3pt),
|
|
fill: theme.dark-gold,
|
|
text(fill: theme.parchment-light, weight: "bold", title),
|
|
)
|
|
|
|
#let identity-table(creature) = {
|
|
let fields = (
|
|
("Nom", creature.name),
|
|
("Dénomination", creature.denomination),
|
|
("Calamité", creature.calamity),
|
|
("Niveau de danger (HSE)", creature.danger-level),
|
|
("Habitat", creature.habitat),
|
|
("Dysmorphisme", creature.dysmorphism),
|
|
("Couleurs", creature.colors),
|
|
("Réaction à l'homme", creature.human-reaction),
|
|
("Variantes", creature.variants),
|
|
("Taille", creature.size),
|
|
("Traces", creature.traces),
|
|
("Mœurs", creature.habits),
|
|
).filter(pair => present(pair.at(1)))
|
|
let rows = fields.map(pair => (
|
|
table.cell(align: left, text(weight: "bold", pair.at(0))),
|
|
table.cell(align: left, rich-text(pair.at(1))),
|
|
)).flatten()
|
|
|
|
table(
|
|
columns: 2,
|
|
column-gutter: 10pt,
|
|
inset: (x: 0pt, y: 2.5pt),
|
|
stroke: none,
|
|
..rows,
|
|
)
|
|
}
|
|
|
|
#let lore-and-rewards(creature) = {
|
|
section-title("Description")
|
|
text(size: 9pt, rich-text(creature.description))
|
|
v(0.5em)
|
|
section-title("Annotations")
|
|
text(size: 9pt, rich-text(creature.annotations))
|
|
v(0.5em)
|
|
section-title("Récompenses")
|
|
|
|
let reward-rows = creature.rewards.map(reward => (
|
|
reward.name,
|
|
reward.category,
|
|
rich-text(reward.cost),
|
|
rich-text(reward.effect),
|
|
)).flatten()
|
|
table(
|
|
columns: (1.1fr, 0.8fr, 0.55fr, 2.4fr),
|
|
inset: (x: 4pt, y: 3pt),
|
|
stroke: none,
|
|
table.header([*Nom*], [*Catégorie*], [*Coût*], [*Effet*]),
|
|
[Sang], [Base / combat / dépeçage], [], [#creature.blood.base / #creature.blood.battle / #creature.blood.carve],
|
|
..reward-rows,
|
|
)
|
|
}
|
|
|
|
#let body-table(creature) = {
|
|
let rows = creature.body-parts.map(part => (
|
|
text(size: 8pt, part.name),
|
|
threshold(part.p1.threshold), protection(part.p1.protection), small-value(part.p1.integrity), small-value(part.p1.life),
|
|
threshold(part.p2.threshold), protection(part.p2.protection), small-value(part.p2.integrity), small-value(part.p2.life),
|
|
)).flatten()
|
|
table(
|
|
columns: (2fr, auto, auto, 1.5fr, 1.5fr, auto, auto, 1.5fr, 1.5fr),
|
|
rows: (1.5em, 1.5em) + (2.5em,) * creature.body-parts.len() + (auto, auto),
|
|
inset: (x: 4pt, y: 2pt),
|
|
align: (x, y) => if (x == 3 or x == 4 or x == 7 or x == 8) and y > 1 {
|
|
right + bottom
|
|
} else if y >= creature.body-parts.len() + 2 {
|
|
left + top
|
|
} else {
|
|
center + horizon
|
|
},
|
|
stroke: none,
|
|
table.vline(x: 5, start: 1, stroke: 0.5pt + theme.border),
|
|
table.header(
|
|
[], table.cell(colspan: 4, align: center)[P1], table.cell(colspan: 4, align: center)[P2],
|
|
[], [Seuil], [Prot], [Intégrité], [PV], [Seuil], [Prot], [Intégrité], [PV],
|
|
),
|
|
table.hline(stroke: 0.5pt + theme.border),
|
|
..rows,
|
|
table.hline(stroke: 0.5pt + theme.border),
|
|
table.cell(colspan: 9)[*Notes*],
|
|
table.cell(colspan: 9, text(size: 8pt, rich-text(creature.master-notes))),
|
|
table.hline(stroke: 0.5pt + theme.border),
|
|
)
|
|
}
|
|
|
|
#let resistance-table(creature) = {
|
|
let headers = (
|
|
[Res],
|
|
element-icon("/images/icons/slash.svg", height: 0.65em, baseline: 0.5pt),
|
|
element-icon("/images/icons/pierce.svg", height: 0.7em, baseline: 0.7pt),
|
|
element-icon("/images/icons/gavel-solid-full.svg", height: 0.7em, baseline: 0.5pt),
|
|
element-icon("/images/icons/sun-solid-full.svg"),
|
|
element-icon("/images/icons/fire-flame-curved-solid-full.svg"),
|
|
element-icon("/images/icons/mountain-solid-full.svg"),
|
|
element-icon("/images/icons/leaf-solid-full.svg"),
|
|
element-icon("/images/icons/water-solid-full.svg"),
|
|
element-icon("/images/icons/moon-solid-full.svg"),
|
|
element-icon("/images/icons/droplet-solid-full.svg", baseline: 0pt),
|
|
element-icon("/images/icons/wind-solid-full.svg"),
|
|
element-icon("/images/icons/icicles-solid-full.svg"),
|
|
element-icon("/images/icons/lightning-fill.svg"),
|
|
)
|
|
let rows = creature.body-parts.map(part => (
|
|
smallcaps(part.name), ..part.resistances.map(resistance),
|
|
)).flatten()
|
|
[
|
|
#show table.cell: it => if it.y > 0 { text(size: 9pt, it) } else { text(size: 12pt, it) }
|
|
#table(
|
|
columns: (25%,) + (75% / 13,) * 13,
|
|
row-gutter: 1.5pt,
|
|
inset: (x: 2pt, y: 3.5pt),
|
|
align: center + horizon,
|
|
stroke: none,
|
|
table.header(..headers),
|
|
table.hline(stroke: 0.5pt + theme.border),
|
|
..rows,
|
|
)
|
|
]
|
|
}
|
|
|
|
#let statistics-table(creature) = {
|
|
let s = creature.stats
|
|
let rows = ()
|
|
for (index, init) in creature.initiatives.enumerate() {
|
|
rows += (cell(init.name), cell(init.p1-value), cell(init.p1-actions), cell(init.p2-value), cell(init.p2-actions))
|
|
if index == 0 {
|
|
rows += (
|
|
[], cell(s.strength), cell(s.perception), cell(s.willpower), cell(s.alteration-resistance), cell(s.torque), cell(s.awareness), cell(s.fatigue),
|
|
[], cell(s.movement.walk), cell(s.movement.trot), cell(s.movement.run), cell(s.movement.flight),
|
|
[], cell(s.transcendental-resistance), cell(s.physical-bonus), cell(s.elemental-bonus),
|
|
)
|
|
} else {
|
|
rows += ([],) * 17
|
|
}
|
|
}
|
|
[
|
|
#show table.cell: it => if it.y == 0 {
|
|
text(size: 12pt, it)
|
|
} else if it.y == 1 {
|
|
text(size: 7pt, align(center + bottom, rotate(-90deg, it, reflow: true)))
|
|
} else { it }
|
|
#align(center)[
|
|
#table(
|
|
columns: (100% / 22,) * 22,
|
|
inset: (x: 1.5pt, y: 2pt),
|
|
align: (x, y) => if y == 1 { right + horizon } else { center + horizon },
|
|
stroke: none,
|
|
table.header(
|
|
[], table.cell(colspan: 2)[P1], table.cell(colspan: 2)[P2], [],
|
|
table.cell(colspan: 7)[Stats], [], table.cell(colspan: 4)[Mouvement], [], table.cell(colspan: 3)[Extra],
|
|
table.hline(start: 1, end: 5, stroke: 0.5pt + theme.border),
|
|
table.hline(start: 6, end: 13, stroke: 0.5pt + theme.border),
|
|
table.hline(start: 14, end: 18, stroke: 0.5pt + theme.border),
|
|
table.hline(start: 19, end: 22, stroke: 0.5pt + theme.border),
|
|
[Initiative], [Valeur], [Action], [Valeur], [Actions], [],
|
|
[Force], [Perception], [Volonté], [Rés. Alt.], [Torque], [Vigilance], [Fatigue], [],
|
|
[Marche], [Trot], [Course], [Vol], [], [Rés. Trans.], [Bon. Phy.], [Bon. Élém.],
|
|
),
|
|
..rows,
|
|
)
|
|
]
|
|
]
|
|
}
|
|
|
|
#let attack-table(creature) = {
|
|
let contents = ()
|
|
for phase in creature.phases {
|
|
contents.push(table.cell(colspan: 13, fill: theme.dark-gold, text(fill: white, weight: "bold", phase.name)))
|
|
for group in phase.groups {
|
|
// Colour belongs to the complete skill group, not to an individual row:
|
|
// multi-line attacks and their explanation therefore read as one unit.
|
|
let group-color-key = group.at(
|
|
"color",
|
|
default: group.attacks.first().type,
|
|
)
|
|
let group-color = if type(group-color-key) == color {
|
|
group-color-key
|
|
} else {
|
|
label-fill.at(group-color-key, default: white)
|
|
}
|
|
for attack in group.attacks {
|
|
contents += (
|
|
table.cell(fill: group-color)[],
|
|
rich-text(attack.name), cell(attack.type), rich-text(attack.timing), rich-text(attack.target),
|
|
rich-text(attack.fatigue-cost), rich-text(attack.action-cost), rich-text(attack.element),
|
|
rich-text(attack.fatigue-damage), rich-text(attack.damage), rich-text(attack.effects),
|
|
cell(attack.parry), cell(attack.dodge),
|
|
)
|
|
}
|
|
if present(group.description) {
|
|
contents += (
|
|
table.cell(fill: group-color)[],
|
|
table.cell(colspan: 12, inset: 4pt, text(size: 8pt, rich-text(group.description))),
|
|
)
|
|
}
|
|
contents.push(table.hline(stroke: 0.35pt + theme.border.lighten(35%)))
|
|
}
|
|
}
|
|
table(
|
|
columns: (0.5em, 8em, 3em, 4em, 1em, 2em, 2em, 3em, 2em, 3em, 1fr, 1em, 1em),
|
|
inset: (x: 2pt, y: 2.5pt),
|
|
align: (x, _) => if x == 1 or x == 10 { left } else { center },
|
|
stroke: none,
|
|
[], [], [], [], [], table.cell(colspan: 2)[Coûts], [], table.cell(colspan: 2)[Dégâts], [], table.cell(colspan: 2)[Seuils],
|
|
table.header([], [], [Type], [Timing], [Ciblage], [Fatigue], [Action], [Élément], [Fatigue], [Normaux], [Effets], [Parade], [Esquive]),
|
|
..contents,
|
|
)
|
|
}
|
|
|
|
#let render-master-creature(creature) = {
|
|
heading(level: 2, creature.name)
|
|
if present(creature.image) {
|
|
align(center, image(creature.image, height: 5cm))
|
|
identity-table(creature)
|
|
} else {
|
|
identity-table(creature)
|
|
}
|
|
v(1fr)
|
|
lore-and-rewards(creature)
|
|
|
|
pagebreak()
|
|
body-table(creature)
|
|
v(0.7em)
|
|
resistance-table(creature)
|
|
v(1fr)
|
|
statistics-table(creature)
|
|
|
|
if creature.phases.len() > 0 {
|
|
pagebreak()
|
|
[
|
|
#show table.cell: it => if it.y == 1 {
|
|
text(size: 6pt, align(center + bottom, rotate(-90deg, it, reflow: true)))
|
|
} else { text(size: 8pt, it) }
|
|
#attack-table(creature)
|
|
]
|
|
}
|
|
|
|
pagebreak()
|
|
section-title("Plan de combat")
|
|
block(inset: 8pt, text(size: 9pt, rich-text(creature.battle-plan)))
|
|
if present(creature.intent-graph) {
|
|
v(1em)
|
|
section-title("Graphique d'intentions")
|
|
block(inset: 8pt, creature.intent-graph)
|
|
}
|
|
pagebreak()
|
|
}
|