refactor niumside source
This commit is contained in:
parent
de450af558
commit
d00c8297e3
1 changed files with 25 additions and 60 deletions
|
@ -287,68 +287,33 @@ pub async fn niumside(world: i32) -> Result<Population, ()> {
|
||||||
.await
|
.await
|
||||||
.unwrap();
|
.unwrap();
|
||||||
|
|
||||||
let vs: i32 = response
|
fn extract(root: &Root, team_id: i32) -> i32 {
|
||||||
.pop
|
root.pop
|
||||||
.iter()
|
.iter()
|
||||||
.map(|pop| {
|
.map(|pop| {
|
||||||
pop.zones
|
pop.zones
|
||||||
.iter()
|
.iter()
|
||||||
.map(|zone| {
|
.map(|zone| {
|
||||||
zone.factions
|
let faction = match zone.factions.iter().find(|faction| {
|
||||||
.iter()
|
faction.faction_id == team_id || faction.faction_id == 4
|
||||||
.find(|faction| faction.faction_id == 1 || faction.faction_id == 4)
|
}) {
|
||||||
.unwrap()
|
Some(faction) => faction,
|
||||||
.teams
|
None => return 0,
|
||||||
.iter()
|
};
|
||||||
.find(|team| team.team_id == 1)
|
|
||||||
.unwrap()
|
|
||||||
.team_population
|
|
||||||
})
|
|
||||||
.sum::<i32>()
|
|
||||||
})
|
|
||||||
.sum::<i32>();
|
|
||||||
|
|
||||||
let nc: i32 = response
|
match faction.teams.iter().find(|team| team.team_id == team_id) {
|
||||||
.pop
|
Some(team) => team.team_population,
|
||||||
.iter()
|
None => 0,
|
||||||
.map(|pop| {
|
}
|
||||||
pop.zones
|
|
||||||
.iter()
|
|
||||||
.map(|zone| {
|
|
||||||
zone.factions
|
|
||||||
.iter()
|
|
||||||
.find(|faction| faction.faction_id == 2 || faction.faction_id == 4)
|
|
||||||
.unwrap()
|
|
||||||
.teams
|
|
||||||
.iter()
|
|
||||||
.find(|team| team.team_id == 2)
|
|
||||||
.unwrap()
|
|
||||||
.team_population
|
|
||||||
})
|
})
|
||||||
.sum::<i32>()
|
.sum::<i32>()
|
||||||
})
|
})
|
||||||
.sum::<i32>();
|
.sum::<i32>()
|
||||||
|
}
|
||||||
|
|
||||||
let tr: i32 = response
|
let vs = extract(&response, 1);
|
||||||
.pop
|
let nc = extract(&response, 2);
|
||||||
.iter()
|
let tr = extract(&response, 3);
|
||||||
.map(|pop| {
|
|
||||||
pop.zones
|
|
||||||
.iter()
|
|
||||||
.map(|zone| {
|
|
||||||
zone.factions
|
|
||||||
.iter()
|
|
||||||
.find(|faction| faction.faction_id == 3 || faction.faction_id == 4)
|
|
||||||
.unwrap()
|
|
||||||
.teams
|
|
||||||
.iter()
|
|
||||||
.find(|team| team.team_id == 3)
|
|
||||||
.unwrap()
|
|
||||||
.team_population
|
|
||||||
})
|
|
||||||
.sum::<i32>()
|
|
||||||
})
|
|
||||||
.sum::<i32>();
|
|
||||||
|
|
||||||
Ok(Population {
|
Ok(Population {
|
||||||
nc,
|
nc,
|
||||||
|
|
Loading…
Add table
Reference in a new issue