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 +}