Archived
1

Pokedex sorting by letter, for moving zero grade to end of the list

This commit is contained in:
Vladimir Hodakov 2018-02-17 19:54:45 +04:00
parent be9b2d72f1
commit 54614bfc4d

View File

@ -228,8 +228,14 @@ func (dc *DataCache) GetAllPokememes() map[int]*dbmapping.PokememeFull {
var keys []string var keys []string
keysToIDs := make(map[string]int) keysToIDs := make(map[string]int)
for i := range dc.fullPokememes { for i := range dc.fullPokememes {
keys = append(keys, strconv.Itoa(dc.fullPokememes[i].Pokememe.Grade)+"_"+strconv.Itoa(dc.fullPokememes[i].Pokememe.Attack+100000000000000)+"_"+dc.fullPokememes[i].Pokememe.Name) gradeKey := ""
keysToIDs[strconv.Itoa(dc.fullPokememes[i].Pokememe.Grade)+"_"+strconv.Itoa(dc.fullPokememes[i].Pokememe.Attack+100000000000000)+"_"+dc.fullPokememes[i].Pokememe.Name] = i if dc.fullPokememes[i].Pokememe.Grade == 0 {
gradeKey += "Z"
} else {
gradeKey += string(rune('A' - 1 + dc.fullPokememes[i].Pokememe.Grade))
}
keys = append(keys, gradeKey+"_"+strconv.Itoa(dc.fullPokememes[i].Pokememe.Attack+100000000000000)+"_"+dc.fullPokememes[i].Pokememe.Name)
keysToIDs[gradeKey+"_"+strconv.Itoa(dc.fullPokememes[i].Pokememe.Attack+100000000000000)+"_"+dc.fullPokememes[i].Pokememe.Name] = i
} }
sort.Strings(keys) sort.Strings(keys)