diff --git a/modules/rtask/module.go b/modules/rtask/module.go index 8717eafaa..a9bb15ae1 100644 --- a/modules/rtask/module.go +++ b/modules/rtask/module.go @@ -24,14 +24,14 @@ var _ comm.IRtask = (*ModuleRtask)(nil) // 限定条件 type rtaskCondHandle struct { - condId int32 //任务条件配置ID - verify verifyHandle //校验任务条件 - find condiFindHandle //检索任务条件 + condId int32 //任务条件配置ID + verify verifyHandle //校验任务条件 update updateDataHandle //更新任务数据 } +// 任务参数校验 type verifyHandle func(uid string, record *pb.DBRtaskRecord, cfg *cfg.GameRdtaskCondiData) (bool, error) -type condiFindHandle func(cfg *cfg.GameRdtaskCondiData, vals ...int32) (int32, error) +// 任务数据更新 type updateDataHandle func(uid string, record *pb.DBRtaskRecord, cfg *cfg.GameRdtaskCondiData, vals ...int32) error type ModuleRtask struct { @@ -75,90 +75,49 @@ func (this *ModuleRtask) registerVerifyHandle(condiId int32, condi *rtaskCondHan this.handleMap.Store(condiId, condi) } -func (this *ModuleRtask) getHandle(tt comm.TaskType) (condis []*rtaskCondHandle) { +func (this *ModuleRtask) getHandle(tt comm.TaskType) (handles []*rtaskCondHandle) { for _, v := range this.configure.getRtaskCondis(int32(tt)) { switch tt { case comm.Rtype1: - condi := &rtaskCondHandle{ + handle := &rtaskCondHandle{ condId: v.Id, - find: this.modelRtaskRecord.equalFirstParam, - verify: this.modelRtaskRecord.verifyFromDb, + verify: this.modelRtaskRecord.verifyGreatEqual, update: this.modelRtaskRecord.addUpdate, } - condis = append(condis, condi) - this.registerVerifyHandle(v.Id, condi) + handles = append(handles, handle) + this.registerVerifyHandle(v.Id, handle) case comm.Rtype3: - condi := &rtaskCondHandle{ + handle := &rtaskCondHandle{ condId: v.Id, - find: this.modelRtaskRecord.equalFirstParam, verify: this.modelRtask.verifyRtype3, update: this.modelRtaskRecord.overrideUpdate, } - condis = append(condis, condi) - this.registerVerifyHandle(v.Id, condi) - case comm.Rtype4: - condi := &rtaskCondHandle{ + handles = append(handles, handle) + this.registerVerifyHandle(v.Id, handle) + case comm.Rtype4, comm.Rtype5, comm.Rtype6, comm.Rtype8, comm.Rtype10: + handle := &rtaskCondHandle{ condId: v.Id, - find: this.modelRtaskRecord.equalFirstParam, - verify: this.modelRtask.verifyRtype4, + verify: this.modelRtaskRecord.verifyGreatEqual, update: this.modelRtaskRecord.overrideUpdate, } - condis = append(condis, condi) - this.registerVerifyHandle(v.Id, condi) - case comm.Rtype5: - condi := &rtaskCondHandle{ - condId: v.Id, - find: this.modelRtaskRecord.equalFirstParam, - verify: this.modelRtask.verifyRtype5, - update: this.modelRtaskRecord.overrideUpdate, - } - condis = append(condis, condi) - this.registerVerifyHandle(v.Id, condi) - case comm.Rtype6: - condi := &rtaskCondHandle{ - condId: v.Id, - find: this.modelRtaskRecord.equalFirstParam, - verify: this.modelRtask.verifyRtype6, - update: this.modelRtaskRecord.overrideUpdate, - } - condis = append(condis, condi) - this.registerVerifyHandle(v.Id, condi) - case comm.Rtype8: - condi := &rtaskCondHandle{ - condId: v.Id, - find: this.modelRtaskRecord.equalFirstParam, - verify: this.modelRtask.verfiyRtype8, - update: this.modelRtaskRecord.overrideUpdate, - } - condis = append(condis, condi) - this.registerVerifyHandle(v.Id, condi) + handles = append(handles, handle) + this.registerVerifyHandle(v.Id, handle) case comm.Rtype9: - condi := &rtaskCondHandle{ + handle := &rtaskCondHandle{ condId: v.Id, - find: this.modelRtaskRecord.equalFirstParam, verify: this.modelRtask.verfiyRtype9, update: this.modelRtaskRecord.overrideUpdate, } - condis = append(condis, condi) - this.registerVerifyHandle(v.Id, condi) - case comm.Rtype10: - condi := &rtaskCondHandle{ - condId: v.Id, - find: this.modelRtaskRecord.equalFirstParam, - verify: this.modelRtask.verfiyRtype10, - update: this.modelRtaskRecord.overrideUpdate, - } - condis = append(condis, condi) - this.registerVerifyHandle(v.Id, condi) + handles = append(handles, handle) + this.registerVerifyHandle(v.Id, handle) case comm.Rtype18: - condi := &rtaskCondHandle{ + handle := &rtaskCondHandle{ condId: v.Id, - find: this.modelRtaskRecord.greatEqualFirstParam, verify: this.modelRtaskRecord.verifyFirstGreatEqualParam, update: this.modelRtaskRecord.addUpdate, } - condis = append(condis, condi) - this.registerVerifyHandle(v.Id, condi) + handles = append(handles, handle) + this.registerVerifyHandle(v.Id, handle) case comm.Rtype7, comm.Rtype12, comm.Rtype13, comm.Rtype14, comm.Rtype15, comm.Rtype19, comm.Rtype21, comm.Rtype24, comm.Rtype26, comm.Rtype27, comm.Rtype28, comm.Rtype38, @@ -169,53 +128,48 @@ func (this *ModuleRtask) getHandle(tt comm.TaskType) (condis []*rtaskCondHandle) comm.Rtype141, comm.Rtype142, comm.Rtype143, comm.Rtype144, comm.Rtype145, comm.Rtype146, comm.Rtype147, comm.Rtype149, comm.Rtype153, comm.Rtype154, comm.Rtype155, comm.Rtype156, comm.Rtype171, comm.Rtype186, comm.Rtype187: - condi := &rtaskCondHandle{ + handle := &rtaskCondHandle{ condId: v.Id, - find: this.modelRtaskRecord.lessEqualFirstParam, verify: this.modelRtaskRecord.verifyFirstGreatEqualParam, update: this.modelRtaskRecord.addUpdate, } - condis = append(condis, condi) - this.registerVerifyHandle(v.Id, condi) + handles = append(handles, handle) + this.registerVerifyHandle(v.Id, handle) case comm.Rtype50, comm.Rtype73: - condi := &rtaskCondHandle{ + handle := &rtaskCondHandle{ condId: v.Id, - find: this.modelRtaskRecord.lessEqualFirstParam, - verify: this.modelRtaskRecord.verifyFromDb, + verify: this.modelRtaskRecord.verifyGreatEqual, update: this.modelRtaskRecord.addUpdate, } - condis = append(condis, condi) - this.registerVerifyHandle(v.Id, condi) + handles = append(handles, handle) + this.registerVerifyHandle(v.Id, handle) case comm.Rtype20: - condi := &rtaskCondHandle{ + handle := &rtaskCondHandle{ condId: v.Id, - find: this.modelRtaskRecord.equalFirstParam, verify: this.modelRtask.verifyRtype20, update: this.modelRtaskRecord.overrideUpdate, } - condis = append(condis, condi) - this.registerVerifyHandle(v.Id, condi) + handles = append(handles, handle) + this.registerVerifyHandle(v.Id, handle) case comm.Rtype109: - condi := &rtaskCondHandle{ + handle := &rtaskCondHandle{ condId: v.Id, - find: this.modelRtaskRecord.equalFirstParam, verify: this.modelRtaskRecord.verifyFirstEqualParam, update: this.modelRtaskRecord.overrideUpdate, } - condis = append(condis, condi) - this.registerVerifyHandle(v.Id, condi) + handles = append(handles, handle) + this.registerVerifyHandle(v.Id, handle) case comm.Rtype16, comm.Rtype17, comm.Rtype35, comm.Rtype61: - condi := &rtaskCondHandle{ + handle := &rtaskCondHandle{ condId: v.Id, - find: this.modelRtaskRecord.equalParams, - verify: this.modelRtaskRecord.verifyFromDb, + verify: this.modelRtaskRecord.verifyGreatEqual, update: this.modelRtaskRecord.overrideUpdate, } - condis = append(condis, condi) - this.registerVerifyHandle(v.Id, condi) + handles = append(handles, handle) + this.registerVerifyHandle(v.Id, handle) case comm.Rtype23, comm.Rtype25, comm.Rtype30, comm.Rtype32, comm.Rtype33, comm.Rtype34, comm.Rtype36, comm.Rtype37, comm.Rtype40, comm.Rtype41, @@ -223,16 +177,15 @@ func (this *ModuleRtask) getHandle(tt comm.TaskType) (condis []*rtaskCondHandle) comm.Rtype46, comm.Rtype47, comm.Rtype52, comm.Rtype55, comm.Rtype56, comm.Rtype65, comm.Rtype66, comm.Rtype67, comm.Rtype68, comm.Rtype70, comm.Rtype140: - condi := &rtaskCondHandle{ + handle := &rtaskCondHandle{ condId: v.Id, - find: this.modelRtaskRecord.lessThanParams, - verify: this.modelRtaskRecord.verifyFromDb, + verify: this.modelRtaskRecord.verifyGreatEqual, update: this.modelRtaskRecord.addUpdate, } - condis = append(condis, condi) - this.registerVerifyHandle(v.Id, condi) + handles = append(handles, handle) + this.registerVerifyHandle(v.Id, handle) default: - log.Warnf("rtaskType[%v] not register", tt) + log.Warnf("rtaskType[%v] handle not register", tt) } } return diff --git a/modules/rtask/verifyHandle.go b/modules/rtask/verifyHandle.go index 08f64b645..70dd5a5b7 100644 --- a/modules/rtask/verifyHandle.go +++ b/modules/rtask/verifyHandle.go @@ -11,7 +11,8 @@ import ( "github.com/spf13/cast" ) -func (this *ModelRtaskRecord) verifyFromDb(uid string, record *pb.DBRtaskRecord, cfg *cfg.GameRdtaskCondiData) (ok bool, err error) { +// GreatEqual +func (this *ModelRtaskRecord) verifyGreatEqual(uid string, record *pb.DBRtaskRecord, cfg *cfg.GameRdtaskCondiData) (ok bool, err error) { if record == nil { err = errors.WithMessagef(err, "玩家数据DBRtaskRecord空") return @@ -278,7 +279,7 @@ func (this *ModelRtask) verfiyRtype8(uid string, record *pb.DBRtaskRecord, cfg * return } -// 连续登陆xx天 +// 连续登陆xx天 未埋点的处理方法 func (this *ModelRtask) verfiyRtype9(uid string, record *pb.DBRtaskRecord, cfg *cfg.GameRdtaskCondiData) (ok bool, err error) { userModule, err := this.service.GetModule(comm.ModuleUser) if err != nil {