diff --git a/chapters/schools/artilleur.typ b/chapters/schools/artilleur.typ index c88e8fb..e1254d0 100644 --- a/chapters/schools/artilleur.typ +++ b/chapters/schools/artilleur.typ @@ -1,11 +1,11 @@ -#import "/setup/setup.typ": ddlvl, gls, school_presentation, st, theme +#import "/setup/setup.typ": ddlvl, gls, radar-graph, school_presentation, st, theme //----- Artilleur ----- #school_presentation(( title: "Artilleur", illustration: "/images/schools/artilleur.jpg", - radar: "/images/icons/nodata.png", + radar: radar-graph("artilleur"), description: [ Extrêmement individualiste, l'artilleur cherche à dominer le combat et en dicter le rythme. Capable d'une très grande quantité de dégâts, il est extrêmement diff --git a/chapters/schools/einerjar.typ b/chapters/schools/einerjar.typ index 9c26df4..b7fc9e3 100644 --- a/chapters/schools/einerjar.typ +++ b/chapters/schools/einerjar.typ @@ -1,8 +1,8 @@ -#import "/setup/setup.typ": gls, gls-description, school_presentation +#import "/setup/setup.typ": gls, gls-description, radar-graph, school_presentation #school_presentation(( title: "Einerjar", illustration: "/images/schools/einerjar.jpg", - radar: "/images/icons/nodata.png", + radar: radar-graph("einerjar"), description: [ Doté d'une grande subtilité dans ses mécaniques tout comme ses attributions, l'Einherjar a pour rôle d'agresser une cible jusqu'à ce que mort s'ensuive. diff --git a/chapters/schools/franc_tireur.typ b/chapters/schools/franc_tireur.typ index 6702e2f..9209685 100644 --- a/chapters/schools/franc_tireur.typ +++ b/chapters/schools/franc_tireur.typ @@ -1,9 +1,9 @@ -#import "/setup/setup.typ": gls, gls-description, school_presentation +#import "/setup/setup.typ": gls, gls-description, radar-graph, school_presentation // Above average skill ceiling & low skill floor, low survivability, low CC & Qol, difficult but straightforward gameplay #school_presentation(( title: "Franc Tirreur", illustration: "/images/schools/franc_tireur.jpg", - radar: "/images/icons/nodata.png", + radar: radar-graph("franc-tireur"), description: [ Excellant dans l'art d'infliger des dégâts à longue distance, le franc-tireur possède une grande capacité utilitaire. Ce soutien a longue distance lui permet d'apporter l'aide nécessaire à son équipe au moment critique tout en restant relativement hors d'atteinte. diff --git a/chapters/schools/guerrier_mage.typ b/chapters/schools/guerrier_mage.typ index 6924be4..7b14f25 100644 --- a/chapters/schools/guerrier_mage.typ +++ b/chapters/schools/guerrier_mage.typ @@ -1,10 +1,10 @@ -#import "/setup/setup.typ": gls, gls-description, ravhelp, school_presentation +#import "/setup/setup.typ": gls, gls-description, radar-graph, ravhelp, school_presentation // High skill ceiling, low skill floor, average survivability, very low CC, high QoL, non-straightforward gameplay #school_presentation(( title: "Guerrier Mage", illustration: "/images/schools/guerrier_mage.jpg", - radar: "/images/icons/nodata.png", + radar: radar-graph("guerrier-mage"), description: [ Guerrier élémentaire, le Guerrier Mage excelle dans l'art d'infuser ses attaques de forces élémentaires. Capable d'infliger une grande quantité diff --git a/chapters/schools/heavy_weapon_specialist.typ b/chapters/schools/heavy_weapon_specialist.typ index 54a3bf1..a58108c 100644 --- a/chapters/schools/heavy_weapon_specialist.typ +++ b/chapters/schools/heavy_weapon_specialist.typ @@ -1,8 +1,8 @@ -#import "/setup/setup.typ": school_presentation +#import "/setup/setup.typ": radar-graph, school_presentation #school_presentation(( title: "Spécialiste des Armes Lourdes", illustration: "/images/schools/specialiste_armes_lourdes.jpg", - radar: "/images/icons/nodata.png", + radar: radar-graph("heavy-weapon-specialist"), description: [ Excelle à infliger de lourds dégâts et à incapaciter ses cibles. diff --git a/chapters/schools/lancier.typ b/chapters/schools/lancier.typ index 48c0556..df4674f 100644 --- a/chapters/schools/lancier.typ +++ b/chapters/schools/lancier.typ @@ -1,9 +1,9 @@ -#import "/setup/setup.typ": gls, gls-description, school_presentation +#import "/setup/setup.typ": gls, gls-description, radar-graph, school_presentation // High skill ceiling, average survivability, average CC, high QoL, counter-intuitive gameplay #school_presentation(( title: "Lancier", illustration: "/images/schools/lancier.png", - radar: "/images/icons/nodata.png", + radar: radar-graph("lancier"), description: [ Maîtres dans les arts du combat aérien, les lanciers sont implacables guerriers, capables de maintenir une cible sous un déluge d'attaques sans jamais sembler s'immobiliser. diff --git a/chapters/schools/mage_bestial.typ b/chapters/schools/mage_bestial.typ index 7aeee9b..24ddd0f 100644 --- a/chapters/schools/mage_bestial.typ +++ b/chapters/schools/mage_bestial.typ @@ -1,10 +1,10 @@ -#import "/setup/setup.typ": gls, gls-description, ravhelp, school_presentation +#import "/setup/setup.typ": gls, gls-description, radar-graph, ravhelp, school_presentation // Very high skill ceiling, skill ceiling mostly in choices outside of fight, high survivability, low CC, high QoL, non-straightforward self-imposed gameplay #school_presentation(( title: "Mage Bestial", illustration: "/images/schools/mage_bestial.jpg", - radar: "/images/icons/nodata.png", + radar: radar-graph("mage-bestial"), description: [ Capables de prendre une partie de l'apparence et les capacités des enfants des calamités, les Mages Bestiaux cumulent au fil de leur évolution un diff --git a/chapters/schools/maitre_lames.typ b/chapters/schools/maitre_lames.typ index a1adcca..efc1fa1 100644 --- a/chapters/schools/maitre_lames.typ +++ b/chapters/schools/maitre_lames.typ @@ -1,9 +1,9 @@ -#import "/setup/setup.typ": gls, gls-description, school_presentation +#import "/setup/setup.typ": gls, gls-description, radar-graph, school_presentation // High skill ceiling, skill floor medium, high survivability, low CC, very high QoL, straightforward-ish gameplay #school_presentation(( title: "Maître-Lames", illustration: "/images/schools/maitre_lames.jpg", - radar: "/images/icons/nodata.png", + radar: radar-graph("maitre-lames"), description: [ Autant aptes dans leurs capacités offensives que défensives, les maîtres-lames sont capables d'imposer leur tempo sur le champ de bataille. diff --git a/chapters/schools/protecteur.typ b/chapters/schools/protecteur.typ index 86d355c..824a7c9 100644 --- a/chapters/schools/protecteur.typ +++ b/chapters/schools/protecteur.typ @@ -1,9 +1,9 @@ -#import "/setup/setup.typ": gls, gls-description, school_presentation +#import "/setup/setup.typ": gls, gls-description, radar-graph, school_presentation // Low skill ceiling & very low skill floor, extremely high survivability, average QoL & CC, straightforward gameplay #school_presentation(( title: "Protecteur", illustration: "/images/schools/protecteur.jpg", - radar: "/images/icons/nodata.png", + radar: radar-graph("protecteur"), description: [ Rempart inflexible, capable d'encaisser sans broncher les éléments les plus destructeurs, le protecteur excelle dans l'art de la survie face aux créatures les plus agressives. diff --git a/chapters/schools/sangremage.typ b/chapters/schools/sangremage.typ index 0a0aaf0..7aa87a5 100644 --- a/chapters/schools/sangremage.typ +++ b/chapters/schools/sangremage.typ @@ -1,9 +1,9 @@ -#import "/setup/setup.typ": gls, gls-description, ravhelp, school_presentation +#import "/setup/setup.typ": gls, gls-description, radar-graph, ravhelp, school_presentation // Very high skill ceiling, very low survivability, low CC & QoL, non-straightforward non-linear proactive gameplay #school_presentation(( title: "Sangremage", illustration: "/images/schools/sangremage.jpg", - radar: "/images/icons/nodata.png", + radar: radar-graph("sangremage"), description: [ Puissant mage élémentaire, il puise sa force dans les pactes abyssaux passés dans le sang. Conjurant de puissants effets de Sangressance dans une diff --git a/setup/generation/radar_graphs.typ b/setup/generation/radar_graphs.typ index e69de29..37a782a 100644 --- a/setup/generation/radar_graphs.typ +++ b/setup/generation/radar_graphs.typ @@ -0,0 +1,148 @@ +// Aggregate the balancing columns from every school TSV and render comparable +// radar charts. Axis totals are normalized against the highest class total for +// that axis across the complete `school-sources` collection. +#import "../theme/variables.typ": theme +#import "@preview/primaviz:0.6.0": radar-chart + +// Selected TSV fields and their reader-facing labels. Add, remove, reorder, or +// rename axes here. `aliases` handles known variations in source headers. +#let radar-fields = ( + (field: "Support", display: "Support", aliases: ()), + (field: "Dégats", display: "Dégâts", aliases: ("Dégâts",)), + (field: "Survivabilité", display: "Survie", aliases: ()), + (field: "Mobilité", display: "Mobilité", aliases: ()), + (field: "C.C", display: "Contrôle", aliases: ()), + (field: "Altérations", display: "Altérations", aliases: ()), + (field: "QoL", display: "Confort", aliases: ()), + (field: "AB", display: "Brise-armure", aliases: ()), + (field: "Compléxité", display: "Complexité", aliases: ("Complexité", "Compl")), +) + +// Canonical public class names and their data sources. +#let school-sources = ( + artilleur: "/data/src/schools/artilleur.tsv", + einerjar: "/data/src/schools/einerjar.tsv", + franc-tireur: "/data/src/schools/franc_tirreur.tsv", + guerrier-mage: "/data/src/schools/guerrier_mage.tsv", + heavy-weapon-specialist: "/data/src/schools/heavy_weapon_specialist.tsv", + lancier: "/data/src/schools/lancier.tsv", + mage-bestial: "/data/src/schools/mage_bestial.tsv", + maitre-lames: "/data/src/schools/maitre_lames.tsv", + protecteur: "/data/src/schools/protecteur.tsv", + sangremage: "/data/src/schools/sangremage.tsv", +) + +#let class-aliases = ( + franc-tirreur: "franc-tireur", + specialiste-armes-lourdes: "heavy-weapon-specialist", +) + +#let canonical-class-name(name) = { + let normalized = lower(name).replace("_", "-").replace(" ", "-") + class-aliases.at(normalized, default: normalized) +} + +#let numeric-cell(value) = { + let value = value.trim() + if value.match(regex("^-?(?:\d+(?:\.\d+)?|\.\d+)$")) != none { + float(value) + } else { + none + } +} + +#let field-index(header, field) = { + let names = (field.field,) + field.aliases + for name in names { + let index = header.position(value => value.trim() == name) + if index != none { return index } + } + panic( + "Radar field `" + field.field + "` was not found in TSV header: " + + header.join(", "), + ) +} + +// Return the raw summed balancing totals for one TSV source. +// Blank and symbolic annotations such as `A`, `M`, or `1/X` are ignored. +#let balancing-totals(source, fields: radar-fields) = { + let rows = csv(source, delimiter: "\t") + let header-index = rows.position(row => "Technique" in row) + if header-index == none { + panic("No technique header found in `" + str(source) + "`") + } + + let header = rows.at(header-index) + let indices = fields.map(field => field-index(header, field)) + let totals = fields.map(_ => 0.0) + + for row in rows.slice(header-index + 1) { + for (axis, column) in indices.enumerate() { + if column < row.len() { + let value = numeric-cell(row.at(column)) + if value != none { totals.at(axis) += value } + } + } + } + totals +} + +// Return raw totals for every configured class, keyed by canonical class name. +#let all-balancing-totals(fields: radar-fields) = { + let totals = (:) + for (name, source) in school-sources { + totals.insert(name, balancing-totals(source, fields: fields)) + } + totals +} + +#let axis-maxima(totals, axis-count) = { + range(axis-count).map(axis => { + let maximum = 0.0 + for (_, values) in totals { + maximum = calc.max(maximum, values.at(axis)) + } + maximum + }) +} + +// Render a class radar graph. `fields` can override `radar-fields` for a +// one-off graph while keeping the same field/display/aliases structure. +#let radar-graph(class-name, fields: radar-fields, size: 170pt) = { + let name = canonical-class-name(class-name) + if name not in school-sources { + panic( + "Unknown radar class `" + class-name + "`. Available classes: " + + school-sources.keys().join(", "), + ) + } + let source = school-sources.at(name) + let all-totals = all-balancing-totals(fields: fields) + let values = all-totals.at(name) + let maxima = axis-maxima(all-totals, fields.len()) + + let normalized = values.enumerate().map(((axis, value)) => { + let maximum = maxima.at(axis) + if maximum == 0 { 0 } else { value / maximum * 100 } + }) + radar-chart( + ( + labels: fields.map(field => field.display), + series: ((name: name, values: normalized),), + ), + size: size, + axis-max-value: 100, + show-legend: false, + show-value-labels: false, + fill-opacity: 24%, + theme: ( + palette: (theme.blood,), + text-color: theme.ink, + border-color: theme.border, + background: none, + show-grid: true, + base-size: 6pt, + base-gap: 4pt, + ), + ) +} diff --git a/setup/models/school.typ b/setup/models/school.typ index 0846ee2..fb118f9 100644 --- a/setup/models/school.typ +++ b/setup/models/school.typ @@ -388,10 +388,11 @@ )[ #align(center)[ #spacers.fantasy-section("PROFIL", theme-name: "warm")[ - #image( - class_info.radar, - width: 82%, - ) + #if type(class_info.radar) == str { + image(class_info.radar, width: 82%) + } else { + class_info.radar + } ] ] ] diff --git a/setup/setup.typ b/setup/setup.typ index ef13cf7..f8464e1 100644 --- a/setup/setup.typ +++ b/setup/setup.typ @@ -8,6 +8,7 @@ #import "theme/symbols.typ" as symbols #import "theme/tables.typ" as st #import "generation/csv-table.typ" as csv_import +#import "generation/radar_graphs.typ" as radar //----- Re-expose shared project data ----- #let ravenous = ravenous @@ -22,6 +23,10 @@ #let hunbal = hunbal #let bigscope = macros.bigscope #let csv-table = csv_import.csv-table +#let radar-fields = radar.radar-fields +#let radar-graph = radar.radar-graph +#let balancing-totals = radar.balancing-totals +#let all-balancing-totals = radar.all-balancing-totals #let kw(c) = [* #c *] //----- Public template for class presentations -----