sort forms

This commit is contained in:
Vomitblood 2024-04-17 00:01:49 +08:00
parent 6411936478
commit 9e94599971

View file

@ -234,12 +234,12 @@ fn read_pokemon_file(
}
fn transform_pokemon_data(
pokemons: &std::collections::HashMap<String, Pokemon>,
pokemon_collection: &std::collections::HashMap<String, Pokemon>,
) -> Vec<ProcessedPokemon> {
let mut processed_pokemons: Vec<ProcessedPokemon> = pokemons
let mut processed_pokemons: Vec<ProcessedPokemon> = pokemon_collection
.iter()
.map(|(_key, p)| {
let forms = p
let mut forms = p
.gen_8
.forms
.keys()
@ -249,6 +249,14 @@ fn transform_pokemon_data(
})
.collect::<Vec<String>>();
// ensure `regular` is first then sort remaining forms alphabetically
// ocd af
forms.sort();
if let Some(pos) = forms.iter().position(|x| x == "regular") {
forms.remove(pos);
forms.insert(0, "regular".to_string());
}
ProcessedPokemon {
// remove leading zeros from the pokedex number
pokedex: p.idx.trim_start_matches('0').to_string(),