This commit is contained in:
nyyu 2021-11-01 08:35:19 +01:00
parent 44410866fb
commit 9bb60ea5f6
3 changed files with 8 additions and 8 deletions

View file

@ -48,7 +48,7 @@ struct Stats {
#[derive(Deserialize)] #[derive(Deserialize)]
struct Build { struct Build {
build: Vec<u32>, build: Vec<u32>,
win_rate: f64, win_rate: f32,
games: u32, games: u32,
} }
@ -171,10 +171,10 @@ impl DataSource for CGGDataSource {
position.to_owned(), position.to_owned(),
blocks, blocks,
Stat { Stat {
win_rate: (champ.stats.wins as f64 / champ.stats.games as f64) * 100f64, win_rate: (champ.stats.wins as f32 / champ.stats.games as f32) * 100f32,
games: champ.stats.games, games: champ.stats.games,
kda: (champ.stats.kills + champ.stats.assists) as f64 kda: (champ.stats.kills + champ.stats.assists) as f32
/ champ.stats.deaths as f64, / champ.stats.deaths as f32,
patch: champ.patch.to_owned(), patch: champ.patch.to_owned(),
}, },
)); ));

View file

@ -33,9 +33,9 @@ pub struct Item {
} }
pub struct Stat { pub struct Stat {
pub win_rate: f64, pub win_rate: f32,
pub games: u32, pub games: u32,
pub kda: f64, pub kda: f32,
pub patch: String, pub patch: String,
} }

View file

@ -82,10 +82,10 @@ impl DataSource for MSDataSource {
let patch = &page[pos + 6..pos + 11]; let patch = &page[pos + 6..pos + 11];
pos = page.find("Win Rate:").unwrap(); pos = page.find("Win Rate:").unwrap();
let win_rate: f64 = (&page[pos + 26..pos + 31]).parse().unwrap(); let win_rate: f32 = (&page[pos + 26..pos + 31]).parse().unwrap();
pos = page.find("KDA:").unwrap(); pos = page.find("KDA:").unwrap();
let kda: f64 = (&page[pos + 21..pos + 25]).parse().unwrap(); let kda: f32 = (&page[pos + 21..pos + 25]).parse().unwrap();
let mut items = vec![]; let mut items = vec![];