上传价格组代码优化
This commit is contained in:
parent
e182aae1a3
commit
99ee5e4f51
@ -33,7 +33,7 @@ const (
|
||||
game_food = "game_breakingbad.json"
|
||||
)
|
||||
|
||||
///配置管理基础组件
|
||||
// /配置管理基础组件
|
||||
type MCompConfigure struct {
|
||||
cbase.ModuleCompBase
|
||||
hlock sync.RWMutex
|
||||
@ -56,7 +56,7 @@ type MCompConfigure struct {
|
||||
_price map[int32][]*cfg.GamePricegroupData
|
||||
}
|
||||
|
||||
//组件初始化接口
|
||||
// 组件初始化接口
|
||||
func (this *MCompConfigure) Init(service core.IService, module core.IModule, comp core.IModuleComp, options core.IModuleOptions) (err error) {
|
||||
err = this.ModuleCompBase.Init(service, module, comp, options)
|
||||
err = this.LoadConfigure(game_global, cfg.NewGameGlobal)
|
||||
@ -293,7 +293,7 @@ func (this *MCompConfigure) LoadConfigure(name string, fn interface{}) (err erro
|
||||
return configure.RegisterConfigure(name, fn, nil)
|
||||
}
|
||||
|
||||
//加载一个配置文件
|
||||
// 加载一个配置文件
|
||||
func (this *MCompConfigure) LoadDropData() {
|
||||
if v, err := this.GetConfigure(game_drop); err == nil {
|
||||
if configure, ok := v.(*cfg.GameDrop); ok {
|
||||
@ -320,7 +320,7 @@ func (this *MCompConfigure) LoadDropData() {
|
||||
return
|
||||
}
|
||||
|
||||
//加载多个配置文件
|
||||
// 加载多个配置文件
|
||||
func (this *MCompConfigure) LoadMultiConfigure(confs map[string]interface{}) (err error) {
|
||||
for k, v := range confs {
|
||||
err = configure.RegisterConfigure(k, v, nil)
|
||||
@ -332,12 +332,12 @@ func (this *MCompConfigure) LoadMultiConfigure(confs map[string]interface{}) (er
|
||||
return
|
||||
}
|
||||
|
||||
//读取配置数据
|
||||
// 读取配置数据
|
||||
func (this *MCompConfigure) GetConfigure(name string) (v interface{}, err error) {
|
||||
return configure.GetConfigure(name)
|
||||
}
|
||||
|
||||
//全局配置
|
||||
// 全局配置
|
||||
func (this *MCompConfigure) GetGlobalConf() *cfg.GameGlobalData {
|
||||
var (
|
||||
configure *cfg.GameGlobal
|
||||
@ -492,7 +492,7 @@ func (this *MCompConfigure) GetHeroConfigData() (data []*cfg.GameHeroData) {
|
||||
return nil
|
||||
}
|
||||
|
||||
//读取物品配置
|
||||
// 读取物品配置
|
||||
func (this *MCompConfigure) GetItemConfigureData(id string) (item *cfg.GameItemData, err error) {
|
||||
var (
|
||||
v interface{}
|
||||
@ -597,7 +597,7 @@ func (this *MCompConfigure) GetPriceGroupCost(pricegroupId int32, purchase int32
|
||||
return
|
||||
}
|
||||
for _, v := range this._price[pricegroupId] {
|
||||
if v.Purchasemin <= purchase && purchase <= v.Purchasemax {
|
||||
if v.Purchasemin <= purchase && (purchase <= v.Purchasemax || v.Purchasemax == -1) {
|
||||
res = v.Cost
|
||||
return
|
||||
}
|
||||
@ -609,8 +609,12 @@ func (this *MCompConfigure) GetPriceGroupLen(pricegroupId int32) (count int32, e
|
||||
if _, ok := this._price[pricegroupId]; !ok {
|
||||
err = comm.NewNotFoundConfErr("tools", game_price, pricegroupId)
|
||||
}
|
||||
count = int32(len(this._price[pricegroupId]))
|
||||
|
||||
count = 0
|
||||
for _, v := range this._price[pricegroupId] {
|
||||
if count < v.Purchasemax {
|
||||
count = v.Purchasemax
|
||||
}
|
||||
}
|
||||
return
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user