package capturesheep import ( "fmt" "go_dreamfactory/comm" "go_dreamfactory/lego/core" "go_dreamfactory/modules" cfg "go_dreamfactory/sys/configure/structs" ) const ( game_arenarobot = "game_arenarobot.json" //ai配置表 game_qualifying = "game_qualifying.json" //段位 game_arenarankreward = "game_arenarankreward.json" //比赛奖励配置 ) type configureComp struct { modules.MCompConfigure module *CaptureSheep } func (this *configureComp) Init(service core.IService, module core.IModule, comp core.IModuleComp, options core.IModuleOptions) (err error) { err = this.MCompConfigure.Init(service, module, comp, options) this.module = module.(*CaptureSheep) err = this.LoadMultiConfigure(map[string]interface{}{ game_arenarobot: cfg.NewGameArenaRobot, }) return } //查询积分段位信息 func (this *configureComp) getActiveReward(integral int32) (result *cfg.GameQualifyingData, err error) { var ( v interface{} ) if v, err = this.GetConfigure(game_qualifying); err != nil { this.module.Errorln(err) } else { for _, v := range v.(*cfg.GameQualifying).GetDataMap() { if integral >= v.ScoreLow && integral <= v.ScoreUp { result = v return } } } err = fmt.Errorf("未找到 匹配积分:%d段位配置", integral) return } //查询积分段位信息 func (this *configureComp) getActiveRewardById(lv int32) (result *cfg.GameArenaActiveRewardData, err error) { var ( v interface{} ok bool ) if v, err = this.GetConfigure(game_qualifying); err != nil { this.module.Errorln(err) } else { if result, ok = v.(*cfg.GameArenaActiveReward).GetDataMap()[lv]; !ok { err = comm.NewNotFoundConfErr(string(this.module.GetType()), game_qualifying, lv) this.module.Errorln(err) } } return } //查询比赛奖励 func (this *configureComp) getRankReward() (result *cfg.GameArenaRankReward, err error) { var ( v interface{} ) if v, err = this.GetConfigure(game_arenarankreward); err != nil { this.module.Errorln(err) } else { result = v.(*cfg.GameArenaRankReward) } return }