更新任务接口调用
This commit is contained in:
parent
4ce03856e6
commit
ab3528cd59
@ -4,7 +4,6 @@ import (
|
|||||||
"fmt"
|
"fmt"
|
||||||
"go_dreamfactory/comm"
|
"go_dreamfactory/comm"
|
||||||
"go_dreamfactory/pb"
|
"go_dreamfactory/pb"
|
||||||
"go_dreamfactory/utils"
|
|
||||||
)
|
)
|
||||||
|
|
||||||
// 任务接取
|
// 任务接取
|
||||||
@ -90,9 +89,17 @@ func (a *apiComp) Accept(session comm.IUserSession, req *pb.WorldtaskAcceptReq)
|
|||||||
a.module.modelWorldtask.taskFinishPush(session, req.GroupId, myWorldtask, curTaskConf)
|
a.module.modelWorldtask.taskFinishPush(session, req.GroupId, myWorldtask, curTaskConf)
|
||||||
} else {
|
} else {
|
||||||
// 已完成的任务条件
|
// 已完成的任务条件
|
||||||
rsp.CondiIds, _, err = a.module.ModuleBuried.CheckCondition(uid, curTaskConf.Completetask...)
|
conds, err := a.module.ModuleBuried.CheckCondition(uid, curTaskConf.Completetask...)
|
||||||
if err == nil {
|
if err == nil {
|
||||||
a.module.ModuleBuried.ActiveCondition(uid, utils.NoContain(rsp.CondiIds, curTaskConf.Completetask)...)
|
var unfinishCondIds []int32
|
||||||
|
for _, cond := range conds {
|
||||||
|
if cond.State == pb.BuriedItemFinishState_finish {
|
||||||
|
rsp.CondiIds = append(rsp.CondiIds, cond.Conid)
|
||||||
|
} else if cond.State == pb.BuriedItemFinishState_unfinish {
|
||||||
|
unfinishCondIds = append(unfinishCondIds, cond.Conid)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
a.module.ModuleBuried.ActiveCondition(uid, unfinishCondIds...)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -45,9 +45,16 @@ 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]
|
||||||
|
|
||||||
condIds, _, err := this.module.ModuleBuried.CheckCondition(uid, req.CondiId)
|
conds, err := this.module.ModuleBuried.CheckCondition(uid, req.CondiId)
|
||||||
if err == nil && len(condIds) > 0 {
|
if err != nil {
|
||||||
wt.CondiIds = append(wt.CondiIds, condIds...)
|
code = pb.ErrorCode_ExternalModule
|
||||||
|
data.Title = code.ToString()
|
||||||
|
data.Message = comm.NewExternalModuleErr("buried", "CheckCondition", uid, req.CondiId).Error()
|
||||||
|
}
|
||||||
|
for _, cond := range conds {
|
||||||
|
if cond.State == pb.BuriedItemFinishState_finish {
|
||||||
|
wt.CondiIds = append(wt.CondiIds, cond.Conid)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
myWorldtask.CurrentTask[req.GroupId] = wt
|
myWorldtask.CurrentTask[req.GroupId] = wt
|
||||||
|
@ -104,11 +104,8 @@ func (this *apiComp) Finish(session comm.IUserSession, req *pb.WorldtaskFinishRe
|
|||||||
for _, condId := range curTaskConf.Completetask {
|
for _, condId := range curTaskConf.Completetask {
|
||||||
if v, ok := userTask.CurrentTask[req.GroupId]; ok {
|
if v, ok := userTask.CurrentTask[req.GroupId]; ok {
|
||||||
if _, ok := utils.Findx(v.CondiIds, condId); !ok {
|
if _, ok := utils.Findx(v.CondiIds, condId); !ok {
|
||||||
//
|
conds, err := this.module.ModuleBuried.CheckCondition(uid, condId)
|
||||||
conIds, _, err := this.module.ModuleBuried.CheckCondition(uid, condId)
|
if err != nil {
|
||||||
if err == nil && len(conIds) > 0 {
|
|
||||||
condiFlag = true
|
|
||||||
} else {
|
|
||||||
code = pb.ErrorCode_ExternalModule
|
code = pb.ErrorCode_ExternalModule
|
||||||
data = &pb.ErrorData{
|
data = &pb.ErrorData{
|
||||||
Title: code.ToString(),
|
Title: code.ToString(),
|
||||||
@ -116,6 +113,11 @@ func (this *apiComp) Finish(session comm.IUserSession, req *pb.WorldtaskFinishRe
|
|||||||
}
|
}
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
for _, cond := range conds {
|
||||||
|
if cond.Conid == condId && cond.State == pb.BuriedItemFinishState_finish {
|
||||||
|
condiFlag = true
|
||||||
|
}
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
condiFlag = true
|
condiFlag = true
|
||||||
}
|
}
|
||||||
@ -164,6 +166,7 @@ func (this *apiComp) Finish(session comm.IUserSession, req *pb.WorldtaskFinishRe
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Deprecated
|
||||||
func (this *apiComp) updateCheckCond(uid string, userTask *pb.DBWorldtask, nextTaskId int32) (*pb.DBWorldtask, error) {
|
func (this *apiComp) updateCheckCond(uid string, userTask *pb.DBWorldtask, nextTaskId int32) (*pb.DBWorldtask, error) {
|
||||||
//检查下个任务的完成条件
|
//检查下个任务的完成条件
|
||||||
nextTaskConf, err := this.module.configure.getWorldtaskById(nextTaskId)
|
nextTaskConf, err := this.module.configure.getWorldtaskById(nextTaskId)
|
||||||
@ -190,29 +193,33 @@ func (this *apiComp) updateCheckCond(uid string, userTask *pb.DBWorldtask, nextT
|
|||||||
userTask.CurrentTask[nextTaskConf.Group] = wt
|
userTask.CurrentTask[nextTaskConf.Group] = wt
|
||||||
update["currentTask"] = userTask.CurrentTask
|
update["currentTask"] = userTask.CurrentTask
|
||||||
} else {
|
} else {
|
||||||
for _, condiId := range nextTaskConf.Completetask {
|
nwt, ok := userTask.CurrentTask[nextTaskConf.Group]
|
||||||
if condiId == 0 {
|
if ok {
|
||||||
continue
|
nwt.TaskId = nextTaskId
|
||||||
|
nwt.TaskType = nextTaskConf.Des
|
||||||
|
} else {
|
||||||
|
nwt = &pb.Worldtask{
|
||||||
|
TaskId: nextTaskId,
|
||||||
|
TaskType: nextTaskConf.Des,
|
||||||
}
|
}
|
||||||
nwt, ok := userTask.CurrentTask[nextTaskConf.Group]
|
|
||||||
if ok {
|
|
||||||
nwt.TaskId = nextTaskId
|
|
||||||
nwt.TaskType = nextTaskConf.Des
|
|
||||||
} else {
|
|
||||||
nwt = &pb.Worldtask{
|
|
||||||
TaskId: nextTaskId,
|
|
||||||
TaskType: nextTaskConf.Des,
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
condIds, _, err := this.module.ModuleBuried.CheckCondition(uid, condiId)
|
|
||||||
if err == nil && len(condIds) > 0 {
|
|
||||||
nwt.CondiIds = condIds
|
|
||||||
userTask.CurrentTask[nextTaskConf.Group] = nwt
|
|
||||||
update["currentTask"] = userTask.CurrentTask
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
conds, err := this.module.ModuleBuried.CheckCondition(uid, nextTaskConf.Completetask...)
|
||||||
|
if err != nil {
|
||||||
|
this.module.Errorf("buried err:%v", err.Error())
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
|
||||||
|
var condIds []int32
|
||||||
|
for _, cond := range conds {
|
||||||
|
if cond.State == pb.BuriedItemFinishState_finish {
|
||||||
|
condIds = append(condIds, cond.Conid)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
nwt.CondiIds = condIds
|
||||||
|
userTask.CurrentTask[nextTaskConf.Group] = nwt
|
||||||
|
update["currentTask"] = userTask.CurrentTask
|
||||||
}
|
}
|
||||||
|
|
||||||
if len(update) > 0 {
|
if len(update) > 0 {
|
||||||
|
@ -195,31 +195,33 @@ func (this *ModelWorldtask) updateCurrentTaskCond(uid string, userLv int32, user
|
|||||||
userTask.CurrentTask[nextTaskConf.Group] = wt
|
userTask.CurrentTask[nextTaskConf.Group] = wt
|
||||||
update["currentTask"] = userTask.CurrentTask
|
update["currentTask"] = userTask.CurrentTask
|
||||||
} else {
|
} else {
|
||||||
for _, condiId := range nextTaskConf.Completetask {
|
nwt, ok := userTask.CurrentTask[nextTaskConf.Group]
|
||||||
if condiId == 0 {
|
if ok {
|
||||||
continue
|
nwt.TaskId = nextTaskId
|
||||||
|
nwt.TaskType = nextTaskConf.Des
|
||||||
|
} else {
|
||||||
|
nwt = &pb.Worldtask{
|
||||||
|
TaskId: nextTaskId,
|
||||||
|
TaskType: nextTaskConf.Des,
|
||||||
}
|
}
|
||||||
nwt, ok := userTask.CurrentTask[nextTaskConf.Group]
|
|
||||||
if ok {
|
|
||||||
nwt.TaskId = nextTaskId
|
|
||||||
nwt.TaskType = nextTaskConf.Des
|
|
||||||
} else {
|
|
||||||
nwt = &pb.Worldtask{
|
|
||||||
TaskId: nextTaskId,
|
|
||||||
TaskType: nextTaskConf.Des,
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
condIds, _, err := this.moduleWorldtask.ModuleBuried.CheckCondition(uid, condiId)
|
|
||||||
if err == nil && len(condIds) > 0 {
|
|
||||||
nwt.CondiIds = condIds
|
|
||||||
userTask.CurrentTask[nextTaskConf.Group] = nwt
|
|
||||||
update["currentTask"] = userTask.CurrentTask
|
|
||||||
}
|
|
||||||
userTask.CurrentTask[nextTaskConf.Group] = nwt
|
|
||||||
update["currentTask"] = userTask.CurrentTask
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
conds, err := this.moduleWorldtask.ModuleBuried.CheckCondition(uid, nextTaskConf.Completetask...)
|
||||||
|
if err != nil {
|
||||||
|
this.moduleWorldtask.Errorf("buried err:%v", err.Error())
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
|
var condIds []int32
|
||||||
|
for _, cond := range conds {
|
||||||
|
if cond.State == pb.BuriedItemFinishState_finish {
|
||||||
|
condIds = append(condIds, cond.Conid)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
nwt.CondiIds = condIds
|
||||||
|
userTask.CurrentTask[nextTaskConf.Group] = nwt
|
||||||
|
update["currentTask"] = userTask.CurrentTask
|
||||||
}
|
}
|
||||||
|
|
||||||
if len(update) > 0 {
|
if len(update) > 0 {
|
||||||
|
@ -58,8 +58,8 @@ func (this *Worldtask) Start() (err error) {
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
func (this *Worldtask) TCondFinishNotify(uid string, conids []int32) {
|
func (this *Worldtask) TCondFinishNotify(uid string, conds []*pb.ConIProgress) {
|
||||||
this.Debug("世界任务完成条件通知", log.Field{Key: "uid", Value: uid}, log.Field{Key: "condIds", Value: conids})
|
this.Debug("世界任务完成条件通知", log.Field{Key: "uid", Value: uid}, log.Field{Key: "condIds", Value: conds})
|
||||||
|
|
||||||
session, ok := this.GetUserSession(uid)
|
session, ok := this.GetUserSession(uid)
|
||||||
if !ok {
|
if !ok {
|
||||||
@ -85,14 +85,14 @@ func (this *Worldtask) TCondFinishNotify(uid string, conids []int32) {
|
|||||||
finishedCondIds := []int32{}
|
finishedCondIds := []int32{}
|
||||||
for _, c := range this.worldtaskConf.GetDataList() {
|
for _, c := range this.worldtaskConf.GetDataList() {
|
||||||
for _, v := range c.Completetask {
|
for _, v := range c.Completetask {
|
||||||
for _, condId := range conids {
|
for _, cond := range conds {
|
||||||
if v == condId {
|
if v == cond.Conid {
|
||||||
//校验任务是否是当前任务
|
//校验任务是否是当前任务
|
||||||
if task, ok := userTask.CurrentTask[c.Group]; ok {
|
if task, ok := userTask.CurrentTask[c.Group]; ok {
|
||||||
if task.NpcStatus == 1 && c.Key == task.TaskId {
|
if task.NpcStatus == 1 && c.Key == task.TaskId {
|
||||||
groupId = c.Group
|
groupId = c.Group
|
||||||
taskId = c.Key
|
taskId = c.Key
|
||||||
finishedCondIds = append(finishedCondIds, condId)
|
finishedCondIds = append(finishedCondIds, cond.Conid)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
break
|
break
|
||||||
|
Loading…
Reference in New Issue
Block a user