Regionality
This commit is contained in:
parent
3b67a92077
commit
942efc9c0d
|
|
@ -63,5 +63,7 @@
|
|||
#if chapter-enabled("creatures.common.profile") { render-common-profile-report() }
|
||||
#if chapter-enabled("creatures.common.rewards") { render-common-reward-report() }
|
||||
#if chapter-enabled("creatures.rewards.analysis") { render-creature-reward-analysis() }
|
||||
#if chapter-enabled("creatures.common.regions") { render-common-region-report() }
|
||||
#if chapter-enabled("creatures.common.regions") {
|
||||
render-common-region-report(map-config: report-config.at("regional_map", default: none))
|
||||
}
|
||||
#if chapter-enabled("creatures.durability") { render-durability-report() }
|
||||
|
|
|
|||
|
|
@ -7,3 +7,22 @@ chapters:
|
|||
- creatures.rewards.analysis
|
||||
- creatures.common.regions
|
||||
- creatures.durability
|
||||
|
||||
# Coordinates are percentages of the map width and height, measured from the
|
||||
# top-left corner. A database region omitted here is automatically listed in
|
||||
# the fallback table instead of silently disappearing.
|
||||
regional_map:
|
||||
image: /images/maps/full_map.png
|
||||
regions:
|
||||
Treorst:
|
||||
# The regional cartouche sits offshore; anchor_* points to the land.
|
||||
x: 57
|
||||
y: 39
|
||||
anchor_x: 66
|
||||
anchor_y: 47
|
||||
subregions:
|
||||
Margoz: { x: 67, y: 40 }
|
||||
Mellior: { x: 75, y: 52 }
|
||||
Thenet: { x: 78, y: 49 }
|
||||
Ebil: { x: 74, y: 58 }
|
||||
Kraorst: { x: 66, y: 61 }
|
||||
|
|
|
|||
|
|
@ -1 +1 @@
|
|||
Subproject commit a557d9cd9e19e571da29871fd28626215370b02e
|
||||
Subproject commit da4c1d16c0fa20cb120bff8453da8cf088a58b8a
|
||||
|
|
@ -93,8 +93,25 @@
|
|||
)
|
||||
})
|
||||
|
||||
#let regions = common-creatures.map(item => item.region).dedup().sorted()
|
||||
#let subregions = common-creatures.map(item => item.region + " / " + item.subregion).dedup().sorted()
|
||||
#let comma-values(value) = value.split(",").map(item => item.trim()).filter(item => item != "")
|
||||
#let creature-regions(creature) = comma-values(creature.region)
|
||||
#let creature-region-pairs(creature) = {
|
||||
let region-values = comma-values(creature.region)
|
||||
let subregion-values = comma-values(creature.subregion)
|
||||
if region-values.len() > 1 and region-values.len() == subregion-values.len() {
|
||||
region-values.enumerate().map(pair => (
|
||||
region: pair.at(1), subregion: subregion-values.at(pair.at(0)),
|
||||
))
|
||||
} else {
|
||||
region-values.map(region => subregion-values.map(subregion => (
|
||||
region: region, subregion: subregion,
|
||||
))).flatten()
|
||||
}
|
||||
}
|
||||
#let regions = common-creatures.map(creature-regions).flatten().dedup().sorted()
|
||||
#let subregions = common-creatures.map(creature-region-pairs).flatten().map(item => (
|
||||
item.region + " / " + item.subregion
|
||||
)).dedup().sorted()
|
||||
#let hse-profiles = ("Lowest", "Low", "Mid", "High", "Highest", "Non renseigné").filter(
|
||||
profile => common-creatures.any(item => item.profile-hse == profile),
|
||||
)
|
||||
|
|
@ -315,7 +332,7 @@
|
|||
)).map(item => item.score),
|
||||
)
|
||||
|
||||
#let region-creatures(region) = common-creatures.filter(item => item.region == region)
|
||||
#let region-creatures(region) = common-creatures.filter(item => region in creature-regions(item))
|
||||
#let region-summaries = regions.map(region => {
|
||||
let entries = region-creatures(region)
|
||||
(
|
||||
|
|
@ -333,7 +350,7 @@
|
|||
let region = parts.first()
|
||||
let subregion = parts.slice(1).join(" / ")
|
||||
let entries = common-creatures.filter(item => (
|
||||
item.region == region and item.subregion == subregion
|
||||
(region: region, subregion: subregion) in creature-region-pairs(item)
|
||||
))
|
||||
(
|
||||
region: region,
|
||||
|
|
@ -344,5 +361,5 @@
|
|||
})
|
||||
|
||||
#let profile-count(profile, region: none) = common-creatures.filter(item => (
|
||||
item.profile-hse == profile and (region == none or item.region == region)
|
||||
item.profile-hse == profile and (region == none or region in creature-regions(item))
|
||||
)).len()
|
||||
|
|
|
|||
|
|
@ -418,7 +418,101 @@
|
|||
)
|
||||
}
|
||||
|
||||
#let render-common-region-report() = {
|
||||
#let render-region-map(map-config) = {
|
||||
let map-width = 260mm
|
||||
let map-height = 146.25mm
|
||||
let map-x(value) = value / 100 * map-width
|
||||
let map-y(value) = value / 100 * map-height
|
||||
let configured = if map-config == none { (:) } else {
|
||||
map-config.at("regions", default: (:))
|
||||
}
|
||||
let mapped = region-summaries.filter(item => item.region in configured)
|
||||
let map-source = if map-config == none { none } else {
|
||||
map-config.at("image", default: none)
|
||||
}
|
||||
|
||||
if map-source != none {
|
||||
page(flipped: true, margin: (x: 12mm, y: 10mm))[
|
||||
#heading(level: 3)[Répartition cartographique des créatures]
|
||||
#text(size: 7.5pt, fill: report-theme.muted-ink)[
|
||||
Le nombre dans chaque marqueur correspond aux créatures de la région.
|
||||
Sa position est configurée en pourcentage dans le YAML du rapport.
|
||||
]
|
||||
#v(4pt)
|
||||
#align(center)[
|
||||
#block(width: map-width, height: map-height, clip: true)[
|
||||
#image(map-source, width: map-width, height: map-height)
|
||||
#for item in mapped {
|
||||
let coordinates = configured.at(item.region)
|
||||
let marker-size = 21pt + calc.min(item.count, 20) * 0.45pt
|
||||
let anchor-x = coordinates.at("anchor_x", default: coordinates.x)
|
||||
let anchor-y = coordinates.at("anchor_y", default: coordinates.y)
|
||||
place(
|
||||
top + left,
|
||||
dx: map-x(coordinates.x), dy: map-y(coordinates.y),
|
||||
line(
|
||||
end: (
|
||||
map-x(anchor-x - coordinates.x),
|
||||
map-y(anchor-y - coordinates.y),
|
||||
),
|
||||
stroke: 1.1pt + report-theme.chart-1,
|
||||
),
|
||||
)
|
||||
place(
|
||||
top + left,
|
||||
dx: map-x(coordinates.x) - marker-size / 2,
|
||||
dy: map-y(coordinates.y) - marker-size / 2,
|
||||
box[
|
||||
#circle(
|
||||
width: marker-size,
|
||||
height: marker-size,
|
||||
fill: report-theme.chart-1.transparentize(8%),
|
||||
stroke: 1.1pt + report-theme.parchment-light,
|
||||
)[#align(center + horizon)[#text(
|
||||
size: 8pt, weight: "bold", fill: white,
|
||||
)[#item.count]]]
|
||||
#align(center)[#box(
|
||||
fill: report-theme.parchment-light.transparentize(8%),
|
||||
stroke: 0.45pt + report-theme.border,
|
||||
inset: (x: 3pt, y: 1pt), radius: 2pt,
|
||||
)[#text(size: 6.5pt, weight: "bold", fill: report-theme.heading)[#item.region]]]
|
||||
],
|
||||
)
|
||||
let configured-subregions = coordinates.at("subregions", default: (:))
|
||||
for (name, subcoordinates) in configured-subregions {
|
||||
let summary = subregion-summaries.find(entry => (
|
||||
entry.region == item.region and entry.subregion == name
|
||||
))
|
||||
let amount = if summary == none { 0 } else { summary.count }
|
||||
place(
|
||||
top + left,
|
||||
dx: map-x(subcoordinates.x) - 3.2pt,
|
||||
dy: map-y(subcoordinates.y) - 3.2pt,
|
||||
box[
|
||||
#circle(
|
||||
width: 6.4pt, height: 6.4pt,
|
||||
fill: report-theme.chart-2,
|
||||
stroke: 0.75pt + report-theme.parchment-light,
|
||||
)
|
||||
#h(1.5pt)
|
||||
#box(
|
||||
fill: report-theme.parchment-light.transparentize(7%),
|
||||
stroke: 0.35pt + report-theme.border,
|
||||
inset: (x: 2pt, y: 0.6pt), radius: 1.5pt,
|
||||
)[#text(size: 5.8pt, weight: "bold", fill: report-theme.heading)[
|
||||
#name · #amount
|
||||
]]
|
||||
],
|
||||
)
|
||||
}
|
||||
}
|
||||
]
|
||||
]
|
||||
]
|
||||
}
|
||||
}
|
||||
|
||||
#let render-common-region-report(map-config: none) = {
|
||||
pagebreak(weak: true)
|
||||
heading(level: 2)[Difficulté par région]
|
||||
|
||||
|
|
@ -475,4 +569,29 @@
|
|||
table-theme: "steingrund",
|
||||
text-size: 7pt,
|
||||
)
|
||||
|
||||
render-region-map(map-config)
|
||||
|
||||
let configured = if map-config == none { (:) } else {
|
||||
map-config.at("regions", default: (:))
|
||||
}
|
||||
let unmapped = region-summaries.filter(item => not (item.region in configured))
|
||||
if unmapped.len() > 0 {
|
||||
heading(level: 3)[Régions absentes de la carte]
|
||||
[Ces régions restent dans le rapport même sans coordonnées cartographiques.]
|
||||
let fallback-rows = unmapped.map(item => (
|
||||
item.region, str(item.count),
|
||||
item.profiles.map(profile => compact-profile(profile.label) + " " + str(profile.count)).join(" · "),
|
||||
str(item.rewards),
|
||||
))
|
||||
tables.set-table-style(
|
||||
table(
|
||||
columns: (1.2fr, 0.6fr, 2fr, 0.7fr),
|
||||
align: (left, right, left, right),
|
||||
table.header([Région non placée], [Créatures], [Difficultés], [Récomp.]),
|
||||
..fallback-rows.flatten(),
|
||||
),
|
||||
table-theme: "steingrund", text-size: 7pt,
|
||||
)
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -0,0 +1,17 @@
|
|||
// Regression checks for comma-separated creature geography.
|
||||
#import "/setup/analysis/creature_common_metrics.typ": creature-region-pairs, creature-regions
|
||||
|
||||
#let paired = (region: "Treorst, Steingrund", subregion: "Mellior, Einvor")
|
||||
#assert.eq(creature-regions(paired), ("Treorst", "Steingrund"))
|
||||
#assert.eq(creature-region-pairs(paired), (
|
||||
(region: "Treorst", subregion: "Mellior"),
|
||||
(region: "Steingrund", subregion: "Einvor"),
|
||||
))
|
||||
|
||||
#let shared = (region: "Treorst, Steingrund", subregion: "Frontière")
|
||||
#assert.eq(creature-region-pairs(shared), (
|
||||
(region: "Treorst", subregion: "Frontière"),
|
||||
(region: "Steingrund", subregion: "Frontière"),
|
||||
))
|
||||
|
||||
[Comma-separated creature geography: OK]
|
||||
Loading…
Reference in New Issue