678 lines
14 KiB
Plaintext
678 lines
14 KiB
Plaintext
#import "variables.typ": theme
|
|
// -----------------------------------------------------------------------------
|
|
// Class presentation — Fantasy Codex
|
|
// -----------------------------------------------------------------------------
|
|
|
|
#let fantasy-label(body) = {
|
|
text(
|
|
size: 7.5pt,
|
|
weight: "bold",
|
|
fill: theme.dark-gold,
|
|
tracking: 0.12em,
|
|
)[ #body ]
|
|
}
|
|
|
|
#let fantasy-rule() = {
|
|
line(
|
|
length: 100%,
|
|
stroke: 0.65pt + theme.border,
|
|
)
|
|
}
|
|
|
|
#let fantasy-section(title, body) = {
|
|
fantasy-label(title)
|
|
v(0.3em)
|
|
body
|
|
}
|
|
|
|
// =============================================================================
|
|
// Technique TSV importer
|
|
//
|
|
// Usage:
|
|
// #techniques("techniques.tsv")
|
|
//
|
|
// Expected TSV structure:
|
|
//
|
|
// Tier 1
|
|
// Technique Niv Type Coût [gauge] Effet [unused columns...]
|
|
// ...
|
|
//
|
|
// Tier 2
|
|
// Technique Niv Type Coût [gauge] Effet [unused columns...]
|
|
// ...
|
|
// =============================================================================
|
|
|
|
// -----------------------------------------------------------------------------
|
|
// Configuration
|
|
// -----------------------------------------------------------------------------
|
|
|
|
#let technique-columns = (
|
|
technique: 0,
|
|
level: 1,
|
|
type: 2,
|
|
blood: 3,
|
|
gauge: 4,
|
|
effect: 5,
|
|
)
|
|
|
|
// -----------------------------------------------------------------------------
|
|
// Helpers
|
|
// -----------------------------------------------------------------------------
|
|
|
|
#let cell(row, index, default: "") = {
|
|
if index < row.len() {
|
|
row.at(index)
|
|
} else {
|
|
default
|
|
}
|
|
}
|
|
|
|
#let is-empty-row(row) = {
|
|
row.all(value => value.trim() == "")
|
|
}
|
|
|
|
#let is-header-row(row) = {
|
|
row.len() > 0 and cell(row, 0).trim() == "Technique"
|
|
}
|
|
|
|
#let tier-name(row) = {
|
|
if row.len() == 0 {
|
|
none
|
|
} else {
|
|
let value = cell(row, 0).trim()
|
|
|
|
if value.starts-with("Tier ") {
|
|
value.slice(5).trim()
|
|
} else {
|
|
none
|
|
}
|
|
}
|
|
}
|
|
|
|
// -----------------------------------------------------------------------------
|
|
// LaTeX-ish → Typst conversion
|
|
// -----------------------------------------------------------------------------
|
|
//
|
|
// The TSV is deliberately allowed to contain the notation used by the
|
|
// original LaTeX source. We translate the commands here rather than
|
|
// modifying the source data.
|
|
//
|
|
// This function returns Typst content, not a string.
|
|
// -----------------------------------------------------------------------------
|
|
|
|
#let format-effect(value) = {
|
|
let s = value
|
|
|
|
// ---------------------------------------------------------------------------
|
|
// Simple commands
|
|
// ---------------------------------------------------------------------------
|
|
|
|
s = s.replace("\\arbreakk", "@armor_break:short")
|
|
s = s.replace("\\damagek", "@damage:short")
|
|
s = s.replace("\\pierce", "pierce")
|
|
s = s.replace("\\WIP", "WIP")
|
|
s = s.replace("\\contondant{}", "contondant")
|
|
|
|
// ---------------------------------------------------------------------------
|
|
// Common formatting commands
|
|
// ---------------------------------------------------------------------------
|
|
|
|
s = s.replace("\\emph{", "#emph[")
|
|
s = s.replace("}", "]")
|
|
|
|
// ---------------------------------------------------------------------------
|
|
// Glossary commands
|
|
//
|
|
// These are deliberately explicit so that the conversion is predictable.
|
|
// Add more terms here as your TSV grows.
|
|
// ---------------------------------------------------------------------------
|
|
|
|
s = s.replace(
|
|
"\\gls{",
|
|
"#gls(",
|
|
)
|
|
|
|
// ---------------------------------------------------------------------------
|
|
// Other LaTeX constructs appearing in the data
|
|
// ---------------------------------------------------------------------------
|
|
|
|
s = s.replace(
|
|
"\\ddlvl{",
|
|
"#ddlvl(",
|
|
)
|
|
|
|
// ---------------------------------------------------------------------------
|
|
// Math fragments
|
|
// ---------------------------------------------------------------------------
|
|
|
|
s = s.replace(
|
|
")$",
|
|
") $",
|
|
)
|
|
s = s.replace(
|
|
"$(",
|
|
"$ (",
|
|
)
|
|
|
|
// ---------------------------------------------------------------------------
|
|
// Convert the resulting string into Typst markup.
|
|
//
|
|
// The TSV is treated as trusted source data.
|
|
// ---------------------------------------------------------------------------
|
|
|
|
// eval(s, mode: "markup")
|
|
s
|
|
}
|
|
|
|
// -----------------------------------------------------------------------------
|
|
// Cost formatting
|
|
// -----------------------------------------------------------------------------
|
|
|
|
#let format-cost(blood, gauge) = {
|
|
let parts = ()
|
|
|
|
if blood.trim() != "" {
|
|
let value = blood.trim()
|
|
value = value.replace("🩸", "@blood:short")
|
|
parts.push(eval(value, mode: "markup"))
|
|
}
|
|
|
|
if gauge.trim() != "" {
|
|
let value = gauge.trim()
|
|
value = value.replace("⚡", "@jauge:short")
|
|
parts.push(eval(value, mode: "markup"))
|
|
}
|
|
|
|
if parts.len() == 0 {
|
|
[]
|
|
} else {
|
|
parts.join("")
|
|
}
|
|
}
|
|
|
|
// -----------------------------------------------------------------------------
|
|
// Convert a TSV data row to table cells
|
|
// -----------------------------------------------------------------------------
|
|
|
|
#let technique-row(row) = {
|
|
let c = technique-columns
|
|
|
|
(
|
|
cell(row, c.technique),
|
|
cell(row, c.level),
|
|
cell(row, c.type),
|
|
format-cost(
|
|
cell(row, c.blood),
|
|
cell(row, c.gauge),
|
|
),
|
|
format-effect(
|
|
cell(row, c.effect),
|
|
),
|
|
)
|
|
}
|
|
|
|
// -----------------------------------------------------------------------------
|
|
// Single tier table
|
|
// -----------------------------------------------------------------------------
|
|
|
|
#let technique-tier-table(tier, rows) = {
|
|
table(
|
|
columns: (
|
|
3.1cm,
|
|
0.48cm,
|
|
2.15cm,
|
|
0.72cm,
|
|
1fr,
|
|
),
|
|
// No column gutter: the background fills the entire table.
|
|
column-gutter: 0pt,
|
|
row-gutter: 0pt,
|
|
inset: 0pt,
|
|
stroke: none,
|
|
align: (
|
|
left,
|
|
center,
|
|
left,
|
|
center,
|
|
left,
|
|
),
|
|
// -------------------------------------------------------------------------
|
|
// Tier title
|
|
// -------------------------------------------------------------------------
|
|
table.cell(
|
|
colspan: 5,
|
|
fill: white,
|
|
stroke: (
|
|
top: 0pt,
|
|
bottom: 0.6pt + theme.border,
|
|
),
|
|
inset: (
|
|
x: 5pt,
|
|
y: 2.5pt,
|
|
),
|
|
[
|
|
#grid(
|
|
columns: (auto, 1fr),
|
|
column-gutter: 0.45em,
|
|
align: horizon,
|
|
)[
|
|
#text(
|
|
size: 7.5pt,
|
|
weight: "bold",
|
|
fill: theme.gold,
|
|
)[◆]
|
|
][
|
|
#text(
|
|
size: 8.5pt,
|
|
weight: "bold",
|
|
fill: theme.dark-gold,
|
|
tracking: 0.08em,
|
|
)[
|
|
TIER #tier
|
|
]
|
|
]
|
|
],
|
|
),
|
|
// -------------------------------------------------------------------------
|
|
// Header
|
|
// -------------------------------------------------------------------------
|
|
table.header(
|
|
table.cell(
|
|
fill: theme.dark-gold,
|
|
inset: (
|
|
x: 4pt,
|
|
y: 2pt,
|
|
),
|
|
[
|
|
#text(
|
|
size: 7.2pt,
|
|
weight: "bold",
|
|
fill: theme.parchment-light,
|
|
)[Technique]
|
|
],
|
|
),
|
|
|
|
table.cell(
|
|
fill: theme.dark-gold,
|
|
inset: (
|
|
x: 2pt,
|
|
y: 2pt,
|
|
),
|
|
[
|
|
#text(
|
|
size: 7.2pt,
|
|
weight: "bold",
|
|
fill: theme.parchment-light,
|
|
)[Niv]
|
|
],
|
|
),
|
|
|
|
table.cell(
|
|
fill: theme.dark-gold,
|
|
inset: (
|
|
x: 4pt,
|
|
y: 2pt,
|
|
),
|
|
[
|
|
#text(
|
|
size: 7.2pt,
|
|
weight: "bold",
|
|
fill: theme.parchment-light,
|
|
)[Type]
|
|
],
|
|
),
|
|
|
|
table.cell(
|
|
fill: theme.dark-gold,
|
|
inset: (
|
|
x: 2pt,
|
|
y: 2pt,
|
|
),
|
|
[
|
|
#text(
|
|
size: 7.2pt,
|
|
weight: "bold",
|
|
fill: theme.parchment-light,
|
|
)[Coût]
|
|
],
|
|
),
|
|
|
|
table.cell(
|
|
fill: theme.dark-gold,
|
|
inset: (
|
|
x: 4pt,
|
|
y: 2pt,
|
|
),
|
|
[
|
|
#text(
|
|
size: 7.2pt,
|
|
weight: "bold",
|
|
fill: theme.parchment-light,
|
|
)[Effet]
|
|
],
|
|
),
|
|
),
|
|
// -------------------------------------------------------------------------
|
|
// Rows
|
|
// -------------------------------------------------------------------------
|
|
..rows.enumerate().map(((index, row)) => {
|
|
let cells = technique-row(row)
|
|
|
|
let fill = if calc.even(index) {
|
|
theme.parchment-light
|
|
} else {
|
|
theme.parchment
|
|
}
|
|
|
|
cells.enumerate().map(((column, content)) => {
|
|
table.cell(
|
|
fill: fill,
|
|
|
|
stroke: (
|
|
bottom: 0.3pt + theme.border,
|
|
),
|
|
|
|
inset: (
|
|
x: if column == 1 or column == 3 {
|
|
2pt
|
|
} else {
|
|
4pt
|
|
},
|
|
y: 1.8pt,
|
|
),
|
|
|
|
[
|
|
// TODO: EXTRACT THIS MAGIC VALUE
|
|
#text(
|
|
size: 10pt,
|
|
fill: theme.ink,
|
|
)[
|
|
#content
|
|
]
|
|
],
|
|
)
|
|
})
|
|
}).flatten(),
|
|
)
|
|
}
|
|
|
|
// -----------------------------------------------------------------------------
|
|
// Parse all tiers
|
|
// -----------------------------------------------------------------------------
|
|
|
|
#let parse-techniques(data) = {
|
|
let tiers = ()
|
|
let current-tier = none
|
|
let current-rows = ()
|
|
|
|
for row in data {
|
|
// Empty separator row
|
|
if is-empty-row(row) {
|
|
continue
|
|
}
|
|
|
|
// -------------------------------------------------------------------------
|
|
// New tier
|
|
// -------------------------------------------------------------------------
|
|
|
|
let tier = tier-name(row)
|
|
|
|
if tier != none {
|
|
// Save previous tier
|
|
if current-tier != none {
|
|
tiers.push((
|
|
current-tier,
|
|
current-rows,
|
|
))
|
|
}
|
|
|
|
current-tier = tier
|
|
current-rows = ()
|
|
|
|
continue
|
|
}
|
|
|
|
// -------------------------------------------------------------------------
|
|
// Repeated header
|
|
// -------------------------------------------------------------------------
|
|
|
|
if is-header-row(row) {
|
|
continue
|
|
}
|
|
|
|
// -------------------------------------------------------------------------
|
|
// Actual technique
|
|
// -------------------------------------------------------------------------
|
|
|
|
// Ignore anything before the first tier.
|
|
if current-tier != none {
|
|
current-rows.push(row)
|
|
}
|
|
}
|
|
|
|
// Save final tier
|
|
if current-tier != none {
|
|
tiers.push((
|
|
current-tier,
|
|
current-rows,
|
|
))
|
|
}
|
|
|
|
tiers
|
|
}
|
|
|
|
// -----------------------------------------------------------------------------
|
|
// Public API
|
|
// -----------------------------------------------------------------------------
|
|
|
|
#let techniques(path) = {
|
|
let data = csv(
|
|
path,
|
|
delimiter: "\t",
|
|
)
|
|
|
|
let tiers = parse-techniques(data)
|
|
|
|
for (index, tier) in tiers.enumerate() {
|
|
// TODO: Remove this magic value
|
|
if (index >= 4){ break }
|
|
let name = tier.at(0)
|
|
let rows = tier.at(1)
|
|
|
|
technique-tier-table(
|
|
name,
|
|
rows,
|
|
)
|
|
|
|
// Space between tiers, but not after the final table.
|
|
if index < tiers.len() - 1 {
|
|
v(0.7em)
|
|
}
|
|
}
|
|
}
|
|
|
|
#let school_presentation(class_info) = {
|
|
set text(
|
|
font: "Libertinus Serif",
|
|
fill: theme.ink,
|
|
)
|
|
|
|
// ---------------------------------------------------------------------------
|
|
// Header
|
|
// ---------------------------------------------------------------------------
|
|
|
|
align(center)[
|
|
#text(
|
|
size: 20pt,
|
|
weight: "bold",
|
|
fill: theme.ink,
|
|
)[
|
|
|
|
|
|
== #class_info.title
|
|
|
|
]
|
|
|
|
#v(0.35em)
|
|
|
|
// Ornamental divider
|
|
#grid(
|
|
columns: (1fr, auto, 1fr),
|
|
column-gutter: 0.55em,
|
|
align: horizon,
|
|
)[
|
|
#line(
|
|
length: 100%,
|
|
stroke: 0.7pt + theme.border,
|
|
)
|
|
][
|
|
#text(
|
|
size: 10pt,
|
|
fill: theme.gold,
|
|
)[◆]
|
|
][
|
|
#line(
|
|
length: 100%,
|
|
stroke: 0.7pt + theme.border,
|
|
)
|
|
]
|
|
]
|
|
|
|
v(1em)
|
|
|
|
// ---------------------------------------------------------------------------
|
|
// Illustration + introduction
|
|
// ---------------------------------------------------------------------------
|
|
|
|
grid(
|
|
columns: (1.05fr, 1.7fr),
|
|
column-gutter: 1.3em,
|
|
align: top,
|
|
// Illustration
|
|
[
|
|
#block(
|
|
fill: theme.parchment-dark,
|
|
stroke: 0.8pt + theme.border,
|
|
inset: 0.3em,
|
|
)[
|
|
#block(
|
|
clip: true,
|
|
stroke: 0.5pt + theme.border,
|
|
)[
|
|
#image(
|
|
class_info.illustration,
|
|
width: 100%,
|
|
)
|
|
]
|
|
]
|
|
], // Description
|
|
[
|
|
#fantasy-section("PRÉSENTATION")[
|
|
#text(
|
|
size: 10.2pt,
|
|
// leading: 1.35em,
|
|
)[
|
|
#class_info.description
|
|
]
|
|
]
|
|
],
|
|
)
|
|
|
|
v(1em)
|
|
|
|
// ---------------------------------------------------------------------------
|
|
// Class profile
|
|
// ---------------------------------------------------------------------------
|
|
|
|
fantasy-rule()
|
|
|
|
v(0.7em)
|
|
|
|
grid(
|
|
columns: (1fr, 1.35fr),
|
|
column-gutter: 1.2em,
|
|
align: top,
|
|
// -------------------------------------------------------------------------
|
|
// Profile / radar
|
|
// -------------------------------------------------------------------------
|
|
[
|
|
#block(
|
|
fill: theme.parchment,
|
|
stroke: 0.7pt + theme.border,
|
|
inset: 0.65em,
|
|
)[
|
|
#align(center)[
|
|
#fantasy-section("PROFIL")[
|
|
#image(
|
|
class_info.radar,
|
|
width: 82%,
|
|
)
|
|
]
|
|
]
|
|
]
|
|
], // -------------------------------------------------------------------------
|
|
// Mechanics
|
|
// -------------------------------------------------------------------------
|
|
[ // Exclusive mechanic
|
|
#block(
|
|
fill: theme.parchment-dark,
|
|
stroke: 0.8pt + theme.gold,
|
|
inset: (x: 0.8em, y: 0.65em),
|
|
)[
|
|
#grid(
|
|
columns: (auto, 1fr),
|
|
column-gutter: 0.5em,
|
|
align: horizon,
|
|
)[
|
|
#text(
|
|
size: 10pt,
|
|
fill: theme.gold,
|
|
)[◆]
|
|
][
|
|
#fantasy-label("MÉCANIQUE EXCLUSIVE")
|
|
]
|
|
|
|
#v(0.4em)
|
|
|
|
#text(
|
|
size: 13pt,
|
|
weight: "bold",
|
|
fill: theme.ink,
|
|
)[
|
|
#class_info.mechanic
|
|
]
|
|
]
|
|
|
|
#v(0.7em)
|
|
|
|
#grid(
|
|
columns: (1fr, auto),
|
|
align: horizon,
|
|
)[
|
|
#fantasy-label("DIFFICULTÉ")
|
|
][
|
|
#grid(
|
|
// columns: repeat(5, 0.7em),
|
|
column-gutter: 0.25em,
|
|
)[
|
|
#for i in range(5) {
|
|
if class_info.difficulty >= i + 1 {
|
|
text(size: 9pt, fill: theme.dark-gold)[●]
|
|
} else if class_info.difficulty >= i + 0.5 {
|
|
text(size: 9pt, fill: theme.dark-gold)[◐]
|
|
} else {
|
|
text(size: 9pt, fill: theme.border)[○]
|
|
}
|
|
}
|
|
]
|
|
]]
|
|
)
|
|
|
|
v(1em)
|
|
pagebreak()
|
|
|
|
[=== Techniques]
|
|
|
|
techniques(class_info.techniques)
|
|
}
|