package moonfantasy import ( "fmt" "go_dreamfactory/comm" "go_dreamfactory/modules" cfg "go_dreamfactory/sys/configure/structs" "go_dreamfactory/lego/core" ) const ( game_dreamlandboos = "game_dreamlandboos.json" game_dreamlandchallenge = "game_dreamlandchallenge.json" game_dreamlandtrigger = "game_dreamlandtrigger.json" ) ///背包配置管理组件 type configureComp struct { modules.MCompConfigure module *Moonfantasy } //组件初始化接口 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.(*Moonfantasy) err = this.LoadConfigure(game_dreamlandboos, cfg.NewGameDreamlandBoos) err = this.LoadConfigure(game_dreamlandchallenge, cfg.NewGameDreamlandChallenge) err = this.LoadConfigure(game_dreamlandtrigger, cfg.NewGameDreamlandTrigger) return } //获取随机monster func (this *configureComp) GetMonster() (result *cfg.GameDreamlandBoosData, err error) { var ( v interface{} configure *cfg.GameDreamlandBoos waget []int32 index int32 ) if v, err = this.GetConfigure(game_dreamlandboos); err != nil { this.module.Errorf("err:%v", err) return } else { configure = v.(*cfg.GameDreamlandBoos) waget = make([]int32, len(configure.GetDataList())) for i, m := range configure.GetDataList() { waget[i] = m.Pro } index = comm.GetRandW(waget) result = configure.GetDataList()[index] return } } func (this *configureComp) GetMonsterById(id string) (result *cfg.GameDreamlandBoosData, err error) { var ( v interface{} ok bool ) if v, err = this.GetConfigure(game_dreamlandboos); err != nil { this.module.Errorln(err) return } else { if result, ok = v.(*cfg.GameDreamlandBoos).GetDataMap()[id]; !ok { err = fmt.Errorf("not found:%s ", id) this.module.Errorln(err) return } } return } ///获取月之秘境触发配置表 func (this *configureComp) GettriggerData(ptypes int32) (result *cfg.GameDreamlandTriggerData, err error) { var ( v interface{} ok bool ) if v, err = this.GetConfigure(game_dreamlandtrigger); err != nil { this.module.Errorln(err) return } else { if result, ok = v.(*cfg.GameDreamlandTrigger).GetDataMap()[ptypes]; !ok { err = fmt.Errorf("not found:%d ", ptypes) this.module.Errorln(err) return } } return } ///获取月之秘境触购买表 func (this *configureComp) GetchallengeData(buynum int32) (result *cfg.GameDreamlandChallengeData, err error) { var ( v interface{} ) if v, err = this.GetConfigure(game_dreamlandchallenge); err != nil { this.module.Errorln(err) return } else { for _, v := range v.(*cfg.GameDreamlandChallenge).GetDataList() { if v.Buynum == buynum { result = v return } result = v } } return } ///获取月之秘境触购买表 func (this *configureComp) GetchallengeDataCount() (count int, err error) { var ( v interface{} ) if v, err = this.GetConfigure(game_dreamlandchallenge); err != nil { this.module.Errorln(err) return } else { count = len(v.(*cfg.GameDreamlandChallenge).GetDataList()) } return }