From 424957278acd493862245008902af5c34471cbc6 Mon Sep 17 00:00:00 2001 From: liwei1dao Date: Fri, 15 Dec 2023 15:19:39 +0800 Subject: [PATCH] =?UTF-8?q?=E6=8B=BE=E5=8F=96=E5=AE=9D=E7=AE=B1=E6=9C=BA?= =?UTF-8?q?=E5=99=A8=E4=BA=BA=E5=8A=9F=E8=83=BD=E8=A1=A5=E5=85=A8?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- modules/robot/modulerobot_wtask.go | 20 ++++++++++++++++++++ modules/robot/statisticalcomp.go | 8 +++++++- 2 files changed, 27 insertions(+), 1 deletion(-) diff --git a/modules/robot/modulerobot_wtask.go b/modules/robot/modulerobot_wtask.go index fe3d0c447..a20441d48 100644 --- a/modules/robot/modulerobot_wtask.go +++ b/modules/robot/modulerobot_wtask.go @@ -87,6 +87,10 @@ func (this *ModuleRobot_WTask) Receive(robot IRobot, stype string, message proto } } break + case "boxchange": + resp := message.(*pb.WTaskBoxChangePush) + this.info.Boxs = resp.Boxs + break } return } @@ -228,6 +232,22 @@ func (this *ModuleRobot_WTask) DoTask(robot IRobot, taskconf *cfg.GameWorldTaskD return } break + case comm.Rtype205: //拾取宝箱 + boxid := int32(0) + for k, v := range this.info.Boxs[taskconf.Key].Boxs { + if v == 0 { + boxid = k + break + } + } + if _, errdata = robot.SendTaskMessage(taskconf.Key, condconf.Id, "wtask", "boxreceive", &pb.WTaskBoxReceiveReq{ + Tid: taskconf.Key, + Boxid: boxid, + }); errdata != nil { + err = errors.New(fmt.Sprintf("code:%d message:%s", errdata.Code, errdata.Message)) + return + } + break } return } diff --git a/modules/robot/statisticalcomp.go b/modules/robot/statisticalcomp.go index fa2fca4ee..b20125144 100644 --- a/modules/robot/statisticalcomp.go +++ b/modules/robot/statisticalcomp.go @@ -4,6 +4,7 @@ import ( "fmt" "go_dreamfactory/lego/core" "go_dreamfactory/lego/core/cbase" + "go_dreamfactory/lego/sys/log" "os" "sort" "sync" @@ -111,11 +112,16 @@ func (this *statisticalComp) OutReport() { func (this *statisticalComp) run() { timer := time.NewTicker(time.Second * 10) +locp: for { select { case <-timer.C: this.OutReport() + if this.failclientNum+this.succclientNum >= this.module.options.RobotTotalNum { + break locp + } } } - + timer.Stop() + log.Debug("[机器人 WTask]") }