This commit is contained in:
meixiongfeng 2023-05-24 16:27:37 +08:00
commit 458c2347a6
15 changed files with 326 additions and 720 deletions

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

@ -221,6 +221,8 @@ type (
IRtask interface {
// 条件校验
CheckCondi(uid string, condiId int32) (code pb.ErrorCode)
// 多条件校验
CheckCondis(uid string, condiIds ...int32) (condIds []int32)
// 远程任务条件校验
RemoteCheckCondi(uid string, condiId int32, rsp *pb.DBRtaskRecord) error
// 删除任务条件数据

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

@ -1,286 +0,0 @@
package rtask
import (
cfg "go_dreamfactory/sys/configure/structs"
"github.com/pkg/errors"
)
func (this *ModelRtaskRecord) equalFirstParam(cfg *cfg.GameRdtaskCondiData, vals ...int32) (condiId int32, err error) {
//只查询参数于配置相等的情况下设置condiId否则返回0
if ok, err1 := soEqual(vals[0], cfg.Data1); !ok {
err = errors.WithMessagef(err1, "id: %v type:%v vals:%v", cfg.Id, cfg.Type, vals)
return
}
condiId = cfg.Id
return
}
func (this *ModelRtaskRecord) greatEqualFirstParam(cfg *cfg.GameRdtaskCondiData, vals ...int32) (condiId int32, err error) {
if ok, err1 := soGreatEqual(vals[0], cfg.Data1); !ok {
err = errors.WithMessagef(err1, "id: %v type:%v vals:%v", cfg.Id, cfg.Type, vals)
return
}
condiId = cfg.Id
return
}
// 传递参数小于等于配置参数
// 适合只比较首个参数(一个参数)
func (this *ModelRtaskRecord) lessEqualFirstParam(cfg *cfg.GameRdtaskCondiData, vals ...int32) (condiId int32, err error) {
if ok, err1 := soLessEqual(vals[0], cfg.Data1); !ok {
err = errors.WithMessagef(err1, "id: %v type:%v vals:%v", cfg.Id, cfg.Type, vals)
return
}
condiId = cfg.Id
return
}
// 与每个参数比较
func (this *ModelRtaskRecord) equalParams(cfg *cfg.GameRdtaskCondiData, vals ...int32) (condiId int32, err error) {
var (
paramLen int
)
if paramLen, err = lenParam(cfg, vals...); err != nil {
return
}
switch paramLen {
case 1:
if ok, err1 := soEqual(vals[0], cfg.Data1); !ok {
err = errors.WithMessagef(err1, "id: %v type:%v vals:%v", cfg.Id, cfg.Type, vals)
return
}
case 2:
if ok, err1 := soEqual(vals[0], cfg.Data1); !ok {
err = errors.WithMessagef(err1, "id: %v type:%v vals:%v", cfg.Id, cfg.Type, vals)
return
}
if ok, err1 := soEqual(vals[1], cfg.Data2); !ok {
err = errors.WithMessagef(err1, "id: %v type:%v vals:%v", cfg.Id, cfg.Type, vals)
return
}
case 3:
if ok, err1 := soEqual(vals[0], cfg.Data1); !ok {
err = errors.WithMessagef(err1, "id: %v type:%v vals:%v", cfg.Id, cfg.Type, vals)
return
}
if ok, err1 := soEqual(vals[1], cfg.Data2); !ok {
err = errors.WithMessagef(err1, "id: %v type:%v vals:%v", cfg.Id, cfg.Type, vals)
return
}
if ok, err1 := soEqual(vals[2], cfg.Data3); !ok {
err = errors.WithMessagef(err1, "id: %v type:%v vals:%v", cfg.Id, cfg.Type, vals)
return
}
case 4:
if ok, err1 := soEqual(vals[0], cfg.Data1); !ok {
err = errors.WithMessagef(err1, "id: %v type:%v vals:%v", cfg.Id, cfg.Type, vals)
return
}
if ok, err1 := soEqual(vals[1], cfg.Data2); !ok {
err = errors.WithMessagef(err1, "id: %v type:%v vals:%v", cfg.Id, cfg.Type, vals)
return
}
if ok, err1 := soEqual(vals[2], cfg.Data3); !ok {
err = errors.WithMessagef(err1, "id: %v type:%v vals:%v", cfg.Id, cfg.Type, vals)
return
}
if ok, err1 := soEqual(vals[3], cfg.Data4); !ok {
err = errors.WithMessagef(err1, "id: %v type:%v vals:%v", cfg.Id, cfg.Type, vals)
return
}
case 5:
if ok, err1 := soEqual(vals[0], cfg.Data1); !ok {
err = errors.WithMessagef(err1, "id: %v type:%v vals:%v", cfg.Id, cfg.Type, vals)
return
}
if ok, err1 := soEqual(vals[1], cfg.Data2); !ok {
err = errors.WithMessagef(err1, "id: %v type:%v vals:%v", cfg.Id, cfg.Type, vals)
return
}
if ok, err1 := soEqual(vals[2], cfg.Data3); !ok {
err = errors.WithMessagef(err1, "id: %v type:%v vals:%v", cfg.Id, cfg.Type, vals)
return
}
if ok, err1 := soEqual(vals[3], cfg.Data4); !ok {
err = errors.WithMessagef(err1, "id: %v type:%v vals:%v", cfg.Id, cfg.Type, vals)
return
}
if ok, err1 := soEqual(vals[4], cfg.Data5); !ok {
err = errors.WithMessagef(err1, "id: %v type:%v vals:%v", cfg.Id, cfg.Type, vals)
return
}
default:
return
}
condiId = cfg.Id
return
}
func (this *ModelRtaskRecord) greatThanParams(cfg *cfg.GameRdtaskCondiData, vals ...int32) (condiId int32, err error) {
var (
paramLen int
)
if paramLen, err = lenParam(cfg, vals...); err != nil {
return
}
switch paramLen {
case 1:
if ok, err1 := soGreatEqual(vals[0], cfg.Data1); !ok {
err = errors.WithMessagef(err1, "id: %v type:%v vals:%v", cfg.Id, cfg.Type, vals)
return
}
case 2:
if ok, err1 := soGreatEqual(vals[0], cfg.Data1); !ok {
err = errors.WithMessagef(err1, "id: %v type:%v vals:%v", cfg.Id, cfg.Type, vals)
return
}
if ok, err1 := soGreatEqual(vals[1], cfg.Data2); !ok {
err = errors.WithMessagef(err1, "id: %v type:%v vals:%v", cfg.Id, cfg.Type, vals)
return
}
case 3:
if ok, err1 := soGreatEqual(vals[0], cfg.Data1); !ok {
err = errors.WithMessagef(err1, "id: %v type:%v vals:%v", cfg.Id, cfg.Type, vals)
return
}
if ok, err1 := soGreatEqual(vals[1], cfg.Data2); !ok {
err = errors.WithMessagef(err1, "id: %v type:%v vals:%v", cfg.Id, cfg.Type, vals)
return
}
if ok, err1 := soGreatEqual(vals[2], cfg.Data3); !ok {
err = errors.WithMessagef(err1, "id: %v type:%v vals:%v", cfg.Id, cfg.Type, vals)
return
}
case 4:
if ok, err1 := soGreatEqual(vals[0], cfg.Data1); !ok {
err = errors.WithMessagef(err1, "id: %v type:%v vals:%v", cfg.Id, cfg.Type, vals)
return
}
if ok, err1 := soGreatEqual(vals[1], cfg.Data2); !ok {
err = errors.WithMessagef(err1, "id: %v type:%v vals:%v", cfg.Id, cfg.Type, vals)
return
}
if ok, err1 := soGreatEqual(vals[2], cfg.Data3); !ok {
err = errors.WithMessagef(err1, "id: %v type:%v vals:%v", cfg.Id, cfg.Type, vals)
return
}
if ok, err1 := soGreatEqual(vals[3], cfg.Data4); !ok {
err = errors.WithMessagef(err1, "id: %v type:%v vals:%v", cfg.Id, cfg.Type, vals)
return
}
case 5:
if ok, err1 := soGreatEqual(vals[0], cfg.Data1); !ok {
err = errors.WithMessagef(err1, "id: %v type:%v vals:%v", cfg.Id, cfg.Type, vals)
return
}
if ok, err1 := soGreatEqual(vals[1], cfg.Data2); !ok {
err = errors.WithMessagef(err1, "id: %v type:%v vals:%v", cfg.Id, cfg.Type, vals)
return
}
if ok, err1 := soGreatEqual(vals[2], cfg.Data3); !ok {
err = errors.WithMessagef(err1, "id: %v type:%v vals:%v", cfg.Id, cfg.Type, vals)
return
}
if ok, err1 := soGreatEqual(vals[3], cfg.Data4); !ok {
err = errors.WithMessagef(err1, "id: %v type:%v vals:%v", cfg.Id, cfg.Type, vals)
return
}
if ok, err1 := soGreatEqual(vals[4], cfg.Data5); !ok {
err = errors.WithMessagef(err1, "id: %v type:%v vals:%v", cfg.Id, cfg.Type, vals)
return
}
default:
return
}
condiId = cfg.Id
return
}
// 需要累加更新的查询
func (this *ModelRtaskRecord) lessThanParams(cfg *cfg.GameRdtaskCondiData, vals ...int32) (condiId int32, err error) {
var (
paramLen int
)
if paramLen, err = lenParam(cfg, vals...); err != nil {
return
}
switch paramLen {
case 1:
if ok, err1 := soLessEqual(vals[0], cfg.Data1); !ok {
err = errors.WithMessagef(err1, "id: %v type:%v vals:%v", cfg.Id, cfg.Type, vals)
return
}
case 2:
if ok, err1 := soLessEqual(vals[0], cfg.Data1); !ok {
err = errors.WithMessagef(err1, "id: %v type:%v vals:%v", cfg.Id, cfg.Type, vals)
return
}
if ok, err1 := soGreatEqual(vals[1], cfg.Data2); !ok {
err = errors.WithMessagef(err1, "id: %v type:%v vals:%v", cfg.Id, cfg.Type, vals)
return
}
case 3:
if ok, err1 := soLessEqual(vals[0], cfg.Data1); !ok {
err = errors.WithMessagef(err1, "id: %v type:%v vals:%v", cfg.Id, cfg.Type, vals)
return
}
if ok, err1 := soGreatEqual(vals[1], cfg.Data2); !ok {
err = errors.WithMessagef(err1, "id: %v type:%v vals:%v", cfg.Id, cfg.Type, vals)
return
}
if ok, err1 := soGreatEqual(vals[2], cfg.Data3); !ok {
err = errors.WithMessagef(err1, "id: %v type:%v vals:%v", cfg.Id, cfg.Type, vals)
return
}
case 4:
if ok, err1 := soLessEqual(vals[0], cfg.Data1); !ok {
err = errors.WithMessagef(err1, "id: %v type:%v vals:%v", cfg.Id, cfg.Type, vals)
return
}
if ok, err1 := soGreatEqual(vals[1], cfg.Data2); !ok {
err = errors.WithMessagef(err1, "id: %v type:%v vals:%v", cfg.Id, cfg.Type, vals)
return
}
if ok, err1 := soGreatEqual(vals[2], cfg.Data3); !ok {
err = errors.WithMessagef(err1, "id: %v type:%v vals:%v", cfg.Id, cfg.Type, vals)
return
}
if ok, err1 := soGreatEqual(vals[3], cfg.Data4); !ok {
err = errors.WithMessagef(err1, "id: %v type:%v vals:%v", cfg.Id, cfg.Type, vals)
return
}
case 5:
if ok, err1 := soLessEqual(vals[0], cfg.Data1); !ok {
err = errors.WithMessagef(err1, "id: %v type:%v vals:%v", cfg.Id, cfg.Type, vals)
return
}
if ok, err1 := soGreatEqual(vals[1], cfg.Data2); !ok {
err = errors.WithMessagef(err1, "id: %v type:%v vals:%v", cfg.Id, cfg.Type, vals)
return
}
if ok, err1 := soGreatEqual(vals[2], cfg.Data3); !ok {
err = errors.WithMessagef(err1, "id: %v type:%v vals:%v", cfg.Id, cfg.Type, vals)
return
}
if ok, err1 := soGreatEqual(vals[3], cfg.Data4); !ok {
err = errors.WithMessagef(err1, "id: %v type:%v vals:%v", cfg.Id, cfg.Type, vals)
return
}
if ok, err1 := soGreatEqual(vals[4], cfg.Data5); !ok {
err = errors.WithMessagef(err1, "id: %v type:%v vals:%v", cfg.Id, cfg.Type, vals)
return
}
default:
return
}
condiId = cfg.Id
return
}

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

@ -26,12 +26,12 @@ var _ comm.IRtask = (*ModuleRtask)(nil)
type rtaskCondHandle struct {
condId int32 //任务条件配置ID
verify verifyHandle //校验任务条件
find condiFindHandle //检索任务条件
update updateDataHandle //更新任务数据
}
type verifyHandle func(uid string, cfg *cfg.GameRdtaskCondiData) (bool, error)
type condiFindHandle func(cfg *cfg.GameRdtaskCondiData, vals ...int32) (int32, error)
// 任务参数校验
type verifyHandle func(uid string, record *pb.DBRtaskRecord, cfg *cfg.GameRdtaskCondiData) (bool, error)
// 任务数据更新
type updateDataHandle func(uid string, record *pb.DBRtaskRecord, cfg *cfg.GameRdtaskCondiData, vals ...int32) error
type ModuleRtask struct {
@ -75,193 +75,117 @@ 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.modelRtask.verfiyRtype1,
verify: this.modelRtaskRecord.verifyGreatEqual,
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)
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)
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)
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,
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:
condi := &rtaskCondHandle{
comm.Rtype171, comm.Rtype186, comm.Rtype187:
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)
case comm.Rtype22, comm.Rtype109:
condi := &rtaskCondHandle{
handles = append(handles, handle)
this.registerVerifyHandle(v.Id, handle)
case comm.Rtype109:
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)
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)
handles = append(handles, handle)
this.registerVerifyHandle(v.Id, handle)
case comm.Rtype16, comm.Rtype17,
comm.Rtype35, comm.Rtype44,
comm.Rtype59, comm.Rtype61:
condi := &rtaskCondHandle{
comm.Rtype35, comm.Rtype61:
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)
case comm.Rtype23, comm.Rtype25, comm.Rtype29, comm.Rtype30, comm.Rtype31,
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,
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{
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
@ -410,10 +334,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,103 @@ 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)
// 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
}
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 +125,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 +140,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 +158,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 +185,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 +222,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 +248,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 +263,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
@ -274,8 +279,8 @@ func (this *ModelRtask) verfiyRtype8(uid string, cfg *cfg.GameRdtaskCondiData) (
return
}
// 连续登陆xx天
func (this *ModelRtask) verfiyRtype9(uid string, cfg *cfg.GameRdtaskCondiData) (ok bool, err error) {
// 连续登陆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 {
return
@ -292,7 +297,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 +311,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 +326,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

@ -107,6 +107,7 @@ type RtaskTestResp struct {
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 (