From 635ec1a35cea4e04bc06721252e9d09a66c27097 Mon Sep 17 00:00:00 2001 From: liwei1dao Date: Wed, 23 Aug 2023 19:17:04 +0800 Subject: [PATCH] =?UTF-8?q?=E4=B8=8A=E4=BC=A0=E5=8E=8B=E6=B5=8B=E5=B7=A5?= =?UTF-8?q?=E5=85=B7=E4=BB=A3=E7=A0=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- modules/robot/modulerobot_practice.go | 63 +++++++++++++++++++++++++++ 1 file changed, 63 insertions(+) create mode 100644 modules/robot/modulerobot_practice.go diff --git a/modules/robot/modulerobot_practice.go b/modules/robot/modulerobot_practice.go new file mode 100644 index 000000000..c12cc2ea5 --- /dev/null +++ b/modules/robot/modulerobot_practice.go @@ -0,0 +1,63 @@ +package robot + +import ( + "errors" + "go_dreamfactory/comm" + "go_dreamfactory/pb" + cfg "go_dreamfactory/sys/configure/structs" + + "google.golang.org/protobuf/proto" +) + +//用户模块 机器人 +type ModuleRobot_Practice struct { + Info *pb.DBPracticeRoom +} + +func (this *ModuleRobot_Practice) Init() { + +} + +//接收到消息 +func (this *ModuleRobot_Practice) Receive(robot IRobot, stype string, message proto.Message) (err error) { + switch stype { + case "info": + resp := message.(*pb.PracticeInfoResp) + this.Info = resp.Info + break + + } + return +} + +//机器人执行流 +func (this *ModuleRobot_Practice) DoPipeline(robot IRobot) (err error) { + var ( + errdata *pb.ErrorData + ) + if _, errdata = robot.SendMessage("hero", "list", &pb.HeroListReq{}); errdata != nil { + err = errors.New(errdata.Message) + return + } + return +} + +//做任务 +func (this *ModuleRobot_Practice) DoTask(robot IRobot, taskconf *cfg.GameWorldTaskData, condconf *cfg.GameBuriedCondiData) (err error) { + var ( + errdata *pb.ErrorData + ) + if _, errdata = robot.SendMessage("practice", "info", &pb.PracticeInfoReq{}); errdata != nil { + err = errors.New(errdata.Message) + return + } + switch comm.TaskType(condconf.Type) { + case comm.Rtype149: + + if _, errdata = robot.SendMessage("practice", "practice", &pb.PracticePracticeReq{}); errdata != nil { + err = errors.New(errdata.Message) + return + } + } + return +}