优化任务通知接口
This commit is contained in:
parent
74f5d0328f
commit
25f4dd7bfb
@ -354,7 +354,7 @@ type (
|
||||
// 设置工会活跃度
|
||||
BingoSetActivity(session IUserSession, activity int32) error
|
||||
// 任务条件达成通知
|
||||
TaskcondNotify(uid string, condId int32) error
|
||||
TaskcondNotify(uid string, condIds []int32) error
|
||||
// 红点
|
||||
IReddot
|
||||
}
|
||||
@ -390,11 +390,7 @@ type (
|
||||
// 世界任务
|
||||
IWorldtask interface {
|
||||
// 任务条件达成通知
|
||||
// Deprecated
|
||||
// TaskcondNotify(session IUserSession, condId int32) error
|
||||
TaskCondFinishNotify(session IUserSession, condId int32) error
|
||||
// bingo所有任务
|
||||
// BingoAllTask(session IUserSession) error
|
||||
TaskCondFinishNotify(session IUserSession, condIds []int32) error
|
||||
// bingo任务
|
||||
BingoJumpTask(session IUserSession, groupId, rtaskId int32) error
|
||||
// 查询我的世界任务
|
||||
|
@ -340,47 +340,36 @@ func (this *ModuleRtask) processTasks(session comm.IUserSession, taskParams ...*
|
||||
|
||||
//去重
|
||||
condIds = removeDuplicate(condIds)
|
||||
|
||||
//带通知的condIds
|
||||
var condIdsForNotify []int32
|
||||
for _, condId := range condIds {
|
||||
r, _ := record.Vals[condId]
|
||||
conf, _ := this.configure.getRtaskTypeById(condId)
|
||||
if r.Data[0] >= conf.Data1 {
|
||||
module, err := this.service.GetModule(comm.ModuleWorldtask)
|
||||
if err == nil {
|
||||
//世界任务
|
||||
if worldtask, ok := module.(comm.IWorldtask); ok {
|
||||
if err := worldtask.TaskCondFinishNotify(session, condId); err != nil {
|
||||
// log.Error("世界任务条件达成通知",
|
||||
// log.Field{Key: "uid", Value: uid},
|
||||
// log.Field{Key: "condId", Value: condId},
|
||||
// log.Field{Key: "err", Value: err.Error()},
|
||||
// )
|
||||
}
|
||||
}
|
||||
condIdsForNotify = append(condIdsForNotify, condId)
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
if len(condIdsForNotify) == 0 {
|
||||
return
|
||||
}
|
||||
//通知世界任务模块
|
||||
module, err := this.service.GetModule(comm.ModuleWorldtask)
|
||||
if err == nil {
|
||||
//世界任务
|
||||
if worldtask, ok := module.(comm.IWorldtask); ok {
|
||||
if err := worldtask.TaskCondFinishNotify(session, condIdsForNotify); err != nil {
|
||||
}
|
||||
// userModule, err := this.service.GetModule(comm.ModuleUser)
|
||||
// if err == nil {
|
||||
// // 公会
|
||||
// if user, ok := userModule.(comm.IUser); ok {
|
||||
// ex, err := user.GetUserExpand(uid)
|
||||
// if err == nil && ex.SociatyId != "" {
|
||||
sociatyModule, err := this.service.GetModule(comm.ModuleSociaty)
|
||||
if err != nil {
|
||||
return
|
||||
}
|
||||
if sociaty, ok := sociatyModule.(comm.ISociaty); ok {
|
||||
if err2 := sociaty.TaskcondNotify(uid, condId); err2 != nil {
|
||||
// log.Error("公会任务条件达成通知",
|
||||
// log.Field{Key: "uid", Value: uid},
|
||||
// log.Field{Key: "sociatyId", Value: ex.SociatyId},
|
||||
// log.Field{Key: "condId", Value: condId},
|
||||
// log.Field{Key: "err", Value: err2.Error()},
|
||||
// )
|
||||
}
|
||||
}
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
}
|
||||
}
|
||||
// 通知公会任务模块
|
||||
sociatyModule, err := this.service.GetModule(comm.ModuleSociaty)
|
||||
if err != nil {
|
||||
return
|
||||
}
|
||||
if sociaty, ok := sociatyModule.(comm.ISociaty); ok {
|
||||
if err2 := sociaty.TaskcondNotify(uid, condIds); err2 != nil {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -239,7 +239,7 @@ type TaskParams struct {
|
||||
}
|
||||
|
||||
// 任务条件达成通知
|
||||
func (this *Sociaty) TaskcondNotify(uid string, condId int32) error {
|
||||
func (this *Sociaty) TaskcondNotify(uid string, condIds []int32) error {
|
||||
// log.Debug("公会任务",
|
||||
// log.Field{Key: "uid", Value: uid},
|
||||
// log.Field{Key: "sociatyId", Value: sociatyId},
|
||||
@ -247,7 +247,7 @@ func (this *Sociaty) TaskcondNotify(uid string, condId int32) error {
|
||||
|
||||
sociaty := this.modelSociaty.getUserSociaty(uid)
|
||||
if sociaty == nil {
|
||||
return fmt.Errorf("公会未找到 uid:%v condId:%v", uid, condId)
|
||||
return fmt.Errorf("公会未找到 uid:%v condIds:%v", uid, condIds)
|
||||
}
|
||||
|
||||
sociatyId := sociaty.Id
|
||||
@ -259,10 +259,11 @@ func (this *Sociaty) TaskcondNotify(uid string, condId int32) error {
|
||||
|
||||
var flag bool
|
||||
for _, v := range dt.TaskList {
|
||||
if v.TaskId == condId {
|
||||
v.Status = 1
|
||||
flag = true
|
||||
break
|
||||
for _, condId := range condIds {
|
||||
if v.TaskId == condId {
|
||||
v.Status = 1
|
||||
flag = true
|
||||
}
|
||||
}
|
||||
}
|
||||
if !flag {
|
||||
|
@ -55,15 +55,13 @@ func (this *Worldtask) Start() (err error) {
|
||||
}
|
||||
|
||||
// 任务条件达成通知
|
||||
func (this *Worldtask) TaskCondFinishNotify(session comm.IUserSession, condId int32) error {
|
||||
|
||||
this.Debug("世界任务完成条件通知", log.Field{Key: "uid", Value: session.GetUserId()}, log.Field{Key: "condId", Value: condId})
|
||||
|
||||
func (this *Worldtask) TaskCondFinishNotify(session comm.IUserSession, condIds []int32) error {
|
||||
this.Debug("世界任务完成条件通知", log.Field{Key: "uid", Value: session.GetUserId()}, log.Field{Key: "condIds", Value: condIds})
|
||||
uid := session.GetUserId()
|
||||
// 玩家世界任务
|
||||
userTask, err := this.modelWorldtask.getWorldtask(uid)
|
||||
if err != nil {
|
||||
this.Error("获取玩家世界任务", log.Field{Key: "uid", Value: uid}, log.Field{Key: "condId", Value: condId})
|
||||
this.Error("获取玩家世界任务", log.Field{Key: "uid", Value: uid})
|
||||
return err
|
||||
}
|
||||
|
||||
@ -72,16 +70,18 @@ func (this *Worldtask) TaskCondFinishNotify(session comm.IUserSession, condId in
|
||||
finishedTaskIds := make(map[int32]int32) //达成的任务条件
|
||||
for _, c := range this.worldtaskConf.GetDataList() {
|
||||
for _, v := range c.Completetask {
|
||||
if v == condId {
|
||||
//校验任务是否是当前任务
|
||||
if task, ok := userTask.CurrentTask[c.Group]; ok {
|
||||
if task.NpcStatus == 1 && c.Key == task.TaskId {
|
||||
finishedTaskIds[c.Group] = c.Key
|
||||
groupId = c.Group
|
||||
taskId = c.Key
|
||||
for _, condId := range condIds {
|
||||
if v == condId {
|
||||
//校验任务是否是当前任务
|
||||
if task, ok := userTask.CurrentTask[c.Group]; ok {
|
||||
if task.NpcStatus == 1 && c.Key == task.TaskId {
|
||||
finishedTaskIds[c.Group] = c.Key
|
||||
groupId = c.Group
|
||||
taskId = c.Key
|
||||
}
|
||||
}
|
||||
break
|
||||
}
|
||||
break
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -102,13 +102,14 @@ func (this *Worldtask) TaskCondFinishNotify(session comm.IUserSession, condId in
|
||||
wt = &pb.Worldtask{}
|
||||
}
|
||||
|
||||
if _, ok := utils.Findx(wt.CondiIds, condId); !ok {
|
||||
wt.CondiIds = append(wt.CondiIds, condId)
|
||||
for _, condId := range condIds {
|
||||
if _, ok := utils.Findx(wt.CondiIds, condId); !ok {
|
||||
wt.CondiIds = append(wt.CondiIds, condId)
|
||||
}
|
||||
}
|
||||
|
||||
userTask.CurrentTask[groupId] = wt
|
||||
|
||||
//this.Debug("当前任务更新", log.Field{Key: "currentTask", Value: userTask.CurrentTask})
|
||||
update := map[string]interface{}{
|
||||
"currentTask": userTask.CurrentTask,
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user