package parkour import ( "fmt" "go_dreamfactory/lego/core" "go_dreamfactory/modules" "go_dreamfactory/sys/configure" cfg "go_dreamfactory/sys/configure/structs" ) const ( game_buzkashiopen = "game_buzkashiopen.json" game_buzkashigrade = "game_buzkashigrade.json" game_buzkashilv = "game_buzkashilv.json" game_buzkashimount = "game_buzkashimount.json" game_buzkashireward = "game_buzkashireward.json" ) ///背包配置管理组件 type configureComp struct { modules.MCompConfigure module *Parkour } //组件初始化接口 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.(*Parkour) this.LoadConfigure(game_buzkashiopen, cfg.NewGameBuzkashiOpen) this.LoadConfigure(game_buzkashigrade, cfg.NewGameBuzkashiGrade) this.LoadConfigure(game_buzkashilv, cfg.NewGameBuzkashiLv) this.LoadConfigure(game_buzkashimount, cfg.NewGameBuzkashiMount) this.LoadConfigure(game_buzkashireward, cfg.NewGameBuzkashiReward) return } //查询开启表 func (this *configureComp) isopen() (open bool) { var ( v interface{} config *cfg.GameBuzkashiOpen currtime string = configure.Now().Format("15:04") err error ok bool ) if v, err = this.GetConfigure(game_buzkashiopen); err != nil { this.module.Errorln(err) return } else { if config, ok = v.(*cfg.GameBuzkashiOpen); !ok { err = fmt.Errorf("config type err:%T", v) return } else { for _, v := range config.GetDataList() { if currtime >= fmt.Sprintf("%d:%d", v.Shtime, v.Smtime) && currtime < fmt.Sprintf("%d:%d", v.Ehtime, v.Emtime) { open = true return } } } } return } //查询坐骑表 func (this *configureComp) getGameBuzkashiMount(id string) (configure *cfg.GameBuzkashiMountData, err error) { var ( v interface{} ok bool ) if v, err = this.GetConfigure(game_buzkashimount); err != nil { this.module.Errorln(err) return } else { if configure, ok = v.(*cfg.GameBuzkashiMount).GetDataMap()[id]; !ok { err = fmt.Errorf("not found:%s ", id) this.module.Errorln(err) return } } return } func (this *configureComp) getGameBuzkashiReward(id int32) (configure *cfg.GameBuzkashiRewardData) { if v, err := this.GetConfigure(game_buzkashireward); err == nil { var ok bool if configure, ok = v.(*cfg.GameBuzkashiReward).GetDataMap()[id]; !ok { err = fmt.Errorf("not found:%d ", id) this.module.Errorln(err) return } } return nil }