package practice import ( "fmt" "go_dreamfactory/lego/core" "go_dreamfactory/modules" cfg "go_dreamfactory/sys/configure/structs" ) const ( game_pandamasmz = "game_pandamasmz.json" pandamas_js = "pandamas_js.json" game_pandamasjs = "game_pandamasjs.json" game_pandamasjx = "game_pandamasjx.json" game_pandamasyxjx = "game_pandamasyxjx.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(pandamas_js, cfg.NewGamePandamasJs) this.LoadConfigure(game_pandamasjs, cfg.NewGamePandamasJs) this.LoadConfigure(game_pandamasjx, cfg.NewGamePandamasJx) this.LoadConfigure(game_pandamasyxjx, cfg.NewGamePandamasYxjx) 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) getGamePandamasJs() (configure []*cfg.GamePandamasJsData, err error) { var ( v interface{} ) if v, err = this.GetConfigure(game_pandamasjx); err != nil { this.module.Errorln(err) return } else { configure = v.(*cfg.GamePandamasJs).GetDataList() } 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 } func (this *configureComp) getGamePandamasYxjx(id int32) (configure *cfg.GamePandamasYxjxData, 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.GamePandamasYxjx).GetDataMap()[id]; !ok { err = fmt.Errorf("not found:%d", id) this.module.Errorln(err) return } } return }