购买价格组整合
This commit is contained in:
parent
2f99a821e9
commit
260d936e20
93
bin/json/game_pricegroup.json
Normal file
93
bin/json/game_pricegroup.json
Normal file
@ -0,0 +1,93 @@
|
||||
[
|
||||
{
|
||||
"id": 1,
|
||||
"pricegroupId": 1001,
|
||||
"purchasemin": 1,
|
||||
"purchasemax": 1,
|
||||
"cost": [
|
||||
{
|
||||
"a": "attr",
|
||||
"t": "diamond",
|
||||
"n": 20
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"id": 2,
|
||||
"pricegroupId": 1001,
|
||||
"purchasemin": 2,
|
||||
"purchasemax": 3,
|
||||
"cost": [
|
||||
{
|
||||
"a": "attr",
|
||||
"t": "diamond",
|
||||
"n": 30
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"id": 3,
|
||||
"pricegroupId": 1001,
|
||||
"purchasemin": 4,
|
||||
"purchasemax": 6,
|
||||
"cost": [
|
||||
{
|
||||
"a": "attr",
|
||||
"t": "diamond",
|
||||
"n": 50
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"id": 4,
|
||||
"pricegroupId": 1001,
|
||||
"purchasemin": 7,
|
||||
"purchasemax": 7,
|
||||
"cost": [
|
||||
{
|
||||
"a": "attr",
|
||||
"t": "diamond",
|
||||
"n": 100
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"id": 5,
|
||||
"pricegroupId": 1001,
|
||||
"purchasemin": 8,
|
||||
"purchasemax": 8,
|
||||
"cost": [
|
||||
{
|
||||
"a": "attr",
|
||||
"t": "diamond",
|
||||
"n": 150
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"id": 6,
|
||||
"pricegroupId": 1001,
|
||||
"purchasemin": 9,
|
||||
"purchasemax": 9,
|
||||
"cost": [
|
||||
{
|
||||
"a": "attr",
|
||||
"t": "diamond",
|
||||
"n": 200
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"id": 7,
|
||||
"pricegroupId": 1001,
|
||||
"purchasemin": 10,
|
||||
"purchasemax": 10,
|
||||
"cost": [
|
||||
{
|
||||
"a": "attr",
|
||||
"t": "diamond",
|
||||
"n": 250
|
||||
}
|
||||
]
|
||||
}
|
||||
]
|
@ -763,5 +763,8 @@ const (
|
||||
SmithyToolsSkill3 = 3 // 所有图纸炉温消耗减少
|
||||
SmithyToolsSkill4 = 4 // 每日顾客数量提升至{0}人
|
||||
SmithyToolsSkill5 = 5 // 顾客购买装备数量上限提高至{0}件
|
||||
|
||||
)
|
||||
|
||||
const (
|
||||
ArenaBuyType = 1001 // 价格组ID
|
||||
)
|
||||
|
@ -455,5 +455,6 @@ type (
|
||||
ITools interface {
|
||||
GetGroupDataByLottery(lotteryId int32, vipLv int32, lv int32) (items []*cfg.Gameatn)
|
||||
GetGlobalConf() *cfg.GameGlobalData
|
||||
GetPriceGroupCost(pricegroupId int32, purchase int32) (res []*cfg.Gameatn)
|
||||
}
|
||||
)
|
||||
|
@ -45,11 +45,17 @@ func (this *apiComp) Buy(session comm.IUserSession, req *pb.ArenaBuyReq) (code p
|
||||
code = pb.ErrorCode_ArenaTicketBuyUp
|
||||
return
|
||||
}
|
||||
if challenge, err = this.module.configure.GetchallengeData(info.Buynum + i + 1); err != nil || challenge == nil {
|
||||
if res := this.module.ModuleTools.GetPriceGroupCost(comm.ArenaBuyType, info.Buynum+i+1); len(res) > 0 {
|
||||
need = append(need, challenge.Need...)
|
||||
} else {
|
||||
code = pb.ErrorCode_ConfigNoFound
|
||||
return
|
||||
}
|
||||
need = append(need, challenge.Need...)
|
||||
// if challenge, err = this.module.configure.GetchallengeData(info.Buynum + i + 1); err != nil || challenge == nil {
|
||||
// code = pb.ErrorCode_ConfigNoFound
|
||||
// return
|
||||
// }
|
||||
// need = append(need, challenge.Need...)
|
||||
}
|
||||
|
||||
if code = this.module.ConsumeRes(session, need, true); code != pb.ErrorCode_Success {
|
||||
|
@ -29,6 +29,7 @@ const (
|
||||
game_equip = "game_equip.json" //装备信息表
|
||||
|
||||
game_lottery = "game_lottery.json"
|
||||
game_price = "game_pricegroup.json"
|
||||
)
|
||||
|
||||
///配置管理基础组件
|
||||
@ -51,6 +52,8 @@ type MCompConfigure struct {
|
||||
Btype map[int32]int32
|
||||
Stype map[int64]int32 // subtype
|
||||
SNum map[int64]int32 // 小组产出数量
|
||||
|
||||
_price map[int32][]*cfg.GamePricegroupData
|
||||
}
|
||||
|
||||
//组件初始化接口
|
||||
@ -72,7 +75,7 @@ func (this *MCompConfigure) Init(service core.IService, module core.IModule, com
|
||||
this._sign = make(map[int32]*cfg.GameSignData, 0)
|
||||
configure.RegisterConfigure(game_drop, cfg.NewGameDrop, this.LoadDropData)
|
||||
configure.RegisterConfigure(game_sign, cfg.NewGameSign, this.LoadSignData)
|
||||
|
||||
configure.RegisterConfigure(game_price, cfg.NewGamePricegroup, this.LoadPriceGroup)
|
||||
this._group = make(map[int64][]int32, 0)
|
||||
this._lotteryType1 = make(map[int32][]int32, 0)
|
||||
this._lotteryType2 = make(map[int32][]int32, 0)
|
||||
@ -587,3 +590,33 @@ func (this *MCompConfigure) GetLotterConfById(id int32) (data *cfg.GameLotteryDa
|
||||
}
|
||||
return
|
||||
}
|
||||
func (this *MCompConfigure) LoadPriceGroup() {
|
||||
this._price = make(map[int32][]*cfg.GamePricegroupData)
|
||||
if v, err := this.GetConfigure(game_price); err == nil {
|
||||
if configure, ok := v.(*cfg.GamePricegroup); ok {
|
||||
this.hlock.Lock()
|
||||
defer this.hlock.Unlock()
|
||||
for _, value := range configure.GetDataList() {
|
||||
this._price[value.PricegroupId] = append(this._price[value.PricegroupId], value)
|
||||
}
|
||||
return
|
||||
}
|
||||
} else {
|
||||
log.Errorf("get game_price conf err:%v", err)
|
||||
}
|
||||
return
|
||||
}
|
||||
|
||||
// 获取
|
||||
func (this *MCompConfigure) GetPriceGroup(pricegroupId int32) (sz []*cfg.GamePricegroupData) {
|
||||
return this._price[pricegroupId]
|
||||
}
|
||||
|
||||
func (this *MCompConfigure) GetPriceGroupCost(pricegroupId int32, purchase int32) (res []*cfg.Gameatn) {
|
||||
for _, v := range this._price[pricegroupId] {
|
||||
if v.Purchasemin <= purchase && purchase <= v.Purchasemax {
|
||||
return v.Cost
|
||||
}
|
||||
}
|
||||
return
|
||||
}
|
||||
|
@ -48,3 +48,7 @@ func (this *Tools) GetGroupDataByLottery(lotteryId int32, vipLv int32, lv int32)
|
||||
func (this *Tools) GetGlobalConf() *cfg.GameGlobalData {
|
||||
return this.configure.GetGlobalConf()
|
||||
}
|
||||
|
||||
func (this *Tools) GetPriceGroupCost(pricegroupId int32, purchase int32) (res []*cfg.Gameatn) {
|
||||
return this.configure.GetPriceGroupCost(pricegroupId, purchase)
|
||||
}
|
||||
|
42
sys/configure/structs/Game.Pricegroup.go
Normal file
42
sys/configure/structs/Game.Pricegroup.go
Normal 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 GamePricegroup struct {
|
||||
_dataMap map[int32]*GamePricegroupData
|
||||
_dataList []*GamePricegroupData
|
||||
}
|
||||
|
||||
func NewGamePricegroup(_buf []map[string]interface{}) (*GamePricegroup, error) {
|
||||
_dataList := make([]*GamePricegroupData, 0, len(_buf))
|
||||
dataMap := make(map[int32]*GamePricegroupData)
|
||||
for _, _ele_ := range _buf {
|
||||
if _v, err2 := DeserializeGamePricegroupData(_ele_); err2 != nil {
|
||||
return nil, err2
|
||||
} else {
|
||||
_dataList = append(_dataList, _v)
|
||||
dataMap[_v.Id] = _v
|
||||
}
|
||||
}
|
||||
return &GamePricegroup{_dataList:_dataList, _dataMap:dataMap}, nil
|
||||
}
|
||||
|
||||
func (table *GamePricegroup) GetDataMap() map[int32]*GamePricegroupData {
|
||||
return table._dataMap
|
||||
}
|
||||
|
||||
func (table *GamePricegroup) GetDataList() []*GamePricegroupData {
|
||||
return table._dataList
|
||||
}
|
||||
|
||||
func (table *GamePricegroup) Get(key int32) *GamePricegroupData {
|
||||
return table._dataMap[key]
|
||||
}
|
||||
|
||||
|
56
sys/configure/structs/Game.PricegroupData.go
Normal file
56
sys/configure/structs/Game.PricegroupData.go
Normal file
@ -0,0 +1,56 @@
|
||||
//------------------------------------------------------------------------------
|
||||
// <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 GamePricegroupData struct {
|
||||
Id int32
|
||||
PricegroupId int32
|
||||
Purchasemin int32
|
||||
Purchasemax int32
|
||||
Cost []*Gameatn
|
||||
}
|
||||
|
||||
const TypeId_GamePricegroupData = -1839697636
|
||||
|
||||
func (*GamePricegroupData) GetTypeId() int32 {
|
||||
return -1839697636
|
||||
}
|
||||
|
||||
func (_v *GamePricegroupData)Deserialize(_buf map[string]interface{}) (err error) {
|
||||
{ var _ok_ bool; var _tempNum_ float64; if _tempNum_, _ok_ = _buf["id"].(float64); !_ok_ { err = errors.New("id error"); return }; _v.Id = int32(_tempNum_) }
|
||||
{ var _ok_ bool; var _tempNum_ float64; if _tempNum_, _ok_ = _buf["pricegroupId"].(float64); !_ok_ { err = errors.New("pricegroupId error"); return }; _v.PricegroupId = int32(_tempNum_) }
|
||||
{ var _ok_ bool; var _tempNum_ float64; if _tempNum_, _ok_ = _buf["purchasemin"].(float64); !_ok_ { err = errors.New("purchasemin error"); return }; _v.Purchasemin = int32(_tempNum_) }
|
||||
{ var _ok_ bool; var _tempNum_ float64; if _tempNum_, _ok_ = _buf["purchasemax"].(float64); !_ok_ { err = errors.New("purchasemax error"); return }; _v.Purchasemax = int32(_tempNum_) }
|
||||
{
|
||||
var _arr_ []interface{}
|
||||
var _ok_ bool
|
||||
if _arr_, _ok_ = _buf["cost"].([]interface{}); !_ok_ { err = errors.New("cost error"); return }
|
||||
|
||||
_v.Cost = make([]*Gameatn, 0, len(_arr_))
|
||||
|
||||
for _, _e_ := range _arr_ {
|
||||
var _list_v_ *Gameatn
|
||||
{ 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 = DeserializeGameatn(_x_); err != nil { return } }
|
||||
_v.Cost = append(_v.Cost, _list_v_)
|
||||
}
|
||||
}
|
||||
|
||||
return
|
||||
}
|
||||
|
||||
func DeserializeGamePricegroupData(_buf map[string]interface{}) (*GamePricegroupData, error) {
|
||||
v := &GamePricegroupData{}
|
||||
if err := v.Deserialize(_buf); err == nil {
|
||||
return v, nil
|
||||
} else {
|
||||
return nil, err
|
||||
}
|
||||
}
|
File diff suppressed because it is too large
Load Diff
Loading…
Reference in New Issue
Block a user