package robot import ( "fmt" "go_dreamfactory/comm" "go_dreamfactory/lego/core" "go_dreamfactory/lego/core/cbase" "go_dreamfactory/lego/sys/log" "go_dreamfactory/sys/configure" cfg "go_dreamfactory/sys/configure/structs" "sync" ) const ( gameWorldTask = "game_worldtask.json" gameWorldtaskBattle = "game_worldbattle.json" game_buriedcondi = "game_buriedcondi.json" game_mainstage = "game_mainstage.json" //主线表 game_equip = "game_equip.json" //装备信息表 game_equipintensify = "game_equipintensify.json" //装备等级消耗表 game_equipenchanting = "game_equipenchanting.json" //装备附魔 // gameWorldAll = "game_worldall.json" // gameburiedCond = "game_buriedcondi.json" // gamerdtasknpc = "game_rdtasknpc.json" // gamesearchitemall = "game_searchitemall.json" // gamesearchitembox = "game_searchitembox.json" // game_worlddeal = "game_worlddeal.json" // game_worldrd = "game_worldrd.json" game_pagoda = "game_pagoda.json" ) type configureComp struct { cbase.ModuleCompBase module *RobotModule hlock sync.RWMutex _mapPagoda map[int32]*cfg.GamePagodaData } func (this *configureComp) Init(service core.IService, module core.IModule, comp core.IModuleComp, options core.IModuleOptions) (err error) { err = this.ModuleCompBase.Init(service, module, comp, options) this.module = module.(*RobotModule) configure.RegisterConfigure(gameWorldTask, cfg.NewGameWorldTask, nil) configure.RegisterConfigure(gameWorldtaskBattle, cfg.NewGameWorldBattle, nil) configure.RegisterConfigure(game_buriedcondi, cfg.NewGameBuriedCondi, nil) configure.RegisterConfigure(game_mainstage, cfg.NewGameMainStage, nil) configure.RegisterConfigure(game_equip, cfg.NewGameEquip, nil) configure.RegisterConfigure(game_equipintensify, cfg.NewGameEquipIntensify, nil) configure.RegisterConfigure(game_pagoda, cfg.NewGamePagoda, this.LoadPagoda) return } //获取任务配置 func (this *configureComp) getGameWorldTaskData(tid int32) (conf *cfg.GameWorldTaskData, err error) { var ( v interface{} ok bool ) if v, err = configure.GetConfigure(gameWorldTask); err != nil { return } else { if conf, ok = v.(*cfg.GameWorldTask).GetDataMap()[tid]; !ok { err = comm.NewNotFoundConfErr(string(this.module.GetType()), gameWorldTask, tid) log.Errorf("err:%v", err) return } } return } //获取战斗配置 func (this *configureComp) getGameWorldBattleData(confId int32) (conf *cfg.GameWorldBattleData, err error) { var ( v interface{} ok bool ) if v, err = configure.GetConfigure(gameWorldtaskBattle); err != nil { return } else { if conf, ok = v.(*cfg.GameWorldBattle).GetDataMap()[confId]; !ok { err = comm.NewNotFoundConfErr(string(this.module.GetType()), gameWorldtaskBattle, confId) log.Errorf("err:%v", err) return } } return } func (this *configureComp) LoadPagoda() { if v, err := configure.GetConfigure(game_pagoda); err == nil { if configure, ok := v.(*cfg.GamePagoda); ok { this.hlock.Lock() defer this.hlock.Unlock() this._mapPagoda = make(map[int32]*cfg.GamePagodaData) for _, value := range configure.GetDataList() { key := value.Tab<<16 + value.LayerNum this._mapPagoda[key] = value } return } } return } func (this *configureComp) GetPagodaConfBytab(tab int32, ly int32) (data *cfg.GamePagoda, err error) { if _, ok := this._mapPagoda[tab<<16+ly]; ok { return } err = comm.NewNotFoundConfErr("pagoda", game_pagoda, fmt.Errorf("tab %d ,ly %d not found", tab, ly)) return }