Reflect latest game update
So, now we can handle 10th grade pokememes (and any two-digit grade pokememes in future). Also, /best and /advice commands for 9th-level players respect new pokememes.
This commit is contained in:
parent
93f2e7d818
commit
dbaa85a517
@ -6,6 +6,11 @@ package appcontext
|
||||
import (
|
||||
"bitbucket.org/pztrn/flagger"
|
||||
"bitbucket.org/pztrn/mogrus"
|
||||
"github.com/go-telegram-bot-api/telegram-bot-api"
|
||||
"github.com/jmoiron/sqlx"
|
||||
"github.com/robfig/cron"
|
||||
"net/http"
|
||||
"os"
|
||||
"source.wtfteam.pro/i2_bot/i2_bot/lib/broadcaster/broadcasterinterface"
|
||||
"source.wtfteam.pro/i2_bot/i2_bot/lib/chatter/chatterinterface"
|
||||
"source.wtfteam.pro/i2_bot/i2_bot/lib/config"
|
||||
@ -23,11 +28,6 @@ import (
|
||||
"source.wtfteam.pro/i2_bot/i2_bot/lib/talkers/talkersinterface"
|
||||
"source.wtfteam.pro/i2_bot/i2_bot/lib/users/usersinterface"
|
||||
"source.wtfteam.pro/i2_bot/i2_bot/lib/welcomer/welcomerinterface"
|
||||
"github.com/go-telegram-bot-api/telegram-bot-api"
|
||||
"github.com/jmoiron/sqlx"
|
||||
"github.com/robfig/cron"
|
||||
"net/http"
|
||||
"os"
|
||||
"time"
|
||||
)
|
||||
|
||||
@ -62,7 +62,7 @@ func (c *Context) Init() {
|
||||
l.Initialize()
|
||||
|
||||
log := l.CreateLogger("i2_bot")
|
||||
log.CreateOutput("stdout", os.Stdout, true, "debug")
|
||||
log.CreateOutput("stdout", os.Stdout, true, "info")
|
||||
c.Log = log
|
||||
|
||||
c.StartupFlags = flagger.New(c.Log)
|
||||
|
@ -43,6 +43,7 @@ func (dc *DataCache) loadPokememes() {
|
||||
dc.pokememesMutex.Lock()
|
||||
dc.fullPokememesMutex.Lock()
|
||||
for i := range pokememes {
|
||||
c.Log.Debug("Loading pokememe with name: " + pokememes[i].Name)
|
||||
dc.pokememes[pokememes[i].ID] = &pokememes[i]
|
||||
|
||||
// Filling fullPokememes
|
||||
@ -121,6 +122,7 @@ func (dc *DataCache) AddPokememe(pokememeData map[string]string, pokememeLocatio
|
||||
}
|
||||
pokememe.ImageURL = pokememeData["image"]
|
||||
pokememe.PlayerID = creatorID
|
||||
pokememe.IsActive = 1
|
||||
pokememe.CreatedAt = time.Now().UTC()
|
||||
|
||||
locations := []datamapping.Location{}
|
||||
@ -153,6 +155,7 @@ func (dc *DataCache) AddPokememe(pokememeData map[string]string, pokememeLocatio
|
||||
insertedPokememe := dbmapping.Pokememe{}
|
||||
err = c.Db.Get(&insertedPokememe, c.Db.Rebind("SELECT * FROM pokememes WHERE grade=? AND name=?"), pokememe.Grade, pokememe.Name)
|
||||
if err != nil {
|
||||
c.Log.Debug("Can't find newly added pokememe!")
|
||||
return 0, err
|
||||
}
|
||||
|
||||
|
@ -4,8 +4,8 @@
|
||||
package pokedexer
|
||||
|
||||
import (
|
||||
"source.wtfteam.pro/i2_bot/i2_bot/lib/dbmapping"
|
||||
"sort"
|
||||
"source.wtfteam.pro/i2_bot/i2_bot/lib/dbmapping"
|
||||
"strconv"
|
||||
"strings"
|
||||
)
|
||||
@ -40,14 +40,16 @@ func (p *Pokedexer) getAdvicePokememes(playerID int, adviceType string) ([]*dbma
|
||||
}
|
||||
|
||||
allPokememes := c.DataCache.GetAllPokememes()
|
||||
neededGrade := 0
|
||||
if profileRaw.LevelID < 10 {
|
||||
neededGrade = profileRaw.LevelID + 1
|
||||
} else {
|
||||
neededGrade = 10
|
||||
}
|
||||
|
||||
c.Log.Debug("This player will search for grade: " + strconv.Itoa(neededGrade))
|
||||
|
||||
for i := range allPokememes {
|
||||
neededGrade := 0
|
||||
if profileRaw.LevelID < 9 {
|
||||
neededGrade = profileRaw.LevelID + 1
|
||||
} else {
|
||||
neededGrade = 9
|
||||
}
|
||||
if allPokememes[i].Pokememe.Grade == neededGrade {
|
||||
matchLeague := false
|
||||
if profileRaw.LevelID < 4 {
|
||||
|
@ -30,8 +30,17 @@ func (p *Pokedexer) ParsePokememe(update *tgbotapi.Update, playerRaw *dbmapping.
|
||||
c.Log.Debug("Processing string: " + pokememeStringsArray[i])
|
||||
if strings.Contains(pokememeStringsArray[i], "⃣") {
|
||||
// Strings with name and grade
|
||||
pokememeData["grade"] = string(pokememeRunesArray[i][0])
|
||||
pokememeData["name"] = string(pokememeRunesArray[i][3:])
|
||||
splitGradeAndName := strings.Split(string(pokememeRunesArray[i]), " ")
|
||||
gradeNumberRegexp := regexp.MustCompile("[0-9]+")
|
||||
pokememeData["grade"] = strings.Join(gradeNumberRegexp.FindAllString(splitGradeAndName[0], -1), "")
|
||||
pokememeData["name"] = strings.Join(splitGradeAndName[1:], " ")
|
||||
}
|
||||
|
||||
// Special case: "10" emoji
|
||||
if strings.Contains(pokememeStringsArray[i], "🔟") {
|
||||
// Strings with name and grade
|
||||
pokememeData["grade"] = "10"
|
||||
pokememeData["name"] = string(pokememeStringsArray[i][5:])
|
||||
}
|
||||
|
||||
if i == 1 {
|
||||
|
@ -33,8 +33,8 @@ func (p *Pokedexer) pokememesListing(update *tgbotapi.Update, page int, pokememe
|
||||
if (i+1 > 50*(page-1)) && (i+1 < (50*page)+1) {
|
||||
pk := pokememesArray[i].Pokememe
|
||||
pkE := pokememesArray[i].Elements
|
||||
message += strconv.Itoa(i+1) + ". " + strconv.Itoa(pk.Grade)
|
||||
message += "⃣ *" + pk.Name
|
||||
message += strconv.Itoa(i+1) + ". *[" + strconv.Itoa(pk.Grade)
|
||||
message += "]* *" + pk.Name
|
||||
message += "* (" + c.Statistics.GetPrintablePoints(pk.HP) + "-" + c.Statistics.GetPrintablePoints(pk.MP) + ") ⚔️ *"
|
||||
message += c.Statistics.GetPrintablePoints(pk.Attack) + "* \\["
|
||||
for j := range pkE {
|
||||
|
@ -42,7 +42,7 @@ func (p *Pokedexer) AdvicePokememesList(update *tgbotapi.Update, playerRaw *dbma
|
||||
pk := pokememes[i].Pokememe
|
||||
pkL := pokememes[i].Locations
|
||||
pkE := pokememes[i].Elements
|
||||
message += strconv.Itoa(pk.Grade) + "⃣ "
|
||||
message += "*[" + strconv.Itoa(pk.Grade) + "]* "
|
||||
message += pk.Name + " (⚔"
|
||||
message += c.Statistics.GetPrintablePoints(pk.Attack)
|
||||
message += ", 🛡" + c.Statistics.GetPrintablePoints(pk.Defence) + ")"
|
||||
@ -118,7 +118,7 @@ func (p *Pokedexer) PokememeInfo(update *tgbotapi.Update, playerRaw *dbmapping.P
|
||||
|
||||
pk := pokememe.Pokememe
|
||||
|
||||
message := strconv.Itoa(pk.Grade) + "⃣ *" + pk.Name + "*\n"
|
||||
message := "*[" + strconv.Itoa(pk.Grade) + "]* *" + pk.Name + "*\n"
|
||||
message += pk.Description + "\n\n"
|
||||
message += "Элементы:"
|
||||
for i := range pokememe.Elements {
|
||||
|
Reference in New Issue
Block a user