上传道具使用掉落组更换
This commit is contained in:
parent
ec2b903fdc
commit
42adce6fd3
@ -23,7 +23,7 @@ func (this *apiComp) Useitem(session comm.IUserSession, req *pb.ItemsUseItemReq)
|
|||||||
err error
|
err error
|
||||||
item *pb.DB_UserItemData
|
item *pb.DB_UserItemData
|
||||||
itemcf *cfg.GameItemData
|
itemcf *cfg.GameItemData
|
||||||
prop []*cfg.GamePropsgroupData
|
prop []*cfg.GameDropData
|
||||||
)
|
)
|
||||||
if code = this.UseitemCheck(session, req); code != pb.ErrorCode_Success {
|
if code = this.UseitemCheck(session, req); code != pb.ErrorCode_Success {
|
||||||
return
|
return
|
||||||
@ -38,7 +38,7 @@ func (this *apiComp) Useitem(session comm.IUserSession, req *pb.ItemsUseItemReq)
|
|||||||
}
|
}
|
||||||
switch itemcf.Usetype {
|
switch itemcf.Usetype {
|
||||||
case 1: //英雄碎片
|
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
|
code = pb.ErrorCode_ConfigNoFound
|
||||||
return
|
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, 1)
|
||||||
this.module.ModuleRtask.SendToRtask(session, comm.Rtype22, utils.ToInt32(sale.Prize[0].T))
|
this.module.ModuleRtask.SendToRtask(session, comm.Rtype22, utils.ToInt32(sale.Prize[0].T))
|
||||||
case 4: //自选宝箱
|
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
|
code = pb.ErrorCode_ConfigNoFound
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
@ -66,7 +66,7 @@ func (this *apiComp) Useitem(session comm.IUserSession, req *pb.ItemsUseItemReq)
|
|||||||
}
|
}
|
||||||
var sale []*cfg.Gameatn
|
var sale []*cfg.Gameatn
|
||||||
for _, v := range prop {
|
for _, v := range prop {
|
||||||
if v.Key == req.Select {
|
if v.Id == req.Select {
|
||||||
for _, v1 := range v.Prize {
|
for _, v1 := range v.Prize {
|
||||||
sale = append(sale, &cfg.Gameatn{
|
sale = append(sale, &cfg.Gameatn{
|
||||||
A: v1.A,
|
A: v1.A,
|
||||||
@ -86,7 +86,7 @@ func (this *apiComp) Useitem(session comm.IUserSession, req *pb.ItemsUseItemReq)
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
case 5: //随机宝箱
|
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
|
code = pb.ErrorCode_ConfigNoFound
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
@ -101,7 +101,7 @@ func (this *apiComp) Useitem(session comm.IUserSession, req *pb.ItemsUseItemReq)
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
case 6: //箱子
|
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
|
code = pb.ErrorCode_ConfigNoFound
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
@ -123,7 +123,7 @@ func (this *apiComp) Useitem(session comm.IUserSession, req *pb.ItemsUseItemReq)
|
|||||||
}
|
}
|
||||||
break
|
break
|
||||||
case 8: //觉醒材料合成
|
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
|
code = pb.ErrorCode_ConfigNoFound
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
@ -4,7 +4,6 @@ import (
|
|||||||
"fmt"
|
"fmt"
|
||||||
"go_dreamfactory/modules"
|
"go_dreamfactory/modules"
|
||||||
"go_dreamfactory/pb"
|
"go_dreamfactory/pb"
|
||||||
"go_dreamfactory/sys/configure"
|
|
||||||
cfg "go_dreamfactory/sys/configure/structs"
|
cfg "go_dreamfactory/sys/configure/structs"
|
||||||
"sync"
|
"sync"
|
||||||
|
|
||||||
@ -12,42 +11,42 @@ import (
|
|||||||
)
|
)
|
||||||
|
|
||||||
const (
|
const (
|
||||||
game_item = "game_item.json"
|
game_item = "game_item.json"
|
||||||
game_propsgroup = "game_propsgroup.json"
|
// game_propsgroup = "game_propsgroup.json"
|
||||||
game_propsgrouplist = "game_propsgrouplist.json"
|
// game_propsgrouplist = "game_propsgrouplist.json"
|
||||||
)
|
)
|
||||||
|
|
||||||
///背包配置管理组件
|
///背包配置管理组件
|
||||||
type ConfigureComp struct {
|
type ConfigureComp struct {
|
||||||
modules.MCompConfigure
|
modules.MCompConfigure
|
||||||
module *Items
|
module *Items
|
||||||
lock sync.RWMutex
|
lock sync.RWMutex
|
||||||
propsgroup map[int32][]*cfg.GamePropsgroupData
|
// propsgroup map[int32][]*cfg.GamePropsgroupData
|
||||||
}
|
}
|
||||||
|
|
||||||
//组件初始化接口
|
//组件初始化接口
|
||||||
func (this *ConfigureComp) Init(service core.IService, module core.IModule, comp core.IModuleComp, options core.IModuleOptions) (err error) {
|
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.MCompConfigure.Init(service, module, comp, options)
|
||||||
this.module = module.(*Items)
|
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 = this.LoadConfigure(game_item, cfg.NewGameItem)
|
||||||
err = configure.RegisterConfigure(game_propsgroup, cfg.NewGamePropsgroup, func() {
|
// err = configure.RegisterConfigure(game_propsgroup, cfg.NewGamePropsgroup, func() {
|
||||||
if v, err := this.GetConfigure(game_propsgroup); err == nil {
|
// if v, err := this.GetConfigure(game_propsgroup); err == nil {
|
||||||
if configure, ok := v.(*cfg.GamePropsgroup); ok {
|
// if configure, ok := v.(*cfg.GamePropsgroup); ok {
|
||||||
this.lock.Lock()
|
// this.lock.Lock()
|
||||||
defer this.lock.Unlock()
|
// defer this.lock.Unlock()
|
||||||
for _, value := range configure.GetDataList() {
|
// for _, value := range configure.GetDataList() {
|
||||||
if _, ok = this.propsgroup[value.Group]; !ok {
|
// if _, ok = this.propsgroup[value.Group]; !ok {
|
||||||
this.propsgroup[value.Group] = make([]*cfg.GamePropsgroupData, 0)
|
// this.propsgroup[value.Group] = make([]*cfg.GamePropsgroupData, 0)
|
||||||
}
|
// }
|
||||||
this.propsgroup[value.Group] = append(this.propsgroup[value.Group], value)
|
// this.propsgroup[value.Group] = append(this.propsgroup[value.Group], value)
|
||||||
}
|
// }
|
||||||
return
|
// return
|
||||||
}
|
// }
|
||||||
} else {
|
// } else {
|
||||||
this.module.Errorln(err)
|
// this.module.Errorln(err)
|
||||||
}
|
// }
|
||||||
})
|
// })
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -112,14 +111,14 @@ func (this *ConfigureComp) GetPackItemByType(itmes []*pb.DB_UserItemData, bagtyp
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
//获取道具礼包组
|
// //获取道具礼包组
|
||||||
func (this *ConfigureComp) GetPropsgroupConfigure(gid int32) (result []*cfg.GamePropsgroupData, err error) {
|
// func (this *ConfigureComp) GetPropsgroupConfigure(gid int32) (result []*cfg.GamePropsgroupData, err error) {
|
||||||
var ok bool
|
// var ok bool
|
||||||
this.lock.RLock()
|
// this.lock.RLock()
|
||||||
result, ok = this.propsgroup[gid]
|
// result, ok = this.getd[gid]
|
||||||
this.lock.RUnlock()
|
// this.lock.RUnlock()
|
||||||
if !ok {
|
// if !ok {
|
||||||
err = fmt.Errorf("no found gid:%d", gid)
|
// err = fmt.Errorf("no found gid:%d", gid)
|
||||||
}
|
// }
|
||||||
return
|
// return
|
||||||
}
|
// }
|
||||||
|
@ -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 {
|
if group == nil || len(group) == 0 {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user