132 lines
3.9 KiB
Plaintext
132 lines
3.9 KiB
Plaintext
// Heuristic alteration metrics extracted from enabled school tiers.
|
|
#import "../generation/radar_graphs.typ": school-sources
|
|
#import "../build_config.typ": school-tiers, tier-is-enabled
|
|
#import "class_costs.typ": class-display-names
|
|
|
|
#let school-number(value) = {
|
|
let cleaned = value.trim()
|
|
if cleaned.match(regex("^-?(?:\d+(?:\.\d+)?|\.\d+)$")) != none {
|
|
float(cleaned)
|
|
} else { none }
|
|
}
|
|
|
|
#let analyze-school-alterations(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"),
|
|
blood: row.position(cell => cell.trim() == "Sang"),
|
|
gauge: row.position(cell => cell.trim() == "Jauge"),
|
|
effect: row.position(cell => cell.trim() == "Effet"),
|
|
)
|
|
continue
|
|
}
|
|
if (
|
|
columns == none
|
|
or current-tier == none
|
|
or not tier-is-enabled(current-tier)
|
|
) { continue }
|
|
if columns.effect >= row.len() { continue }
|
|
let effect = row.at(columns.effect)
|
|
for alteration in effect.matches(regex("@al_([a-z_]+)")) {
|
|
let following = effect.slice(alteration.end)
|
|
let difficulty = following.match(regex("^.{0,24}?#ddlvl\\((-?\\d+)"))
|
|
records.push((
|
|
class: name,
|
|
display: class-display-names.at(name),
|
|
source: source,
|
|
tier: current-tier,
|
|
technique: first,
|
|
level: if columns.level < row.len() {
|
|
school-number(row.at(columns.level))
|
|
} else { none },
|
|
blood: if columns.blood < row.len() {
|
|
school-number(row.at(columns.blood))
|
|
} else { none },
|
|
gauge: if columns.gauge < row.len() {
|
|
school-number(row.at(columns.gauge))
|
|
} else { none },
|
|
subtype: alteration.captures.first(),
|
|
difficulty: if difficulty == none { none } else {
|
|
int(difficulty.captures.first())
|
|
},
|
|
raw: effect,
|
|
))
|
|
}
|
|
}
|
|
records
|
|
}
|
|
|
|
#let all-school-alterations = (
|
|
school-sources
|
|
.pairs()
|
|
.map(pair => (
|
|
analyze-school-alterations(pair.first(), pair.last())
|
|
))
|
|
.flatten()
|
|
)
|
|
|
|
#let school-alterations(
|
|
class: none,
|
|
subtype: none,
|
|
tier: none,
|
|
) = all-school-alterations.filter(item => (
|
|
(class == none or item.class == class)
|
|
and (subtype == none or item.subtype == subtype)
|
|
and (tier == none or item.tier == tier)
|
|
))
|
|
|
|
#let school-alteration-counts = {
|
|
let counts = (:)
|
|
for item in all-school-alterations {
|
|
counts.insert(item.subtype, counts.at(item.subtype, default: 0) + 1)
|
|
}
|
|
counts
|
|
.pairs()
|
|
.map(pair => (label: pair.first(), count: pair.last()))
|
|
.sorted(key: item => -item.count)
|
|
}
|
|
|
|
#let school-alteration-average(records, key) = {
|
|
let values = records.map(item => item.at(key)).filter(value => value != none)
|
|
if values.len() == 0 { none } else {
|
|
calc.round(values.sum() / values.len(), digits: 1)
|
|
}
|
|
}
|
|
|
|
#let school-alteration-profile(subtype) = {
|
|
let records = school-alterations(subtype: subtype)
|
|
let tiers = school-tiers.map(tier => (
|
|
tier: tier,
|
|
count: school-alterations(subtype: subtype, tier: tier).len(),
|
|
))
|
|
let present = tiers.filter(item => item.count > 0)
|
|
let peak = present.sorted(key: item => -item.count).first()
|
|
(
|
|
subtype: subtype,
|
|
count: records.len(),
|
|
first-tier: present.first().tier,
|
|
peak-tier: peak.tier,
|
|
level: school-alteration-average(records, "level"),
|
|
blood: school-alteration-average(records, "blood"),
|
|
gauge: school-alteration-average(records, "gauge"),
|
|
difficulty: school-alteration-average(records, "difficulty"),
|
|
)
|
|
}
|
|
|
|
#let school-alteration-profiles = school-alteration-counts.map(item => (
|
|
school-alteration-profile(item.label)
|
|
))
|