更新分组任务接口

This commit is contained in:
wh_zcy 2023-05-17 14:25:49 +08:00
parent bb6ba7f9db
commit 05215495db
2 changed files with 90 additions and 7 deletions

View File

@ -390,9 +390,9 @@ type (
BingoJumpTask(session IUserSession, groupId, rtaskId int32) error
// 查询我的世界任务
GetMyWorldtask(uid string) *pb.DBWorldtask
//
GetWorldTaskBy(uid string, groupId int32) int32
// 获取分组任务
GetWorldTaskBy(session IUserSession, groupId int32) int32
//更新接取任务
UpdateTaskStatus(uid string, taskId int32)
}
// 支线剧情任务

View File

@ -212,24 +212,107 @@ func (this *Worldtask) BingoJumpTask(session comm.IUserSession, groupId, taskId
}
// 返回任务ID
func (this *Worldtask) GetWorldTaskBy(uid string, groupId int32) (taskId int32) {
func (this *Worldtask) GetWorldTaskBy(session comm.IUserSession, groupId int32) (taskId int32) {
uid := session.GetUserId()
mytask, err := this.modelWorldtask.getWorldtask(uid)
if err != nil {
return 0
}
if gwt, err := this.configure.getWorldtaskCfg(); err == nil {
for _, v := range gwt.GetDataList() {
if v.Group == groupId && v.Des == 5 {
if _, ok := utils.Findx(mytask.TaskList, v.Key); !ok {
return v.Key
taskId = v.Key
break
}
}
}
}
if taskId == 0 {
return
}
myWorldtask, err := this.modelWorldtask.getWorldtask(uid)
if err != nil {
this.Error("获取玩家世界任务失败", log.Field{Key: "uid", Value: uid}, log.Field{Key: "err", Value: err.Error()})
return
}
// 当前任务配置
curTaskConf, err := this.configure.getWorldtaskById(taskId)
if err != nil || curTaskConf == nil {
return
}
if myWorldtask.CurrentTask == nil {
myWorldtask.CurrentTask = make(map[int32]*pb.Worldtask)
}
myWorldtask.CurrentTask[curTaskConf.Group] = &pb.Worldtask{
TaskId: taskId,
TaskType: curTaskConf.Des,
NpcStatus: 1,
}
update := map[string]interface{}{
"currentTask": myWorldtask.CurrentTask,
}
if err := this.modelWorldtask.Change(uid, update); err != nil {
}
//判断是否要结束任务
if ((len(curTaskConf.Completetask) == 1 && curTaskConf.Completetask[0] == 0) ||
len(curTaskConf.Completetask) == 0) &&
curTaskConf.DeliverNpc == 0 {
//结束任务
this.modelWorldtask.taskFinish(session, groupId, taskId, myWorldtask, curTaskConf)
this.modelWorldtask.taskFinishPush(session, groupId, myWorldtask, curTaskConf)
}
return
}
func(this *Worldtask) UpdateTaskStatus(uid string,taskId int32) {
func (this *Worldtask) UpdateTaskStatus(uid string, taskId int32) {
myWorldtask, err := this.modelWorldtask.getWorldtask(uid)
if err != nil {
this.Error("获取玩家世界任务失败", log.Field{Key: "uid", Value: uid}, log.Field{Key: "err", Value: err.Error()})
return
}
}
curTaskConf, err := this.configure.getWorldtaskById(taskId)
if err != nil || curTaskConf == nil {
return
}
if curTaskConf.Des != 5 {
return
}
var wt *pb.Worldtask
if curTaskConf.Ontxe != 0 {
//pre task
wt = &pb.Worldtask{
TaskId: curTaskConf.Ontxe,
TaskType: curTaskConf.Des,
NpcStatus: 1,
}
} else {
wt = &pb.Worldtask{
TaskId: taskId,
TaskType: curTaskConf.Des,
NpcStatus: 1,
}
}
myWorldtask.CurrentTask[curTaskConf.Group] = wt
update := map[string]interface{}{
"currentTask": myWorldtask.CurrentTask,
}
if err := this.modelWorldtask.Change(uid, update); err != nil {
}
}