Skip to content

Commit

Permalink
Track how often a user was marine/alien
Browse files Browse the repository at this point in the history
  • Loading branch information
konsumlamm committed Jan 10, 2024
1 parent 78cc860 commit cbae5d4
Showing 1 changed file with 16 additions and 6 deletions.
22 changes: 16 additions & 6 deletions ns2-stat/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,8 @@ impl<'a, I: Iterator<Item = &'a GameStats>> Games<'a, I> {
pub struct User {
pub total_games: u32,
pub commander: u32,
pub marines: u32,
pub aliens: u32,
pub kills: u32,
pub assists: u32,
pub deaths: u32,
Expand Down Expand Up @@ -111,12 +113,20 @@ impl NS2Stats {
user.deaths += stats.deaths;
}

if player_stat.marines.commander_time > marine_comm_time {
marine_comm = &player_stat.player_name;
marine_comm_time = player_stat.marines.commander_time;
} else if player_stat.aliens.commander_time > alien_comm_time {
alien_comm = &player_stat.player_name;
alien_comm_time = player_stat.aliens.commander_time;
if player_stat.marines.time_played > player_stat.aliens.time_played {
// player was in marine team
user.marines += 1;
if player_stat.marines.commander_time > marine_comm_time {
marine_comm = &player_stat.player_name;
marine_comm_time = player_stat.marines.commander_time;
}
} else {
// player was in alien team
user.aliens += 1;
if player_stat.aliens.commander_time > alien_comm_time {
alien_comm = &player_stat.player_name;
alien_comm_time = player_stat.aliens.commander_time;
}
}
}
if let Some(user) = users.get_mut(marine_comm) {
Expand Down

0 comments on commit cbae5d4

Please sign in to comment.