fix voidwell counts
This commit is contained in:
parent
ae2c32e5ca
commit
30266b294d
1 changed files with 34 additions and 22 deletions
|
@ -118,6 +118,8 @@ pub async fn voidwell(world: i32) -> Result<Population, ()> {
|
||||||
|
|
||||||
#[derive(serde::Deserialize)]
|
#[derive(serde::Deserialize)]
|
||||||
struct Root {
|
struct Root {
|
||||||
|
#[serde(rename = "onlineCharacters")]
|
||||||
|
pub online_characters: i32,
|
||||||
#[serde(rename = "zoneStates")]
|
#[serde(rename = "zoneStates")]
|
||||||
pub zone_states: Vec<ZoneState>,
|
pub zone_states: Vec<ZoneState>,
|
||||||
}
|
}
|
||||||
|
@ -152,29 +154,39 @@ pub async fn voidwell(world: i32) -> Result<Population, ()> {
|
||||||
.await
|
.await
|
||||||
.unwrap();
|
.unwrap();
|
||||||
|
|
||||||
Ok(Population {
|
let ns_avg: i32 = response
|
||||||
nc: response
|
.zone_states
|
||||||
|
.iter()
|
||||||
|
.map(|zone| zone.population.ns)
|
||||||
|
.sum::<i32>()
|
||||||
|
/ 3;
|
||||||
|
|
||||||
|
let nc = response
|
||||||
.zone_states
|
.zone_states
|
||||||
.iter()
|
.iter()
|
||||||
.map(|zone| zone.population.nc)
|
.map(|zone| zone.population.nc)
|
||||||
.sum(),
|
.sum::<i32>()
|
||||||
tr: response
|
+ ns_avg;
|
||||||
|
|
||||||
|
let tr = response
|
||||||
.zone_states
|
.zone_states
|
||||||
.iter()
|
.iter()
|
||||||
.map(|zone| zone.population.tr)
|
.map(|zone| zone.population.tr)
|
||||||
.sum(),
|
.sum::<i32>()
|
||||||
vs: response
|
+ ns_avg;
|
||||||
|
|
||||||
|
let vs = response
|
||||||
.zone_states
|
.zone_states
|
||||||
.iter()
|
.iter()
|
||||||
.map(|zone| zone.population.vs)
|
.map(|zone| zone.population.vs)
|
||||||
.sum(),
|
.sum::<i32>()
|
||||||
total: response
|
+ ns_avg;
|
||||||
.zone_states
|
|
||||||
.iter()
|
Ok(Population {
|
||||||
.map(|zone| {
|
nc,
|
||||||
zone.population.nc + zone.population.tr + zone.population.vs + zone.population.ns
|
tr,
|
||||||
})
|
vs,
|
||||||
.sum(),
|
total: response.online_characters,
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Add table
Reference in a new issue