ravenous_typst/setup/analysis/defense_report.typ

135 lines
4.1 KiB
Plaintext
Raw Permalink Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

// Concise armor and shield comparison for the balance report.
#import "@preview/cetz:0.3.4"
#import "defense_metrics.typ": *
#import "report_style.typ": report-theme
#import "../theme/tables.typ" as tables
#let torque-protection-xy(items, title) = {
let items = items.sorted(key: item => item.torque)
let width = 7.2
let height = 4.1
let x-step = 5
let x-max = (
calc.ceil(calc.max(..items.map(item => item.torque)) / x-step) * x-step
)
let y-max = calc.max(1, calc.max(..items.map(item => item.protection)))
let x-ticks = range(0, x-max + 1, step: x-step)
let y-ticks = range(0, y-max + 1)
let point(item) = (
item.torque / x-max * width,
item.protection / y-max * height,
)
block(width: 100%, breakable: false)[
#align(center)[
#text(size: 8pt, weight: "bold", fill: report-theme.heading)[#title]
#v(4pt)
#cetz.canvas(length: 1cm, {
import cetz.draw: *
for tick in x-ticks {
let x = tick / x-max * width
line(
(x, 0),
(x, height),
stroke: 0.35pt + report-theme.dark-gold.transparentize(65%),
)
content(
(x, -0.2),
text(size: 5.5pt, fill: report-theme.muted-ink)[#tick],
anchor: "north",
)
}
for tick in y-ticks {
let y = tick / y-max * height
line(
(0, y),
(width, y),
stroke: 0.35pt + report-theme.dark-gold.transparentize(65%),
)
content(
(-0.18, y),
text(size: 5.5pt, fill: report-theme.muted-ink)[#tick],
anchor: "east",
)
}
line((0, 0), (width, 0), stroke: 0.75pt + report-theme.dark-gold)
line((0, 0), (0, height), stroke: 0.75pt + report-theme.dark-gold)
for index in range(items.len() - 1) {
line(
point(items.at(index)),
point(items.at(index + 1)),
stroke: 1.4pt + report-theme.chart-2,
)
}
for item in items {
circle(
point(item),
radius: 0.07,
fill: report-theme.chart-2,
stroke: 0.5pt + report-theme.parchment-light,
)
}
content(
(width / 2, -0.62),
text(size: 6.5pt, fill: report-theme.ink)[Torque minimale],
anchor: "north",
)
content(
(-0.72, height / 2),
text(size: 6.5pt, fill: report-theme.ink)[Protection],
angle: -90deg,
anchor: "center",
)
})
]
]
}
#let defense-report() = {
pagebreak()
heading(level: 2)[Artisanat — Armures et boucliers]
[La torque est traitée comme la contrainte; protection, intégrité et parade
comme des bénéfices indépendants. Pour comparer les équipements, `Torque min.`
retient la plus faible prise valide. Les deux prises restent visibles dans le
tableau afin de ne pas masquer les contraintes d’équipement.]
heading(level: 3)[Protection face à la torque]
grid(
columns: (1fr, 1fr),
column-gutter: 12pt,
..("Armors", "Shields").map(category => {
let items = defensive-equipment.filter(item => item.category == category)
torque-protection-xy(items, defense-category-labels.at(category))
}),
)
heading(level: 3)[Tableau défensif]
let rows = defensive-equipment.map(item => (
item.name,
str(item.protection),
str(item.integrity),
if item.parry > 0 { "+" + str(item.parry) } else { str(item.parry) },
if item.torque-one == none { [—] } else { str(item.torque-one) },
if item.torque-two == none { [—] } else { str(item.torque-two) },
str(item.torque),
))
tables.set-table-style(
table(
columns: (1.5fr, 0.72fr, 0.72fr, 0.65fr, 0.72fr, 0.72fr, 0.78fr),
align: (left,) + (right,) * 6,
table.header(
[Équipement],
[Protection],
[Intégrité],
[Parade],
[Torque 1M],
[Torque 2M],
[Torque min.],
),
..rows.flatten(),
),
table-theme: "steingrund",
text-size: 7.5pt,
)
}