From 2320b9a280fb68677d210be0a3cf27ac9cd340e0 Mon Sep 17 00:00:00 2001 From: wh_zcy Date: Thu, 15 Sep 2022 20:33:34 +0800 Subject: [PATCH] =?UTF-8?q?=E6=9B=B4=E6=96=B0=E5=8A=9F=E8=83=BD=E5=BC=80?= =?UTF-8?q?=E5=90=AF?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- comm/const.go | 7 +++ comm/imodule.go | 4 ++ modules/modulebase.go | 7 +++ modules/rtask/api_choose.go | 2 +- modules/rtask/module.go | 98 +++++++------------------------------ 5 files changed, 36 insertions(+), 82 deletions(-) diff --git a/comm/const.go b/comm/const.go index f93c90e3e..eee2c0575 100644 --- a/comm/const.go +++ b/comm/const.go @@ -66,6 +66,7 @@ const ( //数据表名定义处 const ( + TableSys = "sys" ///数据日志表 TableModellog = "model_log" ///用户会话数据表 @@ -200,6 +201,12 @@ const ( ResTaskActive = "taskActive" //任务活跃度 ) +const ( + Gold int32 = 1 //金币 + Diamond int32 = 2 //钻石 + +) + type TaskType int32 // 日常任务事件类型 diff --git a/comm/imodule.go b/comm/imodule.go index 01246c317..cc7aeec7b 100644 --- a/comm/imodule.go +++ b/comm/imodule.go @@ -15,6 +15,10 @@ type ( Describe string //调用描述 } + ISys interface { + IsAccess(funcName string, userLv int32) bool + } + //邮件业务模块对外接口定义 提供给其他模块使用的 Imail interface { CreateNewMail(session IUserSession, mail *pb.DBMailData) bool diff --git a/modules/modulebase.go b/modules/modulebase.go index f5bdb68de..c61997f64 100644 --- a/modules/modulebase.go +++ b/modules/modulebase.go @@ -25,6 +25,7 @@ type ModuleBase struct { options IOptions scomp comm.ISC_GateRouteComp //网关服务组件 //常用的一些通用模块 在底层注册好 + ModuleSys comm.ISys //系统 ModuleUser comm.IUser //用户模块 ModuleItems comm.IItems //道具背包模块 ModuleHero comm.IHero //英雄模块 @@ -62,6 +63,7 @@ func (this *ModuleBase) Start() (err error) { if module, err = this.service.GetModule(comm.ModuleUser); err != nil { return } + this.ModuleUser = module.(comm.IUser) if module, err = this.service.GetModule(comm.ModuleItems); err != nil { return @@ -90,6 +92,11 @@ func (this *ModuleBase) Start() (err error) { return } this.ModuleRtask = module.(comm.IRtask) + + if module, err = this.service.GetModule(comm.ModuleSys); err != nil { + return + } + this.ModuleSys = module.(comm.ISys) return } diff --git a/modules/rtask/api_choose.go b/modules/rtask/api_choose.go index 5b34f06d0..da22b2e77 100644 --- a/modules/rtask/api_choose.go +++ b/modules/rtask/api_choose.go @@ -53,7 +53,7 @@ func (this *apiComp) Choose(session comm.IUserSession, req *pb.RtaskChooseReq) ( // 校验限定条件 if err, ok := this.moduleRtask.modelRtask.checkCondi(session.GetUserId(), chooseCnf.PreTid); !ok { - this.moduleRtask.Error(err.Error()) + log.Errorf("no reach condi err: %v", err) code = pb.ErrorCode_RtaskCondiNoReach return } diff --git a/modules/rtask/module.go b/modules/rtask/module.go index c9477d102..91127586e 100644 --- a/modules/rtask/module.go +++ b/modules/rtask/module.go @@ -125,13 +125,6 @@ func (this *ModuleRtask) initRtaskVerifyHandle() { cfg: typeCfg, verify: this.modelRtask.verfiyRtype10, }) - case comm.Rtype11: - this.registerVerifyHandle(v.Id, &rtaskCondi{ - cfg: typeCfg, - find: this.modelRtaskRecord.equalParams, - verify: this.modelRtaskRecord.verifyFromDb, - update: this.modelRtaskRecord.overrideUpdate, - }) case comm.Rtype12, comm.Rtype13, comm.Rtype14, comm.Rtype15: this.registerVerifyHandle(v.Id, &rtaskCondi{ cfg: typeCfg, @@ -139,47 +132,22 @@ func (this *ModuleRtask) initRtaskVerifyHandle() { verify: this.modelRtaskRecord.verifyFromDb, update: this.modelRtaskRecord.addUpdate, }) - case comm.Rtype16, comm.Rtype17, comm.Rtype19: - this.registerVerifyHandle(v.Id, &rtaskCondi{ - cfg: typeCfg, - find: this.modelRtaskRecord.equalParams, - verify: this.modelRtaskRecord.verifyFromDb, - update: this.modelRtaskRecord.overrideUpdate, - }) - case comm.Rtype18: - this.registerVerifyHandle(v.Id, &rtaskCondi{ - cfg: typeCfg, - find: this.modelRtaskRecord.lessThanParams, - verify: this.modelRtaskRecord.verifyFromDb, - update: this.modelRtaskRecord.overrideUpdate, - }) case comm.Rtype20: this.registerVerifyHandle(v.Id, &rtaskCondi{ cfg: typeCfg, verify: this.modelRtask.verifyRtype20, }) - case comm.Rtype21: + case comm.Rtype11, comm.Rtype16, comm.Rtype17, comm.Rtype21, + comm.Rtype22, comm.Rtype35, comm.Rtype40, comm.Rtype44, + comm.Rtype59, comm.Rtype61, comm.Rtype70: this.registerVerifyHandle(v.Id, &rtaskCondi{ cfg: typeCfg, find: this.modelRtaskRecord.equalParams, verify: this.modelRtaskRecord.verifyFromDb, update: this.modelRtaskRecord.overrideUpdate, }) - case comm.Rtype22: - this.registerVerifyHandle(v.Id, &rtaskCondi{ - cfg: typeCfg, - find: this.modelRtaskRecord.equalParams, - verify: this.modelRtaskRecord.verifyFromDb, - update: this.modelRtaskRecord.overrideUpdate, - }) - case comm.Rtype23: - this.registerVerifyHandle(v.Id, &rtaskCondi{ - cfg: typeCfg, - find: this.modelRtaskRecord.lessThanParams, - verify: this.modelRtaskRecord.verifyFromDb, - update: this.modelRtaskRecord.addUpdate, - }) - case comm.Rtype24, comm.Rtype25, comm.Rtype26, comm.Rtype27, + case comm.Rtype18, comm.Rtype19, comm.Rtype23, comm.Rtype24, + comm.Rtype25, comm.Rtype26, comm.Rtype27, comm.Rtype28, comm.Rtype29, comm.Rtype30, comm.Rtype31, comm.Rtype32, comm.Rtype33, comm.Rtype34, comm.Rtype36, comm.Rtype37, comm.Rtype38, comm.Rtype39, comm.Rtype41, @@ -188,60 +156,18 @@ func (this *ModuleRtask) initRtaskVerifyHandle() { comm.Rtype50, comm.Rtype51, comm.Rtype52, comm.Rtype53, comm.Rtype54, comm.Rtype55, comm.Rtype56, comm.Rtype57, comm.Rtype58, comm.Rtype60, comm.Rtype62, comm.Rtype64, - comm.Rtype65, comm.Rtype66, comm.Rtype67, comm.Rtype69: + comm.Rtype65, comm.Rtype66, comm.Rtype67, comm.Rtype68, comm.Rtype69: this.registerVerifyHandle(v.Id, &rtaskCondi{ cfg: typeCfg, find: this.modelRtaskRecord.lessThanParams, verify: this.modelRtaskRecord.verifyFromDb, update: this.modelRtaskRecord.addUpdate, }) - case comm.Rtype35: - this.registerVerifyHandle(v.Id, &rtaskCondi{ - cfg: typeCfg, - find: this.modelRtaskRecord.equalParams, - verify: this.modelRtaskRecord.verifyFromDb, - update: this.modelRtaskRecord.overrideUpdate, - }) - case comm.Rtype40: - this.registerVerifyHandle(v.Id, &rtaskCondi{ - cfg: typeCfg, - find: this.modelRtaskRecord.equalParams, - verify: this.modelRtaskRecord.verifyFromDb, - update: this.modelRtaskRecord.overrideUpdate, - }) - case comm.Rtype44, comm.Rtype59: - this.registerVerifyHandle(v.Id, &rtaskCondi{ - cfg: typeCfg, - find: this.modelRtaskRecord.equalParams, - verify: this.modelRtaskRecord.verifyFromDb, - update: this.modelRtaskRecord.overrideUpdate, - }) - case comm.Rtype61: - this.registerVerifyHandle(v.Id, &rtaskCondi{ - cfg: typeCfg, - find: this.modelRtaskRecord.equalParams, - verify: this.modelRtaskRecord.verifyFromDb, - update: this.modelRtaskRecord.overrideUpdate, - }) case comm.Rtype63: this.registerVerifyHandle(v.Id, &rtaskCondi{ cfg: typeCfg, verify: this.modelRtask.verifyRtype63, }) - case comm.Rtype68: - this.registerVerifyHandle(v.Id, &rtaskCondi{ - cfg: typeCfg, - find: this.modelRtaskRecord.equalParams, - verify: this.modelRtaskRecord.verifyFromDb, - update: this.modelRtaskRecord.overrideUpdate, - }) - case comm.Rtype70: - this.registerVerifyHandle(v.Id, &rtaskCondi{ - cfg: typeCfg, - find: this.modelRtaskRecord.equalParams, - verify: this.modelRtaskRecord.verifyFromDb, - update: this.modelRtaskRecord.overrideUpdate, - }) default: log.Warnf("rtaskType[%v] not register", typeCfg.Type) } @@ -257,6 +183,12 @@ func (this *ModuleRtask) SendToRtask(session comm.IUserSession, rtaskType comm.T condi *rtaskCondi ) + user := this.ModuleUser.GetUser(session.GetUserId()) + if user == nil { + code = pb.ErrorCode_UserSessionNobeing + return + } + for _, v := range this.handleMap { // 找到任务类型 if int32(rtaskType) == v.cfg.Type { @@ -266,7 +198,11 @@ func (this *ModuleRtask) SendToRtask(session comm.IUserSession, rtaskType comm.T if condiId = v.find(v.cfg, params...); condiId == 0 { continue } else { - condi = v + //数据记录方式是1 + if v.cfg.Datatype == 1 || + v.cfg.Datatype == 2 && this.ModuleSys.IsAccess("task", user.Lv) { + condi = v + } break } }