415 lines
14 KiB
Plaintext
415 lines
14 KiB
Plaintext
// Audit area attacks that do not declare defensive thresholds through the
|
||
// canonical `aoe_thresholds` macro.
|
||
#import "../generation/radar_graphs.typ": school-sources
|
||
#import "../generation/creature-data.typ": master-creatures
|
||
#import "origin_metrics.typ": origin-sources
|
||
#import "../theme/tables.typ" as tables
|
||
#import "report_style.typ": metric-card, report-theme
|
||
|
||
#let has-aoe-thresholds(value) = lower(str(value)).contains("#aoe_thresholds")
|
||
|
||
#let aoe-signals(value) = {
|
||
let text = lower(str(value))
|
||
let signals = ()
|
||
if (text.contains("aire d'effet") or text.contains("aire d’effet")) and not (
|
||
text.contains("si cette attaque était une aire d'effet")
|
||
or text.contains("si cette attaque était une aire d’effet")
|
||
) {
|
||
signals.push("aire d’effet")
|
||
}
|
||
if text.match(regex("(^|[^a-z])aoe([^a-z]|$)")) != none {
|
||
signals.push("AOE")
|
||
}
|
||
if text.contains("zone d'effet") or text.contains("zone d’effet") {
|
||
signals.push("zone d’effet")
|
||
}
|
||
if text.match(regex("(^|[^a-zàâçéèêëîïôûùüÿñæœ])c[oô]ne([^a-zàâçéèêëîïôûùüÿñæœ]|$)")) != none and (
|
||
text.contains("attaque") or text.contains("dégât") or text.contains("inflige") or text.contains("souffle")
|
||
) {
|
||
signals.push("cône")
|
||
}
|
||
let damage = "(?:d[eé]g[aâ]t|inflige|explos)"
|
||
let area = "(?:zone|rayon)"
|
||
if text.match(regex(damage + ".{0,60}" + area)) != none or text.match(regex(
|
||
area + ".{0,60}" + damage,
|
||
)) != none {
|
||
signals.push("zone offensive")
|
||
}
|
||
signals.dedup()
|
||
}
|
||
|
||
#let macro-number(value, field) = {
|
||
let found = str(value).match(regex(field + ":\s*\"?(-?\d+)"))
|
||
if found == none { none } else { int(found.captures.first()) }
|
||
}
|
||
|
||
#let macro-success(value, field) = {
|
||
let normal = str(value).match(regex(
|
||
field + ":\s*\"?-?\d+\s*\((\d+)r\)",
|
||
))
|
||
let reversed = str(value).match(regex(
|
||
field + ":\s*\"?-?\d+\s*\(r(\d+)\)",
|
||
))
|
||
if normal != none {
|
||
int(normal.captures.first())
|
||
} else if reversed != none {
|
||
int(reversed.captures.first())
|
||
} else { none }
|
||
}
|
||
|
||
#let fixed-success(value) = {
|
||
if value == none or value == "" { return none }
|
||
let found = str(value).match(regex("(-?\d+)r"))
|
||
if found == none { none } else { int(found.captures.first()) }
|
||
}
|
||
|
||
#let school-aoe-threshold-usages = {
|
||
let usages = ()
|
||
for (school, source) in school-sources {
|
||
let rows = csv(source, delimiter: "\t")
|
||
let tier = none
|
||
let effect-column = none
|
||
for row in rows {
|
||
if row.len() == 0 { continue }
|
||
let first = row.first().trim()
|
||
if first.starts-with("Tier ") {
|
||
tier = first.replace(regex("\D"), "")
|
||
} else if first == "Technique" {
|
||
effect-column = row.position(cell => cell.trim() == "Effet")
|
||
} else if first != "" and effect-column != none and effect-column < row.len() {
|
||
let effect = row.at(effect-column)
|
||
if has-aoe-thresholds(effect) {
|
||
usages.push((
|
||
owner: school.replace("-", " "),
|
||
stage: if tier == none { "—" } else { tier },
|
||
ability: first,
|
||
repositionning: macro-number(effect, "repositionning"),
|
||
repositionning-success: macro-success(effect, "repositionning"),
|
||
dodge: macro-number(effect, "dodge"),
|
||
dodge-success: macro-success(effect, "dodge"),
|
||
parry: macro-number(effect, "parry"),
|
||
parry-success: macro-success(effect, "parry"),
|
||
))
|
||
}
|
||
}
|
||
}
|
||
}
|
||
usages
|
||
}
|
||
|
||
#let origin-aoe-threshold-usages = {
|
||
let usages = ()
|
||
for source in origin-sources {
|
||
let origin = yaml(source.source)
|
||
for stage in origin.stades {
|
||
for ability in stage.abilities {
|
||
let effect = ability.at("description", default: "")
|
||
if has-aoe-thresholds(effect) {
|
||
usages.push((
|
||
owner: origin.name,
|
||
stage: str(stage.number),
|
||
ability: ability.at("name", default: "Capacité sans nom"),
|
||
repositionning: macro-number(effect, "repositionning"),
|
||
repositionning-success: macro-success(effect, "repositionning"),
|
||
dodge: macro-number(effect, "dodge"),
|
||
dodge-success: macro-success(effect, "dodge"),
|
||
parry: macro-number(effect, "parry"),
|
||
parry-success: macro-success(effect, "parry"),
|
||
))
|
||
}
|
||
}
|
||
}
|
||
}
|
||
usages
|
||
}
|
||
|
||
#let creature-aoe-threshold-usages = {
|
||
let usages = ()
|
||
for creature in master-creatures {
|
||
for phase in creature.phases {
|
||
for group in phase.groups {
|
||
for attack in group.attacks {
|
||
if has-aoe-thresholds(attack.effects) {
|
||
let successes = fixed-success(attack.raw.success)
|
||
usages.push((
|
||
owner: creature.name,
|
||
stage: phase.name,
|
||
ability: attack.name,
|
||
repositionning: if attack.repositionning == "" { none } else {
|
||
int(attack.repositionning)
|
||
},
|
||
repositionning-success: successes,
|
||
dodge: if attack.dodge == "" { none } else { int(attack.dodge) },
|
||
dodge-success: successes,
|
||
parry: if attack.parry == "" { none } else { int(attack.parry) },
|
||
parry-success: successes,
|
||
))
|
||
}
|
||
}
|
||
}
|
||
}
|
||
}
|
||
usages
|
||
}
|
||
|
||
#let difficulty-matrix(usages) = {
|
||
let configured = usages.filter(item => item.repositionning != none)
|
||
if configured.len() == 0 { return [] }
|
||
let thresholds = configured.map(item => item.repositionning).dedup().sorted()
|
||
let known-successes = configured
|
||
.map(item => item.repositionning-success)
|
||
.filter(value => value != none)
|
||
.dedup()
|
||
.sorted()
|
||
let success-columns = known-successes + if configured.any(item => (
|
||
item.repositionning-success == none
|
||
)) { (none,) } else { () }
|
||
let counts = thresholds.map(threshold => success-columns.map(successes => configured.filter(
|
||
item => item.repositionning == threshold
|
||
and item.repositionning-success == successes,
|
||
).len())).flatten()
|
||
let maximum = calc.max(..counts)
|
||
let cells = ()
|
||
for threshold in thresholds {
|
||
cells.push([Seuil #threshold])
|
||
for successes in success-columns {
|
||
let count = configured.filter(item => (
|
||
item.repositionning == threshold
|
||
and item.repositionning-success == successes
|
||
)).len()
|
||
let shade = if count == 0 {
|
||
report-theme.parchment.transparentize(70%)
|
||
} else {
|
||
report-theme.attack-area.transparentize(82% - 52% * count / maximum)
|
||
}
|
||
cells.push(table.cell(fill: shade, align: center)[
|
||
#if count == 0 { text(fill: report-theme.muted-ink.lighten(30%))[·] } else { count }
|
||
])
|
||
}
|
||
}
|
||
tables.set-table-style(
|
||
table(
|
||
columns: (1.1fr,) + (0.7fr,) * success-columns.len(),
|
||
align: (left,) + (center,) * success-columns.len(),
|
||
table.header(
|
||
[Repositionnement],
|
||
..success-columns.map(value => if value == none { [Réussites ?] } else {
|
||
[#value réussites]
|
||
}),
|
||
),
|
||
..cells,
|
||
),
|
||
table-theme: "steingrund",
|
||
text-size: 6.8pt,
|
||
)
|
||
}
|
||
|
||
#let defense-label(item, field) = {
|
||
let threshold = item.at(field)
|
||
let successes = item.at(field + "-success")
|
||
if threshold == none { [—] } else if successes == none { [#threshold / ?r] } else {
|
||
[#threshold / #successes#text[r]]
|
||
}
|
||
}
|
||
|
||
#let usage-detail-table(usages) = {
|
||
let rows = ()
|
||
for item in usages {
|
||
rows += (
|
||
item.owner,
|
||
item.stage,
|
||
item.ability,
|
||
defense-label(item, "dodge"),
|
||
defense-label(item, "repositionning"),
|
||
defense-label(item, "parry"),
|
||
)
|
||
}
|
||
tables.set-table-style(
|
||
table(
|
||
columns: (1.15fr, 0.55fr, 1.45fr, 0.55fr, 0.7fr, 0.55fr),
|
||
align: (left, left, left, center, center, center),
|
||
table.header(
|
||
[Profil], [Niveau], [Capacité], [Esquive], [Reposition.], [Parade],
|
||
),
|
||
..rows,
|
||
),
|
||
table-theme: "steingrund",
|
||
text-size: 6.4pt,
|
||
)
|
||
}
|
||
|
||
#let usage-summary(usages, issues) = {
|
||
let configured = usages.filter(item => item.repositionning != none)
|
||
let acknowledged = usages.filter(item => (
|
||
item.repositionning == none and item.dodge == none and item.parry == none
|
||
))
|
||
grid(
|
||
columns: (1fr, 1fr, 1fr, 1fr),
|
||
column-gutter: 8pt,
|
||
metric-card("Macros", usages.len()),
|
||
metric-card("Repositionnements", configured.len()),
|
||
metric-card("Validations vides", acknowledged.len()),
|
||
metric-card("À vérifier", issues.len()),
|
||
)
|
||
if configured.len() > 0 {
|
||
heading(level: 3)[Difficulté du repositionnement]
|
||
difficulty-matrix(usages)
|
||
text(size: 7pt, fill: report-theme.muted-ink)[
|
||
Les lignes donnent le seuil du jet et les colonnes le nombre de réussites
|
||
fixes à obtenir. « Réussites ? » signale une valeur non renseignée.
|
||
]
|
||
}
|
||
heading(level: 3)[Profils défensifs détaillés]
|
||
usage-detail-table(usages)
|
||
}
|
||
|
||
#let school-aoe-threshold-issues = {
|
||
let issues = ()
|
||
for (school, source) in school-sources {
|
||
let rows = csv(source, delimiter: "\t")
|
||
let tier = none
|
||
let effect-column = none
|
||
for row in rows {
|
||
if row.len() == 0 { continue }
|
||
let first = row.first().trim()
|
||
if first.starts-with("Tier ") {
|
||
tier = first.replace(regex("\D"), "")
|
||
} else if first == "Technique" {
|
||
effect-column = row.position(cell => cell.trim() == "Effet")
|
||
} else if first != "" and effect-column != none and effect-column < row.len() {
|
||
let effect = row.at(effect-column)
|
||
let signals = aoe-signals(effect)
|
||
if signals.len() > 0 and not has-aoe-thresholds(effect) {
|
||
issues.push((
|
||
owner: school.replace("-", " "),
|
||
tier: if tier == none { "—" } else { tier },
|
||
ability: first,
|
||
signals: signals,
|
||
))
|
||
}
|
||
}
|
||
}
|
||
}
|
||
issues
|
||
}
|
||
|
||
#let creature-aoe-threshold-issues = {
|
||
let issues = ()
|
||
for creature in master-creatures {
|
||
for phase in creature.phases {
|
||
for group in phase.groups {
|
||
for attack in group.attacks {
|
||
let effect = str(attack.effects)
|
||
let signals = aoe-signals(effect)
|
||
if attack.type in ("AOE", "WID") { signals.push("type " + attack.type) }
|
||
signals = signals.dedup()
|
||
let zone-target = attack.target in ("Z", "W", "A")
|
||
if signals.len() > 0 and not zone-target and not has-aoe-thresholds(effect) {
|
||
issues.push((
|
||
owner: creature.name,
|
||
tier: phase.name,
|
||
ability: attack.name,
|
||
signals: signals,
|
||
))
|
||
}
|
||
}
|
||
}
|
||
}
|
||
}
|
||
issues
|
||
}
|
||
|
||
#let origin-aoe-threshold-issues = {
|
||
let issues = ()
|
||
for source in origin-sources {
|
||
let origin = yaml(source.source)
|
||
for stage in origin.stades {
|
||
for ability in stage.abilities {
|
||
if ability.type != "named" { continue }
|
||
let effect = ability.at("description", default: "")
|
||
let signals = aoe-signals(effect)
|
||
let lowered = lower(effect)
|
||
if lowered.match(regex("inflige.{0,120}(?:zone|rayon)")) != none or lowered.match(regex(
|
||
"(?:zone|rayon).{0,120}inflige",
|
||
)) != none {
|
||
signals.push("zone offensive")
|
||
signals = signals.dedup()
|
||
}
|
||
if signals.len() > 0 and not has-aoe-thresholds(effect) {
|
||
issues.push((
|
||
owner: origin.name,
|
||
tier: str(stage.number),
|
||
ability: ability.at("name", default: "Capacité sans nom"),
|
||
signals: signals,
|
||
))
|
||
}
|
||
}
|
||
}
|
||
}
|
||
issues
|
||
}
|
||
|
||
#let issue-table(issues, second-heading) = if issues.len() == 0 {
|
||
text(fill: report-theme.muted-ink)[Aucune aire d’effet sans macro détectée.]
|
||
} else {
|
||
let review-label = box(
|
||
inset: (x: 2.5pt, y: 0.65pt),
|
||
radius: 2.5pt,
|
||
fill: report-theme.chart-1.transparentize(82%),
|
||
stroke: 0.4pt + report-theme.chart-1,
|
||
text(
|
||
size: 6pt,
|
||
weight: "bold",
|
||
fill: report-theme.chart-1.darken(14%),
|
||
)[À vérifier],
|
||
)
|
||
let rows = ()
|
||
for issue in issues {
|
||
rows += (
|
||
review-label,
|
||
issue.owner,
|
||
issue.tier,
|
||
issue.ability,
|
||
issue.signals.join(", "),
|
||
)
|
||
}
|
||
tables.set-table-style(
|
||
table(
|
||
columns: (0.65fr, 1.15fr, 0.75fr, 1.35fr, 1.25fr),
|
||
align: (center, left, left, left, left),
|
||
table.header([Statut], [Profil], second-heading, [Capacité], [Détection]),
|
||
..rows,
|
||
),
|
||
table-theme: "steingrund",
|
||
text-size: 7.2pt,
|
||
)
|
||
}
|
||
|
||
#let school-aoe-threshold-audit() = {
|
||
heading(level: 2)[Audit des seuils d’aire d’effet]
|
||
[Techniques susceptibles de produire une aire d’effet mais ne contenant pas
|
||
`#aoe_thresholds(...)`. Cette liste est heuristique et doit être relue.]
|
||
usage-summary(school-aoe-threshold-usages, school-aoe-threshold-issues)
|
||
heading(level: 3)[Techniques à vérifier]
|
||
issue-table(school-aoe-threshold-issues, [Tier])
|
||
}
|
||
|
||
#let creature-aoe-threshold-audit() = {
|
||
heading(level: 1)[Audit des seuils d’aire d’effet]
|
||
[Attaques de type `AOE` ou `WID`, ou dont l’effet décrit une zone offensive,
|
||
sans appel à `#aoe_thresholds(...)`.]
|
||
usage-summary(creature-aoe-threshold-usages, creature-aoe-threshold-issues)
|
||
heading(level: 2)[Attaques à vérifier]
|
||
issue-table(creature-aoe-threshold-issues, [Phase])
|
||
}
|
||
|
||
#let origin-aoe-threshold-audit() = {
|
||
heading(level: 2)[Origines — Audit des seuils d’aire d’effet]
|
||
[Capacités actives susceptibles de produire une aire d’effet sans appel à
|
||
`#aoe_thresholds(...)`. Les passifs qui modifient seulement une aire existante
|
||
sont exclus.]
|
||
usage-summary(origin-aoe-threshold-usages, origin-aoe-threshold-issues)
|
||
heading(level: 3)[Capacités à vérifier]
|
||
issue-table(origin-aoe-threshold-issues, [Stade])
|
||
}
|