diff --git a/modules/robot/configure.go b/modules/robot/configure.go index 13d7096d0..0988d0ac2 100644 --- a/modules/robot/configure.go +++ b/modules/robot/configure.go @@ -1,14 +1,12 @@ 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 ( @@ -19,6 +17,7 @@ const ( game_equip = "game_equip.json" //装备信息表 game_equipintensify = "game_equipintensify.json" //装备等级消耗表 game_equipenchanting = "game_equipenchanting.json" //装备附魔 + equip_suit = "game_equipsuit.json" //装备套装表 // gameWorldAll = "game_worldall.json" // gameburiedCond = "game_buriedcondi.json" // gamerdtasknpc = "game_rdtasknpc.json" @@ -31,9 +30,7 @@ const ( type configureComp struct { cbase.ModuleCompBase - module *RobotModule - hlock sync.RWMutex - _mapPagoda map[int32]*cfg.GamePagodaData + module *RobotModule } func (this *configureComp) Init(service core.IService, module core.IModule, comp core.IModuleComp, options core.IModuleOptions) (err error) { @@ -45,7 +42,8 @@ func (this *configureComp) Init(service core.IService, module core.IModule, comp 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) + configure.RegisterConfigure(game_pagoda, cfg.NewGamePagoda, nil) + configure.RegisterConfigure(equip_suit, cfg.NewGameEquipSuit, nil) return } @@ -86,26 +84,3 @@ func (this *configureComp) getGameWorldBattleData(confId int32) (conf *cfg.GameW } 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 -} diff --git a/modules/robot/modulerobot_equipment.go b/modules/robot/modulerobot_equipment.go index a6e1f886e..cd522e481 100644 --- a/modules/robot/modulerobot_equipment.go +++ b/modules/robot/modulerobot_equipment.go @@ -31,6 +31,12 @@ func (this *ModuleRobot_Equipment) Receive(robot IRobot, stype string, message p this.equipments[v.Id] = v } break + case "upgrade": + resp := message.(*pb.EquipmentUpgradeResp) + for _, v := range resp.Equipment { + this.equipments[v.Id] = v + } + return case "change": resp := message.(*pb.EquipmentChangePush) for _, v := range resp.Equipments { @@ -117,6 +123,27 @@ func (this *ModuleRobot_Equipment) DoTask(robot IRobot, taskconf *cfg.GameWorldT } else { err = fmt.Errorf("no fund can use equipments") } + case comm.Rtype169: //穿戴套装 + var ( + heromodule *ModuleRobot_Hero + hero string + equipments []string + ) + heromodule = robot.GetModule(comm.ModuleHero).(*ModuleRobot_Hero) + hero = heromodule.getbattlehero()[0] + + if equipments, err = this.findsuitEquipment(condconf.Filter[0]); err != nil { + return + } + + if _, errdata = robot.SendTaskMessage(taskconf.Key, condconf.Id, "equipment", "equip", &pb.EquipmentEquipReq{ + HeroCardId: hero, + EquipmentId: equipments, + }); errdata != nil { + err = errors.New(fmt.Sprintf("code:%d message:%s", errdata.Code, errdata.Message)) + return + } + break case comm.Rtype43, comm.Rtype92, comm.Rtype96: //强化 var ( equipment *pb.DB_Equipment @@ -200,6 +227,27 @@ func (this *ModuleRobot_Equipment) DoTask(robot IRobot, taskconf *cfg.GameWorldT return } +//查询套装装备 +func (this *ModuleRobot_Equipment) findsuitEquipment(sid int32) (equipments []string, err error) { + var ( + econf *cfg.GameEquipData + ) + equipments = make([]string, 8) + for _, equipment := range this.equipments { + if equipment.HeroId != "" { + continue + } + if econf, err = this.getGameEquipData(equipment.CId); err != nil { + return + } + if econf.Suittype == sid { + equipments[econf.Pos] = equipment.Id + } + } + + return +} + //查询能穿戴的装备 func (this *ModuleRobot_Equipment) findcanEquipEquipment(hero *pb.DBHero, minstar int32) (equipments []string, change bool, err error) { var ( @@ -325,3 +373,20 @@ func (this *ModuleRobot_Equipment) getEquipenchantings() (confs []*cfg.GameEquip } return } + +// 获取装备套装配置 +func (this *ModuleRobot_Equipment) getGameEquipSuitData(sid int32) (conf *cfg.GameEquipSuitData, err error) { + var ( + v interface{} + ok bool + ) + if v, err = configure.GetConfigure(equip_suit); err != nil { + return + } else { + if conf, ok = v.(*cfg.GameEquipSuit).GetDataMap()[sid]; !ok { + err = comm.NewNotFoundConfErr("robot", equip_suit, sid) + return + } + } + return +} diff --git a/modules/robot/modulerobot_pagoda.go b/modules/robot/modulerobot_pagoda.go index 711bae217..ff5806eef 100644 --- a/modules/robot/modulerobot_pagoda.go +++ b/modules/robot/modulerobot_pagoda.go @@ -13,12 +13,24 @@ import ( //爬塔模块 机器人 type ModuleRobot_Pagoda struct { - pagoda *pb.DBPagoda - c *configureComp + pagoda *pb.DBPagoda + _mapPagoda map[int32]*cfg.GamePagodaData } func (this *ModuleRobot_Pagoda) Init() (err error) { - this.c = new(configureComp) + var ( + v interface{} + ) + if v, err = configure.GetConfigure(game_pagoda); err == nil { + if configure, ok := v.(*cfg.GamePagoda); ok { + this._mapPagoda = make(map[int32]*cfg.GamePagodaData) + for _, value := range configure.GetDataList() { + key := value.Tab<<16 + value.LayerNum + this._mapPagoda[key] = value + } + return + } + } return } diff --git a/modules/robot/modulerobot_wtask.go b/modules/robot/modulerobot_wtask.go index 33d635e61..0990c0368 100644 --- a/modules/robot/modulerobot_wtask.go +++ b/modules/robot/modulerobot_wtask.go @@ -130,7 +130,7 @@ locp: module = comm.ModulePractice case comm.Rtype61: module = comm.ModuleMainline - case comm.Rtype5, comm.Rtype41, comm.Rtype43, comm.Rtype92, comm.Rtype94, comm.Rtype95, comm.Rtype96: + case comm.Rtype5, comm.Rtype41, comm.Rtype43, comm.Rtype92, comm.Rtype94, comm.Rtype95, comm.Rtype96, comm.Rtype169: module = comm.ModuleEquipment case comm.Rtype128, comm.Rtype129, comm.Rtype131: module = comm.ModuleArena diff --git a/modules/robot/robot.go b/modules/robot/robot.go index a48ba7189..d61249de9 100644 --- a/modules/robot/robot.go +++ b/modules/robot/robot.go @@ -170,7 +170,12 @@ func (this *Robot) SendTaskMessage(task, comdi int32, mtype, stype string, msg p messageresp = <-this.await //等待回应 resp = messageresp.resp errdata = messageresp.errdata - log.Debug("[机器人 Message]", log.Field{Key: "t", Value: time.Since(stime).Milliseconds()}, log.Field{Key: "Account", Value: this.account}, log.Field{Key: "Task", Value: fmt.Sprintf("[%d-%d]", task, comdi)}, log.Field{Key: "message", Value: fmt.Sprintf("%s.%s", mtype, stype)}, log.Field{Key: "errdata", Value: errdata == nil}) + if errdata == nil { + log.Debug("[机器人 Message]", log.Field{Key: "t", Value: time.Since(stime).Milliseconds()}, log.Field{Key: "Account", Value: this.account}, log.Field{Key: "Task", Value: fmt.Sprintf("[%d-%d]", task, comdi)}, log.Field{Key: "message", Value: fmt.Sprintf("%s.%s", mtype, stype)}, log.Field{Key: "errdata", Value: errdata == nil}) + } else { + log.Error("[机器人 Message]", log.Field{Key: "t", Value: time.Since(stime).Milliseconds()}, log.Field{Key: "Account", Value: this.account}, log.Field{Key: "Task", Value: fmt.Sprintf("[%d-%d]", task, comdi)}, log.Field{Key: "message", Value: fmt.Sprintf("%s.%s", mtype, stype)}, log.Field{Key: "errdata", Value: errdata.String()}) + } + } return }