Skip to content

Commit

Permalink
Show how many rounds have been won by blu and red
Browse files Browse the repository at this point in the history
  • Loading branch information
Tails8521 committed May 20, 2024
1 parent 6bd2e43 commit 5302f83
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 2 deletions.
2 changes: 1 addition & 1 deletion src/heatmap_analyser.rs
Original file line number Diff line number Diff line change
Expand Up @@ -211,7 +211,7 @@ impl Death {

#[derive(Debug, Clone, Serialize, Deserialize, PartialEq)]
pub struct Round {
winner: Team,
pub winner: Team,
length: f32,
end_tick: u32,
}
Expand Down
10 changes: 9 additions & 1 deletion src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -874,13 +874,21 @@ impl App {
fn show_stats(&mut self) {
let demo_list = self.get_demo_list_pane();
let death_count: usize = demo_list.demo_files.iter().map(|demo_file| demo_file.heatmap_analysis.deaths.len()).sum();
let round_count: usize = demo_list.demo_files.iter().map(|demo_file| demo_file.heatmap_analysis.rounds.len()).sum();
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();
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();
let demo_count = demo_list.demo_files.len();
self.log(&format!(
"Stats: {} death{}, {} demo{}",
"Stats: {} death{}, {} demo{}\nRound count: {}, Blu wins: {} ({:.2}%), Red wins: {} ({:.2}%)",
death_count,
if death_count > 1 { "s" } else { "" },
demo_count,
if demo_count > 1 { "s" } else { "" },
round_count,
blu_wins,
blu_wins as f32 * 100.0 / round_count as f32,
red_wins,
red_wins as f32 * 100.0 / round_count as f32,
));
}
fn try_generate_heatmap(&mut self) {
Expand Down

0 comments on commit 5302f83

Please sign in to comment.