From c220db525cc71b16fe88f1a7118bfb233175acce Mon Sep 17 00:00:00 2001 From: wh_zcy Date: Sat, 1 Apr 2023 10:11:15 +0800 Subject: [PATCH 1/2] update --- modules/worldtask/api_accept.go | 7 ++--- modules/worldtask/model_worldtask.go | 44 +++++++++------------------- modules/worldtask/module.go | 22 ++++++++++---- 3 files changed, 34 insertions(+), 39 deletions(-) diff --git a/modules/worldtask/api_accept.go b/modules/worldtask/api_accept.go index 0eec060b2..f0f68e47c 100644 --- a/modules/worldtask/api_accept.go +++ b/modules/worldtask/api_accept.go @@ -38,12 +38,11 @@ func (a *apiComp) Accept(session comm.IUserSession, req *pb.WorldtaskAcceptReq) myWorldtask.CurrentTask = make(map[int32]*pb.Worldtask) } myWorldtask.CurrentTask[curTaskConf.Group] = &pb.Worldtask{ - TaskId: req.TaskId, - TaskType: curTaskConf.Des, + TaskId: req.TaskId, + TaskType: curTaskConf.Des, + NpcStatus: 1, } - myWorldtask.CurrentTask[curTaskConf.Group].NpcStatus = 1 - update := map[string]interface{}{ "currentTask": myWorldtask.CurrentTask, } diff --git a/modules/worldtask/model_worldtask.go b/modules/worldtask/model_worldtask.go index ad8e124a2..f50e9d8f3 100644 --- a/modules/worldtask/model_worldtask.go +++ b/modules/worldtask/model_worldtask.go @@ -88,49 +88,33 @@ func (this *ModelWorldtask) finishTask(groupId, taskId int32, task *pb.DBWorldta TaskType: taskConf.Des, } + for _, tId := range task.TaskList { + if tId == taskId { + return comm.NewCustomError(pb.ErrorCode_WorldtaskFinihed) + } + } + task.TaskList = append(task.TaskList, taskId) if task.CurrentTask == nil { task.CurrentTask = make(map[int32]*pb.Worldtask) } - wt.NpcStatus = 0 - wt.DeliverNpc = 0 - wt.CondiIds = []int32{} - task.CurrentTask[groupId] = wt + //判断是否有下个任务 + if taskConf.IdAfter != 0 { + wt.NpcStatus = 0 + wt.DeliverNpc = 0 + wt.CondiIds = []int32{} + task.CurrentTask[groupId] = wt + update["currentTask"] = task.CurrentTask + } update["taskList"] = task.TaskList - update["currentTask"] = task.CurrentTask if err := this.Change(task.Uid, update); err != nil { return err } - // if module, err := this.service.GetModule(comm.ModuleLinestory); err == nil { - // if iLinestory, ok := module.(comm.ILinestory); ok { - // if err := iLinestory.TaskFinishNotify(task.Uid, taskId, groupId); err != nil { - // log.Debug("世界任务完成通知支线剧情任务", - // log.Field{Key: "uid", Value: task.Uid}, - // log.Field{Key: "groupId", Value: groupId}, - // log.Field{Key: "taskId", Value: taskId}, - // log.Field{Key: "err", Value: err.Error()}, - // ) - // } - // } - // } - - // if module, err := this.service.GetModule(comm.ModuleLibrary); err == nil { - // if iLibrary, ok := module.(comm.ILibrary); ok { - // if err := iLibrary.TaskFinishNotify(task.Uid, taskId, groupId); err != nil { - // log.Debug("世界任务完成通知羁绊剧情任务", - // log.Field{Key: "uid", Value: task.Uid}, - // log.Field{Key: "fetterId", Value: groupId}, - // log.Field{Key: "taskId", Value: taskId}, - // log.Field{Key: "err", Value: err.Error()}, - // ) - // } - // } - // } return nil } diff --git a/modules/worldtask/module.go b/modules/worldtask/module.go index ff123658a..2ef8ca7f3 100644 --- a/modules/worldtask/module.go +++ b/modules/worldtask/module.go @@ -70,9 +70,20 @@ func (this *Worldtask) TaskCondFinishNotify(session comm.IUserSession, condId in for _, c := range this.worldtaskConf.GetDataList() { for _, v := range c.Completetask { if v == condId { - finishedTaskIds[c.Group] = c.Key - groupId = c.Group - taskId = c.Key + //校验任务是否是当前任务 + if task, ok := userTask.CurrentTask[c.Group]; ok { + this.Debug("推送NextTask", + log.Field{Key: "group", Value: c.Group}, + log.Field{Key: "Key", Value: c.Key}, + log.Field{Key: "taskId", Value: task.TaskId}, + log.Field{Key: "condId", Value: condId}, + log.Field{Key: "npcStatus", Value: task.NpcStatus}) + if task.NpcStatus == 1 { + finishedTaskIds[c.Group] = c.Key + groupId = c.Group + taskId = c.Key + } + } break } } @@ -97,6 +108,7 @@ func (this *Worldtask) TaskCondFinishNotify(session comm.IUserSession, condId in userTask.CurrentTask[groupId] = wt + this.Debug("当前任务更新", log.Field{Key: "currentTask", Value: userTask.CurrentTask}) update := map[string]interface{}{ "currentTask": userTask.CurrentTask, } @@ -111,14 +123,14 @@ func (this *Worldtask) TaskCondFinishNotify(session comm.IUserSession, condId in log.Field{Key: "condiIds", Value: wt.CondiIds}, log.Field{Key: "taskId", Value: taskId}) - //判断是否要结束任务 // 当前任务配置 curTaskConf, err := this.configure.getWorldtaskById(taskId) if err != nil || curTaskConf == nil { return comm.NewCustomError(pb.ErrorCode_ConfigNoFound) } + + //结束任务 if curTaskConf.DeliverNpc == 0 { - //结束任务 this.modelWorldtask.taskFinish(session, groupId, taskId, userTask, curTaskConf) this.modelWorldtask.taskFinishPush(session, groupId, userTask, curTaskConf) } From e8d18907ed573f7b986dbf65ef910c16ea6e7792 Mon Sep 17 00:00:00 2001 From: wh_zcy Date: Sat, 1 Apr 2023 15:19:43 +0800 Subject: [PATCH 2/2] update --- bin/json/game_rdtaskcondi.json | 2 +- bin/json/game_worldtask.json | 39 ++++++++++++++++++++++++++-- modules/worldtask/api_finish.go | 6 +++-- modules/worldtask/model_worldtask.go | 14 +++++----- modules/worldtask/module.go | 8 +----- 5 files changed, 51 insertions(+), 18 deletions(-) diff --git a/bin/json/game_rdtaskcondi.json b/bin/json/game_rdtaskcondi.json index 110cb3ef0..3a0ae855d 100644 --- a/bin/json/game_rdtaskcondi.json +++ b/bin/json/game_rdtaskcondi.json @@ -1201,7 +1201,7 @@ "tasktxt": "", "type": 70, "valid": 0, - "NPC": 4, + "NPC": 10110, "data1": 1, "data2": 114, "data3": 4, diff --git a/bin/json/game_worldtask.json b/bin/json/game_worldtask.json index 825e11adb..8c48ede55 100644 --- a/bin/json/game_worldtask.json +++ b/bin/json/game_worldtask.json @@ -322,7 +322,7 @@ "key": 20100, "lock": 1, "ontxe": 20090, - "id_after": 0, + "id_after": 20110, "group": 20010, "des": 2, "icon": "", @@ -343,7 +343,7 @@ 307 ], "deliver_npc": 10102, - "auto_accept": 1, + "auto_accept": 0, "reword": [ { "a": "item", @@ -353,6 +353,41 @@ ], "module": [] }, + { + "key": 20110, + "lock": 0, + "ontxe": 20100, + "id_after": 0, + "group": 20010, + "des": 2, + "icon": "", + "task_Tname": { + "key": "Mainline_Tasks", + "text": "1" + }, + "task_name": { + "key": "Mainline_Tasks_11", + "text": "敬请期待" + }, + "task_display": { + "key": "story_80", + "text": "1" + }, + "npc": 10110, + "completetask": [ + 193 + ], + "deliver_npc": 0, + "auto_accept": 0, + "reword": [ + { + "a": "item", + "t": "110001", + "n": 110 + } + ], + "module": [] + }, { "key": 30010, "lock": 1, diff --git a/modules/worldtask/api_finish.go b/modules/worldtask/api_finish.go index 63d51799c..4cf15b13d 100644 --- a/modules/worldtask/api_finish.go +++ b/modules/worldtask/api_finish.go @@ -179,10 +179,12 @@ func (this *apiComp) Finish(session comm.IUserSession, req *pb.WorldtaskFinishRe // 章节完成 if _, ok := userTask.Chapters[req.GroupId]; !ok { if userTask.Chapters == nil { + delete(userTask.CurrentTask, req.GroupId) userTask.Chapters = make(map[int32]int32) userTask.Chapters[req.GroupId] = 1 //已解锁待领取 update := map[string]interface{}{ - "chapters": userTask.Chapters, + "chapters": userTask.Chapters, + "currentTask": userTask.CurrentTask, } this.module.modelWorldtask.Change(uid, update) } @@ -213,7 +215,7 @@ func (this *apiComp) Finish(session comm.IUserSession, req *pb.WorldtaskFinishRe log.Field{Key: "code", Value: code}, ) } - + //判断是否配置了通知module for _, m := range curTaskConf.Module { i, err := this.service.GetModule(core.M_Modules(m)) diff --git a/modules/worldtask/model_worldtask.go b/modules/worldtask/model_worldtask.go index f50e9d8f3..b938d20af 100644 --- a/modules/worldtask/model_worldtask.go +++ b/modules/worldtask/model_worldtask.go @@ -226,24 +226,26 @@ func (this *ModelWorldtask) taskFinishPush(session comm.IUserSession, groupId in nextTask[groupId] = &pb.Worldtask{} //表示没有下一个任务 } - // 任务完成推送 - session.SendMsg(string(this.moduleWorldtask.GetType()), WorldtaskNexttaskPush, &pb.WorldtaskNexttaskPush{ - NextTask: nextTask, - }) - if curTaskConf.IdAfter == 0 { // 章节完成 if _, ok := userTask.Chapters[groupId]; !ok { if userTask.Chapters == nil { + delete(userTask.CurrentTask,groupId) userTask.Chapters = make(map[int32]int32) userTask.Chapters[groupId] = 1 //已解锁待领取 update := map[string]interface{}{ - "chapters": userTask.Chapters, + "chapters": userTask.Chapters, + "currentTask": userTask.CurrentTask, } this.Change(session.GetUserId(), update) } } } + + // 任务完成推送 + session.SendMsg(string(this.moduleWorldtask.GetType()), WorldtaskNexttaskPush, &pb.WorldtaskNexttaskPush{ + NextTask: nextTask, + }) } func (this *ModelWorldtask) taskFinish(session comm.IUserSession, groupId, taskId int32, userTask *pb.DBWorldtask, curTaskConf *cfg.GameWorldTaskData) { diff --git a/modules/worldtask/module.go b/modules/worldtask/module.go index 2ef8ca7f3..225dd4e86 100644 --- a/modules/worldtask/module.go +++ b/modules/worldtask/module.go @@ -72,13 +72,7 @@ func (this *Worldtask) TaskCondFinishNotify(session comm.IUserSession, condId in if v == condId { //校验任务是否是当前任务 if task, ok := userTask.CurrentTask[c.Group]; ok { - this.Debug("推送NextTask", - log.Field{Key: "group", Value: c.Group}, - log.Field{Key: "Key", Value: c.Key}, - log.Field{Key: "taskId", Value: task.TaskId}, - log.Field{Key: "condId", Value: condId}, - log.Field{Key: "npcStatus", Value: task.NpcStatus}) - if task.NpcStatus == 1 { + if task.NpcStatus == 1 && c.Key == task.TaskId{ finishedTaskIds[c.Group] = c.Key groupId = c.Group taskId = c.Key