整理任务类型

This commit is contained in:
wh_zcy 2023-05-25 16:06:47 +08:00
parent eeffd69920
commit 40012007d7
2 changed files with 76 additions and 79 deletions

View File

@ -79,47 +79,56 @@ func (this *ModuleRtask) registerVerifyHandle(condiId int32, condi *rtaskCondHan
func (this *ModuleRtask) getHandle(tt comm.TaskType) (handles []*rtaskCondHandle) {
for _, v := range this.configure.getRtaskCondis(int32(tt)) {
switch tt {
case comm.Rtype1:
// 大于1个参数且第一个参数累计第二个参数等于
case comm.Rtype1, comm.Rtype16, comm.Rtype17, comm.Rtype50, comm.Rtype125, comm.Rtype126, comm.Rtype127:
handle := &rtaskCondHandle{
condId: v.Id,
verify: this.modelRtaskRecord.verifyGreatEqual,
verify: this.modelRtaskRecord.verifyMultiEqual,
update: this.modelRtaskRecord.addUpdate,
}
handles = append(handles, 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{
condId: v.Id,
verify: this.modelRtask.verifyRtype3,
}
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,
verify: this.modelRtaskRecord.veriftyEqualParam, //两个参数 等于
update: this.modelRtaskRecord.overrideUpdate,
}
handles = append(handles, handle)
this.registerVerifyHandle(v.Id, handle)
case comm.Rtype9:
// 两个参数 第一个大于等于 第二个等于
case comm.Rtype159, comm.Rtype160, comm.Rtype74, comm.Rtype75:
handle := &rtaskCondHandle{
condId: v.Id,
verify: this.modelRtask.verfiyRtype9,
verify: this.modelRtaskRecord.verifyMultiEqual, //两个参数 等于
update: this.modelRtaskRecord.overrideUpdate,
}
handles = append(handles, 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,
comm.Rtype18, comm.Rtype19, comm.Rtype24,
comm.Rtype18, comm.Rtype19, comm.Rtype23, comm.Rtype24,
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.Rtype62, comm.Rtype64, comm.Rtype87, comm.Rtype88, comm.Rtype89, comm.Rtype90,
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.Rtype106, comm.Rtype108, comm.Rtype113, comm.Rtype114, comm.Rtype115, comm.Rtype116,
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.Rtype141, comm.Rtype142, comm.Rtype143, comm.Rtype144, comm.Rtype145, comm.Rtype146,
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)
this.registerVerifyHandle(v.Id, handle)
case comm.Rtype50:
//////
case comm.Rtype3:
handle := &rtaskCondHandle{
condId: v.Id,
verify: this.modelRtaskRecord.verifyGreatEqual,
update: this.modelRtaskRecord.addUpdate,
verify: this.modelRtask.verifyRtype3,
}
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)
this.registerVerifyHandle(v.Id, handle)
@ -146,20 +162,9 @@ func (this *ModuleRtask) getHandle(tt comm.TaskType) (handles []*rtaskCondHandle
condId: v.Id,
verify: this.modelRtask.verifyRtype20,
}
handles = append(handles, 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:
handle := &rtaskCondHandle{
condId: v.Id,
@ -168,32 +173,17 @@ func (this *ModuleRtask) getHandle(tt comm.TaskType) (handles []*rtaskCondHandle
handles = append(handles, handle)
this.registerVerifyHandle(v.Id, handle)
case comm.Rtype16, comm.Rtype17, comm.Rtype35:
handle := &rtaskCondHandle{
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,
// 多参数 第一个大于等于 其它等于
case comm.Rtype25, comm.Rtype30,
comm.Rtype32, comm.Rtype33, comm.Rtype34, comm.Rtype36,
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.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{
condId: v.Id,
verify: this.modelRtaskRecord.verifyGreatEqual,
verify: this.modelRtaskRecord.verifyMultiEqual,
update: this.modelRtaskRecord.addUpdate,
}
handles = append(handles, handle)
@ -222,14 +212,6 @@ func (this *ModuleRtask) getHandle(tt comm.TaskType) (handles []*rtaskCondHandle
}
handles = append(handles, 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:
log.Warnf("rtaskType[%v] handle not register", tt)
}
@ -291,7 +273,22 @@ func (this *ModuleRtask) processOneTask(session comm.IUserSession, rtaskType com
}
}
if handle.verify != nil {
if ok, d, _ := handle.verify(uid, record, conf, params...); ok {
var (
ok bool
d int32
)
if len(params) == 1 {
ok = true
} else {
ok, d, _ = handle.verify(uid, record, conf, params...)
}
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
@ -309,7 +306,7 @@ func (this *ModuleRtask) processOneTask(session comm.IUserSession, rtaskType com
}
this.modelRtaskRecord.Change(uid, update)
}
}
}

View File

@ -12,8 +12,8 @@ import (
"github.com/spf13/cast"
)
// five 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) {
// n params (1-GreatEqual 2-equal 3-equal 4-equal 5-equal)
func (this *ModelRtaskRecord) verifyMultiEqual(uid string, record *pb.DBRtaskRecord, cfg *cfg.GameRdtaskCondiData, params ...int32) (ok bool, count int32, err error) {
if len(params) == 0 {
err = errors.New("玩家参数数据缺失")
return
@ -165,8 +165,8 @@ func (this *ModelRtaskRecord) verifyThirdGreatEqualParam(uid string, record *pb.
return
}
// two params(first-Great second-Equal)
func (this *ModelRtaskRecord) veriftyFirstGreatParam(uid string, record *pb.DBRtaskRecord, cfg *cfg.GameRdtaskCondiData, params ...int32) (ok bool, count int32, err error) {
// two params (first-Equal second-Equal)
func (this *ModelRtaskRecord) veriftyEqualParam(uid string, record *pb.DBRtaskRecord, cfg *cfg.GameRdtaskCondiData, params ...int32) (ok bool, count int32, err error) {
if len(params) == 0 {
err = errors.New("玩家参数数据缺失")
return