上传机器人代码

This commit is contained in:
liwei1dao 2023-08-24 15:21:43 +08:00
parent 255bcb30e7
commit ff2243d413
5 changed files with 95 additions and 10 deletions

View File

@ -10,12 +10,13 @@ import (
)
const (
gameWorldTask = "game_worldtask.json"
gameWorldtaskBattle = "game_worldbattle.json"
game_buriedcondi = "game_buriedcondi.json"
game_mainstage = "game_mainstage.json" //主线表
game_equip = "game_equip.json" //装备信息表
equip_intensify = "game_equipintensify.json" //装备等级消耗表
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"
@ -38,7 +39,7 @@ func (this *configureComp) Init(service core.IService, module core.IModule, comp
configure.RegisterConfigure(game_buriedcondi, cfg.NewGameBuriedCondi, nil)
configure.RegisterConfigure(game_mainstage, cfg.NewGameMainStage, nil)
configure.RegisterConfigure(game_equip, cfg.NewGameEquip, nil)
configure.RegisterConfigure(equip_intensify, cfg.NewGameEquipIntensify, nil)
configure.RegisterConfigure(game_equipintensify, cfg.NewGameEquipIntensify, nil)
return
}

View File

@ -101,6 +101,11 @@ func (this *ModuleRobot_Equipment) DoTask(robot IRobot, taskconf *cfg.GameWorldT
err = errors.New(errdata.Message)
return
}
case comm.Rtype94: //附魔
if _, errdata = robot.SendTaskMessage(taskconf.Key, condconf.Id, "equipment", "ench", &pb.EquipmentEnchReq{}); errdata != nil {
err = errors.New(errdata.Message)
return
}
}
return
}
@ -174,13 +179,12 @@ func (this *ModuleRobot_Equipment) getGameEquipData(cid string) (conf *cfg.GameE
}
// 读取条件任务id配置
// 获取武器等级消耗表
func (this *ModuleRobot_Equipment) getEquipmentMaxIntensifyConfigure(etype, star int32) (conf *cfg.GameEquipIntensifyData, err error) {
var (
v interface{}
lv int32
)
if v, err = configure.GetConfigure(equip_intensify); err != nil {
if v, err = configure.GetConfigure(game_equipintensify); err != nil {
return
} else {
for _, v1 := range v.(*cfg.GameEquipIntensify).GetDataList() {
@ -196,3 +200,16 @@ func (this *ModuleRobot_Equipment) getEquipmentMaxIntensifyConfigure(etype, star
}
return
}
// 获取附魔数据
func (this *ModuleRobot_Equipment) getEquipenchantings() (confs []*cfg.GameEquipEnchantingData, err error) {
var (
v interface{}
)
if v, err = configure.GetConfigure(game_equipenchanting); err != nil {
return
} else {
confs = v.(*cfg.GameEquipEnchanting).GetDataList()
}
return
}

View File

@ -0,0 +1,66 @@
package robot
import (
"errors"
"go_dreamfactory/comm"
"go_dreamfactory/pb"
cfg "go_dreamfactory/sys/configure/structs"
"google.golang.org/protobuf/proto"
)
//用户模块 机器人
type ModuleRobot_Item struct {
items map[string]*pb.DB_UserItemData
}
func (this *ModuleRobot_Item) Init() (err error) {
this.items = make(map[string]*pb.DB_UserItemData)
return
}
//接收到消息
func (this *ModuleRobot_Item) Receive(robot IRobot, stype string, message proto.Message) (err error) {
switch stype {
case "list":
resp := message.(*pb.ItemsGetlistResp)
for _, v := range resp.Grids {
this.items[v.GridId] = v
}
break
case "change":
resp := message.(*pb.ItemsChangePush)
for _, v := range resp.Grids {
this.items[v.GridId] = v
}
break
}
return
}
//机器人执行流
func (this *ModuleRobot_Item) DoPipeline(robot IRobot) (err error) {
var (
errdata *pb.ErrorData
)
if _, errdata = robot.SendMessage("item", "list", &pb.ItemsGetlistReq{}); errdata != nil {
err = errors.New(errdata.Message)
return
}
return
}
//做任务
func (this *ModuleRobot_Item) DoTask(robot IRobot, taskconf *cfg.GameWorldTaskData, condconf *cfg.GameBuriedCondiData) (err error) {
var (
errdata *pb.ErrorData
)
switch comm.TaskType(condconf.Type) {
case comm.Rtype14:
if _, errdata = robot.SendTaskMessage(taskconf.Key, condconf.Id, "hero", "drawcard", &pb.HeroDrawCardReq{DrawType: 2, DrawCount: 1, Consume: 0}); errdata != nil {
err = errors.New(errdata.Message)
return
}
}
return
}

View File

@ -129,7 +129,7 @@ locp:
module = comm.ModulePractice
case comm.Rtype61:
module = comm.ModuleMainline
case comm.Rtype5:
case comm.Rtype5, comm.Rtype92, comm.Rtype94, comm.Rtype96:
module = comm.ModuleEquipment
default:
log.Error("[Robot DoTask]", log.Field{Key: "ctype", Value: cconf.Type}, log.Field{Key: "conld", Value: cconf.Id}, log.Field{Key: "err", Value: "Not Achieved !"})

View File

@ -47,6 +47,7 @@ func (this *Robot) Init(addr string, client IClient) (err error) {
this.modules[comm.ModuleSys] = new(ModuleRobot_Sys)
this.modules[comm.ModuleHero] = new(ModuleRobot_Hero)
this.modules[comm.ModuleEquipment] = new(ModuleRobot_Equipment)
this.modules[comm.ModuleItems] = new(ModuleRobot_Item)
this.modules[comm.ModuleWtask] = new(ModuleRobot_WTask)
this.modules[comm.ModulePractice] = new(ModuleRobot_Practice)
this.modules[comm.ModuleMainline] = new(ModuleRobot_MainLine)