66 lines
1.6 KiB
Go
66 lines
1.6 KiB
Go
package practice
|
|
|
|
import (
|
|
"fmt"
|
|
"go_dreamfactory/lego/core"
|
|
"go_dreamfactory/modules"
|
|
cfg "go_dreamfactory/sys/configure/structs"
|
|
)
|
|
|
|
const (
|
|
game_pandamasmz = "game_pandamasmz.json"
|
|
game_pandamasjs = "game_pandamasjs.json"
|
|
game_pandamasjx = "game_pandamasjx.json"
|
|
)
|
|
|
|
///背包配置管理组件
|
|
type configureComp struct {
|
|
modules.MCompConfigure
|
|
module *Practice
|
|
}
|
|
|
|
//组件初始化接口
|
|
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.module = module.(*Practice)
|
|
this.LoadConfigure(game_pandamasmz, cfg.NewGamePandamasMz)
|
|
this.LoadConfigure(game_pandamasjs, cfg.NewGamePandamasJs)
|
|
this.LoadConfigure(game_pandamasjx, cfg.NewGamePandamasJx)
|
|
return
|
|
}
|
|
func (this *configureComp) getGamePandamasMz(lv int32) (configure *cfg.GamePandamasMzData, err error) {
|
|
var (
|
|
v interface{}
|
|
ok bool
|
|
)
|
|
if v, err = this.GetConfigure(game_pandamasmz); err != nil {
|
|
this.module.Errorln(err)
|
|
return
|
|
} else {
|
|
if configure, ok = v.(*cfg.GamePandamasMz).GetDataMap()[lv]; !ok {
|
|
err = fmt.Errorf("not found:%d ", lv)
|
|
this.module.Errorln(err)
|
|
return
|
|
}
|
|
}
|
|
return
|
|
}
|
|
|
|
func (this *configureComp) getGamePandamasJx(id string) (configure *cfg.GamePandamasJxData, err error) {
|
|
var (
|
|
v interface{}
|
|
ok bool
|
|
)
|
|
if v, err = this.GetConfigure(game_pandamasjx); err != nil {
|
|
this.module.Errorln(err)
|
|
return
|
|
} else {
|
|
if configure, ok = v.(*cfg.GamePandamasJx).GetDataMap()[id]; !ok {
|
|
err = fmt.Errorf("not found:%s ", id)
|
|
this.module.Errorln(err)
|
|
return
|
|
}
|
|
}
|
|
return
|
|
}
|