remove rdtask check
This commit is contained in:
parent
00c83158b1
commit
47b59bd48d
@ -342,7 +342,7 @@ const (
|
|||||||
EventUserOffline core.Event_Key = "Event_UserOffline" //用户离线事件
|
EventUserOffline core.Event_Key = "Event_UserOffline" //用户离线事件
|
||||||
|
|
||||||
EventUserChanged core.Event_Key = "event_user_changed" //用户数据变化
|
EventUserChanged core.Event_Key = "event_user_changed" //用户数据变化
|
||||||
EventTaskChanged core.Event_Key = "event_task_changed" //任务数据变化
|
// EventTaskChanged core.Event_Key = "event_task_changed" //任务数据变化
|
||||||
EventUserVipChanged core.Event_Key = "event_uservip_changed" //用户数据变化
|
EventUserVipChanged core.Event_Key = "event_uservip_changed" //用户数据变化
|
||||||
EventSociatyRankChanged core.Event_Key = "event_sociatyRank_changed" //公会数据变化
|
EventSociatyRankChanged core.Event_Key = "event_sociatyRank_changed" //公会数据变化
|
||||||
|
|
||||||
|
@ -114,7 +114,7 @@ func (this *ModelGrowtask) list(uid string, taskType int32, gt *pb.DBGrowtask) (
|
|||||||
}
|
}
|
||||||
|
|
||||||
//任务完成
|
//任务完成
|
||||||
if code := this.moduleGrowtask.ModuleRtask.CheckCondi(uid, v.Fstask); code == nil {
|
if _, err := this.moduleGrowtask.ModuleBuried.CheckCondition(uid, v.Fstask); err == nil {
|
||||||
if v.PreTask == 0 {
|
if v.PreTask == 0 {
|
||||||
v.Status = pb.GrowtaskStatus_Wait //待领奖状态
|
v.Status = pb.GrowtaskStatus_Wait //待领奖状态
|
||||||
} else {
|
} else {
|
||||||
|
@ -80,8 +80,8 @@ func (this *modelTask) checkTaskStatus(uid string, taskId int32) bool {
|
|||||||
if conf == nil {
|
if conf == nil {
|
||||||
return false
|
return false
|
||||||
}
|
}
|
||||||
if ec := this.module.ModuleRtask.CheckCondi(uid, conf.TypeId); ec != nil {
|
// if ec := this.module.ModuleRtask.CheckCondi(uid, conf.TypeId); ec != nil {
|
||||||
return false
|
// return false
|
||||||
}
|
// }
|
||||||
return true
|
return true
|
||||||
}
|
}
|
||||||
|
@ -927,26 +927,6 @@ func (this *ModelSociaty) getMemberMax(sociaty *pb.DBSociaty) int32 {
|
|||||||
return 0
|
return 0
|
||||||
}
|
}
|
||||||
|
|
||||||
// 校验任务完成状态
|
|
||||||
func (this *ModelSociaty) validTask(uid string, taskId int32) (err error, ok bool) {
|
|
||||||
rsp := &pb.DBRtaskRecord{}
|
|
||||||
if err = this.module.ModuleRtask.RemoteCheckCondi(uid, taskId, rsp); err != nil {
|
|
||||||
return
|
|
||||||
}
|
|
||||||
|
|
||||||
// 遍历玩家任务数据
|
|
||||||
if data, ok := rsp.Vals[taskId]; ok {
|
|
||||||
//查找表配置
|
|
||||||
conf, ok := this.module.rtaskCondConf.GetDataMap()[taskId]
|
|
||||||
if ok {
|
|
||||||
if data.Rtype == conf.Type && data.Data[0] >= conf.Data1 {
|
|
||||||
return nil, true
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return
|
|
||||||
}
|
|
||||||
|
|
||||||
// 成员退出清理
|
// 成员退出清理
|
||||||
func (this *ModelSociaty) memberClear(sociaty *pb.DBSociaty) error {
|
func (this *ModelSociaty) memberClear(sociaty *pb.DBSociaty) error {
|
||||||
// 邮件接收人
|
// 邮件接收人
|
||||||
|
@ -27,7 +27,7 @@ func (this *ModelTask) Init(service core.IService, module core.IModule, comp cor
|
|||||||
err = this.MCompModel.Init(service, module, comp, options)
|
err = this.MCompModel.Init(service, module, comp, options)
|
||||||
this.moduleTask = module.(*ModuleTask)
|
this.moduleTask = module.(*ModuleTask)
|
||||||
this.EventApp = event_v2.NewApp()
|
this.EventApp = event_v2.NewApp()
|
||||||
this.EventApp.Listen(comm.EventTaskChanged, this.doTaskHandle)
|
// this.EventApp.Listen(comm.EventTaskChanged, this.doTaskHandle)
|
||||||
this.DB.CreateIndex(core.SqlTable(this.TableName), mongo.IndexModel{
|
this.DB.CreateIndex(core.SqlTable(this.TableName), mongo.IndexModel{
|
||||||
Keys: bsonx.Doc{{Key: "uid", Value: bsonx.Int32(1)}},
|
Keys: bsonx.Doc{{Key: "uid", Value: bsonx.Int32(1)}},
|
||||||
})
|
})
|
||||||
@ -387,135 +387,135 @@ func (this *ModelTask) modifyUserTask(uid string, taskId int32, data map[string]
|
|||||||
}
|
}
|
||||||
|
|
||||||
// 清空任务
|
// 清空任务
|
||||||
func (this *ModelTask) clearTask(uid string, taskTag ...comm.TaskTag) {
|
// func (this *ModelTask) clearTask(uid string, taskTag ...comm.TaskTag) {
|
||||||
if len(taskTag) == 0 {
|
// if len(taskTag) == 0 {
|
||||||
this.moduleTask.Error("TaskTag参数缺失",
|
// this.moduleTask.Error("TaskTag参数缺失",
|
||||||
log.Field{Key: "uid", Value: uid},
|
// log.Field{Key: "uid", Value: uid},
|
||||||
log.Field{Key: "params", Value: taskTag},
|
// log.Field{Key: "params", Value: taskTag},
|
||||||
)
|
// )
|
||||||
return
|
// return
|
||||||
}
|
// }
|
||||||
var task *pb.DBTask
|
// var task *pb.DBTask
|
||||||
if err := this.GetList(uid, &task); err != nil {
|
// if err := this.GetList(uid, &task); err != nil {
|
||||||
this.moduleTask.Errorf("getTaskById err %v", err)
|
// this.moduleTask.Errorf("getTaskById err %v", err)
|
||||||
return
|
// return
|
||||||
}
|
// }
|
||||||
|
|
||||||
if task == nil {
|
// if task == nil {
|
||||||
this.moduleTask.Error("任务数据空",
|
// this.moduleTask.Error("任务数据空",
|
||||||
log.Field{Key: "uid", Value: uid},
|
// log.Field{Key: "uid", Value: uid},
|
||||||
log.Field{Key: "taskTag", Value: taskTag},
|
// log.Field{Key: "taskTag", Value: taskTag},
|
||||||
)
|
// )
|
||||||
return
|
// return
|
||||||
}
|
// }
|
||||||
|
|
||||||
dr := this.moduleTask.ModuleRtask.GetCondiData(uid)
|
// dr := this.moduleTask.ModuleRtask.GetCondiData(uid)
|
||||||
|
|
||||||
update := map[string]interface{}{}
|
// update := map[string]interface{}{}
|
||||||
if taskTag[0] == comm.TASK_DAILY {
|
// if taskTag[0] == comm.TASK_DAILY {
|
||||||
for _, v := range task.DayList {
|
// for _, v := range task.DayList {
|
||||||
//删除任务条件数据
|
// //删除任务条件数据
|
||||||
if dr != nil && dr.Vals != nil {
|
// if dr != nil && dr.Vals != nil {
|
||||||
delete(dr.Vals, v.TypeId)
|
// delete(dr.Vals, v.TypeId)
|
||||||
}
|
// }
|
||||||
}
|
// }
|
||||||
if err := this.moduleTask.ModuleRtask.ChangeCondi(uid, dr.Vals); err != nil {
|
// if err := this.moduleTask.ModuleRtask.ChangeCondi(uid, dr.Vals); err != nil {
|
||||||
this.moduleTask.Error("更新任务条件数据", log.Field{Key: "uid", Value: uid})
|
// this.moduleTask.Error("更新任务条件数据", log.Field{Key: "uid", Value: uid})
|
||||||
}
|
// }
|
||||||
update["dayList"] = make([]*pb.TaskData, 0)
|
// update["dayList"] = make([]*pb.TaskData, 0)
|
||||||
} else if taskTag[0] == comm.TASK_WEEKLY {
|
// } else if taskTag[0] == comm.TASK_WEEKLY {
|
||||||
for _, v := range task.WeekList {
|
// for _, v := range task.WeekList {
|
||||||
//删除任务条件数据
|
// //删除任务条件数据
|
||||||
if dr != nil && dr.Vals != nil {
|
// if dr != nil && dr.Vals != nil {
|
||||||
delete(dr.Vals, v.TypeId)
|
// delete(dr.Vals, v.TypeId)
|
||||||
}
|
// }
|
||||||
}
|
// }
|
||||||
if err := this.moduleTask.ModuleRtask.ChangeCondi(uid, dr.Vals); err != nil {
|
// if err := this.moduleTask.ModuleRtask.ChangeCondi(uid, dr.Vals); err != nil {
|
||||||
this.moduleTask.Error("更新任务条件数据", log.Field{Key: "uid", Value: uid})
|
// this.moduleTask.Error("更新任务条件数据", log.Field{Key: "uid", Value: uid})
|
||||||
}
|
// }
|
||||||
update["weekList"] = make([]*pb.TaskData, 0)
|
// update["weekList"] = make([]*pb.TaskData, 0)
|
||||||
} else if taskTag[0] == comm.TASK_ACHIEVE {
|
// } else if taskTag[0] == comm.TASK_ACHIEVE {
|
||||||
for _, v := range task.AchieveList {
|
// for _, v := range task.AchieveList {
|
||||||
//删除任务条件数据
|
// //删除任务条件数据
|
||||||
if dr != nil && dr.Vals != nil {
|
// if dr != nil && dr.Vals != nil {
|
||||||
delete(dr.Vals, v.TypeId)
|
// delete(dr.Vals, v.TypeId)
|
||||||
}
|
// }
|
||||||
}
|
// }
|
||||||
if err := this.moduleTask.ModuleRtask.ChangeCondi(uid, dr.Vals); err != nil {
|
// if err := this.moduleTask.ModuleRtask.ChangeCondi(uid, dr.Vals); err != nil {
|
||||||
this.moduleTask.Error("更新任务条件数据", log.Field{Key: "uid", Value: uid})
|
// this.moduleTask.Error("更新任务条件数据", log.Field{Key: "uid", Value: uid})
|
||||||
}
|
// }
|
||||||
update["weekList"] = make([]*pb.TaskData, 0)
|
// update["weekList"] = make([]*pb.TaskData, 0)
|
||||||
}
|
// }
|
||||||
|
|
||||||
if err := this.moduleTask.modelTask.Change(uid, update); err != nil {
|
// if err := this.moduleTask.modelTask.Change(uid, update); err != nil {
|
||||||
this.moduleTask.Error("清空任务数据", log.Field{Key: "uid", Value: uid})
|
// this.moduleTask.Error("清空任务数据", log.Field{Key: "uid", Value: uid})
|
||||||
}
|
// }
|
||||||
|
|
||||||
}
|
// }
|
||||||
|
|
||||||
// 任务处理
|
// 任务处理
|
||||||
func (this *ModelTask) doTaskHandle(event interface{}, next func(event interface{})) {
|
// func (this *ModelTask) doTaskHandle(event interface{}, next func(event interface{})) {
|
||||||
tl := event.(*TaskListen)
|
// tl := event.(*TaskListen)
|
||||||
|
|
||||||
data, err := this.moduleTask.configure.getTasks(int32(tl.TaskType))
|
// data, err := this.moduleTask.configure.getTasks(int32(tl.TaskType))
|
||||||
if err != nil {
|
// if err != nil {
|
||||||
this.moduleTask.Errorf("taskHandle err %v", err)
|
// this.moduleTask.Errorf("taskHandle err %v", err)
|
||||||
return
|
// return
|
||||||
}
|
// }
|
||||||
|
|
||||||
// 获取玩家的任务条件数据
|
// // 获取玩家的任务条件数据
|
||||||
dr := this.moduleTask.ModuleRtask.GetCondiData(tl.Uid)
|
// dr := this.moduleTask.ModuleRtask.GetCondiData(tl.Uid)
|
||||||
if dr == nil {
|
// if dr == nil {
|
||||||
return
|
// return
|
||||||
}
|
// }
|
||||||
|
|
||||||
// 遍历事件列表
|
// // 遍历事件列表
|
||||||
for _, conf := range data {
|
// for _, conf := range data {
|
||||||
// 从任务条件中查找
|
// // 从任务条件中查找
|
||||||
ret, ok := dr.Vals[conf.TypeId]
|
// ret, ok := dr.Vals[conf.TypeId]
|
||||||
if !ok {
|
// if !ok {
|
||||||
continue
|
// continue
|
||||||
}
|
// }
|
||||||
|
|
||||||
task, ok := this.checkTask(tl.Uid, conf.Key)
|
// task, ok := this.checkTask(tl.Uid, conf.Key)
|
||||||
if !ok {
|
// if !ok {
|
||||||
this.moduleTask.Debug("任务已完成", log.Field{Key: "uid", Value: tl.Uid}, log.Field{Key: "任务ID", Value: conf.Key})
|
// this.moduleTask.Debug("任务已完成", log.Field{Key: "uid", Value: tl.Uid}, log.Field{Key: "任务ID", Value: conf.Key})
|
||||||
continue
|
// continue
|
||||||
}
|
// }
|
||||||
|
|
||||||
var (
|
// var (
|
||||||
progress int32
|
// progress int32
|
||||||
update map[string]interface{}
|
// update map[string]interface{}
|
||||||
)
|
// )
|
||||||
|
|
||||||
if code := this.moduleTask.ModuleRtask.CheckCondi(tl.Uid, conf.TypeId); code == nil {
|
// if code := this.moduleTask.ModuleRtask.CheckCondi(tl.Uid, conf.TypeId); code == nil {
|
||||||
// update data
|
// // update data
|
||||||
if ret != nil && len(ret.Data) > 0 {
|
// if ret != nil && len(ret.Data) > 0 {
|
||||||
progress = ret.Data[0]
|
// progress = ret.Data[0]
|
||||||
}
|
// }
|
||||||
update = map[string]interface{}{
|
// update = map[string]interface{}{
|
||||||
"progress": progress,
|
// "progress": progress,
|
||||||
"status": 1,
|
// "status": 1,
|
||||||
}
|
// }
|
||||||
} else {
|
// } else {
|
||||||
if ret != nil && len(ret.Data) > 0 {
|
// if ret != nil && len(ret.Data) > 0 {
|
||||||
progress = ret.Data[0]
|
// progress = ret.Data[0]
|
||||||
}
|
// }
|
||||||
update = map[string]interface{}{
|
// update = map[string]interface{}{
|
||||||
"progress": progress,
|
// "progress": progress,
|
||||||
}
|
// }
|
||||||
}
|
// }
|
||||||
if err = this.modifyUserTask(tl.Uid, task.TaskId, update); err != nil {
|
// if err = this.modifyUserTask(tl.Uid, task.TaskId, update); err != nil {
|
||||||
return
|
// return
|
||||||
}
|
// }
|
||||||
this.moduleTask.Debug("更新任务",
|
// this.moduleTask.Debug("更新任务",
|
||||||
log.Field{Key: "uid", Value: tl.Uid}, log.Field{Key: "任务ID", Value: conf.Key},
|
// log.Field{Key: "uid", Value: tl.Uid}, log.Field{Key: "任务ID", Value: conf.Key},
|
||||||
log.Field{Key: "事件ID", Value: conf.TypeId}, log.Field{Key: "progress", Value: update["progress"]},
|
// log.Field{Key: "事件ID", Value: conf.TypeId}, log.Field{Key: "progress", Value: update["progress"]},
|
||||||
log.Field{Key: "status", Value: update["status"]},
|
// log.Field{Key: "status", Value: update["status"]},
|
||||||
)
|
// )
|
||||||
}
|
// }
|
||||||
return
|
// return
|
||||||
}
|
// }
|
||||||
|
|
||||||
// 更新活跃度
|
// 更新活跃度
|
||||||
func (this *ModelTask) updateActive(uid string, cfgId int32) error {
|
func (this *ModelTask) updateActive(uid string, cfgId int32) error {
|
||||||
|
@ -119,13 +119,13 @@ func (this *ModuleTask) GetTaskById(uid string, taskTag, taskId int32) *pb.TaskD
|
|||||||
// 重置任务
|
// 重置任务
|
||||||
func (this *ModuleTask) ResetTask(uid string, taskTag comm.TaskTag) {
|
func (this *ModuleTask) ResetTask(uid string, taskTag comm.TaskTag) {
|
||||||
this.resetActive(uid, taskTag)
|
this.resetActive(uid, taskTag)
|
||||||
this.modelTask.clearTask(uid, taskTag)
|
// this.modelTask.clearTask(uid, taskTag)
|
||||||
this.modelTaskActive.clearTask(uid, taskTag)
|
this.modelTaskActive.clearTask(uid, taskTag)
|
||||||
}
|
}
|
||||||
|
|
||||||
// 清理任务数据
|
// 清理任务数据
|
||||||
func (this *ModuleTask) CleanData(uid string) {
|
func (this *ModuleTask) CleanData(uid string) {
|
||||||
this.modelTask.clearTask(uid)
|
// this.modelTask.clearTask(uid)
|
||||||
this.modelTaskActive.clearTask(uid)
|
this.modelTaskActive.clearTask(uid)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user