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