整理任务类型
This commit is contained in:
parent
eeffd69920
commit
40012007d7
@ -79,47 +79,56 @@ func (this *ModuleRtask) registerVerifyHandle(condiId int32, condi *rtaskCondHan
|
|||||||
func (this *ModuleRtask) getHandle(tt comm.TaskType) (handles []*rtaskCondHandle) {
|
func (this *ModuleRtask) getHandle(tt comm.TaskType) (handles []*rtaskCondHandle) {
|
||||||
for _, v := range this.configure.getRtaskCondis(int32(tt)) {
|
for _, v := range this.configure.getRtaskCondis(int32(tt)) {
|
||||||
switch tt {
|
switch tt {
|
||||||
case comm.Rtype1:
|
// 大于1个参数且第一个参数累计,第二个参数等于
|
||||||
|
case comm.Rtype1, comm.Rtype16, comm.Rtype17, comm.Rtype50, comm.Rtype125, comm.Rtype126, comm.Rtype127:
|
||||||
handle := &rtaskCondHandle{
|
handle := &rtaskCondHandle{
|
||||||
condId: v.Id,
|
condId: v.Id,
|
||||||
verify: this.modelRtaskRecord.verifyGreatEqual,
|
verify: this.modelRtaskRecord.verifyMultiEqual,
|
||||||
update: this.modelRtaskRecord.addUpdate,
|
update: this.modelRtaskRecord.addUpdate,
|
||||||
}
|
}
|
||||||
handles = append(handles, handle)
|
handles = append(handles, handle)
|
||||||
this.registerVerifyHandle(v.Id, handle)
|
this.registerVerifyHandle(v.Id, handle)
|
||||||
case comm.Rtype3:
|
//两个参数 第一个参数覆盖 第二个参数等于
|
||||||
|
case comm.Rtype4, comm.Rtype5, comm.Rtype6, comm.Rtype8, comm.Rtype10, comm.Rtype35, comm.Rtype158, comm.Rtype168,
|
||||||
|
comm.Rtype122, comm.Rtype133:
|
||||||
handle := &rtaskCondHandle{
|
handle := &rtaskCondHandle{
|
||||||
condId: v.Id,
|
condId: v.Id,
|
||||||
verify: this.modelRtask.verifyRtype3,
|
verify: this.modelRtaskRecord.veriftyEqualParam, //两个参数 等于
|
||||||
}
|
|
||||||
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,
|
|
||||||
verify: this.modelRtaskRecord.verifyGreatEqual,
|
|
||||||
update: this.modelRtaskRecord.overrideUpdate,
|
update: this.modelRtaskRecord.overrideUpdate,
|
||||||
}
|
}
|
||||||
handles = append(handles, handle)
|
handles = append(handles, handle)
|
||||||
this.registerVerifyHandle(v.Id, handle)
|
this.registerVerifyHandle(v.Id, handle)
|
||||||
case comm.Rtype9:
|
// 两个参数 第一个大于等于 第二个等于
|
||||||
|
case comm.Rtype159, comm.Rtype160, comm.Rtype74, comm.Rtype75:
|
||||||
handle := &rtaskCondHandle{
|
handle := &rtaskCondHandle{
|
||||||
condId: v.Id,
|
condId: v.Id,
|
||||||
verify: this.modelRtask.verfiyRtype9,
|
verify: this.modelRtaskRecord.verifyMultiEqual, //两个参数 等于
|
||||||
|
update: this.modelRtaskRecord.overrideUpdate,
|
||||||
}
|
}
|
||||||
handles = append(handles, handle)
|
handles = append(handles, handle)
|
||||||
this.registerVerifyHandle(v.Id, handle)
|
this.registerVerifyHandle(v.Id, handle)
|
||||||
|
// 一个参数且覆盖
|
||||||
|
case comm.Rtype61, comm.Rtype109, comm.Rtype129, comm.Rtype134:
|
||||||
|
handle := &rtaskCondHandle{
|
||||||
|
condId: v.Id,
|
||||||
|
verify: this.modelRtaskRecord.verifyFirstEqualParam,
|
||||||
|
update: this.modelRtaskRecord.overrideUpdate,
|
||||||
|
}
|
||||||
|
|
||||||
|
handles = append(handles, handle)
|
||||||
|
this.registerVerifyHandle(v.Id, handle)
|
||||||
|
// 一个参数且累计
|
||||||
case comm.Rtype7, comm.Rtype12, comm.Rtype13, comm.Rtype14, comm.Rtype15,
|
case comm.Rtype7, comm.Rtype12, comm.Rtype13, comm.Rtype14, comm.Rtype15,
|
||||||
comm.Rtype18, comm.Rtype19, comm.Rtype24,
|
comm.Rtype18, comm.Rtype19, comm.Rtype23, comm.Rtype24,
|
||||||
comm.Rtype26, comm.Rtype27, comm.Rtype28, comm.Rtype38,
|
comm.Rtype26, comm.Rtype27, comm.Rtype28, comm.Rtype38,
|
||||||
comm.Rtype39, comm.Rtype51, comm.Rtype53,
|
comm.Rtype39, comm.Rtype47, comm.Rtype51, comm.Rtype53,
|
||||||
comm.Rtype54, comm.Rtype57, comm.Rtype60,
|
comm.Rtype54, comm.Rtype57, comm.Rtype60,
|
||||||
comm.Rtype62, comm.Rtype64, comm.Rtype87, comm.Rtype88, comm.Rtype89, comm.Rtype90,
|
comm.Rtype62, comm.Rtype64, comm.Rtype87, comm.Rtype88, comm.Rtype89, comm.Rtype90,
|
||||||
comm.Rtype91, comm.Rtype92, comm.Rtype94, comm.Rtype95, comm.Rtype97, comm.Rtype104,
|
comm.Rtype91, comm.Rtype92, comm.Rtype94, comm.Rtype95, comm.Rtype97, comm.Rtype104,
|
||||||
comm.Rtype96, comm.Rtype98, comm.Rtype99, comm.Rtype102, comm.Rtype103, comm.Rtype105,
|
comm.Rtype96, comm.Rtype98, comm.Rtype99, comm.Rtype102, comm.Rtype103, comm.Rtype105,
|
||||||
comm.Rtype106, comm.Rtype108, comm.Rtype113, comm.Rtype114, comm.Rtype115, comm.Rtype116,
|
comm.Rtype106, comm.Rtype108, comm.Rtype113, comm.Rtype114, comm.Rtype115, comm.Rtype116,
|
||||||
comm.Rtype117, comm.Rtype118, comm.Rtype119, comm.Rtype120, comm.Rtype121, comm.Rtype123,
|
comm.Rtype117, comm.Rtype118, comm.Rtype119, comm.Rtype120, comm.Rtype121, comm.Rtype123,
|
||||||
|
comm.Rtype124,
|
||||||
comm.Rtype128, comm.Rtype130, comm.Rtype131, comm.Rtype132, comm.Rtype135,
|
comm.Rtype128, comm.Rtype130, comm.Rtype131, comm.Rtype132, comm.Rtype135,
|
||||||
comm.Rtype141, comm.Rtype142, comm.Rtype143, comm.Rtype144, comm.Rtype145, comm.Rtype146,
|
comm.Rtype141, comm.Rtype142, comm.Rtype143, comm.Rtype144, comm.Rtype145, comm.Rtype146,
|
||||||
comm.Rtype147, comm.Rtype148, comm.Rtype149, comm.Rtype152, comm.Rtype153, comm.Rtype154,
|
comm.Rtype147, comm.Rtype148, comm.Rtype149, comm.Rtype152, comm.Rtype153, comm.Rtype154,
|
||||||
@ -133,11 +142,18 @@ func (this *ModuleRtask) getHandle(tt comm.TaskType) (handles []*rtaskCondHandle
|
|||||||
}
|
}
|
||||||
handles = append(handles, handle)
|
handles = append(handles, handle)
|
||||||
this.registerVerifyHandle(v.Id, handle)
|
this.registerVerifyHandle(v.Id, handle)
|
||||||
case comm.Rtype50:
|
//////
|
||||||
|
case comm.Rtype3:
|
||||||
handle := &rtaskCondHandle{
|
handle := &rtaskCondHandle{
|
||||||
condId: v.Id,
|
condId: v.Id,
|
||||||
verify: this.modelRtaskRecord.verifyGreatEqual,
|
verify: this.modelRtask.verifyRtype3,
|
||||||
update: this.modelRtaskRecord.addUpdate,
|
}
|
||||||
|
handles = append(handles, handle)
|
||||||
|
this.registerVerifyHandle(v.Id, handle)
|
||||||
|
case comm.Rtype9:
|
||||||
|
handle := &rtaskCondHandle{
|
||||||
|
condId: v.Id,
|
||||||
|
verify: this.modelRtask.verfiyRtype9,
|
||||||
}
|
}
|
||||||
handles = append(handles, handle)
|
handles = append(handles, handle)
|
||||||
this.registerVerifyHandle(v.Id, handle)
|
this.registerVerifyHandle(v.Id, handle)
|
||||||
@ -146,20 +162,9 @@ func (this *ModuleRtask) getHandle(tt comm.TaskType) (handles []*rtaskCondHandle
|
|||||||
condId: v.Id,
|
condId: v.Id,
|
||||||
verify: this.modelRtask.verifyRtype20,
|
verify: this.modelRtask.verifyRtype20,
|
||||||
}
|
}
|
||||||
|
|
||||||
handles = append(handles, handle)
|
handles = append(handles, handle)
|
||||||
this.registerVerifyHandle(v.Id, handle)
|
this.registerVerifyHandle(v.Id, handle)
|
||||||
case comm.Rtype109, comm.Rtype122, comm.Rtype124, comm.Rtype125, comm.Rtype126,
|
|
||||||
comm.Rtype127, comm.Rtype129, comm.Rtype133, comm.Rtype134, comm.Rtype158,
|
|
||||||
comm.Rtype159, comm.Rtype160:
|
|
||||||
handle := &rtaskCondHandle{
|
|
||||||
condId: v.Id,
|
|
||||||
verify: this.modelRtaskRecord.verifyFirstEqualParam,
|
|
||||||
update: this.modelRtaskRecord.overrideUpdate,
|
|
||||||
}
|
|
||||||
|
|
||||||
handles = append(handles, handle)
|
|
||||||
this.registerVerifyHandle(v.Id, handle)
|
|
||||||
case comm.Rtype138:
|
case comm.Rtype138:
|
||||||
handle := &rtaskCondHandle{
|
handle := &rtaskCondHandle{
|
||||||
condId: v.Id,
|
condId: v.Id,
|
||||||
@ -168,32 +173,17 @@ func (this *ModuleRtask) getHandle(tt comm.TaskType) (handles []*rtaskCondHandle
|
|||||||
|
|
||||||
handles = append(handles, handle)
|
handles = append(handles, handle)
|
||||||
this.registerVerifyHandle(v.Id, handle)
|
this.registerVerifyHandle(v.Id, handle)
|
||||||
case comm.Rtype16, comm.Rtype17, comm.Rtype35:
|
// 多参数 第一个大于等于 其它等于
|
||||||
handle := &rtaskCondHandle{
|
case comm.Rtype25, comm.Rtype30,
|
||||||
condId: v.Id,
|
|
||||||
verify: this.modelRtaskRecord.verifyGreatEqual,
|
|
||||||
update: this.modelRtaskRecord.overrideUpdate,
|
|
||||||
}
|
|
||||||
handles = append(handles, handle)
|
|
||||||
this.registerVerifyHandle(v.Id, handle)
|
|
||||||
case comm.Rtype61:
|
|
||||||
handle := &rtaskCondHandle{
|
|
||||||
condId: v.Id,
|
|
||||||
verify: this.modelRtaskRecord.veriftyFirstGreatParam,
|
|
||||||
update: this.modelRtaskRecord.addUpdate,
|
|
||||||
}
|
|
||||||
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.Rtype32, comm.Rtype33, comm.Rtype34, comm.Rtype36,
|
||||||
comm.Rtype37, comm.Rtype40,
|
comm.Rtype37, comm.Rtype40,
|
||||||
comm.Rtype46, comm.Rtype47, comm.Rtype73, comm.Rtype76, comm.Rtype77, comm.Rtype79, comm.Rtype80, comm.Rtype83,
|
comm.Rtype46, comm.Rtype73, comm.Rtype76, comm.Rtype77, comm.Rtype79, comm.Rtype80, comm.Rtype83,
|
||||||
comm.Rtype52, comm.Rtype55, comm.Rtype56, comm.Rtype82,
|
comm.Rtype52, comm.Rtype55, comm.Rtype56, comm.Rtype82,
|
||||||
comm.Rtype65, comm.Rtype66, comm.Rtype67, comm.Rtype68, comm.Rtype70, comm.Rtype140,
|
comm.Rtype65, comm.Rtype66, comm.Rtype67, comm.Rtype68, comm.Rtype70, comm.Rtype140,
|
||||||
comm.Rtype168, comm.Rtype169, comm.Rtype170, comm.Rtype174, comm.Rtype179, comm.Rtype180:
|
comm.Rtype169, comm.Rtype170, comm.Rtype174, comm.Rtype179, comm.Rtype180:
|
||||||
handle := &rtaskCondHandle{
|
handle := &rtaskCondHandle{
|
||||||
condId: v.Id,
|
condId: v.Id,
|
||||||
verify: this.modelRtaskRecord.verifyGreatEqual,
|
verify: this.modelRtaskRecord.verifyMultiEqual,
|
||||||
update: this.modelRtaskRecord.addUpdate,
|
update: this.modelRtaskRecord.addUpdate,
|
||||||
}
|
}
|
||||||
handles = append(handles, handle)
|
handles = append(handles, handle)
|
||||||
@ -222,14 +212,6 @@ func (this *ModuleRtask) getHandle(tt comm.TaskType) (handles []*rtaskCondHandle
|
|||||||
}
|
}
|
||||||
handles = append(handles, handle)
|
handles = append(handles, handle)
|
||||||
this.registerVerifyHandle(v.Id, handle)
|
this.registerVerifyHandle(v.Id, handle)
|
||||||
case comm.Rtype74, comm.Rtype75:
|
|
||||||
handle := &rtaskCondHandle{
|
|
||||||
condId: v.Id,
|
|
||||||
verify: this.modelRtaskRecord.veriftyFirstGreatParam,
|
|
||||||
update: this.modelRtaskRecord.overrideUpdate,
|
|
||||||
}
|
|
||||||
handles = append(handles, handle)
|
|
||||||
this.registerVerifyHandle(v.Id, handle)
|
|
||||||
default:
|
default:
|
||||||
log.Warnf("rtaskType[%v] handle not register", tt)
|
log.Warnf("rtaskType[%v] handle not register", tt)
|
||||||
}
|
}
|
||||||
@ -291,25 +273,40 @@ func (this *ModuleRtask) processOneTask(session comm.IUserSession, rtaskType com
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
if handle.verify != nil {
|
if handle.verify != nil {
|
||||||
if ok, d, _ := handle.verify(uid, record, conf, params...); ok {
|
var (
|
||||||
if handle.update != nil {
|
ok bool
|
||||||
if d > 0 {
|
d int32
|
||||||
params[0] = d
|
)
|
||||||
}
|
if len(params) == 1 {
|
||||||
if err := handle.update(uid, record, conf, params...); err != nil {
|
ok = true
|
||||||
log.Errorf("update task:%v", err)
|
} else {
|
||||||
code = pb.ErrorCode_DBError
|
ok, d, _ = handle.verify(uid, record, conf, params...)
|
||||||
return
|
|
||||||
}
|
|
||||||
}
|
|
||||||
condIds = append(condIds, handle.condId)
|
|
||||||
|
|
||||||
update := map[string]interface{}{
|
|
||||||
"vals": record.Vals,
|
|
||||||
}
|
|
||||||
|
|
||||||
this.modelRtaskRecord.Change(uid, update)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if !ok {
|
||||||
|
this.Debug("验证失败", log.Field{Key: "uid", Value: uid},
|
||||||
|
log.Field{Key: "params", Value: params},
|
||||||
|
log.Field{Key: "conf", Value: conf})
|
||||||
|
continue
|
||||||
|
}
|
||||||
|
if handle.update != nil {
|
||||||
|
if d > 0 {
|
||||||
|
params[0] = d
|
||||||
|
}
|
||||||
|
if err := handle.update(uid, record, conf, params...); err != nil {
|
||||||
|
log.Errorf("update task:%v", err)
|
||||||
|
code = pb.ErrorCode_DBError
|
||||||
|
return
|
||||||
|
}
|
||||||
|
}
|
||||||
|
condIds = append(condIds, handle.condId)
|
||||||
|
|
||||||
|
update := map[string]interface{}{
|
||||||
|
"vals": record.Vals,
|
||||||
|
}
|
||||||
|
|
||||||
|
this.modelRtaskRecord.Change(uid, update)
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -12,8 +12,8 @@ import (
|
|||||||
"github.com/spf13/cast"
|
"github.com/spf13/cast"
|
||||||
)
|
)
|
||||||
|
|
||||||
// five params (1-GreatEqual 2-equal 3-equal 4-equal 5-equal)
|
// n params (1-GreatEqual 2-equal 3-equal 4-equal 5-equal)
|
||||||
func (this *ModelRtaskRecord) verifyGreatEqual(uid string, record *pb.DBRtaskRecord, cfg *cfg.GameRdtaskCondiData, params ...int32) (ok bool, count int32, err error) {
|
func (this *ModelRtaskRecord) verifyMultiEqual(uid string, record *pb.DBRtaskRecord, cfg *cfg.GameRdtaskCondiData, params ...int32) (ok bool, count int32, err error) {
|
||||||
if len(params) == 0 {
|
if len(params) == 0 {
|
||||||
err = errors.New("玩家参数数据缺失")
|
err = errors.New("玩家参数数据缺失")
|
||||||
return
|
return
|
||||||
@ -165,8 +165,8 @@ func (this *ModelRtaskRecord) verifyThirdGreatEqualParam(uid string, record *pb.
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
// two params(first-Great second-Equal)
|
// two params (first-Equal second-Equal)
|
||||||
func (this *ModelRtaskRecord) veriftyFirstGreatParam(uid string, record *pb.DBRtaskRecord, cfg *cfg.GameRdtaskCondiData, params ...int32) (ok bool, count int32, err error) {
|
func (this *ModelRtaskRecord) veriftyEqualParam(uid string, record *pb.DBRtaskRecord, cfg *cfg.GameRdtaskCondiData, params ...int32) (ok bool, count int32, err error) {
|
||||||
if len(params) == 0 {
|
if len(params) == 0 {
|
||||||
err = errors.New("玩家参数数据缺失")
|
err = errors.New("玩家参数数据缺失")
|
||||||
return
|
return
|
||||||
|
Loading…
Reference in New Issue
Block a user