修改任务接口

This commit is contained in:
wh_zcy 2023-05-24 23:59:02 +08:00
parent 46ec141a48
commit bbf8a2d57c
7 changed files with 310 additions and 242 deletions

View File

@ -367,8 +367,8 @@
"type": 22, "type": 22,
"valid": 0, "valid": 0,
"NPC": 0, "NPC": 0,
"data1": 25001, "data1": 1,
"data2": 0, "data2": 25001,
"data3": 0, "data3": 0,
"data4": 0, "data4": 0,
"data5": 0 "data5": 0
@ -487,8 +487,8 @@
"valid": 0, "valid": 0,
"NPC": 0, "NPC": 0,
"data1": 2, "data1": 2,
"data2": 22, "data2": 25004,
"data3": 25004, "data3": 22,
"data4": 0, "data4": 0,
"data5": 0 "data5": 0
}, },
@ -1030,8 +1030,8 @@
"type": 61, "type": 61,
"valid": 0, "valid": 0,
"NPC": 105, "NPC": 105,
"data1": 1100105, "data1": 1,
"data2": 0, "data2": 1100105,
"data3": 0, "data3": 0,
"data4": 0, "data4": 0,
"data5": 0 "data5": 0
@ -1744,8 +1744,8 @@
"type": 61, "type": 61,
"valid": 0, "valid": 0,
"NPC": 29, "NPC": 29,
"data1": 1100101, "data1": 1,
"data2": 0, "data2": 1100101,
"data3": 0, "data3": 0,
"data4": 0, "data4": 0,
"data5": 0 "data5": 0
@ -1761,8 +1761,8 @@
"type": 61, "type": 61,
"valid": 0, "valid": 0,
"NPC": 0, "NPC": 0,
"data1": 104, "data1": 1,
"data2": 0, "data2": 104,
"data3": 0, "data3": 0,
"data4": 0, "data4": 0,
"data5": 0 "data5": 0
@ -1778,8 +1778,8 @@
"type": 61, "type": 61,
"valid": 0, "valid": 0,
"NPC": 0, "NPC": 0,
"data1": 108, "data1": 1,
"data2": 0, "data2": 108,
"data3": 0, "data3": 0,
"data4": 0, "data4": 0,
"data5": 0 "data5": 0
@ -1812,8 +1812,8 @@
"type": 61, "type": 61,
"valid": 0, "valid": 0,
"NPC": 105, "NPC": 105,
"data1": 1100106, "data1": 1,
"data2": 0, "data2": 1100106,
"data3": 0, "data3": 0,
"data4": 0, "data4": 0,
"data5": 0 "data5": 0
@ -6334,8 +6334,8 @@
"type": 61, "type": 61,
"valid": 0, "valid": 0,
"NPC": 10191, "NPC": 10191,
"data1": 1100206, "data1": 1,
"data2": 0, "data2": 1100206,
"data3": 0, "data3": 0,
"data4": 0, "data4": 0,
"data5": 0 "data5": 0
@ -6419,8 +6419,8 @@
"type": 61, "type": 61,
"valid": 0, "valid": 0,
"NPC": 10241, "NPC": 10241,
"data1": 1100301, "data1": 1,
"data2": 0, "data2": 1100301,
"data3": 0, "data3": 0,
"data4": 0, "data4": 0,
"data5": 0 "data5": 0
@ -6436,8 +6436,8 @@
"type": 61, "type": 61,
"valid": 0, "valid": 0,
"NPC": 10251, "NPC": 10251,
"data1": 1100306, "data1": 1,
"data2": 0, "data2": 1100306,
"data3": 0, "data3": 0,
"data4": 0, "data4": 0,
"data5": 0 "data5": 0
@ -6504,8 +6504,8 @@
"type": 61, "type": 61,
"valid": 0, "valid": 0,
"NPC": 10291, "NPC": 10291,
"data1": 1100406, "data1": 1,
"data2": 0, "data2": 1100406,
"data3": 0, "data3": 0,
"data4": 0, "data4": 0,
"data5": 0 "data5": 0
@ -6589,8 +6589,8 @@
"type": 61, "type": 61,
"valid": 0, "valid": 0,
"NPC": 10341, "NPC": 10341,
"data1": 1100506, "data1": 1,
"data2": 0, "data2": 1100506,
"data3": 0, "data3": 0,
"data4": 0, "data4": 0,
"data5": 0 "data5": 0
@ -6708,8 +6708,8 @@
"type": 61, "type": 61,
"valid": 0, "valid": 0,
"NPC": 10411, "NPC": 10411,
"data1": 1100606, "data1": 1,
"data2": 0, "data2": 1100606,
"data3": 0, "data3": 0,
"data4": 0, "data4": 0,
"data5": 0 "data5": 0
@ -6793,8 +6793,8 @@
"type": 61, "type": 61,
"valid": 0, "valid": 0,
"NPC": 10461, "NPC": 10461,
"data1": 1100706, "data1": 1,
"data2": 0, "data2": 1100706,
"data3": 0, "data3": 0,
"data4": 0, "data4": 0,
"data5": 0 "data5": 0
@ -6844,8 +6844,8 @@
"type": 61, "type": 61,
"valid": 0, "valid": 0,
"NPC": 10491, "NPC": 10491,
"data1": 1100806, "data1": 1,
"data2": 0, "data2": 1100806,
"data3": 0, "data3": 0,
"data4": 0, "data4": 0,
"data5": 0 "data5": 0
@ -6895,8 +6895,8 @@
"type": 61, "type": 61,
"valid": 0, "valid": 0,
"NPC": 10521, "NPC": 10521,
"data1": 1100906, "data1": 1,
"data2": 0, "data2": 1100906,
"data3": 0, "data3": 0,
"data4": 0, "data4": 0,
"data5": 0 "data5": 0
@ -6929,8 +6929,8 @@
"type": 61, "type": 61,
"valid": 0, "valid": 0,
"NPC": 10541, "NPC": 10541,
"data1": 11001006, "data1": 1,
"data2": 0, "data2": 11001006,
"data3": 0, "data3": 0,
"data4": 0, "data4": 0,
"data5": 0 "data5": 0
@ -6980,8 +6980,8 @@
"type": 61, "type": 61,
"valid": 0, "valid": 0,
"NPC": 10571, "NPC": 10571,
"data1": 11001106, "data1": 1,
"data2": 0, "data2": 11001106,
"data3": 0, "data3": 0,
"data4": 0, "data4": 0,
"data5": 0 "data5": 0
@ -7014,8 +7014,8 @@
"type": 61, "type": 61,
"valid": 0, "valid": 0,
"NPC": 10591, "NPC": 10591,
"data1": 11001206, "data1": 1,
"data2": 0, "data2": 11001206,
"data3": 0, "data3": 0,
"data4": 0, "data4": 0,
"data5": 0 "data5": 0
@ -7031,8 +7031,8 @@
"type": 61, "type": 61,
"valid": 0, "valid": 0,
"NPC": 10601, "NPC": 10601,
"data1": 1200103, "data1": 1,
"data2": 0, "data2": 1200103,
"data3": 0, "data3": 0,
"data4": 0, "data4": 0,
"data5": 0 "data5": 0
@ -7048,8 +7048,8 @@
"type": 61, "type": 61,
"valid": 0, "valid": 0,
"NPC": 10611, "NPC": 10611,
"data1": 1200106, "data1": 1,
"data2": 0, "data2": 1200106,
"data3": 0, "data3": 0,
"data4": 0, "data4": 0,
"data5": 0 "data5": 0
@ -7065,8 +7065,8 @@
"type": 61, "type": 61,
"valid": 0, "valid": 0,
"NPC": 10621, "NPC": 10621,
"data1": 1200203, "data1": 1,
"data2": 0, "data2": 1200203,
"data3": 0, "data3": 0,
"data4": 0, "data4": 0,
"data5": 0 "data5": 0
@ -7082,8 +7082,8 @@
"type": 61, "type": 61,
"valid": 0, "valid": 0,
"NPC": 10631, "NPC": 10631,
"data1": 1200206, "data1": 1,
"data2": 0, "data2": 1200206,
"data3": 0, "data3": 0,
"data4": 0, "data4": 0,
"data5": 0 "data5": 0
@ -7099,8 +7099,8 @@
"type": 61, "type": 61,
"valid": 0, "valid": 0,
"NPC": 10641, "NPC": 10641,
"data1": 1200303, "data1": 1,
"data2": 0, "data2": 1200303,
"data3": 0, "data3": 0,
"data4": 0, "data4": 0,
"data5": 0 "data5": 0
@ -7116,8 +7116,8 @@
"type": 61, "type": 61,
"valid": 0, "valid": 0,
"NPC": 10651, "NPC": 10651,
"data1": 1200306, "data1": 1,
"data2": 0, "data2": 1200306,
"data3": 0, "data3": 0,
"data4": 0, "data4": 0,
"data5": 0 "data5": 0
@ -7133,8 +7133,8 @@
"type": 61, "type": 61,
"valid": 0, "valid": 0,
"NPC": 10661, "NPC": 10661,
"data1": 1200403, "data1": 1,
"data2": 0, "data2": 1200403,
"data3": 0, "data3": 0,
"data4": 0, "data4": 0,
"data5": 0 "data5": 0
@ -7150,8 +7150,8 @@
"type": 61, "type": 61,
"valid": 0, "valid": 0,
"NPC": 10671, "NPC": 10671,
"data1": 1200406, "data1": 1,
"data2": 0, "data2": 1200406,
"data3": 0, "data3": 0,
"data4": 0, "data4": 0,
"data5": 0 "data5": 0
@ -7167,8 +7167,8 @@
"type": 61, "type": 61,
"valid": 0, "valid": 0,
"NPC": 10681, "NPC": 10681,
"data1": 1200503, "data1": 1,
"data2": 0, "data2": 1200503,
"data3": 0, "data3": 0,
"data4": 0, "data4": 0,
"data5": 0 "data5": 0
@ -7184,8 +7184,8 @@
"type": 61, "type": 61,
"valid": 0, "valid": 0,
"NPC": 10691, "NPC": 10691,
"data1": 1200506, "data1": 1,
"data2": 0, "data2": 1200506,
"data3": 0, "data3": 0,
"data4": 0, "data4": 0,
"data5": 0 "data5": 0
@ -7201,8 +7201,8 @@
"type": 61, "type": 61,
"valid": 0, "valid": 0,
"NPC": 10701, "NPC": 10701,
"data1": 1200603, "data1": 1,
"data2": 0, "data2": 1200603,
"data3": 0, "data3": 0,
"data4": 0, "data4": 0,
"data5": 0 "data5": 0
@ -7218,8 +7218,8 @@
"type": 61, "type": 61,
"valid": 0, "valid": 0,
"NPC": 10711, "NPC": 10711,
"data1": 1200606, "data1": 1,
"data2": 0, "data2": 1200606,
"data3": 0, "data3": 0,
"data4": 0, "data4": 0,
"data5": 0 "data5": 0
@ -7235,8 +7235,8 @@
"type": 61, "type": 61,
"valid": 0, "valid": 0,
"NPC": 10721, "NPC": 10721,
"data1": 1200703, "data1": 1,
"data2": 0, "data2": 1200703,
"data3": 0, "data3": 0,
"data4": 0, "data4": 0,
"data5": 0 "data5": 0
@ -7252,8 +7252,8 @@
"type": 61, "type": 61,
"valid": 0, "valid": 0,
"NPC": 10731, "NPC": 10731,
"data1": 1200706, "data1": 1,
"data2": 0, "data2": 1200706,
"data3": 0, "data3": 0,
"data4": 0, "data4": 0,
"data5": 0 "data5": 0
@ -7269,8 +7269,8 @@
"type": 61, "type": 61,
"valid": 0, "valid": 0,
"NPC": 10741, "NPC": 10741,
"data1": 1200803, "data1": 1,
"data2": 0, "data2": 1200803,
"data3": 0, "data3": 0,
"data4": 0, "data4": 0,
"data5": 0 "data5": 0
@ -7286,8 +7286,8 @@
"type": 61, "type": 61,
"valid": 0, "valid": 0,
"NPC": 10751, "NPC": 10751,
"data1": 1200806, "data1": 1,
"data2": 0, "data2": 1200806,
"data3": 0, "data3": 0,
"data4": 0, "data4": 0,
"data5": 0 "data5": 0
@ -7303,8 +7303,8 @@
"type": 61, "type": 61,
"valid": 0, "valid": 0,
"NPC": 10761, "NPC": 10761,
"data1": 1200903, "data1": 1,
"data2": 0, "data2": 1200903,
"data3": 0, "data3": 0,
"data4": 0, "data4": 0,
"data5": 0 "data5": 0
@ -7320,8 +7320,8 @@
"type": 61, "type": 61,
"valid": 0, "valid": 0,
"NPC": 10771, "NPC": 10771,
"data1": 1200906, "data1": 1,
"data2": 0, "data2": 1200906,
"data3": 0, "data3": 0,
"data4": 0, "data4": 0,
"data5": 0 "data5": 0
@ -7337,8 +7337,8 @@
"type": 61, "type": 61,
"valid": 0, "valid": 0,
"NPC": 10781, "NPC": 10781,
"data1": 12001003, "data1": 1,
"data2": 0, "data2": 12001003,
"data3": 0, "data3": 0,
"data4": 0, "data4": 0,
"data5": 0 "data5": 0
@ -7354,8 +7354,8 @@
"type": 61, "type": 61,
"valid": 0, "valid": 0,
"NPC": 10791, "NPC": 10791,
"data1": 12001006, "data1": 1,
"data2": 0, "data2": 12001006,
"data3": 0, "data3": 0,
"data4": 0, "data4": 0,
"data5": 0 "data5": 0
@ -7371,8 +7371,8 @@
"type": 61, "type": 61,
"valid": 0, "valid": 0,
"NPC": 10801, "NPC": 10801,
"data1": 12001103, "data1": 1,
"data2": 0, "data2": 12001103,
"data3": 0, "data3": 0,
"data4": 0, "data4": 0,
"data5": 0 "data5": 0
@ -7388,8 +7388,8 @@
"type": 61, "type": 61,
"valid": 0, "valid": 0,
"NPC": 10811, "NPC": 10811,
"data1": 12001106, "data1": 1,
"data2": 0, "data2": 12001106,
"data3": 0, "data3": 0,
"data4": 0, "data4": 0,
"data5": 0 "data5": 0
@ -7405,8 +7405,8 @@
"type": 61, "type": 61,
"valid": 0, "valid": 0,
"NPC": 10821, "NPC": 10821,
"data1": 12001203, "data1": 1,
"data2": 0, "data2": 12001203,
"data3": 0, "data3": 0,
"data4": 0, "data4": 0,
"data5": 0 "data5": 0
@ -7422,8 +7422,8 @@
"type": 61, "type": 61,
"valid": 0, "valid": 0,
"NPC": 10831, "NPC": 10831,
"data1": 12001206, "data1": 1,
"data2": 0, "data2": 12001206,
"data3": 0, "data3": 0,
"data4": 0, "data4": 0,
"data5": 0 "data5": 0
@ -11060,8 +11060,8 @@
"type": 61, "type": 61,
"valid": 0, "valid": 0,
"NPC": 0, "NPC": 0,
"data1": 1100105, "data1": 1,
"data2": 0, "data2": 1100105,
"data3": 0, "data3": 0,
"data4": 0, "data4": 0,
"data5": 0 "data5": 0

View File

@ -140,7 +140,8 @@ func (this *RtaskTestView) CreateView(t *model.TestCase) fyne.CanvasObject {
}() }()
go func() { go func() {
if this.resultCount == 0 { var flag bool
for this.resultCount == 0 && flag {
logrus.Debug("结束") logrus.Debug("结束")
record := strings.Join(this.msgs, "\n") record := strings.Join(this.msgs, "\n")
@ -158,6 +159,7 @@ func (this *RtaskTestView) CreateView(t *model.TestCase) fyne.CanvasObject {
if _, err := file.WriteString(buf.String()); err != nil { if _, err := file.WriteString(buf.String()); err != nil {
logrus.Error(err) logrus.Error(err)
} }
flag = true
} }
}() }()
} }

View File

@ -222,7 +222,7 @@ type (
// 随机任务 // 随机任务
IRtask interface { IRtask interface {
// 条件校验 // 条件校验
CheckCondi(uid string, condiId int32) (code pb.ErrorCode) CheckCondi(uid string, condiId int32, p ...int32) (code pb.ErrorCode)
// 多条件校验 // 多条件校验
CheckCondis(uid string, condiIds ...int32) (condIds []int32) CheckCondis(uid string, condiIds ...int32) (condIds []int32)
// 远程任务条件校验 // 远程任务条件校验

View File

@ -75,6 +75,7 @@ func (this *ModelRtaskRecord) getRecord(uid string) *pb.DBRtaskRecord {
if err == mongo.ErrNoDocuments { if err == mongo.ErrNoDocuments {
record.Id = primitive.NewObjectID().Hex() record.Id = primitive.NewObjectID().Hex()
record.Ctime = configure.Now().Unix() record.Ctime = configure.Now().Unix()
record.Vals = make(map[int32]*pb.RtaskData)
if err := this.Add(uid, record); err != nil { if err := this.Add(uid, record); err != nil {
log.Errorln(err) log.Errorln(err)
return nil return nil

View File

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

View File

@ -30,7 +30,7 @@ type rtaskCondHandle struct {
} }
// 任务参数校验 // 任务参数校验
type verifyHandle func(uid string, record *pb.DBRtaskRecord, cfg *cfg.GameRdtaskCondiData) (bool, error) type verifyHandle func(uid string, record *pb.DBRtaskRecord, cfg *cfg.GameRdtaskCondiData, params ...int32) (bool, int32, error)
// 任务数据更新 // 任务数据更新
type updateDataHandle func(uid string, record *pb.DBRtaskRecord, cfg *cfg.GameRdtaskCondiData, vals ...int32) error type updateDataHandle func(uid string, record *pb.DBRtaskRecord, cfg *cfg.GameRdtaskCondiData, vals ...int32) error
@ -168,8 +168,7 @@ func (this *ModuleRtask) getHandle(tt comm.TaskType) (handles []*rtaskCondHandle
handles = append(handles, handle) handles = append(handles, handle)
this.registerVerifyHandle(v.Id, handle) this.registerVerifyHandle(v.Id, handle)
case comm.Rtype16, comm.Rtype17, case comm.Rtype16, comm.Rtype17, comm.Rtype35:
comm.Rtype35, comm.Rtype61:
handle := &rtaskCondHandle{ handle := &rtaskCondHandle{
condId: v.Id, condId: v.Id,
verify: this.modelRtaskRecord.verifyGreatEqual, verify: this.modelRtaskRecord.verifyGreatEqual,
@ -177,10 +176,17 @@ func (this *ModuleRtask) getHandle(tt comm.TaskType) (handles []*rtaskCondHandle
} }
handles = append(handles, handle) handles = append(handles, handle)
this.registerVerifyHandle(v.Id, handle) this.registerVerifyHandle(v.Id, handle)
case comm.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.Rtype23, comm.Rtype25, comm.Rtype30,
comm.Rtype32, comm.Rtype33, comm.Rtype34, comm.Rtype36, comm.Rtype32, comm.Rtype33, comm.Rtype34, comm.Rtype36,
comm.Rtype37, comm.Rtype40, comm.Rtype41, comm.Rtype37, comm.Rtype40,
comm.Rtype42, comm.Rtype43,
comm.Rtype46, comm.Rtype47, comm.Rtype73, comm.Rtype76, comm.Rtype77, comm.Rtype79, comm.Rtype80, comm.Rtype83, comm.Rtype46, comm.Rtype47, comm.Rtype73, comm.Rtype76, comm.Rtype77, comm.Rtype79, comm.Rtype80, comm.Rtype83,
comm.Rtype52, comm.Rtype55, comm.Rtype56, comm.Rtype82, comm.Rtype52, comm.Rtype55, comm.Rtype56, comm.Rtype82,
comm.Rtype65, comm.Rtype66, comm.Rtype67, comm.Rtype68, comm.Rtype70, comm.Rtype140, comm.Rtype65, comm.Rtype66, comm.Rtype67, comm.Rtype68, comm.Rtype70, comm.Rtype140,
@ -192,6 +198,22 @@ func (this *ModuleRtask) getHandle(tt comm.TaskType) (handles []*rtaskCondHandle
} }
handles = append(handles, handle) handles = append(handles, handle)
this.registerVerifyHandle(v.Id, handle) this.registerVerifyHandle(v.Id, handle)
case comm.Rtype41, comm.Rtype42:
handle := &rtaskCondHandle{
condId: v.Id,
verify: this.modelRtaskRecord.verifyThirdGreatEqualParam,
update: this.modelRtaskRecord.addUpdate,
}
handles = append(handles, handle)
this.registerVerifyHandle(v.Id, handle)
case comm.Rtype43:
handle := &rtaskCondHandle{
condId: v.Id,
verify: this.modelRtask.verifyRtype43,
update: this.modelRtaskRecord.overrideUpdate,
}
handles = append(handles, handle)
this.registerVerifyHandle(v.Id, handle)
case comm.Rtype78: case comm.Rtype78:
handle := &rtaskCondHandle{ handle := &rtaskCondHandle{
condId: v.Id, condId: v.Id,
@ -268,8 +290,12 @@ func (this *ModuleRtask) processOneTask(session comm.IUserSession, rtaskType com
} }
} }
} }
if handle.verify != nil {
if ok, d, _ := handle.verify(uid, record, conf, params...); ok {
if handle.update != nil { if handle.update != nil {
if d > 0 {
params[0] = d
}
if err := handle.update(uid, record, conf, params...); err != nil { if err := handle.update(uid, record, conf, params...); err != nil {
log.Errorf("update task:%v", err) log.Errorf("update task:%v", err)
code = pb.ErrorCode_DBError code = pb.ErrorCode_DBError
@ -278,6 +304,9 @@ func (this *ModuleRtask) processOneTask(session comm.IUserSession, rtaskType com
} }
condIds = append(condIds, handle.condId) condIds = append(condIds, handle.condId)
} }
}
}
update := map[string]interface{}{ update := map[string]interface{}{
"vals": record.Vals, "vals": record.Vals,
@ -286,7 +315,7 @@ func (this *ModuleRtask) processOneTask(session comm.IUserSession, rtaskType com
this.modelRtaskRecord.Change(uid, update) this.modelRtaskRecord.Change(uid, update)
for _, condId := range condIds { for _, condId := range condIds {
if code = this.CheckCondi(uid, condId); code == pb.ErrorCode_Success { if code = this.CheckCondi(uid, condId, params...); code == pb.ErrorCode_Success {
module, err := this.service.GetModule(comm.ModuleWorldtask) module, err := this.service.GetModule(comm.ModuleWorldtask)
if err == nil { if err == nil {
//世界任务 //世界任务
@ -357,13 +386,13 @@ func (this *ModuleRtask) TriggerTask(uid string, taskParams ...*comm.TaskParam)
} }
// 任务条件校验 // 任务条件校验
func (this *ModuleRtask) CheckCondi(uid string, condiId int32) (code pb.ErrorCode) { func (this *ModuleRtask) CheckCondi(uid string, condiId int32, params ...int32) (code pb.ErrorCode) {
record := this.modelRtaskRecord.getRecord(uid) record := this.modelRtaskRecord.getRecord(uid)
if record == nil { if record == nil {
code = pb.ErrorCode_DataNotFound code = pb.ErrorCode_DataNotFound
return return
} }
if _, ok := this.modelRtask.checkCondi(uid, condiId, record); !ok { if _, ok := this.modelRtask.checkCondi(uid, condiId, record, params...); !ok {
code = pb.ErrorCode_RtaskCondiNoReach code = pb.ErrorCode_RtaskCondiNoReach
return return
} }

View File

@ -12,8 +12,8 @@ import (
"github.com/spf13/cast" "github.com/spf13/cast"
) )
// GreatEqual // five params (1-GreatEqual 2-equal 3-equal 4-equal 5-equal)
func (this *ModelRtaskRecord) verifyGreatEqual(uid string, record *pb.DBRtaskRecord, cfg *cfg.GameRdtaskCondiData) (ok bool, err error) { func (this *ModelRtaskRecord) verifyGreatEqual(uid string, record *pb.DBRtaskRecord, cfg *cfg.GameRdtaskCondiData, params ...int32) (ok bool, count int32, err error) {
if record == nil { if record == nil {
err = errors.WithMessagef(err, "玩家数据DBRtaskRecord空") err = errors.WithMessagef(err, "玩家数据DBRtaskRecord空")
return return
@ -24,145 +24,165 @@ func (this *ModelRtaskRecord) verifyGreatEqual(uid string, record *pb.DBRtaskRec
err = errors.WithMessagef(err, "玩家参数数据缺失 %v", v.Data) err = errors.WithMessagef(err, "玩家参数数据缺失 %v", v.Data)
return return
} }
params = toArr(v.Data)
}
var paramLen int var paramLen int
if paramLen, err = lenParam(cfg, toArr(v.Data)...); err == nil { if paramLen, err = lenParam(cfg, params...); err == nil {
//参数比较,默认第一个参数soGreateEqual,其它soEqual //参数比较,默认第一个参数soGreateEqual,其它soEqual
switch paramLen { switch paramLen {
case 1: case 1:
return soGreatEqual(v.Data[0], cfg.Data1) ok, err = soGreatEqual(params[0], cfg.Data1)
return
case 2: case 2:
if ok, err = soGreatEqual(v.Data[0], cfg.Data1); !ok { if ok, err = soGreatEqual(params[0], cfg.Data1); !ok {
return return
} }
if ok, err = soEqual(v.Data[1], cfg.Data2); !ok { if ok, err = soEqual(params[1], cfg.Data2); !ok {
return return
} }
case 3: case 3:
if ok, err = soGreatEqual(v.Data[0], cfg.Data1); !ok { if ok, err = soGreatEqual(params[0], cfg.Data1); !ok {
return return
} }
if ok, err = soEqual(v.Data[1], cfg.Data2); !ok { if ok, err = soEqual(params[1], cfg.Data2); !ok {
return return
} }
if ok, err = soEqual(v.Data[2], cfg.Data3); !ok { if ok, err = soEqual(params[2], cfg.Data3); !ok {
return return
} }
case 4: case 4:
if ok, err = soGreatEqual(v.Data[0], cfg.Data1); !ok { if ok, err = soGreatEqual(params[0], cfg.Data1); !ok {
return return
} }
if ok, err = soEqual(v.Data[1], cfg.Data2); !ok { if ok, err = soEqual(params[1], cfg.Data2); !ok {
return return
} }
if ok, err = soEqual(v.Data[2], cfg.Data3); !ok { if ok, err = soEqual(params[2], cfg.Data3); !ok {
return return
} }
if ok, err = soEqual(v.Data[3], cfg.Data4); !ok { if ok, err = soEqual(params[3], cfg.Data4); !ok {
return return
} }
case 5: case 5:
if ok, err = soGreatEqual(v.Data[0], cfg.Data1); !ok { if ok, err = soGreatEqual(params[0], cfg.Data1); !ok {
return return
} }
if ok, err = soEqual(v.Data[1], cfg.Data2); !ok { if ok, err = soEqual(params[1], cfg.Data2); !ok {
return return
} }
if ok, err = soEqual(v.Data[2], cfg.Data3); !ok { if ok, err = soEqual(params[2], cfg.Data3); !ok {
return return
} }
if ok, err = soEqual(v.Data[3], cfg.Data4); !ok { if ok, err = soEqual(params[3], cfg.Data4); !ok {
return return
} }
if ok, err = soEqual(v.Data[4], cfg.Data5); !ok { if ok, err = soEqual(params[4], cfg.Data5); !ok {
return return
} }
} }
} }
}
return return
} }
func (this *ModelRtaskRecord) verifyFirstEqualParam(uid string, record *pb.DBRtaskRecord, cfg *cfg.GameRdtaskCondiData) (ok bool, err error) { // firstParam (first-Equal)
if v, f := record.Vals[cfg.Id]; f { func (this *ModelRtaskRecord) verifyFirstEqualParam(uid string, record *pb.DBRtaskRecord, cfg *cfg.GameRdtaskCondiData, params ...int32) (ok bool, count int32, err error) {
if len(v.Data) == 0 {
err = errors.WithMessagef(err, "玩家参数数据缺失 %v", v.Data) if len(params) == 1 {
return
} ok, err = soEqual(params[0], cfg.Data1)
return soEqual(v.Data[0], cfg.Data1)
} }
return return
} }
func (this *ModelRtaskRecord) verifyFirstGreatEqualParam(uid string, record *pb.DBRtaskRecord, cfg *cfg.GameRdtaskCondiData) (ok bool, err error) { // firstParam (first-greatEqual)
if v, f := record.Vals[cfg.Id]; f { func (this *ModelRtaskRecord) verifyFirstGreatEqualParam(uid string, record *pb.DBRtaskRecord, cfg *cfg.GameRdtaskCondiData, params ...int32) (ok bool, count int32, err error) {
if len(v.Data) == 0 { if len(params) == 1 {
err = errors.WithMessagef(err, "玩家参数数据缺失 %v", v.Data) ok, err = soGreatEqual(params[0], cfg.Data1)
return
} }
return soGreatEqual(v.Data[0], cfg.Data1)
}
return return
} }
func (this *ModelRtaskRecord) verifyThirdLessEqualParam(uid string, record *pb.DBRtaskRecord, cfg *cfg.GameRdtaskCondiData) (ok bool, err error) { // three params (first-greatEqual second-equal third-lessEqual)
if v, f := record.Vals[cfg.Id]; f { func (this *ModelRtaskRecord) verifyThirdLessEqualParam(uid string, record *pb.DBRtaskRecord, cfg *cfg.GameRdtaskCondiData, params ...int32) (ok bool, count int32, err error) {
if len(v.Data) == 0 {
err = errors.WithMessagef(err, "玩家参数数据缺失 %v", v.Data)
return
}
var paramLen int var paramLen int
if paramLen, err = lenParam(cfg, toArr(v.Data)...); err == nil { if paramLen, err = lenParam(cfg, params...); err == nil {
//参数比较,默认第一个参数soGreateEqual,其它soEqual //参数比较,默认第一个参数soGreateEqual,其它soEqual
switch paramLen { switch paramLen {
case 1: case 1:
return soGreatEqual(v.Data[0], cfg.Data1) ok, err = soGreatEqual(params[0], cfg.Data1)
return
case 2: case 2:
if ok, err = soGreatEqual(v.Data[0], cfg.Data1); !ok { if ok, err = soGreatEqual(params[0], cfg.Data1); !ok {
return return
} }
if ok, err = soEqual(v.Data[1], cfg.Data2); !ok { if ok, err = soEqual(params[1], cfg.Data2); !ok {
return return
} }
case 3: case 3:
if ok, err = soGreatEqual(v.Data[0], cfg.Data1); !ok { if ok, err = soGreatEqual(params[0], cfg.Data1); !ok {
return return
} }
if ok, err = soEqual(v.Data[1], cfg.Data2); !ok { if ok, err = soEqual(params[1], cfg.Data2); !ok {
return return
} }
if ok, err = soLessEqual(v.Data[2], cfg.Data3); !ok { if ok, err = soLessEqual(params[2], cfg.Data3); !ok {
return return
} }
} }
} }
}
return
}
func (this *ModelRtaskRecord) veriftyFirstGreatParam(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
} }
// three params (first-greatEqual second-equal third-greatEqual)
func (this *ModelRtaskRecord) verifyThirdGreatEqualParam(uid string, record *pb.DBRtaskRecord, cfg *cfg.GameRdtaskCondiData, params ...int32) (ok bool, count int32, err error) {
var paramLen int var paramLen int
if paramLen, err = lenParam(cfg, toArr(v.Data)...); err == nil { if paramLen, err = lenParam(cfg, params...); err == nil {
//参数比较,默认第一个参数soGreateEqual,其它soEqual //参数比较,默认第一个参数soGreateEqual,其它soEqual
switch paramLen { switch paramLen {
case 1: case 1:
return soGreat(v.Data[0], cfg.Data1) ok, err = soGreatEqual(params[0], cfg.Data1)
return
case 2: case 2:
if ok, err = soGreat(v.Data[0], cfg.Data1); !ok { if ok, err = soGreatEqual(params[0], cfg.Data1); !ok {
return return
} }
if ok, err = soEqual(v.Data[1], cfg.Data2); !ok { if ok, err = soEqual(params[1], cfg.Data2); !ok {
return return
} }
case 3:
if ok, err = soGreatEqual(params[0], cfg.Data1); !ok {
return
}
if ok, err = soEqual(params[1], cfg.Data2); !ok {
return
}
if ok, err = soGreatEqual(params[2], cfg.Data3); !ok {
return
}
}
}
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) {
var paramLen int
if paramLen, err = lenParam(cfg, params...); err == nil {
//参数比较,默认第一个参数soGreateEqual,其它soEqual
switch paramLen {
case 1:
ok, err = soGreat(params[0], cfg.Data1)
return
case 2:
if ok, err = soGreat(params[0], cfg.Data1); !ok {
return
}
if ok, err = soEqual(params[1], cfg.Data2); !ok {
return
} }
} }
} }
@ -170,7 +190,7 @@ func (this *ModelRtaskRecord) veriftyFirstGreatParam(uid string, record *pb.DBRt
} }
// 英雄指定 // 英雄指定
func (this *ModelRtask) verfiyRtype1(uid string, record *pb.DBRtaskRecord, cfg *cfg.GameRdtaskCondiData) (ok bool, err error) { func (this *ModelRtask) verfiyRtype1(uid string, record *pb.DBRtaskRecord, cfg *cfg.GameRdtaskCondiData, params ...int32) (ok bool, err error) {
heroModule, err := this.service.GetModule(comm.ModuleHero) heroModule, err := this.service.GetModule(comm.ModuleHero)
if err != nil { if err != nil {
return false, err return false, err
@ -189,7 +209,7 @@ func (this *ModelRtask) verfiyRtype1(uid string, record *pb.DBRtaskRecord, cfg *
// 剧情 // 剧情
// Deprecated // Deprecated
func (this *ModelRtask) verifyRtype2(uid string, record *pb.DBRtaskRecord, cfg *cfg.GameRdtaskCondiData) (ok bool, err error) { func (this *ModelRtask) verifyRtype2(uid string, record *pb.DBRtaskRecord, cfg *cfg.GameRdtaskCondiData, params ...int32) (ok bool, err error) {
m, err := this.service.GetModule(comm.ModuleMline) m, err := this.service.GetModule(comm.ModuleMline)
if err != nil { if err != nil {
return return
@ -203,7 +223,7 @@ func (this *ModelRtask) verifyRtype2(uid string, record *pb.DBRtaskRecord, cfg *
} }
// 每日任务 // 每日任务
func (this *ModelRtask) verifyRtype3(uid string, record *pb.DBRtaskRecord, cfg *cfg.GameRdtaskCondiData) (ok bool, err error) { func (this *ModelRtask) verifyRtype3(uid string, record *pb.DBRtaskRecord, cfg *cfg.GameRdtaskCondiData, params ...int32) (ok bool, count int32, err error) {
m, err := this.service.GetModule(comm.ModuleTask) m, err := this.service.GetModule(comm.ModuleTask)
if err != nil { if err != nil {
return return
@ -221,7 +241,7 @@ func (this *ModelRtask) verifyRtype3(uid string, record *pb.DBRtaskRecord, cfg *
} }
// 指定英雄等级 // 指定英雄等级
func (this *ModelRtask) verifyRtype4(uid string, record *pb.DBRtaskRecord, cfg *cfg.GameRdtaskCondiData) (ok bool, err error) { func (this *ModelRtask) verifyRtype4(uid string, record *pb.DBRtaskRecord, cfg *cfg.GameRdtaskCondiData, params ...int32) (ok bool, count int32, err error) {
m, err := this.service.GetModule(comm.ModuleHero) m, err := this.service.GetModule(comm.ModuleHero)
if err != nil { if err != nil {
return return
@ -248,7 +268,7 @@ func (this *ModelRtask) verifyRtype4(uid string, record *pb.DBRtaskRecord, cfg *
} }
// 指定英雄的指定装备数量 // 指定英雄的指定装备数量
func (this *ModelRtask) verifyRtype5(uid string, record *pb.DBRtaskRecord, cfg *cfg.GameRdtaskCondiData) (ok bool, err error) { func (this *ModelRtask) verifyRtype5(uid string, record *pb.DBRtaskRecord, cfg *cfg.GameRdtaskCondiData, params ...int32) (ok bool, err error) {
m, err := this.service.GetModule(comm.ModuleHero) m, err := this.service.GetModule(comm.ModuleHero)
if err != nil { if err != nil {
return return
@ -285,7 +305,7 @@ func (this *ModelRtask) verifyRtype5(uid string, record *pb.DBRtaskRecord, cfg *
} }
// 指定英雄星级 // 指定英雄星级
func (this *ModelRtask) verifyRtype6(uid string, record *pb.DBRtaskRecord, cfg *cfg.GameRdtaskCondiData) (ok bool, err error) { func (this *ModelRtask) verifyRtype6(uid string, record *pb.DBRtaskRecord, cfg *cfg.GameRdtaskCondiData, params ...int32) (ok bool, err error) {
m, err := this.service.GetModule(comm.ModuleHero) m, err := this.service.GetModule(comm.ModuleHero)
if err != nil { if err != nil {
return return
@ -311,7 +331,7 @@ func (this *ModelRtask) verifyRtype6(uid string, record *pb.DBRtaskRecord, cfg *
} }
// 日常登录一次 // 日常登录一次
func (this *ModelRtask) verfiyRtype7(uid string, record *pb.DBRtaskRecord, cfg *cfg.GameRdtaskCondiData) (ok bool, err error) { func (this *ModelRtask) verfiyRtype7(uid string, record *pb.DBRtaskRecord, cfg *cfg.GameRdtaskCondiData, params ...int32) (ok bool, err error) {
userModule, err := this.service.GetModule(comm.ModuleUser) userModule, err := this.service.GetModule(comm.ModuleUser)
if err != nil { if err != nil {
return return
@ -326,7 +346,7 @@ func (this *ModelRtask) verfiyRtype7(uid string, record *pb.DBRtaskRecord, cfg *
} }
// 累计登陆xx天 // 累计登陆xx天
func (this *ModelRtask) verfiyRtype8(uid string, record *pb.DBRtaskRecord, cfg *cfg.GameRdtaskCondiData) (ok bool, err error) { func (this *ModelRtask) verfiyRtype8(uid string, record *pb.DBRtaskRecord, cfg *cfg.GameRdtaskCondiData, params ...int32) (ok bool, err error) {
userModule, err := this.service.GetModule(comm.ModuleUser) userModule, err := this.service.GetModule(comm.ModuleUser)
if err != nil { if err != nil {
return return
@ -343,7 +363,7 @@ func (this *ModelRtask) verfiyRtype8(uid string, record *pb.DBRtaskRecord, cfg *
} }
// 连续登陆xx天 未埋点的处理方法 // 连续登陆xx天 未埋点的处理方法
func (this *ModelRtask) verfiyRtype9(uid string, record *pb.DBRtaskRecord, cfg *cfg.GameRdtaskCondiData) (ok bool, err error) { func (this *ModelRtask) verfiyRtype9(uid string, record *pb.DBRtaskRecord, cfg *cfg.GameRdtaskCondiData, params ...int32) (ok bool, count int32, err error) {
userModule, err := this.service.GetModule(comm.ModuleUser) userModule, err := this.service.GetModule(comm.ModuleUser)
if err != nil { if err != nil {
return return
@ -352,15 +372,15 @@ func (this *ModelRtask) verfiyRtype9(uid string, record *pb.DBRtaskRecord, cfg *
if um, y := userModule.(comm.IUser); y { if um, y := userModule.(comm.IUser); y {
ud, err := um.GetUserExpand(uid) ud, err := um.GetUserExpand(uid)
if err != nil { if err != nil {
return false, err return false, 0, err
} }
return soGreatEqual(ud.LoginContinueCount, cfg.Data1) ok, err = soGreatEqual(ud.LoginContinueCount, cfg.Data1)
} }
return return
} }
// 拥有xx个好友 // 拥有xx个好友
func (this *ModelRtask) verfiyRtype10(uid string, record *pb.DBRtaskRecord, cfg *cfg.GameRdtaskCondiData) (ok bool, err error) { func (this *ModelRtask) verfiyRtype10(uid string, record *pb.DBRtaskRecord, cfg *cfg.GameRdtaskCondiData, params ...int32) (ok bool, count int32, err error) {
m, err := this.service.GetModule(comm.ModuleFriend) m, err := this.service.GetModule(comm.ModuleFriend)
if err != nil { if err != nil {
return return
@ -368,13 +388,13 @@ func (this *ModelRtask) verfiyRtype10(uid string, record *pb.DBRtaskRecord, cfg
if mi, y := m.(comm.IFriend); y { if mi, y := m.(comm.IFriend); y {
count := mi.GetFriendCount(uid) count := mi.GetFriendCount(uid)
return soGreatEqual(count, cfg.Data1) ok, err = soGreatEqual(count, cfg.Data1)
} }
return return
} }
// 用户等级达到xx级 // 用户等级达到xx级
func (this *ModelRtask) verifyRtype20(uid string, record *pb.DBRtaskRecord, cfg *cfg.GameRdtaskCondiData) (ok bool, err error) { func (this *ModelRtask) verifyRtype20(uid string, record *pb.DBRtaskRecord, cfg *cfg.GameRdtaskCondiData, params ...int32) (ok bool, count int32, err error) {
userModule, err := this.service.GetModule(comm.ModuleUser) userModule, err := this.service.GetModule(comm.ModuleUser)
if err != nil { if err != nil {
return return
@ -382,14 +402,15 @@ func (this *ModelRtask) verifyRtype20(uid string, record *pb.DBRtaskRecord, cfg
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 soGreatEqual(user.Lv, cfg.Data1) ok, err = soGreatEqual(user.Lv, cfg.Data1)
return
} }
} }
return return
} }
// 日常任务活跃度达到xx // 日常任务活跃度达到xx
func (this *ModelRtask) verifyRtype63(uid string, record *pb.DBRtaskRecord, cfg *cfg.GameRdtaskCondiData) (ok bool, err error) { func (this *ModelRtask) verifyRtype63(uid string, record *pb.DBRtaskRecord, cfg *cfg.GameRdtaskCondiData, params ...int32) (ok bool, count int32, err error) {
userModule, err := this.service.GetModule(comm.ModuleUser) userModule, err := this.service.GetModule(comm.ModuleUser)
if err != nil { if err != nil {
return return
@ -398,11 +419,11 @@ func (this *ModelRtask) verifyRtype63(uid string, record *pb.DBRtaskRecord, cfg
if um, y := userModule.(comm.IUser); y { if um, y := userModule.(comm.IUser); y {
de, err := um.GetUserExpand(uid) de, err := um.GetUserExpand(uid)
if err != nil { if err != nil {
return false, err return false, 0, err
} }
if de != nil { if de != nil {
return soGreatEqual(de.Activeday, cfg.Data1) ok, err = soGreatEqual(de.Activeday, cfg.Data1)
} }
} }
@ -410,7 +431,7 @@ func (this *ModelRtask) verifyRtype63(uid string, record *pb.DBRtaskRecord, cfg
} }
// 记录玩家在线时间并记入进度 // 记录玩家在线时间并记入进度
func (this *ModelRtask) verifyRtype138(uid string, record *pb.DBRtaskRecord, cfg *cfg.GameRdtaskCondiData) (ok bool, err error) { func (this *ModelRtask) verifyRtype138(uid string, record *pb.DBRtaskRecord, cfg *cfg.GameRdtaskCondiData, params ...int32) (ok bool, count int32, err error) {
userModule, err := this.service.GetModule(comm.ModuleUser) userModule, err := this.service.GetModule(comm.ModuleUser)
if err != nil { if err != nil {
return return
@ -420,7 +441,22 @@ func (this *ModelRtask) verifyRtype138(uid string, record *pb.DBRtaskRecord, cfg
if user := um.GetUser(uid); user != nil { if user := um.GetUser(uid); user != nil {
now := configure.Now().Unix() now := configure.Now().Unix()
l := (now - user.Logintime) / 60 l := (now - user.Logintime) / 60
return soGreatEqual(int32(l), cfg.Data1) ok, err = soGreatEqual(int32(l), cfg.Data1)
return
}
}
return
}
func (this *ModelRtask) verifyRtype43(uid string, record *pb.DBRtaskRecord, cfg *cfg.GameRdtaskCondiData, params ...int32) (ok bool, count int32, err error) {
equipment, ec := this.moduleRtask.ModuleEquipment.QueryEquipments(uid)
if ec == pb.ErrorCode_Success {
for _, e := range equipment {
if ok, _ = soGreatEqual(e.Lv, cfg.Data2); ok {
count++
return
}
} }
} }
return return