From c220db525cc71b16fe88f1a7118bfb233175acce Mon Sep 17 00:00:00 2001 From: wh_zcy Date: Sat, 1 Apr 2023 10:11:15 +0800 Subject: [PATCH] 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) }