Pokememes possibilities, some refactoring
This commit is contained in:
@@ -7,12 +7,12 @@ import (
|
||||
// 3rd party
|
||||
"github.com/go-telegram-bot-api/telegram-bot-api"
|
||||
// local
|
||||
"../../dbmappings"
|
||||
"../../dbmapping"
|
||||
)
|
||||
|
||||
|
||||
type ParsersInterface interface {
|
||||
ParsePokememe(text string, player_raw dbmappings.Players) string
|
||||
ParseProfile(update tgbotapi.Update, player_raw dbmappings.Players) string
|
||||
ParsePokememe(text string, player_raw dbmapping.Player) string
|
||||
ParseProfile(update tgbotapi.Update, player_raw dbmapping.Player) string
|
||||
ReturnPoints(points int) string
|
||||
}
|
||||
|
@@ -11,7 +11,7 @@ import (
|
||||
"strconv"
|
||||
"time"
|
||||
// local
|
||||
"../dbmappings"
|
||||
"../dbmapping"
|
||||
)
|
||||
|
||||
// Internal functions
|
||||
@@ -34,7 +34,7 @@ func (p *Parsers) getPoints(points_str string) int {
|
||||
|
||||
// External functions
|
||||
|
||||
func (p *Parsers) ParsePokememe(text string, player_raw dbmappings.Players) string {
|
||||
func (p *Parsers) ParsePokememe(text string, player_raw dbmapping.Player) string {
|
||||
var defendable_pokememe bool = false
|
||||
pokememe_info_strings := strings.Split(text, "\n")
|
||||
pokememe_info_runed_strings := make([][]rune, 0)
|
||||
@@ -47,7 +47,7 @@ func (p *Parsers) ParsePokememe(text string, player_raw dbmappings.Players) stri
|
||||
}
|
||||
|
||||
// Getting elements
|
||||
elements := []dbmappings.Elements{}
|
||||
elements := []dbmapping.Element{}
|
||||
element_emojis := make([]string, 0)
|
||||
element_emojis = append(element_emojis, string(pokememe_info_runed_strings[4][11]))
|
||||
if len(pokememe_info_runed_strings[4]) > 12 {
|
||||
@@ -75,7 +75,7 @@ func (p *Parsers) ParsePokememe(text string, player_raw dbmappings.Players) stri
|
||||
defence := "0"
|
||||
price := "0"
|
||||
|
||||
locations := []dbmappings.Locations{}
|
||||
locations := []dbmapping.Location{}
|
||||
|
||||
purchaseable := false
|
||||
image := ""
|
||||
@@ -180,7 +180,7 @@ func (p *Parsers) ParsePokememe(text string, player_raw dbmappings.Players) stri
|
||||
log.Printf("Image: " + image)
|
||||
|
||||
// Building pokememe
|
||||
pokememe := dbmappings.Pokememes{}
|
||||
pokememe := dbmapping.Pokememe{}
|
||||
// Checking if pokememe exists in database
|
||||
err3 := c.Db.Get(&pokememe, c.Db.Rebind("SELECT * FROM pokememes WHERE grade='" + grade + "' AND name='" + name + "';"))
|
||||
if err3 != nil {
|
||||
@@ -227,7 +227,7 @@ func (p *Parsers) ParsePokememe(text string, player_raw dbmappings.Players) stri
|
||||
return "fail"
|
||||
}
|
||||
for i := range(elements) {
|
||||
link := dbmappings.PokememesElements{}
|
||||
link := dbmapping.PokememeElement{}
|
||||
link.Pokememe_id = pokememe.Id
|
||||
link.Element_id = elements[i].Id
|
||||
link.Created_at = time.Now().UTC()
|
||||
@@ -239,7 +239,7 @@ func (p *Parsers) ParsePokememe(text string, player_raw dbmappings.Players) stri
|
||||
}
|
||||
}
|
||||
for i := range(locations) {
|
||||
link := dbmappings.PokememesLocations{}
|
||||
link := dbmapping.PokememeLocation{}
|
||||
link.Pokememe_id = pokememe.Id
|
||||
link.Location_id = locations[i].Id
|
||||
link.Created_at = time.Now().UTC()
|
||||
|
@@ -13,13 +13,13 @@ import (
|
||||
// 3rd party
|
||||
"github.com/go-telegram-bot-api/telegram-bot-api"
|
||||
// local
|
||||
"../dbmappings"
|
||||
"../dbmapping"
|
||||
)
|
||||
|
||||
// Internal functions
|
||||
|
||||
func (p *Parsers) fillProfilePokememe(profile_id int, meme string, attack string, rarity string) {
|
||||
spk_raw := dbmappings.Pokememes{}
|
||||
spk_raw := dbmapping.Pokememe{}
|
||||
err := c.Db.Get(&spk_raw, c.Db.Rebind("SELECT * FROM pokememes WHERE name='" + meme + "';"))
|
||||
if err != nil {
|
||||
log.Println(err)
|
||||
@@ -32,7 +32,7 @@ func (p *Parsers) fillProfilePokememe(profile_id int, meme string, attack string
|
||||
}
|
||||
level := int(float64(attack_int) / orig_attack)
|
||||
|
||||
ppk := dbmappings.ProfilesPokememes{}
|
||||
ppk := dbmapping.ProfilePokememe{}
|
||||
ppk.Profile_id = profile_id
|
||||
ppk.Pokememe_id = spk_raw.Id
|
||||
ppk.Pokememe_lvl = level
|
||||
@@ -47,7 +47,7 @@ func (p *Parsers) fillProfilePokememe(profile_id int, meme string, attack string
|
||||
|
||||
// External functions
|
||||
|
||||
func (p *Parsers) ParseProfile(update tgbotapi.Update, player_raw dbmappings.Players) string {
|
||||
func (p *Parsers) ParseProfile(update tgbotapi.Update, player_raw dbmapping.Player) string {
|
||||
text := update.Message.Text
|
||||
log.Println(text)
|
||||
|
||||
@@ -57,7 +57,7 @@ func (p *Parsers) ParseProfile(update tgbotapi.Update, player_raw dbmappings.Pla
|
||||
profile_info_runed_strings = append(profile_info_runed_strings, []rune(profile_info_strings[i]))
|
||||
}
|
||||
|
||||
league := dbmappings.Leagues{}
|
||||
league := dbmapping.League{}
|
||||
|
||||
telegram_nickname := update.Message.From.UserName
|
||||
nickname := ""
|
||||
@@ -199,7 +199,7 @@ func (p *Parsers) ParseProfile(update tgbotapi.Update, player_raw dbmappings.Pla
|
||||
}
|
||||
|
||||
// Information is gathered, let's create profile in database!
|
||||
weapon_raw := dbmappings.Weapons{}
|
||||
weapon_raw := dbmapping.Weapon{}
|
||||
err2 := c.Db.Get(&weapon_raw, c.Db.Rebind("SELECT * FROM weapons WHERE name='" + weapon + "'"))
|
||||
if err2 != nil {
|
||||
log.Println(err2)
|
||||
@@ -234,7 +234,7 @@ func (p *Parsers) ParseProfile(update tgbotapi.Update, player_raw dbmappings.Pla
|
||||
}
|
||||
}
|
||||
|
||||
profile_raw := dbmappings.Profiles{}
|
||||
profile_raw := dbmapping.Profile{}
|
||||
profile_raw.Player_id = player_raw.Id
|
||||
profile_raw.Nickname = nickname
|
||||
profile_raw.TelegramNickname = telegram_nickname
|
||||
|
Reference in New Issue
Block a user