Skip to content

Commit 5302f83

Browse files
committed
Show how many rounds have been won by blu and red
1 parent 6bd2e43 commit 5302f83

2 files changed

Lines changed: 10 additions & 2 deletions

File tree

src/heatmap_analyser.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -211,7 +211,7 @@ impl Death {
211211

212212
#[derive(Debug, Clone, Serialize, Deserialize, PartialEq)]
213213
pub struct Round {
214-
winner: Team,
214+
pub winner: Team,
215215
length: f32,
216216
end_tick: u32,
217217
}

src/main.rs

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -874,13 +874,21 @@ impl App {
874874
fn show_stats(&mut self) {
875875
let demo_list = self.get_demo_list_pane();
876876
let death_count: usize = demo_list.demo_files.iter().map(|demo_file| demo_file.heatmap_analysis.deaths.len()).sum();
877+
let round_count: usize = demo_list.demo_files.iter().map(|demo_file| demo_file.heatmap_analysis.rounds.len()).sum();
878+
let blu_wins: usize = demo_list.demo_files.iter().map(|demo_file| demo_file.heatmap_analysis.rounds.iter().filter(|round| round.winner == Team::Blu).count()).sum();
879+
let red_wins: usize = demo_list.demo_files.iter().map(|demo_file| demo_file.heatmap_analysis.rounds.iter().filter(|round| round.winner == Team::Red).count()).sum();
877880
let demo_count = demo_list.demo_files.len();
878881
self.log(&format!(
879-
"Stats: {} death{}, {} demo{}",
882+
"Stats: {} death{}, {} demo{}\nRound count: {}, Blu wins: {} ({:.2}%), Red wins: {} ({:.2}%)",
880883
death_count,
881884
if death_count > 1 { "s" } else { "" },
882885
demo_count,
883886
if demo_count > 1 { "s" } else { "" },
887+
round_count,
888+
blu_wins,
889+
blu_wins as f32 * 100.0 / round_count as f32,
890+
red_wins,
891+
red_wins as f32 * 100.0 / round_count as f32,
884892
));
885893
}
886894
fn try_generate_heatmap(&mut self) {

0 commit comments

Comments
 (0)