diff --git a/README.md b/README.md index 62fe67b..2e28676 100644 --- a/README.md +++ b/README.md @@ -43,7 +43,7 @@ can find the `tinymist` and `typstyle` executables. ### Helix -Add the following to your global Helix `languages.toml` or to +Add the following to your global Helix `~/.config/helix/languages.toml` or to `.helix/languages.toml` inside this repository for a project-local setup: ```toml diff --git a/chapters/craft/traps.typ b/chapters/craft/traps.typ index ee82ab6..0bba898 100644 --- a/chapters/craft/traps.typ +++ b/chapters/craft/traps.typ @@ -7,11 +7,14 @@ La préparation d'un piège nécessite une grande quantité de moyens et peut ai == Choix des effets Créer un piège revient à définir l'effet qui est désiré de ce dernier, ainsi qu'en décrire la taille et l'apparence. De ces deux derniers le @maitredejeu définira une liste d'effets, de prérequis et de matériaux auquel l'équipe devra se soumettre pour placer le piège. -#craft-legend(( - ([@ar_tier:short], [Maîtrise], [niveau requis pour préparer le piège]), - ([@ar_lvl:short], [Difficulté], [niveau d'artisanat minimal de l'équipe]), - ([@ar_time:short], [Temps], [demi-heures de travail pour l'équipe]), -), theme-name: "steingrund") +#craft-legend( + ( + ([@ar_tier:short], [Maîtrise], [niveau requis pour préparer le piège]), + ([@ar_lvl:short], [Difficulté], [niveau d'artisanat minimal de l'équipe]), + ([@ar_time:short], [Temps], [demi-heures de travail pour l'équipe]), + ), + theme-name: "steingrund", +) #craft-table( "/data/src/craft/traps.csv", @@ -47,7 +50,7 @@ Les prérequis correspondent à des compétences ou objets que les chasseurs doi Les pièges reservés à une classe possèdent la particularitée de ne pouvoir etre posés qu'une fois par chasse pour chaque chasseur de cette classe. === Matériaux -Les matériaux sont des ressources qui doivent être préparées par les chasseurs. Là ou certains pièges peuvent tout simplement être fait à l'aide de monticules de terre ou cailloux mis en équilibre, d'autres nécessitent des matériaux plus raffinés.Préparer ces matériaux necessite une a deux étoiles de ressources par piége ou tout les deux pièges, le jet quand a lui representera uniquement le temps supplémentaire à la préparation, un echec infligeant un malus de #macros.timelvl(1) plutot qu'une perde de matériaux. +Les matériaux sont des ressources qui doivent être préparées par les chasseurs. Là ou certains pièges peuvent tout simplement être fait à l'aide de monticules de terre ou cailloux mis en équilibre, d'autres nécessitent des matériaux plus raffinés. Préparer ces matériaux nécéssitera parfois un jet demandé par le @maitredejeu, ou peut étre éludé en temps ou ressources dépensées. ==== Matériaux Travaillés Désignent les matériaux ayant été préparés sur le terrain. Qu'il s'agisse d'arbres débités, cailloux tassés, lianes tressées entre elles, rondins préparés en pals, etc. Ces derniers peuvent être préparés à l'aide d'un jet de survie. diff --git a/data/config/balance_report.yaml b/data/config/balance_report.yaml index fcf10ef..60674df 100644 --- a/data/config/balance_report.yaml +++ b/data/config/balance_report.yaml @@ -47,6 +47,9 @@ weapons: default_precision_modifier: 0 default_action_cost: 1 +classes: + integrity_per_gauge_threshold: 3 + # Ordered list of report sections. Remove or comment an entry to hide it. chapters: - classes.overview @@ -56,6 +59,7 @@ chapters: - classes.actions - classes.interruptions - classes.balance_families + - classes.integrity - classes.alterations - classes.details - origins.summary diff --git a/setup/analysis/class_cost_report.typ b/setup/analysis/class_cost_report.typ index c1c8b51..065fe20 100644 --- a/setup/analysis/class_cost_report.typ +++ b/setup/analysis/class_cost_report.typ @@ -12,6 +12,7 @@ #import "class_action_report.typ": school-action-report #import "class_interrupt_report.typ": school-interruption-report #import "class_balance_family_report.typ": school-balance-family-report +#import "class_integrity_report.typ": school-integrity-report #import "report_config.typ": chapter-enabled #let cost-series(metrics) = ( @@ -270,6 +271,7 @@ if chapter-enabled("classes.balance_families") { school-balance-family-report() } + if chapter-enabled("classes.integrity") { school-integrity-report() } if chapter-enabled("classes.alterations") { school-alteration-report() } if chapter-enabled("classes.details") { for (_, class-data) in classes { class-cost-section(class-data) } diff --git a/setup/analysis/class_integrities.typ b/setup/analysis/class_integrities.typ new file mode 100644 index 0000000..54c069e --- /dev/null +++ b/setup/analysis/class_integrities.typ @@ -0,0 +1,205 @@ +// Heuristic extraction of integrity granted to objects by school techniques. +#import "../generation/radar_graphs.typ": school-sources +#import "../build_config.typ": tier-is-enabled +#import "class_costs.typ": class-display-names, numeric-cost +#import "class_balance_families.typ": all-school-balance-techniques +#import "report_config.typ": class-balance-settings, class-weapon-settings + +#let integrity-threshold = class-balance-settings.integrity_per_gauge_threshold + +#let normalized-integrity-text(value) = lower(value).replace("’", "'") + .replace("à", "a").replace("â", "a").replace("é", "e").replace("è", "e") + .replace("ê", "e").replace("ô", "o").replace("î", "i").replace("ï", "i") + .replace("ù", "u").replace("û", "u").replace("ç", "c") + +#let integrity-number(token) = ( + un: 1, une: 1, deux: 2, trois: 3, quatre: 4, cinq: 5, +).at(token, default: if token.match(regex("^[0-9]+$")) != none { int(token) } else { none }) + +#let inline-gauge-cost(effect) = { + let found = lower(effect).match(regex( + "(?:dépensez?|dépenser|depensez?|depenser|coût|cout|prix).{0,28}([0-9]+)@jauge", + )) + if found == none { none } else { int(found.captures.first()) } +} + +#let analyzed-integrity(value, gauge) = { + let ratio = if value == none or gauge == none or gauge == 0 { none } else { value / gauge } + ( + ratio: ratio, + flagged: value != none and ((gauge == none or gauge == 0) or ratio > integrity-threshold), + status: if value == none { "Valeur symbolique" } + else if gauge == none or gauge == 0 { "À contrôler · sans jauge" } + else if ratio > integrity-threshold { "Au-dessus du seuil" } + else { "Dans le seuil" }, + ) +} + +#let analyze-school-integrities(name, source) = { + let rows = csv(source, delimiter: "\t") + let records = () + let current-tier = none + let columns = none + for row in rows { + if row.len() == 0 { continue } + let first = row.first().trim() + if first.starts-with("Tier") { + let digits = first.match(regex("\\d+")) + if digits != none { current-tier = int(digits.text) } + continue + } + if first == "Technique" { + columns = ( + level: row.position(cell => cell.trim() == "Niv"), + gauge: row.position(cell => cell.trim() == "Jauge"), + effect: row.position(cell => cell.trim() == "Effet"), + ) + continue + } + if first == "" or current-tier == none or columns == none or not tier-is-enabled(current-tier) { continue } + if columns.effect >= row.len() { continue } + let effect = row.at(columns.effect).trim() + let text = lower(effect).replace("’", "'") + let mentions-integrity = ( + text.contains("integrité") or text.contains("integrite") + or text.contains("@rl_integrite") + ) + if not mentions-integrity { continue } + let gauge-cell = if columns.gauge != none and columns.gauge < row.len() { + numeric-cost(row.at(columns.gauge)) + } else { none } + let gauge = if gauge-cell != none { gauge-cell } else { inline-gauge-cost(effect) } + let level = if columns.level != none and columns.level < row.len() { row.at(columns.level).trim() } else { "" } + + let add(value, raw, kind) = { + let analysis = analyzed-integrity(value, gauge) + ( + class: name, display: class-display-names.at(name), tier: current-tier, + level: level, technique: first, gauge: gauge, value: value, raw: raw, + kind: kind, effect: effect, ..analysis, + ) + } + + for found in text.matches(regex( + "([0-9]+|un|une|deux|trois|quatre|cinq)\\s+points?.{0,3}int.grit.", + )) { + let before = text.slice(calc.max(0, found.start - 52), found.start) + let destructive = before.find(regex("perd|perte|redui|fait perdre|au moins|reste à|reste a")) != none + if not destructive { + let kind = if before.find(regex("gagne|supplementaire|augmente")) != none { "Bonus" } else { "Base" } + records.push(add(integrity-number(found.captures.first()), found.text, kind)) + } + } + for found in text.matches(regex( + "([0-9]+|un|une|deux|trois|quatre|cinq)\\s+@rl_integrite(?::short)?", + )) { + records.push(add(integrity-number(found.captures.first()), found.text, "Base")) + } + for found in text.matches(regex( + "@rl_integrite(?::short)?\\s+([0-9]+|psy|psyche|force|volonte)", + )) { + let token = found.captures.first() + let value = if token == "psy" or token == "psyche" { + class-weapon-settings.characteristic_values.at("Psy", default: none) + } else { integrity-number(token) } + records.push(add(value, found.text, if value == none { "Symbolique" } else { "Base" })) + } + for found in text.matches(regex( + "int.grit. (?:de |égale à |egale a )?([0-9]+|un|une|deux|trois|quatre|cinq)", + )) { + records.push(add(integrity-number(found.captures.first()), found.text, "Base")) + } + for found in text.matches(regex( + "(?:gagne(?:nt|z)?|bénéficie(?:nt|z)?).{0,24}([0-9]+|un|une|deux|trois|quatre|cinq) points? de protection et d'int.grit.", + )) { + records.push(add(integrity-number(found.captures.first()), found.text, "Bonus")) + } + if text.find(regex("int.grit. (?:égale à |egale a |que )?(?:votre )?(?:psy|psyché|psyche) moins (?:trois|3)")) != none { + let psy = class-weapon-settings.characteristic_values.at("Psy", default: none) + records.push(add(if psy == none { none } else { psy - 3 }, "Psy − 3", "Formule")) + } else if text.find(regex("autant (?:de points )?d'int.grit. que votre (?:psy|psyché|psyche)")) != none { + records.push(add(class-weapon-settings.characteristic_values.at("Psy", default: none), "Psy", "Formule")) + } + if text.find(regex("ne poss[eèé]de pas d'int.grit.")) != none { + records.push(add(0, "Aucune intégrité", "Base")) + } + } + let seen = () + let distinct = () + for item in records { + let key = item.technique + "/" + item.level + "/" + item.kind + "/" + item.raw + if key not in seen { + seen.push(key) + distinct.push(item) + } + } + distinct +} + +#let extract-technique-integrities(item) = { + let effect = item.effect + let text = lower(effect).replace("’", "'") + let gauge-cell = numeric-cost(item.gauge) + let gauge = if gauge-cell != none { gauge-cell } else { inline-gauge-cost(effect) } + let records = () + let add(value, raw, kind) = { + let analysis = analyzed-integrity(value, gauge) + ( + class: item.class, display: item.display, tier: item.tier, + level: item.level, technique: item.technique, gauge: gauge, + value: value, raw: raw, kind: kind, effect: effect, ..analysis, + ) + } + for found in text.matches(regex( + "([0-9]+|un|une|deux|trois|quatre|cinq)\\s+points?.{0,3}int.grit.", + )) { + let before = text.slice(calc.max(0, found.start - 52), found.start) + if before.find(regex("perd|perte|rédui|redui|fait perdre|au moins|reste à|reste a")) == none { + records.push(add( + integrity-number(found.captures.first()), found.text, + if before.find(regex("gagne|supplémentaire|supplementaire|augmente")) != none { "Bonus" } else { "Base" }, + )) + } + } + for found in text.matches(regex( + "([0-9]+|un|une|deux|trois|quatre|cinq)\\s+@rl_integrite(?::short)?", + )) { records.push(add(integrity-number(found.captures.first()), found.text, "Base")) } + for found in text.matches(regex( + "@rl_integrite(?::short)?\\s+([0-9]+|psy|psyché|psyche|force|volonté|volonte)", + )) { + let token = found.captures.first() + let value = if token == "psy" or token == "psyché" or token == "psyche" { + class-weapon-settings.characteristic_values.at("Psy", default: none) + } else { integrity-number(token) } + records.push(add(value, found.text, if value == none { "Symbolique" } else { "Base" })) + } + for found in text.matches(regex( + "int.grit. (?:de |égale à |egale a )?([0-9]+|un|une|deux|trois|quatre|cinq)", + )) { records.push(add(integrity-number(found.captures.first()), found.text, "Base")) } + for found in text.matches(regex( + "(?:gagne(?:nt|z)?|bénéficie(?:nt|z)?).{0,24}([0-9]+|un|une|deux|trois|quatre|cinq) points? de protection et d'int.grit.", + )) { records.push(add(integrity-number(found.captures.first()), found.text, "Bonus")) } + if text.find(regex("int.grit. (?:égale à |egale a |que )?(?:votre )?(?:psy|psyché|psyche) moins (?:trois|3)")) != none { + let psy = class-weapon-settings.characteristic_values.at("Psy", default: none) + records.push(add(if psy == none { none } else { psy - 3 }, "Psy − 3", "Formule")) + } else if text.find(regex("autant (?:de points )?d'int.grit. que votre (?:psy|psyché|psyche)")) != none { + records.push(add(class-weapon-settings.characteristic_values.at("Psy", default: none), "Psy", "Formule")) + } + if text.find(regex("ne poss[eèé]de pas d'int.grit.")) != none { + records.push(add(0, "Aucune intégrité", "Base")) + } + let seen = () + let distinct = () + for record in records { + let key = record.kind + "/" + record.raw + if key not in seen { seen.push(key); distinct.push(record) } + } + distinct +} + +#let all-school-integrities = all-school-balance-techniques.map( + extract-technique-integrities, +).flatten() +#let numeric-school-integrities = all-school-integrities.filter(item => item.value != none) +#let flagged-school-integrities = all-school-integrities.filter(item => item.flagged) +#let symbolic-school-integrities = all-school-integrities.filter(item => item.value == none) diff --git a/setup/analysis/class_integrity_report.typ b/setup/analysis/class_integrity_report.typ new file mode 100644 index 0000000..fd366fd --- /dev/null +++ b/setup/analysis/class_integrity_report.typ @@ -0,0 +1,68 @@ +// Comparison and audit of object integrity created by school skills. +#import "@preview/primaviz:0.6.0": horizontal-bar-chart +#import "class_integrities.typ": * +#import "report_style.typ": chart-theme, metric-card, rounded +#import "../build_config.typ": school-trigram +#import "../theme/symbols.typ": jauge-box +#import "../theme/tables.typ" as tables + +#let integrity-label(item) = school-trigram(item.class) + " · " + item.technique + " n" + item.level + +#let school-integrity-report() = { + pagebreak() + heading(level: 2)[Classes — Intégrité des objets] + [L’extraction conserve les intégrités de base, les bonus et les formules + caractéristiques. Le seuil configurable est strictement supérieur à + #integrity-threshold points d’intégrité par point de #jauge-box jauge. Une + intégrité positive sans coût de jauge détecté est signalée séparément; les + pertes d’intégrité et les simples références à l’intégrité existante sont + exclues.] + + grid( + columns: (1fr,) * 4, column-gutter: 8pt, + metric-card("Mentions retenues", all-school-integrities.len()), + metric-card("Valeurs calculées", numeric-school-integrities.len()), + metric-card("À contrôler", flagged-school-integrities.len(), note: [ratio > #integrity-threshold ou sans jauge]), + metric-card("Symboliques", symbolic-school-integrities.len()), + ) + + let comparable = numeric-school-integrities.filter(item => item.gauge != none and item.gauge > 0).sorted( + key: item => -item.ratio, + ) + if comparable.len() > 0 { + heading(level: 3)[Comparaison — Intégrité par point de jauge] + horizontal-bar-chart( + ( + labels: comparable.map(integrity-label), + values: comparable.map(item => calc.round(item.ratio, digits: 2)), + ), + width: 100%, height: calc.max(170pt, comparable.len() * 17pt), + x-label: [Intégrité / jauge], show-values: true, theme: chart-theme, + ) + } + + heading(level: 3)[Compétences et valeurs extraites] + let rows = all-school-integrities.sorted(key: item => ( + (if item.flagged { "0" } else { "1" }) + "/" + item.display + "/" + str(item.tier) + "/" + item.technique + )).map(item => ( + school-trigram(item.class), "T" + str(item.tier), item.level, + item.technique, item.kind, item.raw, + if item.value == none { [—] } else { rounded(item.value, digits: 1) }, + if item.gauge == none { [—] } else { rounded(item.gauge, digits: 1) }, + if item.ratio == none { [—] } else { rounded(item.ratio, digits: 2) }, + if item.flagged { strong(item.status) } else { item.status }, + item.effect, + )) + tables.set-table-style( + table( + columns: (0.3fr, 0.25fr, 0.24fr, 0.92fr, 0.48fr, 0.72fr, 0.35fr, 0.35fr, 0.4fr, 0.78fr, 2.3fr), + align: (left, center, center, left, left, left, right, right, right, left, left), + table.header( + [Cl.], [T.], [Niv.], [Tech.], [Type], [Extraction], + [Int.], [#jauge-box J.], [Int./J.], [État], [Effet], + ), + ..rows.flatten(), + ), + table-theme: "steingrund", text-size: 5.5pt, + ) +} diff --git a/setup/analysis/report_config.typ b/setup/analysis/report_config.typ index 8d985a2..74f4c0c 100644 --- a/setup/analysis/report_config.typ +++ b/setup/analysis/report_config.typ @@ -4,6 +4,7 @@ #let sensitivity-settings = weapon-settings.sensitivity #let armor-settings = weapon-settings.armor #let class-weapon-settings = weapon-settings.class_weapons +#let class-balance-settings = report-config.classes #let enabled-report-chapters = report-config.chapters #let inclusive-range(bounds) = range(bounds.min, bounds.max + 1)