上传道具使用配置

This commit is contained in:
liwei1dao 2022-07-22 19:34:05 +08:00
parent efc585f8e3
commit 2bf8b2bf12
5 changed files with 172 additions and 3 deletions

View File

@ -0,0 +1,45 @@
[
{
"group": 10001,
"star": 0,
"prize": [
{
"a": "attr",
"t": "gold",
"n": 1000
},
{
"a": "attr",
"t": "gold",
"n": 2000
},
{
"a": "attr",
"t": "gold",
"n": 3000
}
],
"p": [
1000,
1000,
1000
]
},
{
"group": 20001,
"star": 0,
"prize": [
{
"a": "attr",
"t": "gold",
"n": 4000
},
{
"a": "attr",
"t": "gold",
"n": 5000
}
],
"p": []
}
]

View File

@ -22,6 +22,7 @@ func (this *apiComp) Useitem(session comm.IUserSession, req *pb.ItemsUseItemReq)
err error
item *pb.DB_UserItemData
itemcf *cfg.Game_itemData
prop *cfg.Game_propsgroupData
)
if code = this.UseitemCheck(session, req); code != pb.ErrorCode_Success {
return
@ -35,8 +36,12 @@ func (this *apiComp) Useitem(session comm.IUserSession, req *pb.ItemsUseItemReq)
return
}
switch itemcf.Usetype {
case 4:
sale := make([]*cfg.Game_atn, len(itemcf.Sale))
case 6:
if prop, err = this.module.configure.GetPropsgroupConfigure(itemcf.BoxId); err != nil {
code = pb.ErrorCode_ConfigNoFound
return
}
sale := make([]*cfg.Game_atn, len(prop.Prize))
for _, v := range sale {
v.N = v.N * int32(req.Amount)
}

View File

@ -11,6 +11,7 @@ import (
const (
game_item = "game_item.json"
game_propsgroup = "game_propsgroup.json"
)
///背包配置管理组件
@ -87,3 +88,22 @@ func (this *ConfigureComp) GetPackItemByType(itmes []*pb.DB_UserItemData, usetyp
}
return
}
//获取道具礼包组
func (this *ConfigureComp) GetPropsgroupConfigure(id int32) (item *cfg.Game_propsgroupData, err error) {
var (
v interface{}
ok bool
)
if v, err = this.GetConfigure(game_propsgroup); err != nil {
this.module.Errorf("err:%v", err)
return
} else {
if item, ok = v.(*cfg.Game_propsgroup).GetDataMap()[id]; !ok {
err = fmt.Errorf("no found item:%d configure", id)
this.module.Errorf("err:%v", err)
return
}
}
return
}

View File

@ -0,0 +1,42 @@
//------------------------------------------------------------------------------
// <auto-generated>
// This code was generated by a tool.
// Changes to this file may cause incorrect behavior and will be lost if
// the code is regenerated.
// </auto-generated>
//------------------------------------------------------------------------------
package cfg
type Game_propsgroup struct {
_dataMap map[int32]*Game_propsgroupData
_dataList []*Game_propsgroupData
}
func NewGame_propsgroup(_buf []map[string]interface{}) (*Game_propsgroup, error) {
_dataList := make([]*Game_propsgroupData, 0, len(_buf))
dataMap := make(map[int32]*Game_propsgroupData)
for _, _ele_ := range _buf {
if _v, err2 := NewGame_propsgroupData(_ele_); err2 != nil {
return nil, err2
} else {
_dataList = append(_dataList, _v)
dataMap[_v.Group] = _v
}
}
return &Game_propsgroup{_dataList:_dataList, _dataMap:dataMap}, nil
}
func (table *Game_propsgroup) GetDataMap() map[int32]*Game_propsgroupData {
return table._dataMap
}
func (table *Game_propsgroup) GetDataList() []*Game_propsgroupData {
return table._dataList
}
func (table *Game_propsgroup) Get(key int32) *Game_propsgroupData {
return table._dataMap[key]
}

View File

@ -0,0 +1,57 @@
//------------------------------------------------------------------------------
// <auto-generated>
// This code was generated by a tool.
// Changes to this file may cause incorrect behavior and will be lost if
// the code is regenerated.
// </auto-generated>
//------------------------------------------------------------------------------
package cfg
import "errors"
type Game_propsgroupData struct {
Group int32
Star int32
Prize []*Game_atn
P []int32
}
func (Game_propsgroupData) GetTypeId() int {
return -1658257195
}
func NewGame_propsgroupData(_buf map[string]interface{}) (_v *Game_propsgroupData, err error) {
_v = &Game_propsgroupData{}
{ var _ok_ bool; var _tempNum_ float64; if _tempNum_, _ok_ = _buf["group"].(float64); !_ok_ { err = errors.New("group error"); return }; _v.Group = int32(_tempNum_) }
{ var _ok_ bool; var _tempNum_ float64; if _tempNum_, _ok_ = _buf["star"].(float64); !_ok_ { err = errors.New("star error"); return }; _v.Star = int32(_tempNum_) }
{
var _arr_ []interface{}
var _ok_ bool
if _arr_, _ok_ = _buf["prize"].([]interface{}); !_ok_ { err = errors.New("prize error"); return }
_v.Prize = make([]*Game_atn, 0, len(_arr_))
for _, _e_ := range _arr_ {
var _list_v_ *Game_atn
{ var _ok_ bool; var _x_ map[string]interface{}; if _x_, _ok_ = _e_.(map[string]interface{}); !_ok_ { err = errors.New("_list_v_ error"); return }; if _list_v_, err = NewGame_atn(_x_); err != nil { return } }
_v.Prize = append(_v.Prize, _list_v_)
}
}
{
var _arr_ []interface{}
var _ok_ bool
if _arr_, _ok_ = _buf["p"].([]interface{}); !_ok_ { err = errors.New("p error"); return }
_v.P = make([]int32, 0, len(_arr_))
for _, _e_ := range _arr_ {
var _list_v_ int32
{ var _ok_ bool; var _x_ float64; if _x_, _ok_ = _e_.(float64); !_ok_ { err = errors.New("_list_v_ error"); return }; _list_v_ = int32(_x_) }
_v.P = append(_v.P, _list_v_)
}
}
return
}