埋点接口优化
This commit is contained in:
parent
41eba13ab5
commit
aee07aa8f7
@ -354,7 +354,7 @@ type (
|
||||
// 设置工会活跃度
|
||||
BingoSetActivity(session IUserSession, activity int32) error
|
||||
// 任务条件达成通知
|
||||
TaskcondNotify(uid, sociatyId string, condId int32) error
|
||||
TaskcondNotify(uid string, condId int32) error
|
||||
// 红点
|
||||
IReddot
|
||||
}
|
||||
|
@ -205,3 +205,15 @@ func soLessEqual(actual, expected int32) (ok bool, err error) {
|
||||
ok = true
|
||||
return
|
||||
}
|
||||
|
||||
func removeDuplicate(arr []int32) []int32 {
|
||||
visited := make(map[int32]bool)
|
||||
result := []int32{}
|
||||
for _, num := range arr {
|
||||
if !visited[num] {
|
||||
visited[num] = true
|
||||
result = append(result, num)
|
||||
}
|
||||
}
|
||||
return result
|
||||
}
|
@ -51,26 +51,6 @@ func (this *ModelRtask) GetRtask(uid string) *pb.DBRtask {
|
||||
return rtask
|
||||
}
|
||||
|
||||
// 做任务之前的校验
|
||||
// func (this *ModelRtask) checkHandle(uid string, frtaskIds []int32, conf *cfg.GameRdtaskData) (err error, ok bool) {
|
||||
// //判断前置任务状态
|
||||
// if conf.PreTid != 0 {
|
||||
// if _, ok = utils.Findx(frtaskIds, conf.PreTid); !ok {
|
||||
// err = errors.New("前置任务未完成")
|
||||
// return
|
||||
// }
|
||||
// }
|
||||
|
||||
// //验证限定条件
|
||||
// for _, v := range conf.Condition {
|
||||
// if err, ok = this.checkCondi(uid, v); !ok {
|
||||
// return
|
||||
// }
|
||||
// }
|
||||
|
||||
// return
|
||||
// }
|
||||
|
||||
// 确定选项前的校验
|
||||
func (this *ModelRtask) checkCondi(uid string, condiId int32, record *pb.DBRtaskRecord, params ...int32) (err error, ok bool) {
|
||||
if condiId <= 0 {
|
||||
@ -110,7 +90,7 @@ func (this *ModelRtask) checkCondi(uid string, condiId int32, record *pb.DBRtask
|
||||
return
|
||||
}
|
||||
|
||||
if ok, _, err = condi.verify(uid, record, conf, params...); !ok {
|
||||
if ok, _, err = condi.verify(uid, conf, params...); !ok {
|
||||
err = errors.WithMessagef(err, "uid: %v do rtask [condiId:%v] condition not reach", uid, condiId)
|
||||
return
|
||||
}
|
||||
|
@ -30,7 +30,7 @@ type rtaskCondHandle struct {
|
||||
}
|
||||
|
||||
// 任务参数校验
|
||||
type verifyHandle func(uid string, record *pb.DBRtaskRecord, cfg *cfg.GameRdtaskCondiData, params ...int32) (bool, int32, error)
|
||||
type verifyHandle func(uid string, cfg *cfg.GameRdtaskCondiData, params ...int32) (bool, int32, error)
|
||||
|
||||
// 任务数据更新
|
||||
type updateDataHandle func(uid string, record *pb.DBRtaskRecord, cfg *cfg.GameRdtaskCondiData, vals ...int32) error
|
||||
@ -227,37 +227,14 @@ func (this *ModuleRtask) getHandle(tt comm.TaskType) (handles []*rtaskCondHandle
|
||||
}
|
||||
|
||||
// 处理触发的任务
|
||||
func (this *ModuleRtask) processOneTask(session comm.IUserSession, rtaskType comm.TaskType, params ...int32) (code pb.ErrorCode) {
|
||||
func (this *ModuleRtask) processOneTask(session comm.IUserSession, record *pb.DBRtaskRecord, rtaskType comm.TaskType, params ...int32) (condIds []int32, code pb.ErrorCode) {
|
||||
uid := session.GetUserId()
|
||||
|
||||
var (
|
||||
handles []*rtaskCondHandle
|
||||
condIds []int32
|
||||
)
|
||||
|
||||
if this.IsCross() {
|
||||
//随机任务
|
||||
if _, err := this.service.AcrossClusterRpcGo(
|
||||
context.Background(),
|
||||
session.GetServiecTag(),
|
||||
comm.Service_Worker,
|
||||
string(comm.Rpc_ModuleRtaskSendTask),
|
||||
&pb.RPCRTaskReq{Uid: uid, TaskType: int32(rtaskType), Param: params},
|
||||
nil); err != nil {
|
||||
log.Errorln(err)
|
||||
}
|
||||
return
|
||||
}
|
||||
|
||||
record := this.modelRtaskRecord.getRecord(uid)
|
||||
|
||||
handles = this.getHandle(rtaskType)
|
||||
handles := this.getHandle(rtaskType)
|
||||
|
||||
// update
|
||||
for _, handle := range handles {
|
||||
conf, err := this.configure.getRtaskTypeById(handle.condId)
|
||||
if err != nil {
|
||||
log.Debug("任务配置未找到", log.Field{Key: "condId", Value: handle.condId})
|
||||
code = pb.ErrorCode_RtaskCondiNoFound
|
||||
return
|
||||
}
|
||||
@ -280,13 +257,10 @@ func (this *ModuleRtask) processOneTask(session comm.IUserSession, rtaskType com
|
||||
if len(params) == 1 {
|
||||
ok = true
|
||||
} else {
|
||||
ok, d, _ = handle.verify(uid, record, conf, params...)
|
||||
ok, d, _ = handle.verify(uid, conf, params...)
|
||||
}
|
||||
|
||||
if !ok {
|
||||
// this.Debug("验证失败", log.Field{Key: "uid", Value: uid},
|
||||
// log.Field{Key: "params", Value: params},
|
||||
// log.Field{Key: "conf", Value: conf})
|
||||
continue
|
||||
}
|
||||
if handle.update != nil {
|
||||
@ -300,6 +274,62 @@ func (this *ModuleRtask) processOneTask(session comm.IUserSession, rtaskType com
|
||||
}
|
||||
}
|
||||
condIds = append(condIds, handle.condId)
|
||||
}
|
||||
}
|
||||
|
||||
return
|
||||
}
|
||||
|
||||
type RPCRtaskReq struct {
|
||||
Uid string
|
||||
TaskParams []*comm.TaskParam
|
||||
}
|
||||
|
||||
func (this *ModuleRtask) TriggerTask(uid string, taskParams ...*comm.TaskParam) {
|
||||
session, ok := this.GetUserSession(uid)
|
||||
if !ok {
|
||||
return
|
||||
}
|
||||
this.Debug("任务触发",
|
||||
log.Field{Key: "uid", Value: uid},
|
||||
log.Field{Key: "tasks", Value: taskParams})
|
||||
lock, _ := this.modelRtask.userlock(uid)
|
||||
err := lock.Lock()
|
||||
if err != nil {
|
||||
this.Error("TriggerTask userlock err!", log.Field{Key: "err", Value: err.Error()})
|
||||
}
|
||||
defer lock.Unlock()
|
||||
|
||||
if this.IsCross() {
|
||||
//随机任务
|
||||
if _, err := this.service.AcrossClusterRpcGo(
|
||||
context.Background(),
|
||||
session.GetServiecTag(),
|
||||
comm.Service_Worker,
|
||||
string(comm.Rpc_ModuleRtaskSendTask),
|
||||
&RPCRtaskReq{Uid: uid, TaskParams: taskParams},
|
||||
nil); err != nil {
|
||||
log.Errorln(err)
|
||||
}
|
||||
return
|
||||
}
|
||||
|
||||
this.processTasks(session, taskParams...)
|
||||
|
||||
session.Push()
|
||||
this.PutUserSession(session)
|
||||
return
|
||||
}
|
||||
|
||||
func (this *ModuleRtask) processTasks(session comm.IUserSession, taskParams ...*comm.TaskParam) {
|
||||
uid := session.GetUserId()
|
||||
record := this.modelRtaskRecord.getRecord(uid)
|
||||
var condIds []int32
|
||||
for _, tp := range taskParams {
|
||||
ids, _ := this.processOneTask(session, record, tp.TT, tp.Params...)
|
||||
condIds = append(condIds, ids...)
|
||||
comm.PuttaskParam(tp)
|
||||
}
|
||||
|
||||
update := map[string]interface{}{
|
||||
"vals": record.Vals,
|
||||
@ -307,9 +337,8 @@ func (this *ModuleRtask) processOneTask(session comm.IUserSession, rtaskType com
|
||||
|
||||
this.modelRtaskRecord.Change(uid, update)
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
//去重
|
||||
condIds = removeDuplicate(condIds)
|
||||
|
||||
for _, condId := range condIds {
|
||||
r, _ := record.Vals[condId]
|
||||
@ -334,60 +363,25 @@ func (this *ModuleRtask) processOneTask(session comm.IUserSession, rtaskType com
|
||||
// if user, ok := userModule.(comm.IUser); ok {
|
||||
// ex, err := user.GetUserExpand(uid)
|
||||
// if err == nil && ex.SociatyId != "" {
|
||||
// sociatyModule, err := this.service.GetModule(comm.ModuleSociaty)
|
||||
// if err != nil {
|
||||
// return
|
||||
// }
|
||||
// if sociaty, ok := sociatyModule.(comm.ISociaty); ok {
|
||||
// if err2 := sociaty.TaskcondNotify(uid, ex.SociatyId, condId); err2 != nil {
|
||||
sociatyModule, err := this.service.GetModule(comm.ModuleSociaty)
|
||||
if err != nil {
|
||||
return
|
||||
}
|
||||
if sociaty, ok := sociatyModule.(comm.ISociaty); ok {
|
||||
if err2 := sociaty.TaskcondNotify(uid, condId); err2 != nil {
|
||||
// log.Error("公会任务条件达成通知",
|
||||
// log.Field{Key: "uid", Value: uid},
|
||||
// log.Field{Key: "sociatyId", Value: ex.SociatyId},
|
||||
// log.Field{Key: "condId", Value: condId},
|
||||
// log.Field{Key: "err", Value: err2.Error()},
|
||||
// )
|
||||
// }
|
||||
// this.processOneTask(session, comm.Rtype156, 1)
|
||||
// }
|
||||
}
|
||||
}
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
}
|
||||
}
|
||||
return
|
||||
}
|
||||
|
||||
func (this *ModuleRtask) TriggerTask(uid string, taskParams ...*comm.TaskParam) {
|
||||
session, ok := this.GetUserSession(uid)
|
||||
if !ok {
|
||||
return
|
||||
}
|
||||
this.Debug("任务触发",
|
||||
log.Field{Key: "uid", Value: uid},
|
||||
log.Field{Key: "tasks", Value: taskParams})
|
||||
lock, _ := this.modelRtask.userlock(uid)
|
||||
err := lock.Lock()
|
||||
if err != nil {
|
||||
this.Error("TriggerTask userlock err!", log.Field{Key: "err", Value: err.Error()})
|
||||
}
|
||||
defer lock.Unlock()
|
||||
for _, tp := range taskParams {
|
||||
// this.Debug("任务触发",
|
||||
// log.Field{Key: "uid", Value: uid},
|
||||
// log.Field{Key: "type", Value: tp.TT},
|
||||
// log.Field{Key: "params", Value: tp.Params})
|
||||
|
||||
code := this.processOneTask(session, tp.TT, tp.Params...)
|
||||
if code != pb.ErrorCode_Success {
|
||||
// this.Error("任务处理失败", log.Field{Key: "uid", Value: uid}, log.Field{Key: "code", Value: code})
|
||||
}
|
||||
|
||||
comm.PuttaskParam(tp)
|
||||
}
|
||||
|
||||
session.Push()
|
||||
this.PutUserSession(session)
|
||||
return
|
||||
}
|
||||
|
||||
// 任务条件校验
|
||||
@ -428,10 +422,6 @@ func (this *ModuleRtask) CheckCondis(uid string, condiIds ...int32) (cids []int3
|
||||
cids = append(cids, condId)
|
||||
}
|
||||
}
|
||||
|
||||
// if _, ok := this.modelRtask.checkCondi(uid, condId, record); ok {
|
||||
// cids = append(cids, condId)
|
||||
// }
|
||||
}
|
||||
|
||||
return
|
||||
@ -488,7 +478,7 @@ type TaskProcessResp struct {
|
||||
}
|
||||
|
||||
// 接收区服worker发起的秘境事件
|
||||
func (this *ModuleRtask) Rpc_ModuleRtaskSendTask(ctx context.Context, args *pb.RPCRTaskReq, reply *pb.EmptyResp) (err error) {
|
||||
func (this *ModuleRtask) Rpc_ModuleRtaskSendTask(ctx context.Context, args *RPCRtaskReq, reply *pb.EmptyResp) (err error) {
|
||||
this.Debug("Rpc_ModuleRtaskSendTask",
|
||||
log.Field{Key: "args", Value: args},
|
||||
)
|
||||
@ -506,7 +496,7 @@ func (this *ModuleRtask) Rpc_ModuleRtaskSendTask(ctx context.Context, args *pb.R
|
||||
err = fmt.Errorf("未查询到用户:%s在线信息!", args.Uid)
|
||||
return
|
||||
} else {
|
||||
this.processOneTask(session, comm.TaskType(args.TaskType), args.Param...)
|
||||
this.processTasks(session, args.TaskParams...)
|
||||
session.Push()
|
||||
}
|
||||
return
|
||||
|
@ -13,7 +13,7 @@ import (
|
||||
)
|
||||
|
||||
// n params (1-GreatEqual 2-equal 3-equal 4-equal 5-equal)
|
||||
func (this *ModelRtaskRecord) verifyMultiEqual(uid string, record *pb.DBRtaskRecord, cfg *cfg.GameRdtaskCondiData, params ...int32) (ok bool, count int32, err error) {
|
||||
func (this *ModelRtaskRecord) verifyMultiEqual(uid string, cfg *cfg.GameRdtaskCondiData, params ...int32) (ok bool, count int32, err error) {
|
||||
if len(params) == 0 {
|
||||
err = errors.New("玩家参数数据缺失")
|
||||
return
|
||||
@ -79,7 +79,7 @@ func (this *ModelRtaskRecord) verifyMultiEqual(uid string, record *pb.DBRtaskRec
|
||||
}
|
||||
|
||||
// firstParam (first-Equal)
|
||||
func (this *ModelRtaskRecord) verifyFirstEqualParam(uid string, record *pb.DBRtaskRecord, cfg *cfg.GameRdtaskCondiData, params ...int32) (ok bool, count int32, err error) {
|
||||
func (this *ModelRtaskRecord) verifyFirstEqualParam(uid string, cfg *cfg.GameRdtaskCondiData, params ...int32) (ok bool, count int32, err error) {
|
||||
if len(params) == 1 {
|
||||
ok, err = soEqual(params[0], cfg.Data1)
|
||||
}
|
||||
@ -88,7 +88,7 @@ func (this *ModelRtaskRecord) verifyFirstEqualParam(uid string, record *pb.DBRta
|
||||
}
|
||||
|
||||
// firstParam (first-greatEqual)
|
||||
func (this *ModelRtaskRecord) verifyFirstGreatEqualParam(uid string, record *pb.DBRtaskRecord, cfg *cfg.GameRdtaskCondiData, params ...int32) (ok bool, count int32, err error) {
|
||||
func (this *ModelRtaskRecord) verifyFirstGreatEqualParam(uid string, cfg *cfg.GameRdtaskCondiData, params ...int32) (ok bool, count int32, err error) {
|
||||
if len(params) == 1 {
|
||||
ok = true
|
||||
// ok, err = soGreatEqual(params[0], cfg.Data1)
|
||||
@ -97,7 +97,7 @@ func (this *ModelRtaskRecord) verifyFirstGreatEqualParam(uid string, record *pb.
|
||||
}
|
||||
|
||||
// three params (first-greatEqual second-equal third-lessEqual)
|
||||
func (this *ModelRtaskRecord) verifyThirdLessEqualParam(uid string, record *pb.DBRtaskRecord, cfg *cfg.GameRdtaskCondiData, params ...int32) (ok bool, count int32, err error) {
|
||||
func (this *ModelRtaskRecord) verifyThirdLessEqualParam(uid string, cfg *cfg.GameRdtaskCondiData, params ...int32) (ok bool, count int32, err error) {
|
||||
if len(params) == 0 {
|
||||
err = errors.New("玩家参数数据缺失")
|
||||
return
|
||||
@ -107,7 +107,7 @@ func (this *ModelRtaskRecord) verifyThirdLessEqualParam(uid string, record *pb.D
|
||||
//参数比较,默认第一个参数soGreateEqual,其它soEqual
|
||||
switch paramLen {
|
||||
case 1:
|
||||
ok=true
|
||||
ok = true
|
||||
return
|
||||
case 2:
|
||||
if ok, err = soEqual(params[1], cfg.Data2); !ok {
|
||||
@ -126,7 +126,7 @@ func (this *ModelRtaskRecord) verifyThirdLessEqualParam(uid string, record *pb.D
|
||||
}
|
||||
|
||||
// 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) {
|
||||
func (this *ModelRtaskRecord) verifyThirdGreatEqualParam(uid string, cfg *cfg.GameRdtaskCondiData, params ...int32) (ok bool, count int32, err error) {
|
||||
if len(params) == 0 {
|
||||
err = errors.New("玩家参数数据缺失")
|
||||
return
|
||||
@ -155,7 +155,7 @@ func (this *ModelRtaskRecord) verifyThirdGreatEqualParam(uid string, record *pb.
|
||||
}
|
||||
|
||||
// two params (first-Equal second-Equal)
|
||||
func (this *ModelRtaskRecord) veriftyEqualParam(uid string, record *pb.DBRtaskRecord, cfg *cfg.GameRdtaskCondiData, params ...int32) (ok bool, count int32, err error) {
|
||||
func (this *ModelRtaskRecord) veriftyEqualParam(uid string, cfg *cfg.GameRdtaskCondiData, params ...int32) (ok bool, count int32, err error) {
|
||||
if len(params) != 2 {
|
||||
err = errors.New("玩家参数数据缺失")
|
||||
return
|
||||
@ -180,7 +180,7 @@ func (this *ModelRtaskRecord) veriftyEqualParam(uid string, record *pb.DBRtaskRe
|
||||
}
|
||||
|
||||
// 英雄指定
|
||||
func (this *ModelRtask) verfiyRtype1(uid string, record *pb.DBRtaskRecord, cfg *cfg.GameRdtaskCondiData, params ...int32) (ok bool, err error) {
|
||||
func (this *ModelRtask) verfiyRtype1(uid string, cfg *cfg.GameRdtaskCondiData, params ...int32) (ok bool, err error) {
|
||||
heroModule, err := this.service.GetModule(comm.ModuleHero)
|
||||
if err != nil {
|
||||
return false, err
|
||||
@ -199,7 +199,7 @@ func (this *ModelRtask) verfiyRtype1(uid string, record *pb.DBRtaskRecord, cfg *
|
||||
|
||||
// 剧情
|
||||
// Deprecated
|
||||
func (this *ModelRtask) verifyRtype2(uid string, record *pb.DBRtaskRecord, cfg *cfg.GameRdtaskCondiData, params ...int32) (ok bool, err error) {
|
||||
func (this *ModelRtask) verifyRtype2(uid string, cfg *cfg.GameRdtaskCondiData, params ...int32) (ok bool, err error) {
|
||||
m, err := this.service.GetModule(comm.ModuleMline)
|
||||
if err != nil {
|
||||
return
|
||||
@ -213,7 +213,7 @@ func (this *ModelRtask) verifyRtype2(uid string, record *pb.DBRtaskRecord, cfg *
|
||||
}
|
||||
|
||||
// 每日任务
|
||||
func (this *ModelRtask) verifyRtype3(uid string, record *pb.DBRtaskRecord, cfg *cfg.GameRdtaskCondiData, params ...int32) (ok bool, count int32, err error) {
|
||||
func (this *ModelRtask) verifyRtype3(uid string, cfg *cfg.GameRdtaskCondiData, params ...int32) (ok bool, count int32, err error) {
|
||||
m, err := this.service.GetModule(comm.ModuleTask)
|
||||
if err != nil {
|
||||
return
|
||||
@ -231,7 +231,7 @@ func (this *ModelRtask) verifyRtype3(uid string, record *pb.DBRtaskRecord, cfg *
|
||||
}
|
||||
|
||||
// 指定英雄等级
|
||||
func (this *ModelRtask) verifyRtype4(uid string, record *pb.DBRtaskRecord, cfg *cfg.GameRdtaskCondiData, params ...int32) (ok bool, count int32, err error) {
|
||||
func (this *ModelRtask) verifyRtype4(uid string, cfg *cfg.GameRdtaskCondiData, params ...int32) (ok bool, count int32, err error) {
|
||||
m, err := this.service.GetModule(comm.ModuleHero)
|
||||
if err != nil {
|
||||
return
|
||||
@ -258,7 +258,7 @@ func (this *ModelRtask) verifyRtype4(uid string, record *pb.DBRtaskRecord, cfg *
|
||||
}
|
||||
|
||||
// 指定英雄的指定装备数量
|
||||
func (this *ModelRtask) verifyRtype5(uid string, record *pb.DBRtaskRecord, cfg *cfg.GameRdtaskCondiData, params ...int32) (ok bool, err error) {
|
||||
func (this *ModelRtask) verifyRtype5(uid string, cfg *cfg.GameRdtaskCondiData, params ...int32) (ok bool, err error) {
|
||||
m, err := this.service.GetModule(comm.ModuleHero)
|
||||
if err != nil {
|
||||
return
|
||||
@ -295,7 +295,7 @@ func (this *ModelRtask) verifyRtype5(uid string, record *pb.DBRtaskRecord, cfg *
|
||||
}
|
||||
|
||||
// 指定英雄星级
|
||||
func (this *ModelRtask) verifyRtype6(uid string, record *pb.DBRtaskRecord, cfg *cfg.GameRdtaskCondiData, params ...int32) (ok bool, err error) {
|
||||
func (this *ModelRtask) verifyRtype6(uid string, cfg *cfg.GameRdtaskCondiData, params ...int32) (ok bool, err error) {
|
||||
m, err := this.service.GetModule(comm.ModuleHero)
|
||||
if err != nil {
|
||||
return
|
||||
@ -321,7 +321,7 @@ func (this *ModelRtask) verifyRtype6(uid string, record *pb.DBRtaskRecord, cfg *
|
||||
}
|
||||
|
||||
// 日常登录一次
|
||||
func (this *ModelRtask) verfiyRtype7(uid string, record *pb.DBRtaskRecord, cfg *cfg.GameRdtaskCondiData, params ...int32) (ok bool, err error) {
|
||||
func (this *ModelRtask) verfiyRtype7(uid string, cfg *cfg.GameRdtaskCondiData, params ...int32) (ok bool, err error) {
|
||||
userModule, err := this.service.GetModule(comm.ModuleUser)
|
||||
if err != nil {
|
||||
return
|
||||
@ -336,7 +336,7 @@ func (this *ModelRtask) verfiyRtype7(uid string, record *pb.DBRtaskRecord, cfg *
|
||||
}
|
||||
|
||||
// 累计登陆xx天
|
||||
func (this *ModelRtask) verfiyRtype8(uid string, record *pb.DBRtaskRecord, cfg *cfg.GameRdtaskCondiData, params ...int32) (ok bool, err error) {
|
||||
func (this *ModelRtask) verfiyRtype8(uid string, cfg *cfg.GameRdtaskCondiData, params ...int32) (ok bool, err error) {
|
||||
userModule, err := this.service.GetModule(comm.ModuleUser)
|
||||
if err != nil {
|
||||
return
|
||||
@ -353,7 +353,7 @@ func (this *ModelRtask) verfiyRtype8(uid string, record *pb.DBRtaskRecord, cfg *
|
||||
}
|
||||
|
||||
// 连续登陆xx天 未埋点的处理方法
|
||||
func (this *ModelRtask) verfiyRtype9(uid string, record *pb.DBRtaskRecord, cfg *cfg.GameRdtaskCondiData, params ...int32) (ok bool, count int32, err error) {
|
||||
func (this *ModelRtask) verfiyRtype9(uid string, cfg *cfg.GameRdtaskCondiData, params ...int32) (ok bool, count int32, err error) {
|
||||
userModule, err := this.service.GetModule(comm.ModuleUser)
|
||||
if err != nil {
|
||||
return
|
||||
@ -370,7 +370,7 @@ func (this *ModelRtask) verfiyRtype9(uid string, record *pb.DBRtaskRecord, cfg *
|
||||
}
|
||||
|
||||
// 拥有xx个好友
|
||||
func (this *ModelRtask) verfiyRtype10(uid string, record *pb.DBRtaskRecord, cfg *cfg.GameRdtaskCondiData, params ...int32) (ok bool, count int32, err error) {
|
||||
func (this *ModelRtask) verfiyRtype10(uid string, cfg *cfg.GameRdtaskCondiData, params ...int32) (ok bool, count int32, err error) {
|
||||
m, err := this.service.GetModule(comm.ModuleFriend)
|
||||
if err != nil {
|
||||
return
|
||||
@ -384,7 +384,7 @@ func (this *ModelRtask) verfiyRtype10(uid string, record *pb.DBRtaskRecord, cfg
|
||||
}
|
||||
|
||||
// 用户等级达到xx级
|
||||
func (this *ModelRtask) verifyRtype20(uid string, record *pb.DBRtaskRecord, cfg *cfg.GameRdtaskCondiData, params ...int32) (ok bool, count int32, err error) {
|
||||
func (this *ModelRtask) verifyRtype20(uid string, cfg *cfg.GameRdtaskCondiData, params ...int32) (ok bool, count int32, err error) {
|
||||
userModule, err := this.service.GetModule(comm.ModuleUser)
|
||||
if err != nil {
|
||||
return
|
||||
@ -400,7 +400,7 @@ func (this *ModelRtask) verifyRtype20(uid string, record *pb.DBRtaskRecord, cfg
|
||||
}
|
||||
|
||||
// 日常任务活跃度达到xx
|
||||
func (this *ModelRtask) verifyRtype63(uid string, record *pb.DBRtaskRecord, cfg *cfg.GameRdtaskCondiData, params ...int32) (ok bool, count int32, err error) {
|
||||
func (this *ModelRtask) verifyRtype63(uid string, cfg *cfg.GameRdtaskCondiData, params ...int32) (ok bool, count int32, err error) {
|
||||
userModule, err := this.service.GetModule(comm.ModuleUser)
|
||||
if err != nil {
|
||||
return
|
||||
@ -421,7 +421,7 @@ func (this *ModelRtask) verifyRtype63(uid string, record *pb.DBRtaskRecord, cfg
|
||||
}
|
||||
|
||||
// 记录玩家在线时间并记入进度
|
||||
func (this *ModelRtask) verifyRtype138(uid string, record *pb.DBRtaskRecord, cfg *cfg.GameRdtaskCondiData, params ...int32) (ok bool, count int32, err error) {
|
||||
func (this *ModelRtask) verifyRtype138(uid string, cfg *cfg.GameRdtaskCondiData, params ...int32) (ok bool, count int32, err error) {
|
||||
userModule, err := this.service.GetModule(comm.ModuleUser)
|
||||
if err != nil {
|
||||
return
|
||||
@ -438,7 +438,7 @@ func (this *ModelRtask) verifyRtype138(uid string, record *pb.DBRtaskRecord, cfg
|
||||
return
|
||||
}
|
||||
|
||||
func (this *ModelRtask) verifyRtype43(uid string, record *pb.DBRtaskRecord, cfg *cfg.GameRdtaskCondiData, params ...int32) (ok bool, count int32, err error) {
|
||||
func (this *ModelRtask) verifyRtype43(uid string, 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 {
|
||||
|
@ -239,12 +239,19 @@ type TaskParams struct {
|
||||
}
|
||||
|
||||
// 任务条件达成通知
|
||||
func (this *Sociaty) TaskcondNotify(uid, sociatyId string, condId int32) error {
|
||||
func (this *Sociaty) TaskcondNotify(uid string, condId int32) error {
|
||||
// log.Debug("公会任务",
|
||||
// log.Field{Key: "uid", Value: uid},
|
||||
// log.Field{Key: "sociatyId", Value: sociatyId},
|
||||
// log.Field{Key: "condId", Value: condId})
|
||||
|
||||
sociaty := this.modelSociaty.getUserSociaty(uid)
|
||||
if sociaty == nil {
|
||||
return fmt.Errorf("公会未找到 uid:%v condId:%v", uid, condId)
|
||||
}
|
||||
|
||||
sociatyId := sociaty.Id
|
||||
|
||||
dt := &pb.DBSociatyTask{}
|
||||
err := this.service.AcrossClusterRpcCall(context.Background(), this.GetCrossTag(),
|
||||
comm.Service_Worker, string(comm.Rpc_ModuleSociatyGetTask),
|
||||
|
@ -161,7 +161,7 @@ func (this *ModelWorldtask) checkCondi(uid string, condiId int32) bool {
|
||||
return false
|
||||
}
|
||||
|
||||
func (this *ModelWorldtask) updateCheckCond(uid string, userTask *pb.DBWorldtask, nextTaskId int32) *pb.DBWorldtask {
|
||||
func (this *ModelWorldtask) updateCheckCond(uid string, userLv int32, userTask *pb.DBWorldtask, nextTaskId int32) *pb.DBWorldtask {
|
||||
//检查下个任务的完成条件
|
||||
nextTaskConf, err := this.moduleWorldtask.configure.getWorldtaskById(nextTaskId)
|
||||
if err != nil {
|
||||
@ -171,6 +171,10 @@ func (this *ModelWorldtask) updateCheckCond(uid string, userTask *pb.DBWorldtask
|
||||
return nil
|
||||
}
|
||||
|
||||
if userLv < nextTaskConf.Lock {
|
||||
return nil
|
||||
}
|
||||
|
||||
if nextTaskConf.Des == 1 || nextTaskConf.Des == 4 {
|
||||
return nil
|
||||
}
|
||||
@ -241,13 +245,17 @@ func (this *ModelWorldtask) updateCheckCond(uid string, userTask *pb.DBWorldtask
|
||||
// 任务完成推送
|
||||
func (this *ModelWorldtask) taskFinishPush(session comm.IUserSession, groupId int32, userTask *pb.DBWorldtask, curTaskConf *cfg.GameWorldTaskData) {
|
||||
this.updateRandomTask(session.GetUserId(), userTask)
|
||||
u := this.moduleWorldtask.ModuleUser.GetUser(session.GetUserId())
|
||||
if u == nil {
|
||||
return
|
||||
}
|
||||
|
||||
nextTaskIds := this.findNextTasks(curTaskConf.Key)
|
||||
this.moduleWorldtask.Debug("nextTaskIds", log.Field{Key: "nextTaskIds", Value: nextTaskIds})
|
||||
|
||||
nextTask := make(map[int32]*pb.Worldtask)
|
||||
for _, next := range nextTaskIds {
|
||||
ut := this.updateCheckCond(session.GetUserId(), userTask, next)
|
||||
ut := this.updateCheckCond(session.GetUserId(), u.Lv, userTask, next)
|
||||
if ut != nil {
|
||||
for k, v := range ut.CurrentTask {
|
||||
nextTask[k] = &pb.Worldtask{
|
||||
|
Loading…
Reference in New Issue
Block a user