71 lines
1.8 KiB
Go
71 lines
1.8 KiB
Go
package pagoda
|
|
|
|
import (
|
|
"go_dreamfactory/lego/core"
|
|
"go_dreamfactory/lego/core/cbase"
|
|
"go_dreamfactory/lego/sys/log"
|
|
"go_dreamfactory/sys/configure"
|
|
cfg "go_dreamfactory/sys/configure/structs"
|
|
)
|
|
|
|
const (
|
|
game_pagoda = "game_pagoda.json"
|
|
game_pagodaseasonreward = "game_pagodaseasonreward.json"
|
|
game_pagodataskreward = "game_pagodataskreward.json"
|
|
)
|
|
|
|
///配置管理基础组件
|
|
type configureComp struct {
|
|
cbase.ModuleCompBase
|
|
}
|
|
|
|
//组件初始化接口
|
|
func (this *configureComp) 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.LoadMultiConfigure(map[string]interface{}{
|
|
game_pagoda: cfg.NewGame_pagoda,
|
|
game_pagodaseasonreward: cfg.NewGame_pagodaSeasonReward,
|
|
game_pagodataskreward: cfg.NewGame_pagodaTaskReward,
|
|
})
|
|
return
|
|
}
|
|
|
|
//加载多个配置文件
|
|
func (this *configureComp) LoadMultiConfigure(confs map[string]interface{}) (err error) {
|
|
for k, v := range confs {
|
|
err = configure.RegisterConfigure(k, v)
|
|
if err != nil {
|
|
log.Errorf("配置文件:%s解析失败!", k)
|
|
break
|
|
}
|
|
}
|
|
return
|
|
}
|
|
|
|
//读取配置数据
|
|
func (this *configureComp) GetConfigure(name string) (v interface{}, err error) {
|
|
return configure.GetConfigure(name)
|
|
}
|
|
|
|
// 获取爬塔配置表数据
|
|
func (this *configureComp) GetPagodaconfig(id int32) (data *cfg.Game_pagodaData) {
|
|
if v, err := this.GetConfigure(game_pagoda); err != nil {
|
|
log.Errorf("get global conf err:%v", err)
|
|
return
|
|
} else {
|
|
var (
|
|
configure *cfg.Game_pagoda
|
|
ok bool
|
|
)
|
|
if configure, ok = v.(*cfg.Game_pagoda); !ok {
|
|
log.Errorf("%T no is *cfg.Game_pagodaData", v)
|
|
return
|
|
}
|
|
|
|
if data, ok = configure.GetDataMap()[id]; ok {
|
|
return
|
|
}
|
|
}
|
|
return
|
|
}
|