修改完成条件校验

This commit is contained in:
wh_zcy 2023-05-24 14:57:29 +08:00
parent 310f06821f
commit ee517f963e
14 changed files with 3279 additions and 1075 deletions

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

View File

@ -118,7 +118,7 @@ func (this *RtaskTestView) CreateView(t *model.TestCase) fyne.CanvasObject {
logrus.Error(err)
return
}
logrus.Debugf("执行任务 id:%v rtype:%v params:%v", condId, rtype, p)
// logrus.Debugf("执行任务 id:%v rtype:%v params:%v", condId, rtype, p)
msgs = append(msgs, fmt.Sprintf("condId:%v rtype:%v params:%v", condId, rtype, p))
}(v.Id, v.Type, p)
wg.Wait()
@ -202,9 +202,9 @@ func (this *RtaskTestView) rtestListener() {
return
}
if !rsp.Flag {
logrus.Debug(fmt.Sprintf("%v", rsp.Flag))
}
// if !rsp.Flag {
logrus.Debug(fmt.Sprintf("%v - %v", rsp.RtaskType, rsp.Flag))
// }
}
},
})

View File

@ -655,6 +655,7 @@ const (
Rtype184 TaskType = 184 //使用好友武馆木桩X次(接取任务后,每次使用好友的木桩训练英雄一次,进度便加一)
Rtype185 TaskType = 185 //完成X次每日1健(接取任务后每完成1次每日1健便进度加一)
Rtype186 TaskType = 186
Rtype187 TaskType = 187
)
const (

View File

@ -16,6 +16,7 @@ func (this *apiComp) Getall(session comm.IUserSession, req *pb.OldtimesGetallReq
rsp := &pb.OldtimesGetallResp{}
d := this.module.modelOldtimes.getDBOldtimes(uid)
// 解锁的关卡
var unlockLevelIds []int32
// 更新关卡状态
if imodule, err := this.service.GetModule(comm.ModuleCombat); err == nil {
@ -36,6 +37,7 @@ func (this *apiComp) Getall(session comm.IUserSession, req *pb.OldtimesGetallReq
if err := this.module.modelOldtimes.updateOldtimes(uid, d); err != nil {
this.module.Error("oldtime更新失败",
log.Field{Key: "uid", Value: uid})
continue
}
unlockLevelIds = append(unlockLevelIds, level.Lid)
}

View File

@ -2,11 +2,9 @@ package rtask
import (
"go_dreamfactory/comm"
"go_dreamfactory/lego/sys/log"
"go_dreamfactory/pb"
"strings"
"github.com/pkg/errors"
"github.com/spf13/cast"
)
@ -17,9 +15,9 @@ func (this *apiComp) RtestCheck(session comm.IUserSession, req *pb.RtaskTestReq)
func (this *apiComp) Rtest(session comm.IUserSession, req *pb.RtaskTestReq) (code pb.ErrorCode, data *pb.ErrorData) {
rsp := &pb.RtaskTestResp{Flag: true}
if req.CondiId != 0 {
if err, ok := this.moduleRtask.modelRtask.checkCondi(session.GetUserId(), req.CondiId); !ok {
if code = this.moduleRtask.CheckCondi(session.GetUserId(), req.CondiId); code != pb.ErrorCode_Success {
rsp.Flag = false
log.Errorf("%v", errors.WithMessage(err, session.GetUserId()))
return
}
} else if req.GroupId != 0 {
// 获取当前玩家
@ -53,6 +51,7 @@ func (this *apiComp) Rtest(session comm.IUserSession, req *pb.RtaskTestReq) (cod
TT: comm.TaskType(req.RtaskType),
Params: req.Params,
})
rsp.Flag = true
}

View File

@ -34,6 +34,7 @@ func (this *ModelRtaskRecord) Init(service core.IService, module core.IModule, c
}
// 获取玩家待校验数据
// Deprecated
func (this *ModelRtaskRecord) GetVerifyData(uid string, condiId int32) (*pb.RtaskData, error) {
record := &pb.DBRtaskRecord{}
err := this.Get(uid, record)

View File

@ -72,7 +72,7 @@ func (this *ModelRtask) GetRtask(uid string) *pb.DBRtask {
// }
// 确定选项前的校验
func (this *ModelRtask) checkCondi(uid string, condiId int32) (err error, ok bool) {
func (this *ModelRtask) checkCondi(uid string, condiId int32, record *pb.DBRtaskRecord) (err error, ok bool) {
if condiId <= 0 {
return nil, true
}
@ -110,7 +110,7 @@ func (this *ModelRtask) checkCondi(uid string, condiId int32) (err error, ok boo
return
}
if ok, err = condi.verify(uid, conf); !ok {
if ok, err = condi.verify(uid, record, conf); !ok {
err = errors.WithMessagef(err, "uid: %v do rtask [condiId:%v] condition not reach", uid, condiId)
return
}

View File

@ -30,7 +30,7 @@ type rtaskCondHandle struct {
update updateDataHandle //更新任务数据
}
type verifyHandle func(uid string, cfg *cfg.GameRdtaskCondiData) (bool, error)
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
@ -82,20 +82,11 @@ func (this *ModuleRtask) getHandle(tt comm.TaskType) (condis []*rtaskCondHandle)
condi := &rtaskCondHandle{
condId: v.Id,
find: this.modelRtaskRecord.equalFirstParam,
verify: this.modelRtask.verfiyRtype1,
verify: this.modelRtaskRecord.verifyFromDb,
update: this.modelRtaskRecord.addUpdate,
}
condis = append(condis, condi)
this.registerVerifyHandle(v.Id, condi)
case comm.Rtype2:
condi := &rtaskCondHandle{
condId: v.Id,
find: this.modelRtaskRecord.equalFirstParam,
verify: this.modelRtask.verifyRtype2,
update: this.modelRtaskRecord.overrideUpdate,
}
condis = append(condis, condi)
this.registerVerifyHandle(v.Id, condi)
case comm.Rtype3:
condi := &rtaskCondHandle{
condId: v.Id,
@ -157,16 +148,6 @@ func (this *ModuleRtask) getHandle(tt comm.TaskType) (condis []*rtaskCondHandle)
verify: this.modelRtask.verfiyRtype10,
update: this.modelRtaskRecord.overrideUpdate,
}
condis = append(condis, condi)
this.registerVerifyHandle(v.Id, condi)
case comm.Rtype11, comm.Rtype84, comm.Rtype85:
condi := &rtaskCondHandle{
condId: v.Id,
find: this.modelRtaskRecord.lessEqualFirstParam,
verify: this.modelRtaskRecord.verifyFirstGreatEqualParam,
update: this.modelRtaskRecord.overrideUpdate,
}
condis = append(condis, condi)
this.registerVerifyHandle(v.Id, condi)
case comm.Rtype18:
@ -182,12 +163,12 @@ func (this *ModuleRtask) getHandle(tt comm.TaskType) (condis []*rtaskCondHandle)
comm.Rtype19, comm.Rtype21, comm.Rtype24,
comm.Rtype26, comm.Rtype27, comm.Rtype28, comm.Rtype38,
comm.Rtype39, comm.Rtype51, comm.Rtype53,
comm.Rtype54, comm.Rtype57, comm.Rtype58, comm.Rtype60,
comm.Rtype62, comm.Rtype64, comm.Rtype69, comm.Rtype72, comm.Rtype88, comm.Rtype104,
comm.Rtype54, comm.Rtype57, comm.Rtype60,
comm.Rtype62, comm.Rtype64, comm.Rtype88, comm.Rtype104,
comm.Rtype96, comm.Rtype105, comm.Rtype128, comm.Rtype130, comm.Rtype131,
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.Rtype171, comm.Rtype186, comm.Rtype187:
condi := &rtaskCondHandle{
condId: v.Id,
find: this.modelRtaskRecord.lessEqualFirstParam,
@ -215,7 +196,7 @@ func (this *ModuleRtask) getHandle(tt comm.TaskType) (condis []*rtaskCondHandle)
condis = append(condis, condi)
this.registerVerifyHandle(v.Id, condi)
case comm.Rtype22, comm.Rtype109:
case comm.Rtype109:
condi := &rtaskCondHandle{
condId: v.Id,
find: this.modelRtaskRecord.equalFirstParam,
@ -223,20 +204,10 @@ func (this *ModuleRtask) getHandle(tt comm.TaskType) (condis []*rtaskCondHandle)
update: this.modelRtaskRecord.overrideUpdate,
}
condis = append(condis, condi)
this.registerVerifyHandle(v.Id, condi)
case comm.Rtype63:
condi := &rtaskCondHandle{
condId: v.Id,
find: this.modelRtaskRecord.equalFirstParam,
verify: this.modelRtask.verifyRtype63,
update: this.modelRtaskRecord.addUpdate,
}
condis = append(condis, condi)
this.registerVerifyHandle(v.Id, condi)
case comm.Rtype16, comm.Rtype17,
comm.Rtype35, comm.Rtype44,
comm.Rtype59, comm.Rtype61:
comm.Rtype35, comm.Rtype61:
condi := &rtaskCondHandle{
condId: v.Id,
find: this.modelRtaskRecord.equalParams,
@ -245,11 +216,11 @@ func (this *ModuleRtask) getHandle(tt comm.TaskType) (condis []*rtaskCondHandle)
}
condis = append(condis, condi)
this.registerVerifyHandle(v.Id, condi)
case comm.Rtype23, comm.Rtype25, comm.Rtype29, comm.Rtype30, comm.Rtype31,
case comm.Rtype23, comm.Rtype25, comm.Rtype30,
comm.Rtype32, comm.Rtype33, comm.Rtype34, comm.Rtype36,
comm.Rtype37, comm.Rtype40, comm.Rtype41,
comm.Rtype42, comm.Rtype43, comm.Rtype45,
comm.Rtype46, comm.Rtype47, comm.Rtype48, comm.Rtype49,
comm.Rtype42, comm.Rtype43,
comm.Rtype46, comm.Rtype47,
comm.Rtype52, comm.Rtype55, comm.Rtype56,
comm.Rtype65, comm.Rtype66, comm.Rtype67, comm.Rtype68, comm.Rtype70, comm.Rtype140:
condi := &rtaskCondHandle{
@ -408,10 +379,30 @@ func (this *ModuleRtask) TriggerTask(uid string, taskParams ...*comm.TaskParam)
// 任务条件校验
func (this *ModuleRtask) CheckCondi(uid string, condiId int32) (code pb.ErrorCode) {
// this.Debug("检查任务条件", log.Field{Key: "uid", Value: uid}, log.Field{Key: "condiId", Value: condiId})
if _, ok := this.modelRtask.checkCondi(uid, condiId); !ok {
code = pb.ErrorCode_RtaskCondiNoReach
record := this.modelRtaskRecord.getRecord(uid)
if record == nil {
code = pb.ErrorCode_DataNotFound
return
}
if _, ok := this.modelRtask.checkCondi(uid, condiId, record); !ok {
code = pb.ErrorCode_RtaskCondiNoReach
return
}
return
}
func (this *ModuleRtask) CheckCondis(uid string, condiIds ...int32) (condIds []int32) {
record := this.modelRtaskRecord.getRecord(uid)
if record == nil {
return
}
for _, condId := range condIds {
if _, ok := this.modelRtask.checkCondi(uid, condId, record); ok {
condIds = append(condIds, condId)
}
}
return
}

View File

@ -11,99 +11,102 @@ import (
"github.com/spf13/cast"
)
func (this *ModelRtaskRecord) verifyFromDb(uid string, cfg *cfg.GameRdtaskCondiData) (ok bool, err error) {
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)
func (this *ModelRtaskRecord) verifyFromDb(uid string, record *pb.DBRtaskRecord, cfg *cfg.GameRdtaskCondiData) (ok bool, err error) {
if record == nil {
err = errors.WithMessagef(err, "玩家数据DBRtaskRecord空")
return
}
if v, f := record.Vals[cfg.Id]; f {
if len(v.Data) == 0 {
err = errors.WithMessagef(err, "玩家参数数据缺失 %v", v.Data)
return
}
var paramLen int
if paramLen, err = lenParam(cfg, toArr(rd.Data)...); err == nil {
if paramLen, err = lenParam(cfg, toArr(v.Data)...); err == nil {
//参数比较,默认第一个参数soGreateEqual,其它soEqual
switch paramLen {
case 1:
return soGreatEqual(rd.Data[0], cfg.Data1)
return soGreatEqual(v.Data[0], cfg.Data1)
case 2:
if ok, err = soGreatEqual(rd.Data[0], cfg.Data1); !ok {
if ok, err = soGreatEqual(v.Data[0], cfg.Data1); !ok {
return
}
if ok, err = soEqual(rd.Data[1], cfg.Data2); !ok {
if ok, err = soEqual(v.Data[1], cfg.Data2); !ok {
return
}
case 3:
if ok, err = soGreatEqual(rd.Data[0], cfg.Data1); !ok {
if ok, err = soGreatEqual(v.Data[0], cfg.Data1); !ok {
return
}
if ok, err = soEqual(rd.Data[1], cfg.Data2); !ok {
if ok, err = soEqual(v.Data[1], cfg.Data2); !ok {
return
}
if ok, err = soEqual(rd.Data[2], cfg.Data3); !ok {
if ok, err = soEqual(v.Data[2], cfg.Data3); !ok {
return
}
case 4:
if ok, err = soGreatEqual(rd.Data[0], cfg.Data1); !ok {
if ok, err = soGreatEqual(v.Data[0], cfg.Data1); !ok {
return
}
if ok, err = soEqual(rd.Data[1], cfg.Data2); !ok {
if ok, err = soEqual(v.Data[1], cfg.Data2); !ok {
return
}
if ok, err = soEqual(rd.Data[2], cfg.Data3); !ok {
if ok, err = soEqual(v.Data[2], cfg.Data3); !ok {
return
}
if ok, err = soEqual(rd.Data[3], cfg.Data4); !ok {
if ok, err = soEqual(v.Data[3], cfg.Data4); !ok {
return
}
case 5:
if ok, err = soGreatEqual(rd.Data[0], cfg.Data1); !ok {
if ok, err = soGreatEqual(v.Data[0], cfg.Data1); !ok {
return
}
if ok, err = soEqual(rd.Data[1], cfg.Data2); !ok {
if ok, err = soEqual(v.Data[1], cfg.Data2); !ok {
return
}
if ok, err = soEqual(rd.Data[2], cfg.Data3); !ok {
if ok, err = soEqual(v.Data[2], cfg.Data3); !ok {
return
}
if ok, err = soEqual(rd.Data[3], cfg.Data4); !ok {
if ok, err = soEqual(v.Data[3], cfg.Data4); !ok {
return
}
if ok, err = soEqual(rd.Data[4], cfg.Data5); !ok {
if ok, err = soEqual(v.Data[4], cfg.Data5); !ok {
return
}
}
}
}
return
}
func (this *ModelRtaskRecord) verifyFirstEqualParam(uid string, cfg *cfg.GameRdtaskCondiData) (ok bool, err error) {
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)
func (this *ModelRtaskRecord) verifyFirstEqualParam(uid string, record *pb.DBRtaskRecord, cfg *cfg.GameRdtaskCondiData) (ok bool, err error) {
if v, f := record.Vals[cfg.Id]; f {
if len(v.Data) == 0 {
err = errors.WithMessagef(err, "玩家参数数据缺失 %v", v.Data)
return
}
return soEqual(rd.Data[0], cfg.Data1)
return soEqual(v.Data[0], cfg.Data1)
}
return
}
func (this *ModelRtaskRecord) verifyFirstGreatEqualParam(uid string, cfg *cfg.GameRdtaskCondiData) (ok bool, err error) {
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)
func (this *ModelRtaskRecord) verifyFirstGreatEqualParam(uid string, record *pb.DBRtaskRecord, cfg *cfg.GameRdtaskCondiData) (ok bool, err error) {
if v, f := record.Vals[cfg.Id]; f {
if len(v.Data) == 0 {
err = errors.WithMessagef(err, "玩家参数数据缺失 %v", v.Data)
return
}
return soGreatEqual(rd.Data[0], cfg.Data1)
return soGreatEqual(v.Data[0], cfg.Data1)
}
return
}
// 英雄指定
func (this *ModelRtask) verfiyRtype1(uid string, cfg *cfg.GameRdtaskCondiData) (ok bool, err error) {
func (this *ModelRtask) verfiyRtype1(uid string, record *pb.DBRtaskRecord, cfg *cfg.GameRdtaskCondiData) (ok bool, err error) {
heroModule, err := this.service.GetModule(comm.ModuleHero)
if err != nil {
return false, err
@ -121,7 +124,8 @@ func (this *ModelRtask) verfiyRtype1(uid string, cfg *cfg.GameRdtaskCondiData) (
}
// 剧情
func (this *ModelRtask) verifyRtype2(uid string, cfg *cfg.GameRdtaskCondiData) (ok bool, err error) {
// Deprecated
func (this *ModelRtask) verifyRtype2(uid string, record *pb.DBRtaskRecord, cfg *cfg.GameRdtaskCondiData) (ok bool, err error) {
m, err := this.service.GetModule(comm.ModuleMline)
if err != nil {
return
@ -135,7 +139,7 @@ func (this *ModelRtask) verifyRtype2(uid string, cfg *cfg.GameRdtaskCondiData) (
}
// 每日任务
func (this *ModelRtask) verifyRtype3(uid string, cfg *cfg.GameRdtaskCondiData) (ok bool, err error) {
func (this *ModelRtask) verifyRtype3(uid string, record *pb.DBRtaskRecord, cfg *cfg.GameRdtaskCondiData) (ok bool, err error) {
m, err := this.service.GetModule(comm.ModuleTask)
if err != nil {
return
@ -153,7 +157,7 @@ func (this *ModelRtask) verifyRtype3(uid string, cfg *cfg.GameRdtaskCondiData) (
}
// 指定英雄等级
func (this *ModelRtask) verifyRtype4(uid string, cfg *cfg.GameRdtaskCondiData) (ok bool, err error) {
func (this *ModelRtask) verifyRtype4(uid string, record *pb.DBRtaskRecord, cfg *cfg.GameRdtaskCondiData) (ok bool, err error) {
m, err := this.service.GetModule(comm.ModuleHero)
if err != nil {
return
@ -180,7 +184,7 @@ func (this *ModelRtask) verifyRtype4(uid string, cfg *cfg.GameRdtaskCondiData) (
}
// 指定英雄的指定装备数量
func (this *ModelRtask) verifyRtype5(uid string, cfg *cfg.GameRdtaskCondiData) (ok bool, err error) {
func (this *ModelRtask) verifyRtype5(uid string, record *pb.DBRtaskRecord, cfg *cfg.GameRdtaskCondiData) (ok bool, err error) {
m, err := this.service.GetModule(comm.ModuleHero)
if err != nil {
return
@ -217,7 +221,7 @@ func (this *ModelRtask) verifyRtype5(uid string, cfg *cfg.GameRdtaskCondiData) (
}
// 指定英雄星级
func (this *ModelRtask) verifyRtype6(uid string, cfg *cfg.GameRdtaskCondiData) (ok bool, err error) {
func (this *ModelRtask) verifyRtype6(uid string, record *pb.DBRtaskRecord, cfg *cfg.GameRdtaskCondiData) (ok bool, err error) {
m, err := this.service.GetModule(comm.ModuleHero)
if err != nil {
return
@ -243,7 +247,7 @@ func (this *ModelRtask) verifyRtype6(uid string, cfg *cfg.GameRdtaskCondiData) (
}
// 日常登录一次
func (this *ModelRtask) verfiyRtype7(uid string, cfg *cfg.GameRdtaskCondiData) (ok bool, err error) {
func (this *ModelRtask) verfiyRtype7(uid string, record *pb.DBRtaskRecord, cfg *cfg.GameRdtaskCondiData) (ok bool, err error) {
userModule, err := this.service.GetModule(comm.ModuleUser)
if err != nil {
return
@ -258,7 +262,7 @@ func (this *ModelRtask) verfiyRtype7(uid string, cfg *cfg.GameRdtaskCondiData) (
}
// 累计登陆xx天
func (this *ModelRtask) verfiyRtype8(uid string, cfg *cfg.GameRdtaskCondiData) (ok bool, err error) {
func (this *ModelRtask) verfiyRtype8(uid string, record *pb.DBRtaskRecord, cfg *cfg.GameRdtaskCondiData) (ok bool, err error) {
userModule, err := this.service.GetModule(comm.ModuleUser)
if err != nil {
return
@ -275,7 +279,7 @@ func (this *ModelRtask) verfiyRtype8(uid string, cfg *cfg.GameRdtaskCondiData) (
}
// 连续登陆xx天
func (this *ModelRtask) verfiyRtype9(uid string, cfg *cfg.GameRdtaskCondiData) (ok bool, err error) {
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 {
return
@ -292,7 +296,7 @@ func (this *ModelRtask) verfiyRtype9(uid string, cfg *cfg.GameRdtaskCondiData) (
}
// 拥有xx个好友
func (this *ModelRtask) verfiyRtype10(uid string, cfg *cfg.GameRdtaskCondiData) (ok bool, err error) {
func (this *ModelRtask) verfiyRtype10(uid string, record *pb.DBRtaskRecord, cfg *cfg.GameRdtaskCondiData) (ok bool, err error) {
m, err := this.service.GetModule(comm.ModuleFriend)
if err != nil {
return
@ -306,7 +310,7 @@ func (this *ModelRtask) verfiyRtype10(uid string, cfg *cfg.GameRdtaskCondiData)
}
// 用户等级达到xx级
func (this *ModelRtask) verifyRtype20(uid string, cfg *cfg.GameRdtaskCondiData) (ok bool, err error) {
func (this *ModelRtask) verifyRtype20(uid string, record *pb.DBRtaskRecord, cfg *cfg.GameRdtaskCondiData) (ok bool, err error) {
userModule, err := this.service.GetModule(comm.ModuleUser)
if err != nil {
return
@ -321,7 +325,7 @@ func (this *ModelRtask) verifyRtype20(uid string, cfg *cfg.GameRdtaskCondiData)
}
// 日常任务活跃度达到xx
func (this *ModelRtask) verifyRtype63(uid string, cfg *cfg.GameRdtaskCondiData) (ok bool, err error) {
func (this *ModelRtask) verifyRtype63(uid string, record *pb.DBRtaskRecord, cfg *cfg.GameRdtaskCondiData) (ok bool, err error) {
userModule, err := this.service.GetModule(comm.ModuleUser)
if err != nil {
return

View File

@ -1,71 +0,0 @@
package rtask
import (
"fmt"
"go_dreamfactory/pb"
cfg "go_dreamfactory/sys/configure/structs"
"reflect"
"testing"
"github.com/agiledragon/gomonkey/v2"
. "github.com/smartystreets/goconvey/convey"
)
var vals []int32 //通过接口传入的参数组
var conf *cfg.GameRdtaskCondiData
func TestVerify(t *testing.T) {
Convey("校验处理器测试", t, func() {
Convey("校验接口参数组", func() {
patches := gomonkey.ApplyGlobalVar(&conf, &cfg.GameRdtaskCondiData{
Id: 101,
Type: 1,
Data1: 25001,
})
defer patches.Reset()
patches2 := gomonkey.ApplyGlobalVar(&vals, []int32{25002})
defer patches2.Reset()
n, err := lenParam(conf, vals...)
fmt.Println(n, err)
})
})
}
func TestVerify2(t *testing.T) {
Convey("校验处理测试", t, func() {
Convey("rtype1", func() {
var r *ModelRtask
// 修改
patches := gomonkey.ApplyMethod(reflect.TypeOf(r), "GetVerifyData", func(_ *ModelRtask, uid string, condiId int32) (*pb.RtaskData, error) {
return &pb.RtaskData{
Data: map[int32]int32{0: 25001},
}, nil
})
defer patches.Reset()
//
rtask := &ModelRtaskRecord{}
conf := &cfg.GameRdtaskCondiData{
Id: 101,
Type: 1,
Data1: 25001,
}
err, ok := rtask.verifyFromDb("11", conf)
So(err, ShouldEqual, nil)
So(ok, ShouldEqual, true)
//模拟接口参数传入
patches3 := gomonkey.ApplyGlobalVar(&vals, []int32{25001})
defer patches3.Reset()
condiId, _ := rtask.equalParams(conf, vals...)
So(condiId, ShouldEqual, 101)
})
})
}

View File

@ -141,7 +141,6 @@ func (this *apiComp) Login(session comm.IUserSession, req *pb.UserLoginReq) (cod
this.module.RecoverUserPsStart(user.Uid)
// 日常登录任务
// this.module.ModuleRtask.SendToRtask(session, comm.Rtype8, 1)
go this.module.ModuleRtask.TriggerTask(session.GetUserId(), comm.GettaskParam(comm.Rtype8, 1))
this.module.ModulePrivilege.CheckDailyPrivilegeMail(session)

View File

@ -951,7 +951,7 @@ func (this *User) BingoSetUserVipLv(session comm.IUserSession, lv int32) error {
return nil
}
//添加用户皮肤数据
// 添加用户皮肤数据
func (this *User) AddPer(session comm.IUserSession, pers map[string]int32, bPush bool) (code pb.ErrorCode) {
var (
err error

View File

@ -105,8 +105,9 @@ type RtaskTestResp struct {
sizeCache protoimpl.SizeCache
unknownFields protoimpl.UnknownFields
Flag bool `protobuf:"varint,1,opt,name=flag,proto3" json:"flag"`
RtaskIds []int32 `protobuf:"varint,2,rep,packed,name=rtaskIds,proto3" json:"rtaskIds"`
Flag bool `protobuf:"varint,1,opt,name=flag,proto3" json:"flag"`
RtaskIds []int32 `protobuf:"varint,2,rep,packed,name=rtaskIds,proto3" json:"rtaskIds"`
RtaskType int32 `protobuf:"varint,3,opt,name=rtaskType,proto3" json:"rtaskType"`
}
func (x *RtaskTestResp) Reset() {
@ -155,6 +156,13 @@ func (x *RtaskTestResp) GetRtaskIds() []int32 {
return nil
}
func (x *RtaskTestResp) GetRtaskType() int32 {
if x != nil {
return x.RtaskType
}
return 0
}
var File_rtask_rtask_msg_proto protoreflect.FileDescriptor
var file_rtask_rtask_msg_proto_rawDesc = []byte{
@ -168,12 +176,14 @@ var file_rtask_rtask_msg_proto_rawDesc = []byte{
0x07, 0x63, 0x6f, 0x6e, 0x64, 0x69, 0x49, 0x64, 0x12, 0x18, 0x0a, 0x07, 0x67, 0x72, 0x6f, 0x75,
0x70, 0x49, 0x64, 0x18, 0x04, 0x20, 0x01, 0x28, 0x05, 0x52, 0x07, 0x67, 0x72, 0x6f, 0x75, 0x70,
0x49, 0x64, 0x12, 0x1a, 0x0a, 0x08, 0x72, 0x74, 0x61, 0x73, 0x6b, 0x49, 0x64, 0x73, 0x18, 0x05,
0x20, 0x01, 0x28, 0x09, 0x52, 0x08, 0x72, 0x74, 0x61, 0x73, 0x6b, 0x49, 0x64, 0x73, 0x22, 0x3f,
0x20, 0x01, 0x28, 0x09, 0x52, 0x08, 0x72, 0x74, 0x61, 0x73, 0x6b, 0x49, 0x64, 0x73, 0x22, 0x5d,
0x0a, 0x0d, 0x52, 0x74, 0x61, 0x73, 0x6b, 0x54, 0x65, 0x73, 0x74, 0x52, 0x65, 0x73, 0x70, 0x12,
0x12, 0x0a, 0x04, 0x66, 0x6c, 0x61, 0x67, 0x18, 0x01, 0x20, 0x01, 0x28, 0x08, 0x52, 0x04, 0x66,
0x6c, 0x61, 0x67, 0x12, 0x1a, 0x0a, 0x08, 0x72, 0x74, 0x61, 0x73, 0x6b, 0x49, 0x64, 0x73, 0x18,
0x02, 0x20, 0x03, 0x28, 0x05, 0x52, 0x08, 0x72, 0x74, 0x61, 0x73, 0x6b, 0x49, 0x64, 0x73, 0x42,
0x06, 0x5a, 0x04, 0x2e, 0x3b, 0x70, 0x62, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33,
0x02, 0x20, 0x03, 0x28, 0x05, 0x52, 0x08, 0x72, 0x74, 0x61, 0x73, 0x6b, 0x49, 0x64, 0x73, 0x12,
0x1c, 0x0a, 0x09, 0x72, 0x74, 0x61, 0x73, 0x6b, 0x54, 0x79, 0x70, 0x65, 0x18, 0x03, 0x20, 0x01,
0x28, 0x05, 0x52, 0x09, 0x72, 0x74, 0x61, 0x73, 0x6b, 0x54, 0x79, 0x70, 0x65, 0x42, 0x06, 0x5a,
0x04, 0x2e, 0x3b, 0x70, 0x62, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33,
}
var (