From 0892a6c8e92bb107b94ebf0d66693593ba5f459f Mon Sep 17 00:00:00 2001 From: wh_zcy Date: Thu, 25 May 2023 17:51:04 +0800 Subject: [PATCH] =?UTF-8?q?=E5=85=AC=E4=BC=9A=E5=9F=8B=E7=82=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- cmd/v2/ui/views/rtask_testview.go | 87 ++++++++++++++++------------- comm/const.go | 1 + modules/rtask/module.go | 35 ++++++------ modules/sociaty/api_cross_create.go | 1 + 4 files changed, 68 insertions(+), 56 deletions(-) diff --git a/cmd/v2/ui/views/rtask_testview.go b/cmd/v2/ui/views/rtask_testview.go index 4d817abf0..03d81dbc0 100644 --- a/cmd/v2/ui/views/rtask_testview.go +++ b/cmd/v2/ui/views/rtask_testview.go @@ -11,20 +11,20 @@ import ( "go_dreamfactory/comm" "go_dreamfactory/pb" "go_dreamfactory/utils" + "io/ioutil" "os" "path/filepath" "strings" "sync" "sync/atomic" - cfg "go_dreamfactory/sys/configure/structs" - "fyne.io/fyne/v2" "fyne.io/fyne/v2/container" "fyne.io/fyne/v2/dialog" "fyne.io/fyne/v2/widget" "github.com/sirupsen/logrus" "github.com/spf13/cast" + "github.com/tidwall/gjson" ) type RtaskTestView struct { @@ -35,6 +35,7 @@ type RtaskTestView struct { flag bool msgs []string reportPath string //Json Data数据路径 + loadCount int32 } func (this *RtaskTestView) CreateView(t *model.TestCase) fyne.CanvasObject { @@ -84,7 +85,7 @@ func (this *RtaskTestView) CreateView(t *model.TestCase) fyne.CanvasObject { //"F:\\projects\\workspace\\go_dreamfactory\\bin\\json" jsonPathEntry := widget.NewEntry() - jsonPathEntry.SetText("F:\\projects\\workspace\\go_dreamfactory\\bin\\json") + jsonPathEntry.SetText("F:\\") reportEntry := widget.NewEntry() reportEntry.SetText("F:\\") @@ -101,55 +102,65 @@ func (this *RtaskTestView) CreateView(t *model.TestCase) fyne.CanvasObject { this.reportPath = reportEntry.Text var wg sync.WaitGroup - if tb, err := cfg.NewTables(commCfg.Loader); err == nil { - for _, v := range tb.RdtaskCondi.GetDataList() { - wg.Add(1) - params := []int32{v.Data1, v.Data2, v.Data3, v.Data4, v.Data5} - var p []int32 - for _, v := range params { - if v > 0 { - p = append(p, v) - } + b, err := ioutil.ReadFile(filepath.Join(commCfg.Path, "game_rdtaskcondi.json")) + if err != nil { + logrus.Error(err) + return + } + + r := gjson.ParseBytes(b) + + for _, line := range r.Array() { + logrus.Debug(line.String()) + id := line.Get("id").Int() + rtype := line.Get("type").Int() + data1 := line.Get("data1").Int() + data2 := line.Get("data2").Int() + data3 := line.Get("data3").Int() + data4 := line.Get("data4").Int() + data5 := line.Get("data5").Int() + + wg.Add(1) + params := []int32{int32(data1), int32(data2), int32(data3), int32(data4), int32(data5)} + + var p []int32 + for _, v := range params { + if v > 0 { + p = append(p, v) } - go func(condId, rtype int32, p []int32) { - defer wg.Done() - if err := service.GetPttService().SendToClient( - t.MainType, - t.SubType, - &pb.RtaskTestReq{ - RtaskType: rtype, - Params: p, - }, - ); err != nil { - logrus.Error(err) - return - } - // logrus.Debugf("执行任务 id:%v rtype:%v params:%v", condId, rtype, p) - // msgs = append(msgs, fmt.Sprintf("condId:%v rtype:%v params:%v", condId, rtype, p)) - }(v.Id, v.Type, p) - wg.Wait() } + logrus.Debugf("id:%v rtype:%v params:%v", id, rtype, p) + go func(condId, rtype int32, p []int32) { + defer wg.Done() + if err := service.GetPttService().SendToClient( + t.MainType, + t.SubType, + &pb.RtaskTestReq{ + RtaskType: rtype, + Params: p, + }, + ); err != nil { + logrus.Error(err) + return + } + }(int32(id), int32(rtype), p) + wg.Wait() } go func() { for msg := range this.resultChan { - // logrus.Debug("add msg") this.msgs = append(this.msgs, msg) - // old := atomic.LoadInt32(&this.resultCount) - // n := old - 1 - // if atomic.CompareAndSwapInt32(&this.resultCount, old, n) { - // break - // } + atomic.AddInt32(&this.loadCount, 1) } - }() go func() { var flag bool for !flag { count := atomic.LoadInt32(&this.resultCount) - logrus.Debug("count:", count) - if count == 100 { + lcount := atomic.LoadInt32(&this.loadCount) + // logrus.Debug("count:", count) + if count == lcount { logrus.Debug("结束") record := strings.Join(this.msgs, "\n") var buf bytes.Buffer diff --git a/comm/const.go b/comm/const.go index 1131625e6..25fe6a0b3 100644 --- a/comm/const.go +++ b/comm/const.go @@ -669,6 +669,7 @@ const ( Rtype185 TaskType = 185 //完成X次每日1健(接取任务后,每完成1次每日1健,便进度加一) Rtype186 TaskType = 186 Rtype187 TaskType = 187 + Rtype188 TaskType = 188 //玩家创建1个工会 ) const ( diff --git a/modules/rtask/module.go b/modules/rtask/module.go index 28ae04831..0d598c7ef 100644 --- a/modules/rtask/module.go +++ b/modules/rtask/module.go @@ -79,8 +79,8 @@ func (this *ModuleRtask) registerVerifyHandle(condiId int32, condi *rtaskCondHan func (this *ModuleRtask) getHandle(tt comm.TaskType) (handles []*rtaskCondHandle) { for _, v := range this.configure.getRtaskCondis(int32(tt)) { switch tt { - // 大于1个参数且第一个参数累计,第二个参数等于 - case comm.Rtype1, comm.Rtype16, comm.Rtype17, comm.Rtype50, comm.Rtype125, comm.Rtype126, comm.Rtype127: + // 两个参数 大于1个参数且第一个参数累计,第二个参数等于 + case comm.Rtype1, comm.Rtype16, comm.Rtype17, comm.Rtype50, comm.Rtype125, comm.Rtype126, comm.Rtype127, comm.Rtype187: handle := &rtaskCondHandle{ condId: v.Id, verify: this.modelRtaskRecord.verifyMultiEqual, @@ -118,23 +118,22 @@ func (this *ModuleRtask) getHandle(tt comm.TaskType) (handles []*rtaskCondHandle handles = append(handles, handle) this.registerVerifyHandle(v.Id, handle) // 一个参数且累计 - case comm.Rtype7, comm.Rtype12, comm.Rtype13, comm.Rtype14, comm.Rtype15, - comm.Rtype18, comm.Rtype19, comm.Rtype23, comm.Rtype24, - comm.Rtype26, comm.Rtype27, comm.Rtype28, comm.Rtype38, - comm.Rtype39, comm.Rtype47, comm.Rtype51, comm.Rtype53, - comm.Rtype54, comm.Rtype57, comm.Rtype60, - comm.Rtype62, comm.Rtype64, comm.Rtype87, comm.Rtype88, comm.Rtype89, comm.Rtype90, - comm.Rtype91, comm.Rtype92, comm.Rtype94, comm.Rtype95, comm.Rtype97, comm.Rtype104, - comm.Rtype96, comm.Rtype98, comm.Rtype99, comm.Rtype102, comm.Rtype103, comm.Rtype105, - comm.Rtype106, comm.Rtype108, comm.Rtype113, comm.Rtype114, comm.Rtype115, comm.Rtype116, - comm.Rtype117, comm.Rtype118, comm.Rtype119, comm.Rtype120, comm.Rtype121, comm.Rtype123, - comm.Rtype124, - comm.Rtype128, comm.Rtype130, comm.Rtype131, comm.Rtype132, comm.Rtype135, - comm.Rtype141, comm.Rtype142, comm.Rtype143, comm.Rtype144, comm.Rtype145, comm.Rtype146, - comm.Rtype147, comm.Rtype148, comm.Rtype149, comm.Rtype152, comm.Rtype153, comm.Rtype154, - comm.Rtype156, comm.Rtype161, comm.Rtype165, comm.Rtype166, comm.Rtype167, + case comm.Rtype7, + comm.Rtype12, comm.Rtype13, comm.Rtype14, comm.Rtype15, comm.Rtype18, comm.Rtype19, + comm.Rtype23, comm.Rtype24, comm.Rtype26, comm.Rtype27, comm.Rtype28, comm.Rtype38, comm.Rtype39, + comm.Rtype47, + comm.Rtype51, comm.Rtype53, comm.Rtype54, comm.Rtype57, + comm.Rtype60, comm.Rtype62, comm.Rtype64, comm.Rtype87, comm.Rtype88, comm.Rtype89, + comm.Rtype90, comm.Rtype91, comm.Rtype92, comm.Rtype94, comm.Rtype95, comm.Rtype97, comm.Rtype96, comm.Rtype98, comm.Rtype99, + comm.Rtype104, comm.Rtype102, comm.Rtype103, comm.Rtype105, comm.Rtype106, comm.Rtype108, + comm.Rtype113, comm.Rtype114, comm.Rtype115, comm.Rtype116, comm.Rtype117, comm.Rtype118, comm.Rtype119, + comm.Rtype120, comm.Rtype121, comm.Rtype123, comm.Rtype124, comm.Rtype128, + comm.Rtype130, comm.Rtype131, comm.Rtype132, comm.Rtype135, + comm.Rtype141, comm.Rtype142, comm.Rtype143, comm.Rtype144, comm.Rtype145, comm.Rtype146, comm.Rtype147, comm.Rtype148, comm.Rtype149, + comm.Rtype152, comm.Rtype153, comm.Rtype154, comm.Rtype156, + comm.Rtype161, comm.Rtype165, comm.Rtype166, comm.Rtype167, comm.Rtype171, comm.Rtype172, comm.Rtype173, comm.Rtype175, comm.Rtype177, - comm.Rtype181, comm.Rtype182, comm.Rtype183, comm.Rtype184, comm.Rtype185, comm.Rtype186, comm.Rtype187: + comm.Rtype181, comm.Rtype182, comm.Rtype183, comm.Rtype184, comm.Rtype185, comm.Rtype186, comm.Rtype188: handle := &rtaskCondHandle{ condId: v.Id, verify: this.modelRtaskRecord.verifyFirstGreatEqualParam, diff --git a/modules/sociaty/api_cross_create.go b/modules/sociaty/api_cross_create.go index 1a4d081c0..3012dbaeb 100644 --- a/modules/sociaty/api_cross_create.go +++ b/modules/sociaty/api_cross_create.go @@ -136,6 +136,7 @@ func (this *apiComp) Create(session comm.IUserSession, req *pb.SociatyCreateReq) return } + go this.module.ModuleRtask.TriggerTask(session.GetUserId(), comm.GettaskParam(comm.Rtype188, 1)) // 初始化玩家公会任务 go func() { if err := this.module.modelSociatyTask.initSociatyTask(user.Uid, sociaty.Id); err != nil {