/advice command for searching most valuable pokememes
This commit is contained in:
@@ -6,17 +6,28 @@ package pokedexer
|
||||
import (
|
||||
"git.wtfteam.pro/fat0troll/i2_bot/lib/dbmapping"
|
||||
"github.com/go-telegram-bot-api/telegram-bot-api"
|
||||
"sort"
|
||||
"strconv"
|
||||
"strings"
|
||||
)
|
||||
|
||||
// BestPokememesList shows list for catching based on player league and grade
|
||||
func (p *Pokedexer) BestPokememesList(update *tgbotapi.Update, playerRaw *dbmapping.Player) string {
|
||||
pokememes, ok := p.getBestPokememes(playerRaw.ID)
|
||||
if !ok {
|
||||
c.Log.Error("Cannot get pokememes from getter!")
|
||||
return "fail"
|
||||
// AdvicePokememesList shows list for catching
|
||||
// It may be list of best or most valuable pokememes
|
||||
func (p *Pokedexer) AdvicePokememesList(update *tgbotapi.Update, playerRaw *dbmapping.Player) string {
|
||||
pokememes := make([]*dbmapping.PokememeFull, 0)
|
||||
if update.Message.Command() == "best" {
|
||||
neededPokememes, ok := p.getBestPokememes(playerRaw.ID)
|
||||
if !ok {
|
||||
c.Log.Error("Cannot get pokememes from getter!")
|
||||
return "fail"
|
||||
}
|
||||
pokememes = neededPokememes
|
||||
} else {
|
||||
neededPokememes, ok := p.getHighPricedPokememes(playerRaw.ID)
|
||||
if !ok {
|
||||
c.Log.Error("Cannot get pokememes from getter!")
|
||||
return "fail"
|
||||
}
|
||||
pokememes = neededPokememes
|
||||
}
|
||||
|
||||
profileRaw, err := c.DataCache.GetProfileByPlayerID(playerRaw.ID)
|
||||
@@ -25,11 +36,12 @@ func (p *Pokedexer) BestPokememesList(update *tgbotapi.Update, playerRaw *dbmapp
|
||||
return "fail"
|
||||
}
|
||||
|
||||
sort.Slice(pokememes, func(i, j int) bool {
|
||||
return pokememes[i].Pokememe.Attack > pokememes[j].Pokememe.Attack
|
||||
})
|
||||
|
||||
message := "*Лучшие покемемы для ловли*\n\n"
|
||||
message := ""
|
||||
if update.Message.Command() == "best" {
|
||||
message += "*Лучшие покемемы для поимки*\n\n"
|
||||
} else {
|
||||
message += "*Самые дорогие покемемы для поимки*\n\n"
|
||||
}
|
||||
for i := range pokememes {
|
||||
pk := pokememes[i].Pokememe
|
||||
pkL := pokememes[i].Locations
|
||||
@@ -56,6 +68,9 @@ func (p *Pokedexer) BestPokememesList(update *tgbotapi.Update, playerRaw *dbmapp
|
||||
} else {
|
||||
message += "Нельзя"
|
||||
}
|
||||
if update.Message.Command() == "advice" {
|
||||
message += "\nСтоимость продажи: 💲" + c.Statistics.GetPrintablePoints(pk.Price)
|
||||
}
|
||||
if len(message) > 3000 {
|
||||
msg := tgbotapi.NewMessage(update.Message.Chat.ID, message)
|
||||
msg.ParseMode = "Markdown"
|
||||
|
||||
Reference in New Issue
Block a user