hdkv
/
i2_bot
Archived
1
Fork 0

Fix for non-finding weapons

master
Vladimir Hodakov 2018-01-30 18:41:23 +04:00
parent 78c882347d
commit 7bcaca66aa
2 changed files with 7 additions and 2 deletions

View File

@ -7,6 +7,7 @@ import (
"errors"
"git.wtfteam.pro/fat0troll/i2_bot/lib/dbmapping"
"strconv"
"strings"
)
func (dc *DataCache) initWeapons() {
@ -37,7 +38,7 @@ func (dc *DataCache) loadWeapons() {
func (dc *DataCache) GetWeaponTypeByName(name string) (*dbmapping.Weapon, error) {
dc.weaponsMutex.Lock()
for i := range dc.weapons {
if dc.weapons[i].Name == name {
if strings.HasPrefix(dc.weapons[i].Name, name) {
dc.weaponsMutex.Unlock()
return dc.weapons[i], nil
}

View File

@ -247,7 +247,11 @@ func (u *Users) ParseProfile(update *tgbotapi.Update, playerRaw *dbmapping.Playe
profileRaw.Exp = expInt
profileRaw.EggExp = eggexpInt
profileRaw.Power = powerInt
profileRaw.WeaponID = weaponRaw.ID
if weaponRaw != nil {
profileRaw.WeaponID = weaponRaw.ID
} else {
profileRaw.WeaponID = 0
}
profileRaw.Crystalls = crystallsInt
profileRaw.CreatedAt = time.Now().UTC()