diff --git a/README.md b/README.md index 47ba7eb..b519d3b 100644 --- a/README.md +++ b/README.md @@ -8,6 +8,35 @@ World of Tanks Blitz replay parser in Rust. ![License: MIT](https://img.shields.io/crates/l/wotbreplay-parser) [![docs.rs](https://img.shields.io/docsrs/wotbreplay-parser)](https://docs.rs/wotbreplay-parser) +## Quickstart + +```rust +use std::fs::File; + +use anyhow::Result; +use wotbreplay_parser::Replay; +use wotbreplay_parser::models::TeamNumber; + +fn main() -> Result<()> { + let battle_results = Replay::open(File::open("tests/replays/battle_results_ok.wotbreplay")?)? + .read_battle_results()?; + + assert_eq!(battle_results.timestamp, 1670018359); + assert_eq!(battle_results.players.len(), 14); + + assert_eq!(battle_results.players[0].account_id, 520886428); + assert_eq!(battle_results.players[0].info.nickname, "77mmmr"); + assert_eq!(battle_results.players[0].info.team_number(), TeamNumber::Two); + assert_eq!(battle_results.players[0].info.platoon_id, None); + + assert_eq!(battle_results.players[1].info.nickname, "SNAK_THE_RIPPER"); + assert_eq!(battle_results.players[1].info.team_number(), TeamNumber::One); + assert_eq!(battle_results.players[1].info.platoon_id, Some(547466834)); + + Ok(()) +} +``` + ## Replay structure `*.wotbreplay` is a ZIP-archive containing: diff --git a/tests/battle_results.rs b/tests/battle_results.rs index cb17d70..7677fe6 100644 --- a/tests/battle_results.rs +++ b/tests/battle_results.rs @@ -4,26 +4,6 @@ use anyhow::Result; use wotbreplay_parser::models::TeamNumber; use wotbreplay_parser::Replay; -#[test] -fn battle_results_ok() -> Result<()> { - let battle_results = Replay::open(File::open("tests/replays/battle_results_ok.wotbreplay")?)? - .read_battle_results()?; - - assert_eq!(battle_results.timestamp, 1670018359); - assert_eq!(battle_results.players.len(), 14); - - assert_eq!(battle_results.players[0].account_id, 520886428); - assert_eq!(battle_results.players[0].info.nickname, "77mmmr"); - assert_eq!(battle_results.players[0].info.team_number(), TeamNumber::Two); - assert_eq!(battle_results.players[0].info.platoon_id, None); - - assert_eq!(battle_results.players[1].info.nickname, "SNAK_THE_RIPPER"); - assert_eq!(battle_results.players[1].info.team_number(), TeamNumber::One); - assert_eq!(battle_results.players[1].info.platoon_id, Some(547466834)); - - Ok(()) -} - #[test] fn player_results_ok() -> Result<()> { let battle_results = Replay::open(File::open("tests/replays/player_results_ok.wotbreplay")?)?