Extend cargo selector and save-world analysis surfaces

This commit is contained in:
Jan Petykiewicz 2026-04-17 13:01:26 -07:00
commit 6b8f849731
11 changed files with 639 additions and 26 deletions

View file

@ -69,6 +69,8 @@ pub struct CargoEconomySourceReport {
pub cargo_skin_only_visible_names: Vec<String>,
pub live_registry_count: usize,
pub live_registry_entries: Vec<CargoLiveRegistryEntry>,
pub price_selector_candidate_excess_count: usize,
pub price_selector_candidate_only_visible_names: Vec<String>,
pub production_selector: Option<CargoSelectorReport>,
pub price_selector: CargoSelectorReport,
pub notes: Vec<String>,
@ -271,7 +273,25 @@ fn build_cargo_economy_source_report(
build_live_registry_entries(&cargo_types.entries, &cargo_skins.entries);
let production_selector =
cargo_bindings.map(|bindings| build_production_selector(bindings, &live_registry_entries));
let price_selector_candidate_only_visible_names = production_selector
.as_ref()
.map(|selector| {
let selector_names = selector
.entries
.iter()
.map(|entry| entry.visible_name.as_str())
.collect::<BTreeSet<_>>();
live_registry_entries
.iter()
.filter(|entry| !selector_names.contains(entry.visible_name.as_str()))
.map(|entry| entry.visible_name.clone())
.collect::<Vec<_>>()
})
.unwrap_or_default();
let price_selector = build_price_selector(&live_registry_entries);
let price_selector_candidate_excess_count = live_registry_entries
.len()
.saturating_sub(NAMED_CARGO_PRICE_DESCRIPTOR_ROW_COUNT);
let mut notes = Vec::new();
notes.push(format!(
@ -313,6 +333,8 @@ fn build_cargo_economy_source_report(
cargo_skin_only_visible_names,
live_registry_count: live_registry_entries.len(),
live_registry_entries,
price_selector_candidate_excess_count,
price_selector_candidate_only_visible_names,
production_selector,
price_selector,
notes,
@ -661,6 +683,12 @@ mod tests {
);
assert!(!report.price_selector.exact_resolution);
assert_eq!(report.price_selector.candidate_registry_count, 3);
assert_eq!(report.price_selector_candidate_excess_count, 0);
assert!(
report
.price_selector_candidate_only_visible_names
.is_empty()
);
assert!(report.production_selector.is_none());
}
@ -733,5 +761,11 @@ mod tests {
]
);
assert_eq!(selector.entries[1].visible_name, "Coal");
assert!(
report
.price_selector_candidate_only_visible_names
.is_empty()
);
assert_eq!(report.price_selector_candidate_excess_count, 0);
}
}