上传道具使用掉落组更换

This commit is contained in:
liwei1dao 2022-09-27 20:16:21 +08:00
parent ec2b903fdc
commit 42adce6fd3
3 changed files with 43 additions and 44 deletions

View File

@ -23,7 +23,7 @@ func (this *apiComp) Useitem(session comm.IUserSession, req *pb.ItemsUseItemReq)
err error
item *pb.DB_UserItemData
itemcf *cfg.GameItemData
prop []*cfg.GamePropsgroupData
prop []*cfg.GameDropData
)
if code = this.UseitemCheck(session, req); code != pb.ErrorCode_Success {
return
@ -38,7 +38,7 @@ func (this *apiComp) Useitem(session comm.IUserSession, req *pb.ItemsUseItemReq)
}
switch itemcf.Usetype {
case 1: //英雄碎片
if prop, err = this.module.configure.GetPropsgroupConfigure(itemcf.BoxId); err != nil {
if prop = this.module.configure.GetDropData(itemcf.BoxId); prop == nil {
code = pb.ErrorCode_ConfigNoFound
return
}
@ -57,7 +57,7 @@ func (this *apiComp) Useitem(session comm.IUserSession, req *pb.ItemsUseItemReq)
this.module.ModuleRtask.SendToRtask(session, comm.Rtype22, 1)
this.module.ModuleRtask.SendToRtask(session, comm.Rtype22, utils.ToInt32(sale.Prize[0].T))
case 4: //自选宝箱
if prop, err = this.module.configure.GetPropsgroupConfigure(itemcf.BoxId); err != nil {
if prop = this.module.configure.GetDropData(itemcf.BoxId); prop == nil {
code = pb.ErrorCode_ConfigNoFound
return
}
@ -66,7 +66,7 @@ func (this *apiComp) Useitem(session comm.IUserSession, req *pb.ItemsUseItemReq)
}
var sale []*cfg.Gameatn
for _, v := range prop {
if v.Key == req.Select {
if v.Id == req.Select {
for _, v1 := range v.Prize {
sale = append(sale, &cfg.Gameatn{
A: v1.A,
@ -86,7 +86,7 @@ func (this *apiComp) Useitem(session comm.IUserSession, req *pb.ItemsUseItemReq)
return
}
case 5: //随机宝箱
if prop, err = this.module.configure.GetPropsgroupConfigure(itemcf.BoxId); err != nil {
if prop = this.module.configure.GetDropData(itemcf.BoxId); prop == nil {
code = pb.ErrorCode_ConfigNoFound
return
}
@ -101,7 +101,7 @@ func (this *apiComp) Useitem(session comm.IUserSession, req *pb.ItemsUseItemReq)
return
}
case 6: //箱子
if prop, err = this.module.configure.GetPropsgroupConfigure(itemcf.BoxId); err != nil {
if prop = this.module.configure.GetDropData(itemcf.BoxId); prop == nil {
code = pb.ErrorCode_ConfigNoFound
return
}
@ -123,7 +123,7 @@ func (this *apiComp) Useitem(session comm.IUserSession, req *pb.ItemsUseItemReq)
}
break
case 8: //觉醒材料合成
if prop, err = this.module.configure.GetPropsgroupConfigure(itemcf.BoxId); err != nil {
if prop = this.module.configure.GetDropData(itemcf.BoxId); prop == nil {
code = pb.ErrorCode_ConfigNoFound
return
}

View File

@ -4,7 +4,6 @@ import (
"fmt"
"go_dreamfactory/modules"
"go_dreamfactory/pb"
"go_dreamfactory/sys/configure"
cfg "go_dreamfactory/sys/configure/structs"
"sync"
@ -12,42 +11,42 @@ import (
)
const (
game_item = "game_item.json"
game_propsgroup = "game_propsgroup.json"
game_propsgrouplist = "game_propsgrouplist.json"
game_item = "game_item.json"
// game_propsgroup = "game_propsgroup.json"
// game_propsgrouplist = "game_propsgrouplist.json"
)
///背包配置管理组件
type ConfigureComp struct {
modules.MCompConfigure
module *Items
lock sync.RWMutex
propsgroup map[int32][]*cfg.GamePropsgroupData
module *Items
lock sync.RWMutex
// propsgroup map[int32][]*cfg.GamePropsgroupData
}
//组件初始化接口
func (this *ConfigureComp) Init(service core.IService, module core.IModule, comp core.IModuleComp, options core.IModuleOptions) (err error) {
this.MCompConfigure.Init(service, module, comp, options)
this.module = module.(*Items)
this.propsgroup = make(map[int32][]*cfg.GamePropsgroupData)
// this.propsgroup = make(map[int32][]*cfg.GamePropsgroupData)
err = this.LoadConfigure(game_item, cfg.NewGameItem)
err = configure.RegisterConfigure(game_propsgroup, cfg.NewGamePropsgroup, func() {
if v, err := this.GetConfigure(game_propsgroup); err == nil {
if configure, ok := v.(*cfg.GamePropsgroup); ok {
this.lock.Lock()
defer this.lock.Unlock()
for _, value := range configure.GetDataList() {
if _, ok = this.propsgroup[value.Group]; !ok {
this.propsgroup[value.Group] = make([]*cfg.GamePropsgroupData, 0)
}
this.propsgroup[value.Group] = append(this.propsgroup[value.Group], value)
}
return
}
} else {
this.module.Errorln(err)
}
})
// err = configure.RegisterConfigure(game_propsgroup, cfg.NewGamePropsgroup, func() {
// if v, err := this.GetConfigure(game_propsgroup); err == nil {
// if configure, ok := v.(*cfg.GamePropsgroup); ok {
// this.lock.Lock()
// defer this.lock.Unlock()
// for _, value := range configure.GetDataList() {
// if _, ok = this.propsgroup[value.Group]; !ok {
// this.propsgroup[value.Group] = make([]*cfg.GamePropsgroupData, 0)
// }
// this.propsgroup[value.Group] = append(this.propsgroup[value.Group], value)
// }
// return
// }
// } else {
// this.module.Errorln(err)
// }
// })
return
}
@ -112,14 +111,14 @@ func (this *ConfigureComp) GetPackItemByType(itmes []*pb.DB_UserItemData, bagtyp
return
}
//获取道具礼包组
func (this *ConfigureComp) GetPropsgroupConfigure(gid int32) (result []*cfg.GamePropsgroupData, err error) {
var ok bool
this.lock.RLock()
result, ok = this.propsgroup[gid]
this.lock.RUnlock()
if !ok {
err = fmt.Errorf("no found gid:%d", gid)
}
return
}
// //获取道具礼包组
// func (this *ConfigureComp) GetPropsgroupConfigure(gid int32) (result []*cfg.GamePropsgroupData, err error) {
// var ok bool
// this.lock.RLock()
// result, ok = this.getd[gid]
// this.lock.RUnlock()
// if !ok {
// err = fmt.Errorf("no found gid:%d", gid)
// }
// return
// }

View File

@ -27,7 +27,7 @@ var (
)
//随机权重宝箱
func RandomProps(group []*cfg.GamePropsgroupData) (prop *cfg.GamePropsgroupData) {
func RandomProps(group []*cfg.GameDropData) (prop *cfg.GameDropData) {
if group == nil || len(group) == 0 {
return
}