diff --git a/modules/robot/configure.go b/modules/robot/configure.go index 0988d0ac2..9b627cf8a 100644 --- a/modules/robot/configure.go +++ b/modules/robot/configure.go @@ -26,6 +26,7 @@ const ( // game_worlddeal = "game_worlddeal.json" // game_worldrd = "game_worldrd.json" game_pagoda = "game_pagoda.json" + hero_talent = "game_herotalent.json" // 天赋详细数据 ) type configureComp struct { @@ -44,6 +45,7 @@ func (this *configureComp) Init(service core.IService, module core.IModule, comp configure.RegisterConfigure(game_equipintensify, cfg.NewGameEquipIntensify, nil) configure.RegisterConfigure(game_pagoda, cfg.NewGamePagoda, nil) configure.RegisterConfigure(equip_suit, cfg.NewGameEquipSuit, nil) + configure.RegisterConfigure(hero_talent, cfg.NewGameHeroTalent, nil) return } diff --git a/modules/robot/modulerobot_hero.go b/modules/robot/modulerobot_hero.go index 364ed2a1b..d784dfbe7 100644 --- a/modules/robot/modulerobot_hero.go +++ b/modules/robot/modulerobot_hero.go @@ -5,6 +5,7 @@ import ( "fmt" "go_dreamfactory/comm" "go_dreamfactory/pb" + "go_dreamfactory/sys/configure" cfg "go_dreamfactory/sys/configure/structs" "sort" @@ -13,7 +14,8 @@ import ( //用户模块 机器人 type ModuleRobot_Hero struct { - heros map[string]*pb.DBHero + heros map[string]*pb.DBHero + talent []*pb.DBHeroTalent // 天赋数据 } func (this *ModuleRobot_Hero) Init() (err error) { @@ -36,6 +38,10 @@ func (this *ModuleRobot_Hero) Receive(robot IRobot, stype string, message proto. this.heros[v.Id] = v } break + case "talentlist": // 获取天赋数据 + resp := message.(*pb.HeroTalentListResp) + this.talent = resp.Telnet + break } return } @@ -63,6 +69,40 @@ func (this *ModuleRobot_Hero) DoTask(robot IRobot, taskconf *cfg.GameWorldTaskDa err = errors.New(fmt.Sprintf("code:%d message:%s", errdata.Code, errdata.Message)) return } + + case comm.Rtype199: + resp := &pb.HeroTalentLearnReq{ + TalentID: 0, + ObjId: "", + Heroid: "", + } + // 获取英雄数据 + var bFound bool + for k, v := range this.heros { + if c, err := this.GMGetTalentByHeroId(k); err != nil { + for _, v1 := range this.talent { + if v1.HeroId == v.HeroID { + bFound = true + resp.ObjId = v1.Id + resp.Heroid = v.HeroID + // 依次往后学 + if len(v1.Talent) < len(c) { + resp.TalentID = c[len(v1.Talent)].Skillid + } + break + } + } + } + break + } + + if !bFound { + resp.ObjId = "" + } + if _, errdata = robot.SendTaskMessage(taskconf.Key, condconf.Id, "hero", "talentlearn", resp); errdata != nil { + err = errors.New(fmt.Sprintf("code:%d message:%s", errdata.Code, errdata.Message)) + return + } } return } @@ -100,3 +140,23 @@ func (this *ModuleRobot_Hero) getpracticehero() (bheros string) { } return } + +func (this *ModuleRobot_Hero) GMGetTalentByHeroId(hid string) (data []*cfg.GameHeroTalentData, err error) { + var ( + v interface{} + ) + if v, err = configure.GetConfigure(hero_talent); err == nil { + if configure, ok := v.(*cfg.GameHeroTalent); ok { + for _, v1 := range configure.GetDataList() { + if v1.Hid == hid { + data = append(data, v1) + } + } + } + } + if len(data) == 0 { + err = comm.NewNotFoundConfErr("robot", hero_talent, hid) + } + + return +}