From ba28620be777dfd11708022e4c807235a54c4b7b Mon Sep 17 00:00:00 2001 From: Pavel Perestoronin Date: Wed, 7 Dec 2022 15:40:34 +0100 Subject: [PATCH] New: add `AvatarInfo` --- src/models/battle_results.rs | 21 +++++++++++++++++++++ tests/battle_results.rs | 13 ++++++++++++- 2 files changed, 33 insertions(+), 1 deletion(-) diff --git a/src/models/battle_results.rs b/src/models/battle_results.rs index 66b6df8..cf2ab1d 100644 --- a/src/models/battle_results.rs +++ b/src/models/battle_results.rs @@ -72,6 +72,9 @@ pub struct PlayerInfo { #[prost(string, optional, tag = "5")] pub clan_tag: Option, + + #[prost(message, required, tag = "7")] + pub avatar: Avatar, } #[derive( @@ -191,3 +194,21 @@ pub struct Author { #[prost(uint32, tag = "101")] pub account_id: u32, } + +#[derive(Message, Serialize)] +pub struct Avatar { + #[prost(message, required, tag = "2")] + pub info: AvatarInfo, +} + +#[derive(Message, Serialize)] +pub struct AvatarInfo { + #[prost(string, tag = "2")] + pub gfx_url: String, + + #[prost(string, tag = "3")] + pub gfx2_url: String, + + #[prost(string, tag = "4")] + pub kind: String, +} diff --git a/tests/battle_results.rs b/tests/battle_results.rs index 4de0565..48ebcbf 100644 --- a/tests/battle_results.rs +++ b/tests/battle_results.rs @@ -67,12 +67,23 @@ fn player_results_ok() -> Result<()> { } #[test] -fn clan_tags_ok() -> Result<()> { +fn player_info_ok() -> Result<()> { let battle_results = Replay::open(File::open("tests/replays/player_results.wotbreplay")?)? .read_battle_results()?; assert_eq!(battle_results.players[1].info.clan_tag.as_deref(), Some("AN0NY")); + assert_eq!(battle_results.players[10].info.clan_tag.as_deref(), Some("BBS")); + assert_eq!(battle_results.players[10].info.avatar.info.kind, "legendary"); + assert_eq!( + battle_results.players[10].info.avatar.info.gfx_url, + "https://stufficons.wgcdn.co/Gfx/avatar_UFO_legendary_anim/220523_104739_752791.webp" + ); + assert_eq!( + battle_results.players[10].info.avatar.info.gfx2_url, + "https://stufficons.wgcdn.co/Gfx2/avatar_UFO_legendary_anim/220523_104755_251331.webp" + ); + assert_eq!(battle_results.players[11].info.clan_tag, None); Ok(())