Fix for non-finding weapons
This commit is contained in:
parent
78c882347d
commit
7bcaca66aa
@ -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
|
||||
}
|
||||
|
@ -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()
|
||||
|
||||
|
Reference in New Issue
Block a user