diff --git a/comm/const.go b/comm/const.go index 5c118e612..c2d36b3b3 100644 --- a/comm/const.go +++ b/comm/const.go @@ -411,6 +411,11 @@ const ( type TaskType int32 +type TaskParam struct { + TT TaskType + Params []int32 +} + // 日常任务事件类型 const ( TaskTypeUpEquip TaskType = 101 //任意装备升级 diff --git a/modules/rtask/module.go b/modules/rtask/module.go index b41975a74..b8cbeb5bf 100644 --- a/modules/rtask/module.go +++ b/modules/rtask/module.go @@ -218,6 +218,55 @@ func (this *ModuleRtask) initRtaskVerifyHandle() { } } +func (this *ModuleRtask) processOneTask(session comm.IUserSession, rtaskType comm.TaskType, params ...int32) (code pb.ErrorCode) { + uid := session.GetUserId() + var condis []*rtaskCondi + for _, codiConf := range this.configure.getRtaskCondis(int32(rtaskType)) { + v, ok := this.handleMap[codiConf.Id] + if !ok { + this.Warn("未注册事件处理器", + log.Field{Key: "uid", Value: uid}, + log.Field{Key: "condiId", Value: codiConf.Id}, + ) + code = pb.ErrorCode_RtaskCondiNoFound + return + } + + if v.find == nil { + this.Warn("未设置find Handle", + log.Field{Key: "uid", Value: uid}, + log.Field{Key: "condiId", Value: codiConf.Id}, + ) + return + } + + if condiId, _ := v.find(codiConf, params...); condiId != 0 { + v.condId = codiConf.Id + condis = append(condis, v) + } + } + + // update + for _, v := range condis { + conf, err := this.configure.getRtaskTypeById(v.condId) + if err != nil { + log.Errorf("get condId conf err:%v", err) + code = pb.ErrorCode_RtaskCondiNoFound + return + } + + if v.update != nil { + if err := v.update(uid, conf, params...); err != nil { + log.Errorf("update task:%v", err) + code = pb.ErrorCode_DBError + } + } + + } + + return +} + func (this *ModuleRtask) SendToRtask(session comm.IUserSession, rtaskType comm.TaskType, params ...int32) (code pb.ErrorCode) { uid := session.GetUserId() if this.IsCross() { @@ -240,9 +289,7 @@ func (this *ModuleRtask) SendToRtask(session comm.IUserSession, rtaskType comm.T // log.Field{Key: "params", Value: params}, // ) var ( - // err error - // condiId int32 - condis []*rtaskCondi + condis []*rtaskCondi ) for _, codiConf := range this.configure.getRtaskCondis(int32(rtaskType)) { @@ -265,14 +312,9 @@ func (this *ModuleRtask) SendToRtask(session comm.IUserSession, rtaskType comm.T } if condiId, _ := v.find(codiConf, params...); condiId != 0 { - // if err != nil { - // this.Warnln(errors.WithMessage(err, uid).Error()) - // } - // } else { v.condId = codiConf.Id condis = append(condis, v) } - } // update @@ -371,6 +413,10 @@ func (this *ModuleRtask) SendToRtask(session comm.IUserSession, rtaskType comm.T return } +func (this *ModuleRtask) TriggerTask(uid string, taskParams ...comm.TaskParam) (code pb.ErrorCode) { + return +} + // 任务条件校验 func (this *ModuleRtask) CheckCondi(uid string, condiId int32) (code pb.ErrorCode) { if _, ok := this.modelRtask.checkCondi(uid, condiId); !ok {