diff --git a/src/models/battle_results.rs b/src/models/battle_results.rs index 76aa362..7f454b6 100644 --- a/src/models/battle_results.rs +++ b/src/models/battle_results.rs @@ -24,6 +24,14 @@ pub struct BattleResults { #[prost(enumeration = "TeamNumber", tag = "3")] pub winning_team: i32, + /// Replay's author results. + #[prost(message, required, tag = "8")] + pub author_results: AuthorResults, + + /// Author's free XP, including premium. + #[prost(uint32, tag = "137")] + pub free_xp: u32, + /// Players in the battle. #[prost(message, repeated, tag = "201")] pub players: Vec, @@ -93,7 +101,7 @@ pub struct PlayerResults { pub struct PlayerResultsInfo { /// Credits earned – without special awards and medals and premium account excluded. #[prost(uint32, tag = "2")] - pub credits: u32, + pub credits_earned: u32, /// Base XP (the total without multipliers). #[prost(uint32, tag = "3")] @@ -166,3 +174,17 @@ impl PlayerResultsInfo { .map(|mm_rating| (mm_rating * 10.0 + 3000.0) as u32) } } + +#[derive(Message, Serialize)] +pub struct AuthorResults { + /// Earned credits, including premium and special awards and medals. + #[prost(uint32, tag = "2")] + pub credits_earned: u32, + + /// Combat XP, including premium. + #[prost(uint32, tag = "3")] + pub combat_xp: u32, + + #[prost(uint32, tag = "8")] + pub damage_dealt: u32, +} diff --git a/tests/battle_results.rs b/tests/battle_results.rs index 679ae5b..902c097 100644 --- a/tests/battle_results.rs +++ b/tests/battle_results.rs @@ -38,7 +38,7 @@ fn player_results_ok() -> Result<()> { assert_eq!(zeekrab_info.victory_points_earned, 40); assert_eq!(zeekrab_info.victory_points_seized, 40); assert_eq!(zeekrab_info.tank_id, 26657); - assert_eq!(zeekrab_info.credits, 37679); + assert_eq!(zeekrab_info.credits_earned, 37679); assert_eq!(zeekrab_info.n_enemies_damaged, 2); assert_eq!(zeekrab_info.n_enemies_destroyed, 1); @@ -105,3 +105,16 @@ fn winning_team_ok() -> Result<()> { Ok(()) } + +#[test] +fn author_results_ok() -> Result<()> { + let battle_results = Replay::open(File::open("tests/replays/author_results.wotbreplay")?)? + .read_battle_results()?; + + assert_eq!(battle_results.author_results.credits_earned, 53623); + assert_eq!(battle_results.author_results.combat_xp, 2370); + assert_eq!(battle_results.author_results.damage_dealt, 1738); + assert_eq!(battle_results.free_xp, 116); + + Ok(()) +} diff --git a/tests/replays/author_results.wotbreplay b/tests/replays/author_results.wotbreplay new file mode 100644 index 0000000..c000f61 Binary files /dev/null and b/tests/replays/author_results.wotbreplay differ