@@ -34,7 +34,8 @@ use std::{cmp::max, collections::hash_map::DefaultHasher, hash::Hasher};
3434use std:: { collections:: HashMap , hash:: Hash } ;
3535
3636use crate :: utils:: {
37- calculate_efficiency, calculate_kills_deaths_assists, calculate_kills_deaths_ratio,
37+ calculate_efficiency, calculate_kills_deaths_assists,
38+ calculate_kills_deaths_ratio,
3839} ;
3940
4041const PLAYER_START_BUFFER : u32 = 30 ;
@@ -55,7 +56,10 @@ pub struct CrucibleActivity {
5556}
5657
5758impl CrucibleActivity {
58- pub fn get_member_performance ( & self , member_id : & str ) -> Option < & CruciblePlayerPerformance > {
59+ pub fn get_member_performance (
60+ & self ,
61+ member_id : & str ,
62+ ) -> Option < & CruciblePlayerPerformance > {
5963 for t in self . teams . values ( ) {
6064 for p in & t. player_performances {
6165 if p. player . member_id == member_id {
@@ -225,7 +229,8 @@ impl AggregateCruciblePerformances {
225229 performances : & [ & CruciblePlayerPerformance ] ,
226230 ) -> AggregateCruciblePerformances {
227231 let mut out = AggregateCruciblePerformances :: default ( ) ;
228- let mut extended = ExtendedCruciblePlayerActivityPerformances :: default ( ) ;
232+ let mut extended =
233+ ExtendedCruciblePlayerActivityPerformances :: default ( ) ;
229234
230235 out. total_activities = performances. len ( ) as u32 ;
231236
@@ -258,7 +263,8 @@ impl AggregateCruciblePerformances {
258263 out. highest_deaths = max ( p. stats . deaths , out. highest_deaths ) ;
259264 out. highest_opponents_defeated =
260265 max ( p. stats . opponents_defeated , out. highest_opponents_defeated ) ;
261- out. highest_efficiency = out. highest_efficiency . max ( p. stats . efficiency ) ;
266+ out. highest_efficiency =
267+ out. highest_efficiency . max ( p. stats . efficiency ) ;
262268 out. highest_kills_deaths_ratio = out
263269 . highest_kills_deaths_ratio
264270 . max ( p. stats . kills_deaths_ratio ) ;
@@ -289,9 +295,11 @@ impl AggregateCruciblePerformances {
289295
290296 #[ allow( clippy:: comparison_chain) ]
291297 if streak > 0 {
292- longest_win_streak = std:: cmp:: max ( longest_win_streak, streak as u32 ) ;
298+ longest_win_streak =
299+ std:: cmp:: max ( longest_win_streak, streak as u32 ) ;
293300 } else if streak < 0 {
294- longest_loss_streak = std:: cmp:: max ( longest_loss_streak, streak. abs ( ) as u32 ) ;
301+ longest_loss_streak =
302+ std:: cmp:: max ( longest_loss_streak, streak. abs ( ) as u32 ) ;
295303 }
296304
297305 last_standing = p. stats . standing ;
@@ -317,12 +325,18 @@ impl AggregateCruciblePerformances {
317325 e. weapon_kills_grenade ,
318326 ) ;
319327
320- extended. highest_weapon_kills_melee =
321- max ( extended. highest_weapon_kills_melee , e. weapon_kills_melee ) ;
322- extended. highest_weapon_kills_super =
323- max ( extended. highest_weapon_kills_super , e. weapon_kills_super ) ;
324- extended. highest_all_medals_earned =
325- max ( extended. highest_all_medals_earned , e. all_medals_earned ) ;
328+ extended. highest_weapon_kills_melee = max (
329+ extended. highest_weapon_kills_melee ,
330+ e. weapon_kills_melee ,
331+ ) ;
332+ extended. highest_weapon_kills_super = max (
333+ extended. highest_weapon_kills_super ,
334+ e. weapon_kills_super ,
335+ ) ;
336+ extended. highest_all_medals_earned = max (
337+ extended. highest_all_medals_earned ,
338+ e. all_medals_earned ,
339+ ) ;
326340
327341 for m in & e. medals {
328342 let key = & m. medal . id ;
@@ -362,7 +376,8 @@ impl AggregateCruciblePerformances {
362376 if ws. kills == 0 {
363377 0.0
364378 } else {
365- ( ws. precision_kills as f32 / ws. kills as f32 ) * 100.0
379+ ( ws. precision_kills as f32 / ws. kills as f32 )
380+ * 100.0
366381 }
367382 } ;
368383 }
@@ -373,11 +388,13 @@ impl AggregateCruciblePerformances {
373388 out. longest_loss_streak = longest_loss_streak;
374389
375390 if has_extended {
376- let mut medals: Vec < MedalStat > = medal_hash. into_iter ( ) . map ( |( _id, m) | m) . collect ( ) ;
391+ let mut medals: Vec < MedalStat > =
392+ medal_hash. into_iter ( ) . map ( |( _id, m) | m) . collect ( ) ;
377393
378394 medals. sort_by ( |a, b| b. count . cmp ( & a. count ) ) ;
379395
380- let mut weapons: Vec < WeaponStat > = weapon_hash. into_iter ( ) . map ( |( _id, w) | w) . collect ( ) ;
396+ let mut weapons: Vec < WeaponStat > =
397+ weapon_hash. into_iter ( ) . map ( |( _id, w) | w) . collect ( ) ;
381398 weapons. sort_by ( |a, b| b. kills . cmp ( & a. kills ) ) ;
382399
383400 extended. medals = medals;
@@ -389,11 +406,14 @@ impl AggregateCruciblePerformances {
389406 }
390407
391408 if out. total_activities > 0 {
392- out. win_rate = ( out. wins as f32 / out. total_activities as f32 ) * 100.0 ;
409+ out. win_rate =
410+ ( out. wins as f32 / out. total_activities as f32 ) * 100.0 ;
393411 }
394412
395- out. efficiency = calculate_efficiency ( out. kills , out. deaths , out. assists ) ;
396- out. kills_deaths_ratio = calculate_kills_deaths_ratio ( out. kills , out. deaths ) ;
413+ out. efficiency =
414+ calculate_efficiency ( out. kills , out. deaths , out. assists ) ;
415+ out. kills_deaths_ratio =
416+ calculate_kills_deaths_ratio ( out. kills , out. deaths ) ;
397417 out. kills_deaths_assists =
398418 calculate_kills_deaths_assists ( out. kills , out. deaths , out. assists ) ;
399419
0 commit comments