更新分组任务接口
This commit is contained in:
parent
bb6ba7f9db
commit
05215495db
@ -390,9 +390,9 @@ type (
|
|||||||
BingoJumpTask(session IUserSession, groupId, rtaskId int32) error
|
BingoJumpTask(session IUserSession, groupId, rtaskId int32) error
|
||||||
// 查询我的世界任务
|
// 查询我的世界任务
|
||||||
GetMyWorldtask(uid string) *pb.DBWorldtask
|
GetMyWorldtask(uid string) *pb.DBWorldtask
|
||||||
//
|
// 获取分组任务
|
||||||
GetWorldTaskBy(uid string, groupId int32) int32
|
GetWorldTaskBy(session IUserSession, groupId int32) int32
|
||||||
|
//更新接取任务
|
||||||
UpdateTaskStatus(uid string, taskId int32)
|
UpdateTaskStatus(uid string, taskId int32)
|
||||||
}
|
}
|
||||||
// 支线剧情任务
|
// 支线剧情任务
|
||||||
|
@ -212,24 +212,107 @@ func (this *Worldtask) BingoJumpTask(session comm.IUserSession, groupId, taskId
|
|||||||
}
|
}
|
||||||
|
|
||||||
// 返回任务ID
|
// 返回任务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)
|
mytask, err := this.modelWorldtask.getWorldtask(uid)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return 0
|
return 0
|
||||||
}
|
}
|
||||||
|
|
||||||
if gwt, err := this.configure.getWorldtaskCfg(); err == nil {
|
if gwt, err := this.configure.getWorldtaskCfg(); err == nil {
|
||||||
for _, v := range gwt.GetDataList() {
|
for _, v := range gwt.GetDataList() {
|
||||||
if v.Group == groupId && v.Des == 5 {
|
if v.Group == groupId && v.Des == 5 {
|
||||||
if _, ok := utils.Findx(mytask.TaskList, v.Key); !ok {
|
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
|
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 {
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user