Color code names in round event log
This commit is contained in:
@@ -455,6 +455,7 @@ async fn perround(
|
|||||||
.map(|dteam| common::demo_analysis::PerRoundTeam {
|
.map(|dteam| common::demo_analysis::PerRoundTeam {
|
||||||
name: dteam.start_name,
|
name: dteam.start_name,
|
||||||
number: dteam.team as u32,
|
number: dteam.team as u32,
|
||||||
|
players: players.iter().filter(|p| p.team == dteam.team).map(|p| p.name.clone()).collect(),
|
||||||
})
|
})
|
||||||
.collect();
|
.collect();
|
||||||
|
|
||||||
|
|||||||
@@ -29,6 +29,7 @@ pub struct PerRoundResult {
|
|||||||
pub struct PerRoundTeam {
|
pub struct PerRoundTeam {
|
||||||
pub name: String,
|
pub name: String,
|
||||||
pub number: u32,
|
pub number: u32,
|
||||||
|
pub players: std::collections::HashSet<String>,
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Debug, Clone, PartialEq, Eq, serde::Serialize, serde::Deserialize)]
|
#[derive(Debug, Clone, PartialEq, Eq, serde::Serialize, serde::Deserialize)]
|
||||||
|
|||||||
@@ -57,10 +57,10 @@ pub fn per_round() -> impl leptos::IntoView {
|
|||||||
margin: 0px;
|
margin: 0px;
|
||||||
}
|
}
|
||||||
|
|
||||||
.won.ct_won {
|
.won.ct_won, .ct_player {
|
||||||
background-color: #1111ff77;
|
background-color: #1111ff77;
|
||||||
}
|
}
|
||||||
.won.t_won {
|
.won.t_won, .t_player {
|
||||||
background-color: #dd111177;
|
background-color: #dd111177;
|
||||||
}
|
}
|
||||||
.lose {
|
.lose {
|
||||||
@@ -72,19 +72,37 @@ pub fn per_round() -> impl leptos::IntoView {
|
|||||||
|
|
||||||
let events_list = move || {
|
let events_list = move || {
|
||||||
let round_index = round();
|
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 {
|
match (current_round, teams) {
|
||||||
Some(round) => {
|
(Some(round), Some(teams)) => {
|
||||||
round.events.iter().map(|event| {
|
round.events.iter().map(|event| {
|
||||||
match event {
|
match event {
|
||||||
common::demo_analysis::RoundEvent::BombPlanted => view! { <li>Bomb has been planted</li> }.into_view(),
|
common::demo_analysis::RoundEvent::BombPlanted => view! { <li>Bomb has been planted</li> }.into_view(),
|
||||||
common::demo_analysis::RoundEvent::BombDefused => view! { <li>Bomb has been defused</li> }.into_view(),
|
common::demo_analysis::RoundEvent::BombDefused => view! { <li>Bomb has been defused</li> }.into_view(),
|
||||||
common::demo_analysis::RoundEvent::Killed { attacker, died } => view! { <li>{"'"}{ attacker }{"'"} killed {"'"}{ died }{"'"}</li> }.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,
|
||||||
|
<li>{"'"}
|
||||||
|
<span class:t_player=move || attacker_t class:ct_player=move || !attacker_t>{ attacker }</span>{"'"} killed {"'"}
|
||||||
|
<span class:t_player=move || died_t class:ct_player=move || !died_t>{ died }</span>{"'"}
|
||||||
|
</li>
|
||||||
|
}.into_view()
|
||||||
|
},
|
||||||
}
|
}
|
||||||
}).collect::<Vec<_>>().into_view()
|
}).collect::<Vec<_>>().into_view()
|
||||||
}
|
}
|
||||||
None => view! {}.into_view(),
|
_ => view! {}.into_view(),
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user