diff --git a/backend/src/api/demos.rs b/backend/src/api/demos.rs index d79ba49..8389e95 100644 --- a/backend/src/api/demos.rs +++ b/backend/src/api/demos.rs @@ -455,6 +455,7 @@ async fn perround( .map(|dteam| common::demo_analysis::PerRoundTeam { name: dteam.start_name, number: dteam.team as u32, + players: players.iter().filter(|p| p.team == dteam.team).map(|p| p.name.clone()).collect(), }) .collect(); diff --git a/common/src/demo_analysis.rs b/common/src/demo_analysis.rs index defc264..3f06b35 100644 --- a/common/src/demo_analysis.rs +++ b/common/src/demo_analysis.rs @@ -29,6 +29,7 @@ pub struct PerRoundResult { pub struct PerRoundTeam { pub name: String, pub number: u32, + pub players: std::collections::HashSet, } #[derive(Debug, Clone, PartialEq, Eq, serde::Serialize, serde::Deserialize)] diff --git a/frontend/src/demo/perround.rs b/frontend/src/demo/perround.rs index 2cca48f..d0002ba 100644 --- a/frontend/src/demo/perround.rs +++ b/frontend/src/demo/perround.rs @@ -57,10 +57,10 @@ pub fn per_round() -> impl leptos::IntoView { margin: 0px; } - .won.ct_won { + .won.ct_won, .ct_player { background-color: #1111ff77; } - .won.t_won { + .won.t_won, .t_player { background-color: #dd111177; } .lose { @@ -72,19 +72,37 @@ pub fn per_round() -> impl leptos::IntoView { let events_list = move || { let round_index = round(); - let current_round = perround_resource.get().map(|rs| rs.rounds.get(round_index).cloned()).flatten(); + let data = perround_resource.get(); + let current_round = data.as_ref().map(|rs| rs.rounds.get(round_index).cloned()).flatten(); + let teams = data.as_ref().map(|rs| rs.teams.clone()); - match current_round { - Some(round) => { + match (current_round, teams) { + (Some(round), Some(teams)) => { round.events.iter().map(|event| { match event { common::demo_analysis::RoundEvent::BombPlanted => view! {
  • Bomb has been planted
  • }.into_view(), common::demo_analysis::RoundEvent::BombDefused => view! {
  • Bomb has been defused
  • }.into_view(), - common::demo_analysis::RoundEvent::Killed { attacker, died } => view! {
  • {"'"}{ attacker }{"'"} killed {"'"}{ died }{"'"}
  • }.into_view(), + common::demo_analysis::RoundEvent::Killed { attacker, died } => { + let mut attacker_t = teams.iter().find(|t| t.players.contains(attacker)).map(|t| t.name == "TERRORIST").unwrap_or(false); + let mut died_t = teams.iter().find(|t| t.players.contains(died)).map(|t| t.name == "TERRORIST").unwrap_or(false); + + if (12..27).contains(&round_index) { + attacker_t = !attacker_t; + died_t = !died_t; + } + + view! { + class=style, +
  • {"'"} + { attacker }{"'"} killed {"'"} + { died }{"'"} +
  • + }.into_view() + }, } }).collect::>().into_view() } - None => view! {}.into_view(), + _ => view! {}.into_view(), } };