From 900ee8c362431130ff40ecc42d11edfbe0acc351 Mon Sep 17 00:00:00 2001 From: wh_zcy Date: Tue, 30 May 2023 11:03:45 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BB=BB=E5=8A=A1=E9=80=9A=E7=9F=A5=E6=9D=A1?= =?UTF-8?q?=E4=BB=B6=E6=A0=A1=E9=AA=8C?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- modules/worldtask/module.go | 18 ++++++++++++++++-- 1 file changed, 16 insertions(+), 2 deletions(-) diff --git a/modules/worldtask/module.go b/modules/worldtask/module.go index 43aeda3e7..89815440c 100644 --- a/modules/worldtask/module.go +++ b/modules/worldtask/module.go @@ -35,7 +35,7 @@ func (this *Worldtask) Init(service core.IService, module core.IModule, options func (this *Worldtask) OnInstallComp() { this.ModuleBase.OnInstallComp() - event.Register(comm.EventBuriedComplete, this.TCondFinishNotify) + event.RegisterGO(comm.EventBuriedComplete, this.TCondFinishNotify) this.api = this.RegisterComp(new(apiComp)).(*apiComp) this.modelWorldtask = this.RegisterComp(new(ModelWorldtask)).(*ModelWorldtask) this.configure = this.RegisterComp(new(configureComp)).(*configureComp) @@ -58,6 +58,10 @@ func (this *Worldtask) Start() (err error) { func (this *Worldtask) TCondFinishNotify(uid string, conids []int32) { session, ok := this.GetUserSession(uid) + defer func() { + session.Push() + this.PutUserSession(session) + }() if !ok { return } @@ -73,6 +77,7 @@ func (this *Worldtask) TCondFinishNotify(uid string, conids []int32) { var groupId, taskId int32 // 检索condId是否是世界任务的完成条件 finishedTaskIds := make(map[int32]int32) //达成的任务条件 + finishedCondIds := []int32{} for _, c := range this.worldtaskConf.GetDataList() { for _, v := range c.Completetask { for _, condId := range conids { @@ -83,6 +88,7 @@ func (this *Worldtask) TCondFinishNotify(uid string, conids []int32) { finishedTaskIds[c.Group] = c.Key groupId = c.Group taskId = c.Key + finishedCondIds = append(finishedCondIds, condId) } } break @@ -109,7 +115,14 @@ func (this *Worldtask) TCondFinishNotify(uid string, conids []int32) { for _, condId := range conids { if _, ok := utils.Findx(wt.CondiIds, condId); !ok { - wt.CondiIds = append(wt.CondiIds, condId) + condIds, err := this.ModuleBuried.CheckCondition(uid, condId) + if err != nil { + this.Error("完成条件校验错误", log.Field{Key: "condId", Value: condId}) + return + } + if len(condIds) == 1 && condIds[0] == condId { + wt.CondiIds = append(wt.CondiIds, condId) + } } } @@ -140,6 +153,7 @@ func (this *Worldtask) TCondFinishNotify(uid string, conids []int32) { this.modelWorldtask.taskFinish(session, groupId, taskId, userTask, curTaskConf) this.modelWorldtask.taskFinishPush(session, groupId, userTask, curTaskConf) } + return }