153 lines
7.2 KiB
Plaintext
153 lines
7.2 KiB
Plaintext
// Failure-tolerant extraction of weapon-like profiles from school skill trees.
|
|
#import "weapon_metrics.typ": analyze-weapon-profile, all-weapon-metrics, commitment-pools, natural-precision
|
|
#import "report_config.typ": class-weapon-settings
|
|
#import "../build_config.typ": tier-is-enabled
|
|
|
|
#let capture(text, pattern, index: 0) = {
|
|
let found = text.match(regex(pattern))
|
|
if found == none { none } else { found.captures.at(index, default: none) }
|
|
}
|
|
|
|
#let configured-base(symbol) = class-weapon-settings.characteristic_values.at(
|
|
symbol, default: none,
|
|
)
|
|
|
|
#let parse-school-attacks(school, display, source) = {
|
|
let rows = csv(source, delimiter: "\t")
|
|
let current-tier = none
|
|
let effect-column = none
|
|
let results = ()
|
|
let issues = ()
|
|
for row in rows {
|
|
if row.len() == 0 { continue }
|
|
let first = row.first().trim()
|
|
if first.starts-with("Tier") {
|
|
let digits = first.replace(regex("\\D"), "")
|
|
if digits != "" { current-tier = int(digits) }
|
|
continue
|
|
}
|
|
if first == "Technique" {
|
|
effect-column = row.position(cell => cell.trim() == "Effet")
|
|
continue
|
|
}
|
|
if first == "" or effect-column == none or effect-column >= row.len() { continue }
|
|
if current-tier != none and not tier-is-enabled(current-tier) { continue }
|
|
let effect = row.at(effect-column)
|
|
let damage = effect.match(regex("(?i)(F|Psy|[0-9]+)/\\+([0-9]+)"))
|
|
if damage == none { continue }
|
|
if effect.contains("jusqu'à 6 éclairs") or effect.contains("jusqu'à 6 eclairs") {
|
|
issues.push((school: display, technique: first, tier: current-tier,
|
|
reason: "Salve à réussites réparties: allocation entre éclairs non résolue"))
|
|
continue
|
|
}
|
|
if effect.contains("cette attaque gagne +1") {
|
|
issues.push((school: display, technique: first, tier: current-tier,
|
|
reason: "Profil dynamique (+0 à +10) dépendant du combat"))
|
|
continue
|
|
}
|
|
let base-token = damage.captures.at(0)
|
|
let base = if base-token.match(regex("^[0-9]+$")) != none {
|
|
int(base-token)
|
|
} else { configured-base(base-token) }
|
|
let rmax = capture(effect, "@rl_rmax(?::short)?\\s+([0-9]+)")
|
|
if base == none or rmax == none {
|
|
issues.push((school: display, technique: first, tier: current-tier,
|
|
reason: if base == none { "Caractéristique `" + base-token + "` sans valeur configurée" } else { "R.Max absent" }))
|
|
continue
|
|
}
|
|
let threshold = capture(effect, "(?i)seuil\\s+([0-9]+)")
|
|
let channel = capture(effect, "(?i)([0-9]+)\\s+actions")
|
|
let explicit-two = effect.match(regex("(?:^|\\s)2A(?:[.,;]|\\s|$)")) != none
|
|
let actions = if channel != none { int(channel) } else if explicit-two { 2 } else {
|
|
class-weapon-settings.default_action_cost
|
|
}
|
|
let precision = if threshold == none {
|
|
class-weapon-settings.default_precision_modifier
|
|
} else { int(threshold) - natural-precision }
|
|
let armor-break = capture(effect, "@rl_arbreak\\s+([0-9]+)")
|
|
let level = if row.len() > 1 and row.at(1).trim() != "" { " · niv. " + row.at(1).trim() } else { "" }
|
|
results.push((
|
|
school: display,
|
|
tier: current-tier,
|
|
technique: first,
|
|
base-token: base-token,
|
|
channelled: channel != none,
|
|
metric: analyze-weapon-profile(
|
|
first + level, base, int(damage.captures.at(1)), int(rmax),
|
|
precision: precision, actions: actions,
|
|
allow-chain: channel == none,
|
|
armor-break: if armor-break == none { 0 } else { int(armor-break) },
|
|
source: effect,
|
|
),
|
|
))
|
|
}
|
|
(profiles: results, issues: issues)
|
|
}
|
|
|
|
#let parse-artilleur() = {
|
|
let source = read("/chapters/schools/artilleur.typ")
|
|
let base-pattern = regex("(?s)\\[([^]\\n]+)\\],\\s*\\n\\s*\\[[^]\\n]+\\],\\s*\\n\\s*\\[([0-9]+)/\\+([0-9]+)\\],\\s*\\n\\s*\\[([0-9]+)\\],\\s*\\n\\s*\\[([0-9]+)\\],\\s*\\n\\s*\\[([^]]*)\\],\\s*\\n\\s*\\[([0-9]+)A\\]")
|
|
let bases = source.matches(base-pattern).filter(found => (
|
|
found.start < source.match(regex("group-row\\(\\[Cannon\\]")).start
|
|
)).map(found => (
|
|
name: found.captures.at(0), damage: int(found.captures.at(1)),
|
|
p-damage: int(found.captures.at(2)), rmax: int(found.captures.at(3)),
|
|
precision: if found.captures.at(5).contains("Précision +1") { 1 } else { 0 },
|
|
))
|
|
let loaders = source.matches(regex("\\[Chargeur (Rotatif|Long|Unique)\\]")).map(found => found.captures.at(0))
|
|
let unique-damage = source.match(regex("(?s)\\[Chargeur Unique\\],\\s*\\n\\s*\\[[^]]+\\],\\s*\\n\\s*\\[\\+([0-9]+)/\\+([0-9]+)\\]"))
|
|
let unique-base-bonus = if unique-damage == none { 0 } else { int(unique-damage.captures.at(0)) }
|
|
let unique-p-bonus = if unique-damage == none { 0 } else { int(unique-damage.captures.at(1)) }
|
|
let cannons = ("Simple", "Double")
|
|
let profiles = ()
|
|
let issues = ()
|
|
for base in bases {
|
|
for cannon in cannons {
|
|
for loader in loaders {
|
|
let simple = cannon == "Simple"
|
|
let unique = loader == "Unique"
|
|
let metric = analyze-weapon-profile(
|
|
base.name + " · Canon " + cannon + " · " + loader,
|
|
base.damage + (if unique { unique-base-bonus } else { 0 }),
|
|
base.p-damage + (if simple { 1 } else { 0 }) + (if unique { unique-p-bonus } else { 0 }),
|
|
base.rmax + (if simple { 1 } else { 0 }),
|
|
precision: base.precision + (if cannon == "Double" { 4 } else { 0 }),
|
|
actions: 1,
|
|
source: source,
|
|
)
|
|
profiles.push((
|
|
school: "Artilleur", tier: none, technique: metric.name,
|
|
base-token: str(base.damage), channelled: false, metric: metric,
|
|
artillery-base: base.name, artillery-cannon: cannon,
|
|
artillery-loader: loader,
|
|
))
|
|
}
|
|
}
|
|
}
|
|
if bases.len() == 0 { issues.push((school: "Artilleur", technique: "Bases", tier: none, reason: "Aucune base de canon reconnue")) }
|
|
if loaders.len() == 0 { issues.push((school: "Artilleur", technique: "Chargeurs", tier: none, reason: "Aucun chargeur reconnu")) }
|
|
if unique-damage == none { issues.push((school: "Artilleur", technique: "Chargeur Unique", tier: none, reason: "Modificateur +X/+Y illisible")) }
|
|
(profiles: profiles, issues: issues)
|
|
}
|
|
|
|
#let sangremage = parse-school-attacks("sangremage", "Sangremage", "/data/src/schools/sangremage.tsv")
|
|
#let mage-bestial = parse-school-attacks("mage-bestial", "Mage bestial", "/data/src/schools/mage_bestial.tsv")
|
|
#let artilleur = parse-artilleur()
|
|
#let class-weapon-profiles = sangremage.profiles + mage-bestial.profiles + artilleur.profiles
|
|
#let class-weapon-issues = sangremage.issues + mage-bestial.issues + artilleur.issues
|
|
#let class-weapon-schools = class-weapon-profiles.map(profile => profile.school).dedup()
|
|
#let class-weapon-maxima = class-weapon-schools.map(school => {
|
|
let winner = class-weapon-profiles.filter(profile => profile.school == school).sorted(
|
|
key: profile => -profile.metric.max-damage,
|
|
).first()
|
|
(school: school, profile: winner, damage: winner.metric.max-damage)
|
|
})
|
|
|
|
#let catalog-average = (
|
|
name: "Arme moyenne du catalogue",
|
|
commitments: commitment-pools.map(scenario => (
|
|
scenario.key, all-weapon-metrics.map(item => item.commitments.at(scenario.key).best).sum() / all-weapon-metrics.len()
|
|
)).to-dict(),
|
|
)
|
|
#let catalog-best = all-weapon-metrics.sorted(key: item => -item.commitments.full.best).first()
|