优化任务完成后方法调用
This commit is contained in:
parent
d0576acabf
commit
edb52d8be2
@ -95,6 +95,7 @@ func (a *apiComp) Accept(session comm.IUserSession, req *pb.WorldtaskAcceptReq)
|
|||||||
|
|
||||||
// 检查当前任务的完成条件
|
// 检查当前任务的完成条件
|
||||||
func (this *apiComp) checkCurrentCompleteCond(uid string, completeCondIds []int32, userTask *pb.DBWorldtask) (condIds []int32) {
|
func (this *apiComp) checkCurrentCompleteCond(uid string, completeCondIds []int32, userTask *pb.DBWorldtask) (condIds []int32) {
|
||||||
|
|
||||||
for _, condId := range completeCondIds {
|
for _, condId := range completeCondIds {
|
||||||
if condId == 0 {
|
if condId == 0 {
|
||||||
continue
|
continue
|
||||||
|
@ -77,55 +77,6 @@ func (this *apiComp) Finish(session comm.IUserSession, req *pb.WorldtaskFinishRe
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
finishRsp := func() {
|
|
||||||
this.module.modelWorldtask.updateRandomTask(session.GetUserId(), userTask)
|
|
||||||
|
|
||||||
nextTaskIds := this.module.modelWorldtask.findNextTasks(curTaskConf.Key)
|
|
||||||
this.module.Debug("nextTaskIds", log.Field{Key: "nextTaskIds", Value: nextTaskIds})
|
|
||||||
|
|
||||||
nextTask := make(map[int32]*pb.Worldtask)
|
|
||||||
for _, next := range nextTaskIds {
|
|
||||||
ut := this.updateCheckCond(uid, userTask, next)
|
|
||||||
if ut != nil {
|
|
||||||
for k, v := range ut.CurrentTask {
|
|
||||||
nextTask[k] = &pb.Worldtask{
|
|
||||||
TaskId: v.TaskId,
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if err := session.SendMsg(string(this.module.GetType()), WorldtaskSubtypeFinish, rsp); err != nil {
|
|
||||||
code = pb.ErrorCode_SystemError
|
|
||||||
return
|
|
||||||
}
|
|
||||||
|
|
||||||
if curTaskConf.IdAfter != 0 {
|
|
||||||
// 任务完成推送
|
|
||||||
if err := session.SendMsg(string(this.module.GetType()), WorldtaskNexttaskPush, &pb.WorldtaskNexttaskPush{
|
|
||||||
NextTask: nextTask,
|
|
||||||
FinishedTaskIds: []int32{curTaskConf.Key},
|
|
||||||
}); err != nil {
|
|
||||||
code = pb.ErrorCode_SystemError
|
|
||||||
return
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
// 章节完成
|
|
||||||
if _, ok := userTask.Chapters[req.GroupId]; !ok {
|
|
||||||
delete(userTask.CurrentTask, req.GroupId)
|
|
||||||
if userTask.Chapters == nil {
|
|
||||||
userTask.Chapters = make(map[int32]int32)
|
|
||||||
}
|
|
||||||
userTask.Chapters[req.GroupId] = 1 //已解锁待领取
|
|
||||||
update := map[string]interface{}{
|
|
||||||
"chapters": userTask.Chapters,
|
|
||||||
"currentTask": userTask.CurrentTask,
|
|
||||||
}
|
|
||||||
this.module.modelWorldtask.Change(uid, update)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
//判断任务是否已完成
|
//判断任务是否已完成
|
||||||
for _, v := range userTask.TaskList {
|
for _, v := range userTask.TaskList {
|
||||||
if v == req.TaskId {
|
if v == req.TaskId {
|
||||||
@ -133,7 +84,8 @@ func (this *apiComp) Finish(session comm.IUserSession, req *pb.WorldtaskFinishRe
|
|||||||
log.Field{Key: "uid", Value: uid},
|
log.Field{Key: "uid", Value: uid},
|
||||||
log.Field{Key: "taskId", Value: req.TaskId},
|
log.Field{Key: "taskId", Value: req.TaskId},
|
||||||
)
|
)
|
||||||
finishRsp()
|
// finishRsp()
|
||||||
|
this.module.modelWorldtask.taskFinishPush(session, req.GroupId, userTask, curTaskConf)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -194,7 +146,7 @@ func (this *apiComp) Finish(session comm.IUserSession, req *pb.WorldtaskFinishRe
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
finishRsp()
|
this.module.modelWorldtask.taskFinishPush(session, req.GroupId, userTask, curTaskConf)
|
||||||
|
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user