更新任务条件
This commit is contained in:
parent
3ab87cbc56
commit
20db79f117
@ -654,7 +654,7 @@ var (
|
|||||||
Enabled: true,
|
Enabled: true,
|
||||||
},
|
},
|
||||||
ff(comm.ModuleRtask, "rtest"): {
|
ff(comm.ModuleRtask, "rtest"): {
|
||||||
NavLabel: "测试",
|
NavLabel: "测试条件",
|
||||||
Desc: "测试任务触发",
|
Desc: "测试任务触发",
|
||||||
MainType: string(comm.ModuleRtask),
|
MainType: string(comm.ModuleRtask),
|
||||||
SubType: "rtest",
|
SubType: "rtest",
|
||||||
|
@ -73,7 +73,7 @@ func (this *apiComp) Choose(session comm.IUserSession, req *pb.RtaskChooseReq) (
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
if chooseCnf.GotoLevel == 0 {
|
if chooseCnf.NextTid != 0 {
|
||||||
// 更新完成的任务
|
// 更新完成的任务
|
||||||
frtaskArr.RtaskIds = append(frtaskArr.RtaskIds, req.RtaskId)
|
frtaskArr.RtaskIds = append(frtaskArr.RtaskIds, req.RtaskId)
|
||||||
if rtask.FrtaskIds == nil {
|
if rtask.FrtaskIds == nil {
|
||||||
@ -87,13 +87,21 @@ func (this *apiComp) Choose(session comm.IUserSession, req *pb.RtaskChooseReq) (
|
|||||||
code = pb.ErrorCode_SystemError
|
code = pb.ErrorCode_SystemError
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
// 发奖励
|
||||||
|
code = this.moduleRtask.DispenseRes(session, sideConf.Reward, true)
|
||||||
|
|
||||||
|
rsp := &pb.RtaskFinishPush{
|
||||||
|
RtaskId: req.RtaskId,
|
||||||
|
}
|
||||||
|
if err := session.SendMsg(string(this.moduleRtask.GetType()), RtaskSubTypeChoose, rsp); err != nil {
|
||||||
|
code = pb.ErrorCode_SystemError
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
rsp := &pb.RtaskChooseResp{
|
rsp := &pb.RtaskChooseResp{
|
||||||
RtaskId: req.RtaskId,
|
RtaskId: req.RtaskId,
|
||||||
ChooseId: req.ChooseId,
|
ChooseId: req.ChooseId,
|
||||||
}
|
}
|
||||||
|
|
||||||
if err := session.SendMsg(string(this.moduleRtask.GetType()), RtaskSubTypeChoose, rsp); err != nil {
|
if err := session.SendMsg(string(this.moduleRtask.GetType()), RtaskSubTypeChoose, rsp); err != nil {
|
||||||
code = pb.ErrorCode_SystemError
|
code = pb.ErrorCode_SystemError
|
||||||
}
|
}
|
||||||
|
@ -3,13 +3,39 @@ package rtask
|
|||||||
|
|
||||||
import cfg "go_dreamfactory/sys/configure/structs"
|
import cfg "go_dreamfactory/sys/configure/structs"
|
||||||
|
|
||||||
|
func (this *ModelRtaskRecord) equalFirstParam(cfg *cfg.GameRdtaskCondiData, vals ...int32) (condiId int32) {
|
||||||
|
//只查询参数于配置相等的情况下设置condiId,否则返回0
|
||||||
|
if !soEqual(vals[0], cfg.Data1) {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
condiId = cfg.Id
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
func (this *ModelRtaskRecord) greatEqualFirstParam(cfg *cfg.GameRdtaskCondiData, vals ...int32) (condiId int32) {
|
||||||
|
if !soGreatEqual(vals[0], cfg.Data1) {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
condiId = cfg.Id
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
func (this *ModelRtaskRecord) lessEqualFirstParam(cfg *cfg.GameRdtaskCondiData, vals ...int32) (condiId int32) {
|
||||||
|
if !soLessEqual(vals[0], cfg.Data1) {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
condiId = cfg.Id
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
// 与每个参数比较
|
// 与每个参数比较
|
||||||
|
// Deprecated
|
||||||
func (this *ModelRtaskRecord) equalParams(cfg *cfg.GameRdtaskCondiData, vals ...int32) (condiId int32) {
|
func (this *ModelRtaskRecord) equalParams(cfg *cfg.GameRdtaskCondiData, vals ...int32) (condiId int32) {
|
||||||
var (
|
var (
|
||||||
err error
|
err error
|
||||||
paramLen int
|
paramLen int
|
||||||
)
|
)
|
||||||
if paramLen, err = verifyParam(cfg, vals...); err != nil {
|
if paramLen, err = lenParam(cfg, vals...); err != nil {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -19,21 +45,21 @@ func (this *ModelRtaskRecord) equalParams(cfg *cfg.GameRdtaskCondiData, vals ...
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
case 2:
|
case 2:
|
||||||
if !(soEqual(vals[0], cfg.Data1) && soEqual(vals[1], cfg.Data2)) {
|
if !(soEqual(vals[0], cfg.Data1) && soGreatEqual(vals[1], cfg.Data2)) {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
case 3:
|
case 3:
|
||||||
if !(soEqual(vals[0], cfg.Data1) && soEqual(vals[1], cfg.Data2) && soEqual(vals[2], cfg.Data3)) {
|
if !(soEqual(vals[0], cfg.Data1) && soGreatEqual(vals[1], cfg.Data2) && soGreatEqual(vals[2], cfg.Data3)) {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
case 4:
|
case 4:
|
||||||
if !(soEqual(vals[0], cfg.Data1) && soEqual(vals[1], cfg.Data2) &&
|
if !(soEqual(vals[0], cfg.Data1) && soGreatEqual(vals[1], cfg.Data2) &&
|
||||||
soEqual(vals[2], cfg.Data3) && soEqual(vals[3], cfg.Data4)) {
|
soGreatEqual(vals[2], cfg.Data3) && soGreatEqual(vals[3], cfg.Data4)) {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
case 5:
|
case 5:
|
||||||
if !(soEqual(vals[0], cfg.Data1) && soEqual(vals[1], cfg.Data2) &&
|
if !(soEqual(vals[0], cfg.Data1) && soGreatEqual(vals[1], cfg.Data2) &&
|
||||||
soEqual(vals[2], cfg.Data3) && soEqual(vals[3], cfg.Data4) && soEqual(vals[4], cfg.Data5)) {
|
soGreatEqual(vals[2], cfg.Data3) && soGreatEqual(vals[3], cfg.Data4) && soGreatEqual(vals[4], cfg.Data5)) {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
default:
|
default:
|
||||||
@ -50,30 +76,30 @@ func (this *ModelRtaskRecord) greatThanParams(cfg *cfg.GameRdtaskCondiData, vals
|
|||||||
err error
|
err error
|
||||||
paramLen int
|
paramLen int
|
||||||
)
|
)
|
||||||
if paramLen, err = verifyParam(cfg, vals...); err != nil {
|
if paramLen, err = lenParam(cfg, vals...); err != nil {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
switch paramLen {
|
switch paramLen {
|
||||||
case 1:
|
case 1:
|
||||||
if !soGreatThan(vals[0], cfg.Data1) {
|
if !soGreatEqual(vals[0], cfg.Data1) {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
case 2:
|
case 2:
|
||||||
if !(soGreatThan(vals[0], cfg.Data1) && soEqual(vals[1], cfg.Data2)) {
|
if !(soGreatEqual(vals[0], cfg.Data1) && soEqual(vals[1], cfg.Data2)) {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
case 3:
|
case 3:
|
||||||
if !(soGreatThan(vals[0], cfg.Data1) && soEqual(vals[1], cfg.Data2) && soEqual(vals[2], cfg.Data3)) {
|
if !(soGreatEqual(vals[0], cfg.Data1) && soEqual(vals[1], cfg.Data2) && soEqual(vals[2], cfg.Data3)) {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
case 4:
|
case 4:
|
||||||
if !(soGreatThan(vals[0], cfg.Data1) && soEqual(vals[1], cfg.Data2) &&
|
if !(soGreatEqual(vals[0], cfg.Data1) && soEqual(vals[1], cfg.Data2) &&
|
||||||
soEqual(vals[2], cfg.Data3) && soEqual(vals[3], cfg.Data4)) {
|
soEqual(vals[2], cfg.Data3) && soEqual(vals[3], cfg.Data4)) {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
case 5:
|
case 5:
|
||||||
if !(soGreatThan(vals[0], cfg.Data1) && soEqual(vals[1], cfg.Data2) &&
|
if !(soGreatEqual(vals[0], cfg.Data1) && soEqual(vals[1], cfg.Data2) &&
|
||||||
soEqual(vals[2], cfg.Data3) && soEqual(vals[3], cfg.Data4) && soEqual(vals[4], cfg.Data5)) {
|
soEqual(vals[2], cfg.Data3) && soEqual(vals[3], cfg.Data4) && soEqual(vals[4], cfg.Data5)) {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
@ -91,31 +117,31 @@ func (this *ModelRtaskRecord) lessThanParams(cfg *cfg.GameRdtaskCondiData, vals
|
|||||||
err error
|
err error
|
||||||
paramLen int
|
paramLen int
|
||||||
)
|
)
|
||||||
if paramLen, err = verifyParam(cfg, vals...); err != nil {
|
if paramLen, err = lenParam(cfg, vals...); err != nil {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
switch paramLen {
|
switch paramLen {
|
||||||
case 1:
|
case 1:
|
||||||
if !soLessThan(vals[0], cfg.Data1) {
|
if !soLessEqual(vals[0], cfg.Data1) {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
case 2:
|
case 2:
|
||||||
if !(soLessThan(vals[0], cfg.Data1) && soEqual(vals[1], cfg.Data2)) {
|
if !(soLessEqual(vals[0], cfg.Data1) && soGreatEqual(vals[1], cfg.Data2)) {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
case 3:
|
case 3:
|
||||||
if !(soLessThan(vals[0], cfg.Data1) && soEqual(vals[1], cfg.Data2) && soEqual(vals[2], cfg.Data3)) {
|
if !(soLessEqual(vals[0], cfg.Data1) && soGreatEqual(vals[1], cfg.Data2) && soGreatEqual(vals[2], cfg.Data3)) {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
case 4:
|
case 4:
|
||||||
if !(soLessThan(vals[0], cfg.Data1) && soEqual(vals[1], cfg.Data2) &&
|
if !(soLessEqual(vals[0], cfg.Data1) && soGreatEqual(vals[1], cfg.Data2) &&
|
||||||
soEqual(vals[2], cfg.Data3) && soEqual(vals[3], cfg.Data4)) {
|
soGreatEqual(vals[2], cfg.Data3) && soGreatEqual(vals[3], cfg.Data4)) {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
case 5:
|
case 5:
|
||||||
if !(soLessThan(vals[0], cfg.Data1) && soEqual(vals[1], cfg.Data2) &&
|
if !(soLessEqual(vals[0], cfg.Data1) && soGreatEqual(vals[1], cfg.Data2) &&
|
||||||
soEqual(vals[2], cfg.Data3) && soEqual(vals[3], cfg.Data4) && soEqual(vals[4], cfg.Data5)) {
|
soGreatEqual(vals[2], cfg.Data3) && soGreatEqual(vals[3], cfg.Data4) && soGreatEqual(vals[4], cfg.Data5)) {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
default:
|
default:
|
||||||
|
@ -9,10 +9,10 @@ import (
|
|||||||
"github.com/pkg/errors"
|
"github.com/pkg/errors"
|
||||||
)
|
)
|
||||||
|
|
||||||
func verifyParam(cfg *cfg.GameRdtaskCondiData, vals ...int32) (n int, err error) {
|
func lenParam(cfg *cfg.GameRdtaskCondiData, vals ...int32) (n int, err error) {
|
||||||
if cfg.Data1 != 0 && cfg.Data2 != 0 && cfg.Data3 != 0 && cfg.Data4 != 0 && cfg.Data5 != 0 {
|
if cfg.Data1 != 0 && cfg.Data2 != 0 && cfg.Data3 != 0 && cfg.Data4 != 0 && cfg.Data5 != 0 {
|
||||||
if len(vals) != 5 {
|
if len(vals) != 5 {
|
||||||
err = errors.New(fmt.Sprintf("参数个数不一致,期望5实际是%v", len(vals)))
|
err = errors.New(fmt.Sprintf("%v 参数个数不一致,期望5实际是%v", cfg.Id, len(vals)))
|
||||||
return
|
return
|
||||||
} else {
|
} else {
|
||||||
n = len(vals)
|
n = len(vals)
|
||||||
@ -22,7 +22,7 @@ func verifyParam(cfg *cfg.GameRdtaskCondiData, vals ...int32) (n int, err error)
|
|||||||
|
|
||||||
if cfg.Data1 != 0 && cfg.Data2 != 0 && cfg.Data3 != 0 && cfg.Data4 != 0 {
|
if cfg.Data1 != 0 && cfg.Data2 != 0 && cfg.Data3 != 0 && cfg.Data4 != 0 {
|
||||||
if len(vals) != 4 {
|
if len(vals) != 4 {
|
||||||
err = errors.New(fmt.Sprintf("参数个数不一致,期望4实际是%v", len(vals)))
|
err = errors.New(fmt.Sprintf("%v 参数个数不一致,期望4实际是%v", cfg.Id, len(vals)))
|
||||||
return
|
return
|
||||||
} else {
|
} else {
|
||||||
n = len(vals)
|
n = len(vals)
|
||||||
@ -32,7 +32,7 @@ func verifyParam(cfg *cfg.GameRdtaskCondiData, vals ...int32) (n int, err error)
|
|||||||
|
|
||||||
if cfg.Data1 != 0 && cfg.Data2 != 0 && cfg.Data3 != 0 {
|
if cfg.Data1 != 0 && cfg.Data2 != 0 && cfg.Data3 != 0 {
|
||||||
if len(vals) != 3 {
|
if len(vals) != 3 {
|
||||||
err = errors.New(fmt.Sprintf("参数个数不一致,期望3实际是%v", len(vals)))
|
err = errors.New(fmt.Sprintf("%v 参数个数不一致,期望3实际是%v", cfg.Id, len(vals)))
|
||||||
return
|
return
|
||||||
} else {
|
} else {
|
||||||
n = len(vals)
|
n = len(vals)
|
||||||
@ -42,7 +42,7 @@ func verifyParam(cfg *cfg.GameRdtaskCondiData, vals ...int32) (n int, err error)
|
|||||||
|
|
||||||
if cfg.Data1 != 0 && cfg.Data2 != 0 {
|
if cfg.Data1 != 0 && cfg.Data2 != 0 {
|
||||||
if len(vals) != 2 {
|
if len(vals) != 2 {
|
||||||
err = errors.New(fmt.Sprintf("参数个数不一致,期望2实际是%v", len(vals)))
|
err = errors.New(fmt.Sprintf("%v 参数个数不一致,期望2实际是%v", cfg.Id, len(vals)))
|
||||||
return
|
return
|
||||||
} else {
|
} else {
|
||||||
n = len(vals)
|
n = len(vals)
|
||||||
@ -52,7 +52,7 @@ func verifyParam(cfg *cfg.GameRdtaskCondiData, vals ...int32) (n int, err error)
|
|||||||
|
|
||||||
if cfg.Data1 != 0 {
|
if cfg.Data1 != 0 {
|
||||||
if len(vals) != 1 {
|
if len(vals) != 1 {
|
||||||
err = errors.New(fmt.Sprintf("参数个数不一致,期望1实际是%v", len(vals)))
|
err = errors.New(fmt.Sprintf("%v 参数个数不一致,期望1实际是%v", cfg.Id, len(vals)))
|
||||||
return
|
return
|
||||||
} else {
|
} else {
|
||||||
n = len(vals)
|
n = len(vals)
|
||||||
@ -139,15 +139,18 @@ type Num interface {
|
|||||||
~int32 | ~string | ~bool
|
~int32 | ~string | ~bool
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// 等于
|
||||||
func equal[T Num](actual, expected T) bool {
|
func equal[T Num](actual, expected T) bool {
|
||||||
return actual == expected
|
return actual == expected
|
||||||
}
|
}
|
||||||
|
|
||||||
func greatThan(actual, expected int32) bool {
|
// 大于等于
|
||||||
|
func greatEual(actual, expected int32) bool {
|
||||||
return actual >= expected
|
return actual >= expected
|
||||||
}
|
}
|
||||||
|
|
||||||
func lessThan(actual, expected int32) bool {
|
//小于等于
|
||||||
|
func lessEqual(actual, expected int32) bool {
|
||||||
return actual <= expected
|
return actual <= expected
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -160,8 +163,8 @@ func soEqual[T Num](actual T, expected T) (ok bool) {
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
func soGreatThan(actual, expected int32) (ok bool) {
|
func soGreatEqual(actual, expected int32) (ok bool) {
|
||||||
if !greatThan(actual, expected) {
|
if !greatEual(actual, expected) {
|
||||||
log.Debugf("实际:%v 期望:%v", actual, expected)
|
log.Debugf("实际:%v 期望:%v", actual, expected)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
@ -169,8 +172,8 @@ func soGreatThan(actual, expected int32) (ok bool) {
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
func soLessThan(actual, expected int32) (ok bool) {
|
func soLessEqual(actual, expected int32) (ok bool) {
|
||||||
if !lessThan(actual, expected) {
|
if !lessEqual(actual, expected) {
|
||||||
log.Debugf("实际:%v 期望:%v", actual, expected)
|
log.Debugf("实际:%v 期望:%v", actual, expected)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
@ -125,11 +125,23 @@ func (this *ModuleRtask) initRtaskVerifyHandle() {
|
|||||||
cfg: typeCfg,
|
cfg: typeCfg,
|
||||||
verify: this.modelRtask.verfiyRtype10,
|
verify: this.modelRtask.verfiyRtype10,
|
||||||
})
|
})
|
||||||
case comm.Rtype12, comm.Rtype13, comm.Rtype14, comm.Rtype15:
|
case comm.Rtype11:
|
||||||
this.registerVerifyHandle(v.Id, &rtaskCondi{
|
this.registerVerifyHandle(v.Id, &rtaskCondi{
|
||||||
cfg: typeCfg,
|
cfg: typeCfg,
|
||||||
find: this.modelRtaskRecord.lessThanParams,
|
find: this.modelRtaskRecord.lessEqualFirstParam,
|
||||||
verify: this.modelRtaskRecord.verifyFromDb,
|
verify: this.modelRtaskRecord.verifyFirstGreatEqualParam,
|
||||||
|
update: this.modelRtaskRecord.overrideUpdate,
|
||||||
|
})
|
||||||
|
case comm.Rtype12, comm.Rtype13, comm.Rtype14, comm.Rtype15,
|
||||||
|
comm.Rtype18, comm.Rtype19, comm.Rtype21, comm.Rtype24,
|
||||||
|
comm.Rtype26, comm.Rtype27, comm.Rtype28, comm.Rtype38,
|
||||||
|
comm.Rtype39, comm.Rtype50, comm.Rtype51, comm.Rtype53,
|
||||||
|
comm.Rtype54, comm.Rtype57, comm.Rtype58, comm.Rtype60,
|
||||||
|
comm.Rtype62, comm.Rtype64, comm.Rtype69:
|
||||||
|
this.registerVerifyHandle(v.Id, &rtaskCondi{
|
||||||
|
cfg: typeCfg,
|
||||||
|
find: this.modelRtaskRecord.lessEqualFirstParam,
|
||||||
|
verify: this.modelRtaskRecord.verifyFirstGreatEqualParam,
|
||||||
update: this.modelRtaskRecord.addUpdate,
|
update: this.modelRtaskRecord.addUpdate,
|
||||||
})
|
})
|
||||||
case comm.Rtype20:
|
case comm.Rtype20:
|
||||||
@ -137,8 +149,20 @@ func (this *ModuleRtask) initRtaskVerifyHandle() {
|
|||||||
cfg: typeCfg,
|
cfg: typeCfg,
|
||||||
verify: this.modelRtask.verifyRtype20,
|
verify: this.modelRtask.verifyRtype20,
|
||||||
})
|
})
|
||||||
case comm.Rtype11, comm.Rtype16, comm.Rtype17, comm.Rtype21,
|
case comm.Rtype22:
|
||||||
comm.Rtype22, comm.Rtype35, comm.Rtype40, comm.Rtype44,
|
this.registerVerifyHandle(v.Id, &rtaskCondi{
|
||||||
|
cfg: typeCfg,
|
||||||
|
find: this.modelRtaskRecord.equalFirstParam,
|
||||||
|
verify: this.modelRtaskRecord.verifyFirstEqualParam,
|
||||||
|
update: this.modelRtaskRecord.overrideUpdate,
|
||||||
|
})
|
||||||
|
case comm.Rtype63:
|
||||||
|
this.registerVerifyHandle(v.Id, &rtaskCondi{
|
||||||
|
cfg: typeCfg,
|
||||||
|
verify: this.modelRtask.verifyRtype63,
|
||||||
|
})
|
||||||
|
case comm.Rtype16, comm.Rtype17,
|
||||||
|
comm.Rtype35, comm.Rtype44,
|
||||||
comm.Rtype59, comm.Rtype61, comm.Rtype70:
|
comm.Rtype59, comm.Rtype61, comm.Rtype70:
|
||||||
this.registerVerifyHandle(v.Id, &rtaskCondi{
|
this.registerVerifyHandle(v.Id, &rtaskCondi{
|
||||||
cfg: typeCfg,
|
cfg: typeCfg,
|
||||||
@ -146,28 +170,20 @@ func (this *ModuleRtask) initRtaskVerifyHandle() {
|
|||||||
verify: this.modelRtaskRecord.verifyFromDb,
|
verify: this.modelRtaskRecord.verifyFromDb,
|
||||||
update: this.modelRtaskRecord.overrideUpdate,
|
update: this.modelRtaskRecord.overrideUpdate,
|
||||||
})
|
})
|
||||||
case comm.Rtype18, comm.Rtype19, comm.Rtype23, comm.Rtype24,
|
case comm.Rtype23, comm.Rtype25, comm.Rtype29, comm.Rtype30, comm.Rtype31,
|
||||||
comm.Rtype25, comm.Rtype26, comm.Rtype27,
|
|
||||||
comm.Rtype28, comm.Rtype29, comm.Rtype30, comm.Rtype31,
|
|
||||||
comm.Rtype32, comm.Rtype33, comm.Rtype34, comm.Rtype36,
|
comm.Rtype32, comm.Rtype33, comm.Rtype34, comm.Rtype36,
|
||||||
comm.Rtype37, comm.Rtype38, comm.Rtype39, comm.Rtype41,
|
comm.Rtype37, comm.Rtype40, comm.Rtype41,
|
||||||
comm.Rtype42, comm.Rtype43, comm.Rtype45,
|
comm.Rtype42, comm.Rtype43, comm.Rtype45,
|
||||||
comm.Rtype46, comm.Rtype47, comm.Rtype48, comm.Rtype49,
|
comm.Rtype46, comm.Rtype47, comm.Rtype48, comm.Rtype49,
|
||||||
comm.Rtype50, comm.Rtype51, comm.Rtype52, comm.Rtype53,
|
comm.Rtype52, comm.Rtype55, comm.Rtype56,
|
||||||
comm.Rtype54, comm.Rtype55, comm.Rtype56, comm.Rtype57,
|
comm.Rtype65, comm.Rtype66, comm.Rtype67, comm.Rtype68:
|
||||||
comm.Rtype58, comm.Rtype60, comm.Rtype62, comm.Rtype64,
|
|
||||||
comm.Rtype65, comm.Rtype66, comm.Rtype67, comm.Rtype68, comm.Rtype69:
|
|
||||||
this.registerVerifyHandle(v.Id, &rtaskCondi{
|
this.registerVerifyHandle(v.Id, &rtaskCondi{
|
||||||
cfg: typeCfg,
|
cfg: typeCfg,
|
||||||
find: this.modelRtaskRecord.lessThanParams,
|
find: this.modelRtaskRecord.lessThanParams,
|
||||||
verify: this.modelRtaskRecord.verifyFromDb,
|
verify: this.modelRtaskRecord.verifyFromDb,
|
||||||
update: this.modelRtaskRecord.addUpdate,
|
update: this.modelRtaskRecord.addUpdate,
|
||||||
})
|
})
|
||||||
case comm.Rtype63:
|
|
||||||
this.registerVerifyHandle(v.Id, &rtaskCondi{
|
|
||||||
cfg: typeCfg,
|
|
||||||
verify: this.modelRtask.verifyRtype63,
|
|
||||||
})
|
|
||||||
default:
|
default:
|
||||||
log.Warnf("rtaskType[%v] not register", typeCfg.Type)
|
log.Warnf("rtaskType[%v] not register", typeCfg.Type)
|
||||||
}
|
}
|
||||||
|
@ -14,7 +14,7 @@ import (
|
|||||||
// 覆盖更新
|
// 覆盖更新
|
||||||
func (this *ModelRtaskRecord) overrideUpdate(uid string, cfg *cfg.GameRdtaskCondiData, vals ...int32) (err error) {
|
func (this *ModelRtaskRecord) overrideUpdate(uid string, cfg *cfg.GameRdtaskCondiData, vals ...int32) (err error) {
|
||||||
var paramLen int
|
var paramLen int
|
||||||
if paramLen, err = verifyParam(cfg, vals...); err != nil {
|
if paramLen, err = lenParam(cfg, vals...); err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -19,18 +19,19 @@ func (this *ModelRtaskRecord) verifyFromDb(uid string, cfg *cfg.GameRdtaskCondiD
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
var paramLen int
|
var paramLen int
|
||||||
if paramLen, err = verifyParam(cfg, toArr(rd.Data)...); err == nil {
|
if paramLen, err = lenParam(cfg, toArr(rd.Data)...); err == nil {
|
||||||
|
//参数比较,默认第一个参数soGreateEqual,其它soEqual
|
||||||
switch paramLen {
|
switch paramLen {
|
||||||
case 1:
|
case 1:
|
||||||
return nil, soEqual(rd.Data[0], cfg.Data1)
|
return nil, soGreatEqual(rd.Data[0], cfg.Data1)
|
||||||
case 2:
|
case 2:
|
||||||
return nil, soEqual(rd.Data[0], cfg.Data1) && soEqual(rd.Data[1], cfg.Data2)
|
return nil, soGreatEqual(rd.Data[0], cfg.Data1) && soEqual(rd.Data[1], cfg.Data2)
|
||||||
case 3:
|
case 3:
|
||||||
return nil, soEqual(rd.Data[0], cfg.Data1) && soEqual(rd.Data[1], cfg.Data2) && soEqual(rd.Data[2], cfg.Data3)
|
return nil, soGreatEqual(rd.Data[0], cfg.Data1) && soEqual(rd.Data[1], cfg.Data2) && soEqual(rd.Data[2], cfg.Data3)
|
||||||
case 4:
|
case 4:
|
||||||
return nil, soEqual(rd.Data[0], cfg.Data1) && soEqual(rd.Data[1], cfg.Data2) && soEqual(rd.Data[2], cfg.Data3) && soEqual(rd.Data[3], cfg.Data4)
|
return nil, soGreatEqual(rd.Data[0], cfg.Data1) && soEqual(rd.Data[1], cfg.Data2) && soEqual(rd.Data[2], cfg.Data3) && soEqual(rd.Data[3], cfg.Data4)
|
||||||
case 5:
|
case 5:
|
||||||
return nil, soEqual(rd.Data[0], cfg.Data1) && soEqual(rd.Data[1], cfg.Data2) && soEqual(rd.Data[2], cfg.Data3) &&
|
return nil, soGreatEqual(rd.Data[0], cfg.Data1) && soEqual(rd.Data[1], cfg.Data2) && soEqual(rd.Data[2], cfg.Data3) &&
|
||||||
soEqual(rd.Data[3], cfg.Data4) && soEqual(rd.Data[4], cfg.Data5)
|
soEqual(rd.Data[3], cfg.Data4) && soEqual(rd.Data[4], cfg.Data5)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -38,6 +39,32 @@ func (this *ModelRtaskRecord) verifyFromDb(uid string, cfg *cfg.GameRdtaskCondiD
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (this *ModelRtaskRecord) verifyFirstEqualParam(uid string, cfg *cfg.GameRdtaskCondiData) (err error, ok bool) {
|
||||||
|
var rd *pb.RtaskData
|
||||||
|
if rd, err = this.GetVerifyData(uid, cfg.Id); rd != nil {
|
||||||
|
if len(rd.Data) == 0 {
|
||||||
|
err = errors.WithMessagef(err, "玩家参数数据缺失 %v", rd.Data)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
return nil, soEqual(rd.Data[0], cfg.Data1)
|
||||||
|
}
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
func (this *ModelRtaskRecord) verifyFirstGreatEqualParam(uid string, cfg *cfg.GameRdtaskCondiData) (err error, ok bool) {
|
||||||
|
var rd *pb.RtaskData
|
||||||
|
if rd, err = this.GetVerifyData(uid, cfg.Id); rd != nil {
|
||||||
|
if len(rd.Data) == 0 {
|
||||||
|
err = errors.WithMessagef(err, "玩家参数数据缺失 %v", rd.Data)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
return nil, soGreatEqual(rd.Data[0], cfg.Data1)
|
||||||
|
}
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
// 英雄指定
|
// 英雄指定
|
||||||
func (this *ModelRtask) verfiyRtype1(uid string, cfg *cfg.GameRdtaskCondiData) (err error, ok bool) {
|
func (this *ModelRtask) verfiyRtype1(uid string, cfg *cfg.GameRdtaskCondiData) (err error, ok bool) {
|
||||||
heroModule, err := this.service.GetModule(comm.ModuleHero)
|
heroModule, err := this.service.GetModule(comm.ModuleHero)
|
||||||
@ -47,13 +74,12 @@ func (this *ModelRtask) verfiyRtype1(uid string, cfg *cfg.GameRdtaskCondiData) (
|
|||||||
|
|
||||||
if h, y := heroModule.(comm.IHero); y {
|
if h, y := heroModule.(comm.IHero); y {
|
||||||
for _, v := range h.GetHeroList(uid) {
|
for _, v := range h.GetHeroList(uid) {
|
||||||
if cast.ToString(cfg.Data1) == v.HeroID {
|
if soEqual(cast.ToString(cfg.Data1), v.HeroID) {
|
||||||
ok = true
|
ok = true
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -66,7 +92,7 @@ func (this *ModelRtask) verifyRtype2(uid string, cfg *cfg.GameRdtaskCondiData) (
|
|||||||
|
|
||||||
if ml, y := m.(comm.IMainline); y {
|
if ml, y := m.(comm.IMainline); y {
|
||||||
qjId := ml.GetUsermainLineData(uid)
|
qjId := ml.GetUsermainLineData(uid)
|
||||||
return nil, qjId == cfg.Data1
|
return nil, soEqual(qjId, cfg.Data1)
|
||||||
}
|
}
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
@ -107,7 +133,7 @@ func (this *ModelRtask) verifyRtype4(uid string, cfg *cfg.GameRdtaskCondiData) (
|
|||||||
}
|
}
|
||||||
if hero != nil {
|
if hero != nil {
|
||||||
return nil, soEqual(hero.HeroID, cast.ToString(cfg.Data1)) &&
|
return nil, soEqual(hero.HeroID, cast.ToString(cfg.Data1)) &&
|
||||||
soEqual(hero.Lv, cfg.Data2)
|
soGreatEqual(hero.Lv, cfg.Data2)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return
|
return
|
||||||
@ -139,7 +165,7 @@ func (this *ModelRtask) verifyRtype5(uid string, cfg *cfg.GameRdtaskCondiData) (
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
return nil, soEqual(hero.HeroID, cast.ToString(cfg.Data1)) &&
|
return nil, soEqual(hero.HeroID, cast.ToString(cfg.Data1)) &&
|
||||||
soEqual(count, cfg.Data2)
|
soGreatEqual(count, cfg.Data2)
|
||||||
}
|
}
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
@ -163,7 +189,7 @@ func (this *ModelRtask) verifyRtype6(uid string, cfg *cfg.GameRdtaskCondiData) (
|
|||||||
|
|
||||||
if hero != nil {
|
if hero != nil {
|
||||||
return nil, soEqual(hero.HeroID, cast.ToString(cfg.Data1)) &&
|
return nil, soEqual(hero.HeroID, cast.ToString(cfg.Data1)) &&
|
||||||
soEqual(hero.Star, cfg.Data2)
|
soGreatEqual(hero.Star, cfg.Data2)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return
|
return
|
||||||
@ -198,7 +224,7 @@ func (this *ModelRtask) verfiyRtype8(uid string, cfg *cfg.GameRdtaskCondiData) (
|
|||||||
if err != nil {
|
if err != nil {
|
||||||
return err, false
|
return err, false
|
||||||
}
|
}
|
||||||
return nil, soEqual(ud.LoginAddCount, cfg.Data1)
|
return nil, soGreatEqual(ud.LoginAddCount, cfg.Data1)
|
||||||
}
|
}
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
@ -216,7 +242,7 @@ func (this *ModelRtask) verfiyRtype9(uid string, cfg *cfg.GameRdtaskCondiData) (
|
|||||||
if err != nil {
|
if err != nil {
|
||||||
return err, false
|
return err, false
|
||||||
}
|
}
|
||||||
return nil, soEqual(ud.LoginContinueCount, cfg.Data1)
|
return nil, soGreatEqual(ud.LoginContinueCount, cfg.Data1)
|
||||||
}
|
}
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
@ -231,7 +257,7 @@ func (this *ModelRtask) verfiyRtype10(uid string, cfg *cfg.GameRdtaskCondiData)
|
|||||||
|
|
||||||
if mi, y := m.(comm.IFriend); y {
|
if mi, y := m.(comm.IFriend); y {
|
||||||
count := mi.GetFriendCount(uid)
|
count := mi.GetFriendCount(uid)
|
||||||
return nil, soGreatThan(count, cfg.Data1)
|
return nil, soGreatEqual(count, cfg.Data1)
|
||||||
}
|
}
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
@ -246,7 +272,7 @@ func (this *ModelRtask) verifyRtype20(uid string, cfg *cfg.GameRdtaskCondiData)
|
|||||||
|
|
||||||
if um, y := userModule.(comm.IUser); y {
|
if um, y := userModule.(comm.IUser); y {
|
||||||
if user := um.GetUser(uid); user != nil {
|
if user := um.GetUser(uid); user != nil {
|
||||||
return nil, soEqual(user.Lv, cfg.Data1)
|
return nil, soGreatEqual(user.Lv, cfg.Data1)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return
|
return
|
||||||
@ -266,9 +292,7 @@ func (this *ModelRtask) verifyRtype63(uid string, cfg *cfg.GameRdtaskCondiData)
|
|||||||
}
|
}
|
||||||
|
|
||||||
if de != nil {
|
if de != nil {
|
||||||
if de.Activeday == cfg.Data1 {
|
ok = soGreatEqual(de.Activeday, cfg.Data1)
|
||||||
ok = true
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -28,7 +28,7 @@ func TestVerify(t *testing.T) {
|
|||||||
patches2 := gomonkey.ApplyGlobalVar(&vals, []int32{25002})
|
patches2 := gomonkey.ApplyGlobalVar(&vals, []int32{25002})
|
||||||
defer patches2.Reset()
|
defer patches2.Reset()
|
||||||
|
|
||||||
n, err := verifyParam(conf, vals...)
|
n, err := lenParam(conf, vals...)
|
||||||
fmt.Println(n, err)
|
fmt.Println(n, err)
|
||||||
})
|
})
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user