更新任务接口
This commit is contained in:
parent
b3e16d641e
commit
53387bbd0b
@ -4,6 +4,7 @@ import (
|
|||||||
"go_dreamfactory/comm"
|
"go_dreamfactory/comm"
|
||||||
"go_dreamfactory/lego/sys/log"
|
"go_dreamfactory/lego/sys/log"
|
||||||
"go_dreamfactory/pb"
|
"go_dreamfactory/pb"
|
||||||
|
"go_dreamfactory/utils"
|
||||||
)
|
)
|
||||||
|
|
||||||
// 任务接取
|
// 任务接取
|
||||||
@ -87,9 +88,10 @@ func (a *apiComp) Accept(session comm.IUserSession, req *pb.WorldtaskAcceptReq)
|
|||||||
} else {
|
} else {
|
||||||
// 已完成的任务条件
|
// 已完成的任务条件
|
||||||
rsp.CondiIds = a.module.ModuleBuried.CheckCondition(uid, curTaskConf.Completetask...)
|
rsp.CondiIds = a.module.ModuleBuried.CheckCondition(uid, curTaskConf.Completetask...)
|
||||||
|
a.module.ModuleBuried.ActiveCondition(uid, utils.NoContain(rsp.CondiIds, curTaskConf.Completetask)...)
|
||||||
}
|
}
|
||||||
|
|
||||||
a.sendMsg(session, WorldtaskSubtypeAccept, rsp)
|
a.sendMsg(session, WorldtaskSubtypeAccept, rsp)
|
||||||
a.module.ModuleBuried.ActiveCondition(uid, curTaskConf.Completetask...)
|
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
@ -2,9 +2,7 @@ package worldtask
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"go_dreamfactory/comm"
|
"go_dreamfactory/comm"
|
||||||
"go_dreamfactory/lego/sys/log"
|
|
||||||
"go_dreamfactory/pb"
|
"go_dreamfactory/pb"
|
||||||
"go_dreamfactory/utils"
|
|
||||||
)
|
)
|
||||||
|
|
||||||
// 任务完成条件
|
// 任务完成条件
|
||||||
@ -43,28 +41,32 @@ func (this *apiComp) CompleteCondi(session comm.IUserSession, req *pb.WorldtaskC
|
|||||||
|
|
||||||
myWorldtask.Uid = uid
|
myWorldtask.Uid = uid
|
||||||
wt := myWorldtask.CurrentTask[req.GroupId]
|
wt := myWorldtask.CurrentTask[req.GroupId]
|
||||||
if m, err := this.module.service.GetModule(comm.ModuleRtask); err == nil {
|
// if m, err := this.module.service.GetModule(comm.ModuleRtask); err == nil {
|
||||||
iwt, ok := m.(comm.IRtask)
|
// iwt, ok := m.(comm.IRtask)
|
||||||
if ok {
|
// if ok {
|
||||||
if code = iwt.CheckCondi(uid, req.CondiId); code != pb.ErrorCode_Success {
|
// if code = iwt.CheckCondi(uid, req.CondiId); code != pb.ErrorCode_Success {
|
||||||
rsp.Code = code
|
// rsp.Code = code
|
||||||
rsp.CondiId = req.CondiId
|
// rsp.CondiId = req.CondiId
|
||||||
rsp.TaskId = req.TaskId
|
// rsp.TaskId = req.TaskId
|
||||||
this.module.Debug("任务完成条件不满足",
|
// this.module.Debug("任务完成条件不满足",
|
||||||
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},
|
||||||
log.Field{Key: "condiId", Value: req.CondiId},
|
// log.Field{Key: "condiId", Value: req.CondiId},
|
||||||
)
|
// )
|
||||||
this.sendMsg(session, WorldtaskComplete, rsp)
|
// this.sendMsg(session, WorldtaskComplete, rsp)
|
||||||
return
|
// return
|
||||||
}
|
// }
|
||||||
if wt == nil {
|
// if wt == nil {
|
||||||
wt = &pb.Worldtask{}
|
// wt = &pb.Worldtask{}
|
||||||
}
|
// }
|
||||||
if _, b := utils.Findx(wt.CondiIds, req.CondiId); !b {
|
// if _, b := utils.Findx(wt.CondiIds, req.CondiId); !b {
|
||||||
wt.CondiIds = append(wt.CondiIds, req.CondiId)
|
// wt.CondiIds = append(wt.CondiIds, req.CondiId)
|
||||||
}
|
// }
|
||||||
}
|
// }
|
||||||
|
// }
|
||||||
|
condIds := this.module.ModuleBuried.CheckCondition(uid, req.CondiId)
|
||||||
|
if len(condIds) > 0 {
|
||||||
|
wt.CondiIds = append(wt.CondiIds, condIds...)
|
||||||
}
|
}
|
||||||
|
|
||||||
myWorldtask.CurrentTask[req.GroupId] = wt
|
myWorldtask.CurrentTask[req.GroupId] = wt
|
||||||
|
@ -95,7 +95,9 @@ func (this *apiComp) Finish(session comm.IUserSession, req *pb.WorldtaskFinishRe
|
|||||||
condiFlag bool
|
condiFlag bool
|
||||||
)
|
)
|
||||||
for _, condId := range curTaskConf.Completetask {
|
for _, condId := range curTaskConf.Completetask {
|
||||||
if this.module.modelWorldtask.checkCondi(uid, condId) {
|
conIds := this.module.ModuleBuried.CheckCondition(uid, condId)
|
||||||
|
// if this.module.modelWorldtask.checkCondi(uid, condId) {
|
||||||
|
if len(conIds) > 0 {
|
||||||
condiFlag = true
|
condiFlag = true
|
||||||
} else {
|
} else {
|
||||||
condiFlag = false
|
condiFlag = false
|
||||||
@ -194,28 +196,33 @@ func (this *apiComp) updateCheckCond(uid string, userTask *pb.DBWorldtask, nextT
|
|||||||
TaskType: nextTaskConf.Des,
|
TaskType: nextTaskConf.Des,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if m, err := this.module.service.GetModule(comm.ModuleRtask); err == nil {
|
// if m, err := this.module.service.GetModule(comm.ModuleRtask); err == nil {
|
||||||
iwt, ok := m.(comm.IRtask)
|
// iwt, ok := m.(comm.IRtask)
|
||||||
if ok {
|
// if ok {
|
||||||
if mc := iwt.CheckCondi(uid, condiId); mc != pb.ErrorCode_Success {
|
// if mc := iwt.CheckCondi(uid, condiId); mc != pb.ErrorCode_Success {
|
||||||
this.module.Debug("任务完成条件不满足",
|
// this.module.Debug("任务完成条件不满足",
|
||||||
log.Field{Key: "uid", Value: uid},
|
// log.Field{Key: "uid", Value: uid},
|
||||||
log.Field{Key: "taskId", Value: nextTaskId},
|
// log.Field{Key: "taskId", Value: nextTaskId},
|
||||||
log.Field{Key: "condiId", Value: condiId},
|
// log.Field{Key: "condiId", Value: condiId},
|
||||||
)
|
// )
|
||||||
} else {
|
// } else {
|
||||||
if ok {
|
// if ok {
|
||||||
nwt.CondiIds = append(nwt.CondiIds, condiId)
|
// nwt.CondiIds = append(nwt.CondiIds, condiId)
|
||||||
} else {
|
// } else {
|
||||||
condiIds := []int32{condiId}
|
// condiIds := []int32{condiId}
|
||||||
nwt.CondiIds = condiIds
|
// nwt.CondiIds = condiIds
|
||||||
}
|
// }
|
||||||
}
|
// }
|
||||||
}
|
// }
|
||||||
}
|
// }
|
||||||
|
condIds := this.module.ModuleBuried.CheckCondition(uid, condiId)
|
||||||
|
if len(condIds) > 0 {
|
||||||
|
nwt.CondiIds = condIds
|
||||||
userTask.CurrentTask[nextTaskConf.Group] = nwt
|
userTask.CurrentTask[nextTaskConf.Group] = nwt
|
||||||
update["currentTask"] = userTask.CurrentTask
|
update["currentTask"] = userTask.CurrentTask
|
||||||
}
|
}
|
||||||
|
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if len(update) > 0 {
|
if len(update) > 0 {
|
||||||
|
@ -208,24 +208,30 @@ func (this *ModelWorldtask) updateCheckCond(uid string, userLv int32, userTask *
|
|||||||
TaskType: nextTaskConf.Des,
|
TaskType: nextTaskConf.Des,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if m, err := this.service.GetModule(comm.ModuleRtask); err == nil {
|
// if m, err := this.service.GetModule(comm.ModuleRtask); err == nil {
|
||||||
iwt, ok := m.(comm.IRtask)
|
// iwt, ok := m.(comm.IRtask)
|
||||||
if ok {
|
// if ok {
|
||||||
if mc := iwt.CheckCondi(uid, condiId); mc != pb.ErrorCode_Success {
|
// if mc := iwt.CheckCondi(uid, condiId); mc != pb.ErrorCode_Success {
|
||||||
this.moduleWorldtask.Debug("任务完成条件不满足",
|
// this.moduleWorldtask.Debug("任务完成条件不满足",
|
||||||
log.Field{Key: "uid", Value: uid},
|
// log.Field{Key: "uid", Value: uid},
|
||||||
log.Field{Key: "taskId", Value: nextTaskId},
|
// log.Field{Key: "taskId", Value: nextTaskId},
|
||||||
log.Field{Key: "condiId", Value: condiId},
|
// log.Field{Key: "condiId", Value: condiId},
|
||||||
)
|
// )
|
||||||
} else {
|
// } else {
|
||||||
if ok {
|
// if ok {
|
||||||
nwt.CondiIds = append(nwt.CondiIds, condiId)
|
// nwt.CondiIds = append(nwt.CondiIds, condiId)
|
||||||
} else {
|
// } else {
|
||||||
condiIds := []int32{condiId}
|
// condiIds := []int32{condiId}
|
||||||
nwt.CondiIds = condiIds
|
// nwt.CondiIds = condiIds
|
||||||
}
|
// }
|
||||||
}
|
// }
|
||||||
}
|
// }
|
||||||
|
// }
|
||||||
|
condIds := this.moduleWorldtask.ModuleBuried.CheckCondition(uid, condiId)
|
||||||
|
if len(condIds) > 0 {
|
||||||
|
nwt.CondiIds = condIds
|
||||||
|
userTask.CurrentTask[nextTaskConf.Group] = nwt
|
||||||
|
update["currentTask"] = userTask.CurrentTask
|
||||||
}
|
}
|
||||||
userTask.CurrentTask[nextTaskConf.Group] = nwt
|
userTask.CurrentTask[nextTaskConf.Group] = nwt
|
||||||
update["currentTask"] = userTask.CurrentTask
|
update["currentTask"] = userTask.CurrentTask
|
||||||
|
@ -27,3 +27,16 @@ func RemoveDuplicate(arr []int32) []int32 {
|
|||||||
}
|
}
|
||||||
return result
|
return result
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func NoContain(exist, all []int32) (contain []int32) {
|
||||||
|
existMap := make(map[int32]bool)
|
||||||
|
for _, b := range exist {
|
||||||
|
existMap[b] = true
|
||||||
|
}
|
||||||
|
for _, a := range all {
|
||||||
|
if !existMap[a] {
|
||||||
|
contain = append(contain, a)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return
|
||||||
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user