上传配置

This commit is contained in:
liwei1dao 2023-04-11 19:24:59 +08:00
parent d4a06fe214
commit 6955acb918
3 changed files with 15 additions and 9 deletions

View File

@ -20,10 +20,11 @@ const (
)
var (
ItemNotEnoughError = errors.New("item not enough!") //物品不足
NoFoundGirdError = errors.New("no found gvrid!") //未找到格子
PackGridNumUpper = errors.New("grid amount upper!") //背包格子达到上限
GirdAmountUpper = errors.New("grid amount upper!") //格子容量达到上限
NoFoundItemConfig = errors.New("no found itemconfig!") //道具配置未找到
ItemNotEnoughError = errors.New("item not enough!") //物品不足
NoFoundGirdError = errors.New("no found gvrid!") //未找到格子
PackGridNumUpper = errors.New("grid amount upper!") //背包格子达到上限
GirdAmountUpper = errors.New("grid amount upper!") //格子容量达到上限
)
//随机权重宝箱

View File

@ -228,7 +228,9 @@ func (this *ModelItemsComp) AddItemToUserPack(uId string, itemId string, addnum
return
}
change = make([]*pb.DB_UserItemData, 0)
add, update, del, leftnum = this.addItemToUserPack(uId, itmes, itemId, addnum)
if add, update, del, leftnum, err = this.addItemToUserPack(uId, itmes, itemId, addnum); err != nil {
return
}
if leftnum < 0 {
err = ItemNotEnoughError
return
@ -275,7 +277,9 @@ func (this *ModelItemsComp) AddItemsToUserPack(uId string, items map[string]int3
}
change = make([]*pb.DB_UserItemData, 0)
for k, v := range items {
add, update, del, leftnum = this.addItemToUserPack(uId, itmes, k, v)
if add, update, del, leftnum, err = this.addItemToUserPack(uId, itmes, k, v); err != nil {
return
}
if leftnum < 0 {
err = ItemNotEnoughError
return
@ -352,9 +356,8 @@ func (this *ModelItemsComp) AddItemToUserPackByGrid(uId string, gridid string, a
}
///添加移除物品到用户背包
func (this *ModelItemsComp) addItemToUserPack(uid string, items []*pb.DB_UserItemData, itemId string, addnum int32) (add, update, del []*pb.DB_UserItemData, leftnum int64) {
func (this *ModelItemsComp) addItemToUserPack(uid string, items []*pb.DB_UserItemData, itemId string, addnum int32) (add, update, del []*pb.DB_UserItemData, leftnum int64, err error) {
var (
err error
conf *cfg.GameItemData
num int64
isNew bool
@ -364,6 +367,7 @@ func (this *ModelItemsComp) addItemToUserPack(uid string, items []*pb.DB_UserIte
}
if conf, err = this.module.configure.GetItemConfigure(itemId); err != nil {
this.module.Errorln(err)
err = NoFoundItemConfig
return
}
if conf.UpperLimit == 0 {

View File

@ -148,6 +148,8 @@ func (this *Items) AddItems(session comm.IUserSession, items map[string]int32, b
code = pb.ErrorCode_ItemsNoEnough
} else if err == PackGridNumUpper {
code = pb.ErrorCode_ItemsGridNumUpper
} else if err == NoFoundItemConfig {
code = pb.ErrorCode_ConfigNoFound
} else {
code = pb.ErrorCode_Unknown
}
@ -192,7 +194,6 @@ func (this *Items) RecoverTicket(session comm.IUserSession) (code pb.ErrorCode)
//Evens--------------------------------------------------------------------------------------------------------------------------------
//推送道具变化消息
func (this *Items) itemsChangePush(session comm.IUserSession, items []*pb.DB_UserItemData) (err error) {
session.SendMsg(string(this.GetType()), "change", &pb.ItemsChangePush{Grids: items})
return
}