#32746 任务 优化需求 后端 任务埋点ai逻辑 199

This commit is contained in:
meixiongfeng 2023-08-28 11:36:50 +08:00
parent ab2f83c4e2
commit 4029b664e4
2 changed files with 63 additions and 1 deletions

View File

@ -26,6 +26,7 @@ const (
// game_worlddeal = "game_worlddeal.json" // game_worlddeal = "game_worlddeal.json"
// game_worldrd = "game_worldrd.json" // game_worldrd = "game_worldrd.json"
game_pagoda = "game_pagoda.json" game_pagoda = "game_pagoda.json"
hero_talent = "game_herotalent.json" // 天赋详细数据
) )
type configureComp struct { 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_equipintensify, cfg.NewGameEquipIntensify, nil)
configure.RegisterConfigure(game_pagoda, cfg.NewGamePagoda, nil) configure.RegisterConfigure(game_pagoda, cfg.NewGamePagoda, nil)
configure.RegisterConfigure(equip_suit, cfg.NewGameEquipSuit, nil) configure.RegisterConfigure(equip_suit, cfg.NewGameEquipSuit, nil)
configure.RegisterConfigure(hero_talent, cfg.NewGameHeroTalent, nil)
return return
} }

View File

@ -5,6 +5,7 @@ import (
"fmt" "fmt"
"go_dreamfactory/comm" "go_dreamfactory/comm"
"go_dreamfactory/pb" "go_dreamfactory/pb"
"go_dreamfactory/sys/configure"
cfg "go_dreamfactory/sys/configure/structs" cfg "go_dreamfactory/sys/configure/structs"
"sort" "sort"
@ -14,6 +15,7 @@ import (
//用户模块 机器人 //用户模块 机器人
type ModuleRobot_Hero struct { type ModuleRobot_Hero struct {
heros map[string]*pb.DBHero heros map[string]*pb.DBHero
talent []*pb.DBHeroTalent // 天赋数据
} }
func (this *ModuleRobot_Hero) Init() (err error) { 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 this.heros[v.Id] = v
} }
break break
case "talentlist": // 获取天赋数据
resp := message.(*pb.HeroTalentListResp)
this.talent = resp.Telnet
break
} }
return 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)) err = errors.New(fmt.Sprintf("code:%d message:%s", errdata.Code, errdata.Message))
return 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 return
} }
@ -100,3 +140,23 @@ func (this *ModuleRobot_Hero) getpracticehero() (bheros string) {
} }
return 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
}