From 822e06dc3b105d2aacae2cb6443d73e54ecf7479 Mon Sep 17 00:00:00 2001 From: Dandaedre Date: Fri, 21 Aug 2026 20:07:24 +0200 Subject: [PATCH] Classes trigrams --- data/config/build.yaml | 14 ++++++ setup/analysis/class_alteration_report.typ | 56 +++++++++++++--------- setup/analysis/class_category_report.typ | 16 +------ setup/analysis/class_cost_report.typ | 17 +------ setup/build_config.typ | 22 +++++++++ 5 files changed, 74 insertions(+), 51 deletions(-) diff --git a/data/config/build.yaml b/data/config/build.yaml index 50c9517..4f4265a 100644 --- a/data/config/build.yaml +++ b/data/config/build.yaml @@ -25,6 +25,20 @@ build: # Always excluded, in addition to the exclusions from the selected preset. disabled_chapters: [] +# Canonical three-letter identifiers used in compact tables and graphs. +schools: + trigrams: + artilleur: ART + einerjar: EIN + franc-tireur: FTI + guerrier-mage: GMA + heavy-weapon-specialist: ALD + lancier: LAN + mage-bestial: MBE + maitre-lames: MLA + protecteur: PRO + sangremage: SGM + # Chapter IDs are defined in main.typ. Presets only list what they hide, so new # chapters remain visible by default and a custom exclusion stays easy to audit. presets: diff --git a/setup/analysis/class_alteration_report.typ b/setup/analysis/class_alteration_report.typ index 515e1f9..ad2bf93 100644 --- a/setup/analysis/class_alteration_report.typ +++ b/setup/analysis/class_alteration_report.typ @@ -2,10 +2,10 @@ #import "@preview/primaviz:0.6.0": bar-chart, horizontal-bar-chart #import "class_alterations.typ": * #import "class_costs.typ": class-display-names -#import "report_style.typ": chart-theme, metric-card, rounded +#import "report_style.typ": chart-theme, metric-card, report-theme, rounded #import "../generation/radar_graphs.typ": school-sources #import "../theme/tables.typ" as tables -#import "../build_config.typ": school-tiers +#import "../build_config.typ": school-tiers, school-trigram #let school-alteration-report() = { pagebreak() @@ -36,7 +36,7 @@ labels: school-alteration-counts.map(item => item.label.replace("_", " ")), values: school-alteration-counts.map(item => item.count), ), - width: 100%, height: 175pt, show-values: true, theme: chart-theme, + width: 100%, height: calc.max(175pt, school-alteration-counts.len() * 13pt), show-values: true, theme: chart-theme, ) heading(level: 3)[Mentions par classe et par tier] @@ -59,6 +59,37 @@ ), ) + pagebreak(weak: true) + heading(level: 3)[Types d’altération par classe] + [La matrice croît verticalement lorsque de nouvelles altérations sont ajoutées. + La teinte indique le nombre de mentions; une cellule blanche signifie zéro.] + let matrix = () + for alteration in school-alteration-counts { + matrix.push(alteration.label.replace("_", " ")) + for name in school-sources.keys() { + let count = school-alterations(class: name, subtype: alteration.label).len() + let shade = if count == 0 { report-theme.parchment-light } else { + report-theme.chart-2.transparentize(calc.max(16%, 82% - count * 9%)) + } + matrix.push(table.cell(fill: shade)[#count]) + } + matrix.push(str(alteration.count)) + } + tables.set-table-style( + table( + columns: (1.3fr,) + (0.56fr,) * school-sources.len() + (0.5fr,), + align: (left,) + (center,) * school-sources.len() + (right,), + table.header( + [Altération], + ..school-sources.keys().map(name => [#school-trigram(name)]), + [Total], + ), + ..matrix, + ), + table-theme: "steingrund", + text-size: 6.6pt, + ) + heading(level: 3)[Contraintes moyennes par altération] let rows = school-alteration-profiles.map(profile => ( profile.subtype.replace("_", " "), str(profile.count), @@ -77,25 +108,6 @@ text-size: 7.4pt, ) - heading(level: 3)[Matrice classe × altération] - let matrix = () - for name in school-sources.keys() { - matrix.push(class-display-names.at(name)) - for alteration in school-alteration-counts { - matrix.push(str(school-alterations(class: name, subtype: alteration.label).len())) - } - } - tables.set-table-style( - table( - columns: (1.45fr,) + (0.85fr,) * school-alteration-counts.len(), - align: (left,) + (right,) * school-alteration-counts.len(), - table.header([Classe], ..school-alteration-counts.map(item => [#item.label.replace("_", " ")])), - ..matrix, - ), - table-theme: "steingrund", - text-size: 7pt, - ) - heading(level: 3)[Audit des mentions] let audit = all-school-alterations.map(item => ( item.display, "T" + str(item.tier), item.technique, diff --git a/setup/analysis/class_category_report.typ b/setup/analysis/class_category_report.typ index e2267a2..1171039 100644 --- a/setup/analysis/class_category_report.typ +++ b/setup/analysis/class_category_report.typ @@ -3,22 +3,10 @@ #import "class_categories.typ": * #import "report_style.typ": chart-theme, metric-card #import "../theme/tables.typ" as tables +#import "../build_config.typ": school-trigram #let percent-label(value) = str(calc.round(value / 1%, digits: 1)) + " %" -#let class-short-labels = ( - artilleur: "Art.", - einerjar: "Ein.", - franc-tireur: "F.-tir.", - guerrier-mage: "G. mage", - heavy-weapon-specialist: "A. lourdes", - lancier: "Lanc.", - mage-bestial: "M. best.", - maitre-lames: "M.-lames", - protecteur: "Prot.", - sangremage: "Sang.", -) - #let school-tier-matrix(exclusive) = { let rows = () for school in exclusive-by-class { @@ -146,7 +134,7 @@ align: (left,) + (center,) * exclusive-by-class.len(), table.header( [Catégorie], - ..exclusive-by-class.map(item => [#class-short-labels.at(item.name)]), + ..exclusive-by-class.map(item => [#school-trigram(item.name)]), ), ..category-matrix, ), diff --git a/setup/analysis/class_cost_report.typ b/setup/analysis/class_cost_report.typ index 6ad9b66..9d78bc7 100644 --- a/setup/analysis/class_cost_report.typ +++ b/setup/analysis/class_cost_report.typ @@ -3,24 +3,11 @@ #import "class_costs.typ": * #import "report_style.typ": chart-theme, metric-card, report-theme, rounded #import "../theme/tables.typ" as tables -#import "../build_config.typ": school-tiers +#import "../build_config.typ": school-tiers, school-trigram #import "class_alteration_report.typ": school-alteration-report #import "class_category_report.typ": school-category-report #import "report_config.typ": chapter-enabled -#let class-chart-labels = ( - artilleur: "Art.", - einerjar: "Ein.", - franc-tireur: "F.-tir.", - guerrier-mage: "G. mage", - heavy-weapon-specialist: "A. lourdes", - lancier: "Lanc.", - mage-bestial: "M. best.", - maitre-lames: "M.-lames", - protecteur: "Prot.", - sangremage: "Sang.", -) - #let cost-series(metrics) = ( ( name: "Sang", @@ -102,7 +89,7 @@ #let tier-comparison(classes, tier-number) = { let names = classes.keys() let tier-index = tier-number - 1 - let labels = names.map(name => class-chart-labels.at(name)) + let labels = names.map(school-trigram) let metrics = classes.values().map(class-data => class-data.tiers.at(tier-index)) heading(level: 3)[Tier #tier-number] diff --git a/setup/build_config.typ b/setup/build_config.typ index 362e62f..bd011f4 100644 --- a/setup/build_config.typ +++ b/setup/build_config.typ @@ -3,6 +3,7 @@ #let document-config = config.document #let raw-build-config = config.build #let presets = config.presets +#let school-trigrams = config.schools.trigrams // `--input preset=...` is the lightweight entry point for alternate editions. #let selected-preset = sys.inputs.at("preset", default: raw-build-config.preset) @@ -34,4 +35,25 @@ #let origin-enabled(id) = selected-origin == "" or selected-origin == id #let school-enabled(id) = selected-school == "" or selected-school == id +#let school-trigram(name) = { + let normalized = lower(name).replace("_", "-").replace(" ", "-") + let canonical = ( + franc-tirreur: "franc-tireur", + specialiste-armes-lourdes: "heavy-weapon-specialist", + ).at(normalized, default: normalized) + if canonical not in school-trigrams { + panic("Unknown school trigram: " + name) + } + school-trigrams.at(canonical) +} + #assert(max-tier-exclusive > 1, message: "build.max_tier_exclusive must be greater than 1") +#assert( + school-trigrams.values().all(value => value.match(regex("^[A-Z]{3}$")) != none), + message: "Every schools.trigrams value must contain exactly three uppercase letters", +) +#assert.eq( + school-trigrams.values().dedup().len(), + school-trigrams.len(), + message: "schools.trigrams values must be unique", +)