This commit is contained in:
wh_zcy 2023-04-01 10:11:15 +08:00
parent 4cda2451d6
commit c220db525c
3 changed files with 34 additions and 39 deletions

View File

@ -38,12 +38,11 @@ func (a *apiComp) Accept(session comm.IUserSession, req *pb.WorldtaskAcceptReq)
myWorldtask.CurrentTask = make(map[int32]*pb.Worldtask) myWorldtask.CurrentTask = make(map[int32]*pb.Worldtask)
} }
myWorldtask.CurrentTask[curTaskConf.Group] = &pb.Worldtask{ myWorldtask.CurrentTask[curTaskConf.Group] = &pb.Worldtask{
TaskId: req.TaskId, TaskId: req.TaskId,
TaskType: curTaskConf.Des, TaskType: curTaskConf.Des,
NpcStatus: 1,
} }
myWorldtask.CurrentTask[curTaskConf.Group].NpcStatus = 1
update := map[string]interface{}{ update := map[string]interface{}{
"currentTask": myWorldtask.CurrentTask, "currentTask": myWorldtask.CurrentTask,
} }

View File

@ -88,49 +88,33 @@ func (this *ModelWorldtask) finishTask(groupId, taskId int32, task *pb.DBWorldta
TaskType: taskConf.Des, TaskType: taskConf.Des,
} }
for _, tId := range task.TaskList {
if tId == taskId {
return comm.NewCustomError(pb.ErrorCode_WorldtaskFinihed)
}
}
task.TaskList = append(task.TaskList, taskId) task.TaskList = append(task.TaskList, taskId)
if task.CurrentTask == nil { if task.CurrentTask == nil {
task.CurrentTask = make(map[int32]*pb.Worldtask) task.CurrentTask = make(map[int32]*pb.Worldtask)
} }
wt.NpcStatus = 0 //判断是否有下个任务
wt.DeliverNpc = 0 if taskConf.IdAfter != 0 {
wt.CondiIds = []int32{} wt.NpcStatus = 0
task.CurrentTask[groupId] = wt wt.DeliverNpc = 0
wt.CondiIds = []int32{}
task.CurrentTask[groupId] = wt
update["currentTask"] = task.CurrentTask
}
update["taskList"] = task.TaskList update["taskList"] = task.TaskList
update["currentTask"] = task.CurrentTask
if err := this.Change(task.Uid, update); err != nil { if err := this.Change(task.Uid, update); err != nil {
return err 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 return nil
} }

View File

@ -70,9 +70,20 @@ func (this *Worldtask) TaskCondFinishNotify(session comm.IUserSession, condId in
for _, c := range this.worldtaskConf.GetDataList() { for _, c := range this.worldtaskConf.GetDataList() {
for _, v := range c.Completetask { for _, v := range c.Completetask {
if v == condId { if v == condId {
finishedTaskIds[c.Group] = c.Key //校验任务是否是当前任务
groupId = c.Group if task, ok := userTask.CurrentTask[c.Group]; ok {
taskId = c.Key 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 break
} }
} }
@ -97,6 +108,7 @@ func (this *Worldtask) TaskCondFinishNotify(session comm.IUserSession, condId in
userTask.CurrentTask[groupId] = wt userTask.CurrentTask[groupId] = wt
this.Debug("当前任务更新", log.Field{Key: "currentTask", Value: userTask.CurrentTask})
update := map[string]interface{}{ update := map[string]interface{}{
"currentTask": userTask.CurrentTask, "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: "condiIds", Value: wt.CondiIds},
log.Field{Key: "taskId", Value: taskId}) log.Field{Key: "taskId", Value: taskId})
//判断是否要结束任务
// 当前任务配置 // 当前任务配置
curTaskConf, err := this.configure.getWorldtaskById(taskId) curTaskConf, err := this.configure.getWorldtaskById(taskId)
if err != nil || curTaskConf == nil { if err != nil || curTaskConf == nil {
return comm.NewCustomError(pb.ErrorCode_ConfigNoFound) return comm.NewCustomError(pb.ErrorCode_ConfigNoFound)
} }
//结束任务
if curTaskConf.DeliverNpc == 0 { if curTaskConf.DeliverNpc == 0 {
//结束任务
this.modelWorldtask.taskFinish(session, groupId, taskId, userTask, curTaskConf) this.modelWorldtask.taskFinish(session, groupId, taskId, userTask, curTaskConf)
this.modelWorldtask.taskFinishPush(session, groupId, userTask, curTaskConf) this.modelWorldtask.taskFinishPush(session, groupId, userTask, curTaskConf)
} }