Reverted /best logic, because of fuckup
This commit is contained in:
parent
292440f411
commit
bacf76fd39
@ -5,12 +5,13 @@ package pokedexer
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"git.wtfteam.pro/fat0troll/i2_bot/lib/dbmapping"
|
"git.wtfteam.pro/fat0troll/i2_bot/lib/dbmapping"
|
||||||
|
"sort"
|
||||||
)
|
)
|
||||||
|
|
||||||
// External functions
|
// External functions
|
||||||
|
|
||||||
func (p *Pokedexer) getBestPokememes(playerID int) (map[int]*dbmapping.PokememeFull, bool) {
|
func (p *Pokedexer) getBestPokememes(playerID int) ([]*dbmapping.PokememeFull, bool) {
|
||||||
pokememesArray := make(map[int]*dbmapping.PokememeFull)
|
pokememesArray := make([]*dbmapping.PokememeFull, 0)
|
||||||
|
|
||||||
playerRaw, err := c.DataCache.GetPlayerByID(playerID)
|
playerRaw, err := c.DataCache.GetPlayerByID(playerID)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
@ -28,49 +29,54 @@ func (p *Pokedexer) getBestPokememes(playerID int) (map[int]*dbmapping.PokememeF
|
|||||||
}
|
}
|
||||||
|
|
||||||
allPokememes := c.DataCache.GetAllPokememes()
|
allPokememes := c.DataCache.GetAllPokememes()
|
||||||
if profileRaw.LevelID < 4 {
|
|
||||||
|
pokememesArraySorted := make([]*dbmapping.PokememeFull, 0)
|
||||||
|
|
||||||
for i := range allPokememes {
|
for i := range allPokememes {
|
||||||
if (allPokememes[i].Pokememe.Defence < profileRaw.Power) || (allPokememes[i].Pokememe.Purchaseable) {
|
pokememesArraySorted = append(pokememesArraySorted, allPokememes[i])
|
||||||
if len(pokememesArray) < 5 {
|
|
||||||
if allPokememes[i].Pokememe.Grade == profileRaw.LevelID+1 {
|
|
||||||
pokememesArray[allPokememes[i].Pokememe.Attack] = allPokememes[i]
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
sort.Slice(pokememesArraySorted, func(i, j int) bool {
|
||||||
|
return pokememesArraySorted[i].Pokememe.Attack > pokememesArraySorted[j].Pokememe.Attack
|
||||||
|
})
|
||||||
|
|
||||||
|
if profileRaw.LevelID < 4 {
|
||||||
|
for i := range pokememesArraySorted {
|
||||||
|
if (pokememesArraySorted[i].Pokememe.Defence < profileRaw.Power) || (pokememesArraySorted[i].Pokememe.Purchaseable) {
|
||||||
|
if allPokememes[i].Pokememe.Grade == profileRaw.LevelID+1 {
|
||||||
|
pokememesArray = append(pokememesArray, pokememesArraySorted[i])
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else if profileRaw.LevelID > 8 {
|
} else if profileRaw.LevelID > 8 {
|
||||||
// TODO: Remove it on 10th grade pokememes arrival
|
// TODO: Remove it on 10th grade pokememes arrival
|
||||||
for i := range allPokememes {
|
for i := range allPokememes {
|
||||||
if allPokememes[i].Pokememe.Grade == 9 {
|
if pokememesArraySorted[i].Pokememe.Grade == 9 {
|
||||||
matchLeague := false
|
matchLeague := false
|
||||||
for j := range allPokememes[i].Elements {
|
for j := range pokememesArraySorted[i].Elements {
|
||||||
if allPokememes[i].Elements[j].LeagueID == playerRaw.LeagueID {
|
if pokememesArraySorted[i].Elements[j].LeagueID == playerRaw.LeagueID {
|
||||||
matchLeague = true
|
matchLeague = true
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if matchLeague {
|
if matchLeague {
|
||||||
if (allPokememes[i].Pokememe.Defence < profileRaw.Power) || (allPokememes[i].Pokememe.Purchaseable) {
|
if (pokememesArraySorted[i].Pokememe.Defence < profileRaw.Power) || (pokememesArraySorted[i].Pokememe.Purchaseable) {
|
||||||
if len(pokememesArray) < 5 {
|
pokememesArray = append(pokememesArray, pokememesArraySorted[i])
|
||||||
pokememesArray[allPokememes[i].Pokememe.Attack] = allPokememes[i]
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
for i := range allPokememes {
|
for i := range allPokememes {
|
||||||
if allPokememes[i].Pokememe.Grade == profileRaw.LevelID+1 {
|
if pokememesArraySorted[i].Pokememe.Grade == profileRaw.LevelID+1 {
|
||||||
matchLeague := false
|
matchLeague := false
|
||||||
for j := range allPokememes[i].Elements {
|
for j := range pokememesArraySorted[i].Elements {
|
||||||
if allPokememes[i].Elements[j].LeagueID == playerRaw.LeagueID {
|
if pokememesArraySorted[i].Elements[j].LeagueID == playerRaw.LeagueID {
|
||||||
matchLeague = true
|
matchLeague = true
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if matchLeague {
|
if matchLeague {
|
||||||
if (allPokememes[i].Pokememe.Defence < profileRaw.Power) || (allPokememes[i].Pokememe.Purchaseable) {
|
if (pokememesArraySorted[i].Pokememe.Defence < profileRaw.Power) || (pokememesArraySorted[i].Pokememe.Purchaseable) {
|
||||||
if len(pokememesArray) < 5 {
|
pokememesArray = append(pokememesArray, pokememesArraySorted[i])
|
||||||
pokememesArray[allPokememes[i].Pokememe.Attack] = allPokememes[i]
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -25,14 +25,12 @@ func (p *Pokedexer) BestPokememesList(update *tgbotapi.Update, playerRaw *dbmapp
|
|||||||
return "fail"
|
return "fail"
|
||||||
}
|
}
|
||||||
|
|
||||||
var attacks []int
|
sort.Slice(pokememes, func(i, j int) bool {
|
||||||
for i := range pokememes {
|
return pokememes[i].Pokememe.Attack > pokememes[j].Pokememe.Attack
|
||||||
attacks = append(attacks, i)
|
})
|
||||||
}
|
|
||||||
sort.Sort(sort.Reverse(sort.IntSlice(attacks)))
|
|
||||||
|
|
||||||
message := "*Лучшие покемемы для ловли*\n\n"
|
message := "*Лучшие покемемы для ловли*\n\n"
|
||||||
for _, i := range attacks {
|
for i := range pokememes {
|
||||||
pk := pokememes[i].Pokememe
|
pk := pokememes[i].Pokememe
|
||||||
pkL := pokememes[i].Locations
|
pkL := pokememes[i].Locations
|
||||||
pkE := pokememes[i].Elements
|
pkE := pokememes[i].Elements
|
||||||
|
Reference in New Issue
Block a user