Move world cache report to presentation adapter
Co-Authored-By: Codex <noreply@openai.com>
This commit is contained in:
@@ -0,0 +1,34 @@
|
||||
//! Player-facing world-cache report, also used by the headless scenario driver.
|
||||
use airdef_core::sim::world::WorldCache;
|
||||
|
||||
pub fn text(world: &WorldCache) -> String {
|
||||
let s = &world.stats;
|
||||
format!(
|
||||
"мир: {} секций ({} КБ), запросов {}, неизвестно {}, лучей {} (ударов {}, неизв. {}), клеток {}; взрывы в блоках: {} (подтверждено {}, без перемен {}, нет чанка {}), чужих ответов {}",
|
||||
world.len(), world.bytes() / 1024, s.sections_asked, s.sections_unknown,
|
||||
s.sweeps, s.hits, s.unknown_sweeps, s.cells, s.blasts_asked,
|
||||
s.blasts_confirmed, s.blasts_unchanged, s.blasts_unloaded, s.late_dropped
|
||||
)
|
||||
}
|
||||
|
||||
#[cfg(test)]
|
||||
mod tests {
|
||||
use super::*;
|
||||
|
||||
#[test]
|
||||
fn reports_cache_counts_in_existing_format() {
|
||||
let mut world = WorldCache::default();
|
||||
world.stats.sections_asked = 1;
|
||||
world.stats.sections_unknown = 2;
|
||||
world.stats.sweeps = 3;
|
||||
world.stats.hits = 4;
|
||||
world.stats.unknown_sweeps = 5;
|
||||
world.stats.cells = 6;
|
||||
world.stats.blasts_asked = 7;
|
||||
world.stats.blasts_confirmed = 8;
|
||||
world.stats.blasts_unchanged = 9;
|
||||
world.stats.blasts_unloaded = 10;
|
||||
world.stats.late_dropped = 11;
|
||||
assert_eq!(text(&world), "мир: 0 секций (0 КБ), запросов 1, неизвестно 2, лучей 3 (ударов 4, неизв. 5), клеток 6; взрывы в блоках: 7 (подтверждено 8, без перемен 9, нет чанка 10), чужих ответов 11");
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user