ravenous_typst/chapters/craft/forge-table.typ

242 lines
5.4 KiB
Plaintext

#import "forge-data.typ": equipments
#import "/setup/setup.typ": bigscope, ddlvl, st
#import "/setup/craft_config.typ": craft-config
// Temporary handling names. These are presentation/game-rule data rather than
// composition rules, so they deliberately live beside the forge table.
#let handling-by-shape = (
"Griffes": "Tranchante",
"Hast": "Hast",
"Épée": "Tranchante",
"Marteau": "Contondante",
"Hache": "Tranchante",
"Arbalète": "Distance",
"Arc": "Distance",
"Bouclier": "-",
"Armure": "-",
)
#let super-heavy-handling = (
"Griffes": "Frienzä",
"Hast": "Paysagiste",
"Épée": "Haroth",
"Marteau": "Rhödarak",
"Hache": "Kahml",
)
#let handling(item) = {
if (
item.nature_category == "SuperHeavy"
and item.shape_name in super-heavy-handling
) {
super-heavy-handling.at(item.shape_name)
} else {
handling-by-shape.at(item.shape_name, default: "-")
}
}
// The database stores a generic adjective per nature. French gender and the
// plural form of "Griffes" are presentation details, kept here with handling.
#let adjectives-by-shape = (
"Griffes": (
Light: "légères",
Medium: "moyennes",
Heavy: "lourdes",
SuperHeavy: "super-lourdes",
),
"Hast": (
Light: "léger",
Medium: "moyen",
Heavy: "lourd",
SuperHeavy: "super-lourd",
),
"Épée": (
Light: "légère",
Medium: "moyenne",
Heavy: "lourde",
SuperHeavy: "super-lourde",
),
"Marteau": (
Light: "léger",
Medium: "moyen",
Heavy: "lourd",
SuperHeavy: "super-lourd",
),
"Hache": (
Light: "légère",
Medium: "moyenne",
Heavy: "lourde",
SuperHeavy: "super-lourde",
),
"Arbalète": (
Light: "légère",
Medium: "moyenne",
Heavy: "lourde",
SuperHeavy: "super-lourde",
),
"Arc": (
Light: "léger",
Medium: "moyen",
Heavy: "lourd",
SuperHeavy: "super-lourd",
),
"Bouclier": (
Light: "léger",
Medium: "moyen",
Heavy: "lourd",
SuperHeavy: "super-lourd",
),
"Armure": (
Light: "légère",
Medium: "moyenne",
Heavy: "lourde",
SuperHeavy: "super-lourde",
),
)
#let display-name(item) = {
let adjectives = adjectives-by-shape.at(item.shape_name, default: none)
if adjectives == none {
item.name
} else {
item.shape_name + " " + adjectives.at(item.nature_category)
}
}
#let damage-symbols = (
"Slash": [@el_slash],
"Blunt": [@el_blunt],
"Pierce": [@el_pierce],
)
#let mode(mode-data) = {
let (rank, damage-type) = mode-data.pairs().first()
let symbol = damage-symbols.at(damage-type, default: [#damage-type])
if rank == "Secondary" {
[\[#symbol\]]
} else if rank == "Tertiary" {
[\[\[#symbol\]\]]
} else {
symbol
}
}
#let modes(item) = item.damage_type.map(mode).join([, ])
#let signed(value) = if value > 0 { "+" + str(value) } else { str(value) }
#let shown(value) = if value == none { [-] } else { [#value] }
#let special(item) = {
let parts = ()
if item.action_cost > 1 {
parts.push([#(str(item.action_cost) + "A")])
}
if item.reload_cost != none and item.reload_cost != "null" {
parts.push([#item.reload_cost@rl_reload])
}
if item.armor_pierce != 0 {
parts.push([Perce-armure #signed(item.armor_pierce)])
}
if item.antimaterial != 0 {
parts.push([Antimatériel #signed(item.antimaterial)])
}
if item.range > 0 {
parts.push([#item.range m])
}
if item.precision != 0 {
parts.push([@rl_precision #signed(item.precision)])
}
if item.agility_bonus != 0 {
parts.push([Agilité #signed(item.agility_bonus)])
}
parts += item.special.map(effect => eval(
effect,
mode: "markup",
scope: bigscope,
))
if parts.len() == 0 { [-] } else { parts.join([, ]) }
}
// Category-specific post-treatment belongs in the helpers above. The data
// module remains responsible only for importing and composing equipment.
#page(
flipped: true,
)[
#align(center)[
#st.set-table-style(
table-theme: "steel",
stroke: none,
text-size: craft-config.table.text-size,
inset-y: craft-config.table.inset-y,
header-inset-y: craft-config.table.header-inset-y,
table(
columns: 17,
// TODO: This might be a little too tight
// inset: (x: 2pt, y: 3pt),
align: (
left,
left,
right,
right,
right,
right,
right,
right,
right,
right,
center,
right,
right,
right,
right,
left,
right,
),
table.header(
[Forme],
[Maniement],
[Dég.],
[+],
[@rl_rmax:short],
[@rl_arbreak:short],
[@rl_protection:short],
[@rl_integrity:short],
[T2],
[T1],
[Modes],
[Esq.],
[Par.],
[Vit.],
[Disc.],
[Spécial],
[Diff.],
),
..equipments
.map(item => (
[#display-name(item)],
[#handling(item)],
[#item.damage],
[#item.p_damage],
[#item.rmax],
[#item.armor_break],
[#item.protection],
[#item.integrity],
shown(item.torque_two_handed),
shown(item.torque_one_handed),
[#modes(item)],
[#item.dodge],
[#item.parry],
[#item.speed],
[#item.stealth],
[#special(item)],
[#ddlvl(item.difficulty)],
))
.flatten(),
),
)
]
]