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..5442e3b89 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 { + //数据记录方式是1 + // if v.cfg.Datatype == 1 || + // v.cfg.Datatype == 2 && this.ModuleSys.IsAccess("task", user.Lv) { condi = v + // } break } } diff --git a/modules/sys/config.go b/modules/sys/config.go index 3547f4bdb..b86fef7bc 100644 --- a/modules/sys/config.go +++ b/modules/sys/config.go @@ -37,6 +37,15 @@ func (this *configureComp) getOpencondCfg() (data *cfg.GameOpencond, err error) return } +func (this *configureComp) getFuncCfg(funcName string) (data *cfg.GameOpencondData) { + if cfg, err := this.getOpencondCfg(); err != nil { + return nil + } else { + data = cfg.GetDataMap()[funcName] + } + return +} + func (this *configureComp) getOpencondList() (list []*cfg.GameOpencondData) { if cfg, err := this.getOpencondCfg(); err != nil { return nil diff --git a/modules/sys/model_sys.go b/modules/sys/model_sys.go new file mode 100644 index 000000000..e6feddb94 --- /dev/null +++ b/modules/sys/model_sys.go @@ -0,0 +1,30 @@ +package sys + +import ( + "go_dreamfactory/comm" + "go_dreamfactory/lego/core" + "go_dreamfactory/modules" +) + +type ModelSys struct { + modules.MCompModel + moduleSys *ModuleSys + service core.IService +} + +func (this *ModelSys) Init(service core.IService, module core.IModule, comp core.IModuleComp, options core.IModuleOptions) (err error) { + this.TableName = comm.TableSys + err = this.MCompModel.Init(service, module, comp, options) + this.moduleSys = module.(*ModuleSys) + this.service = service + return +} + +// 是否允许访问功能,条件:玩家等级 +func (this *ModelSys) IsAccess(funName string, userLv int32) bool { + conf := this.moduleSys.configure.getFuncCfg(funName) + if conf != nil { + return userLv >= conf.Main + } + return false +} diff --git a/modules/sys/module.go b/modules/sys/module.go index e1b5cc7b9..a077ae4d4 100644 --- a/modules/sys/module.go +++ b/modules/sys/module.go @@ -6,10 +6,14 @@ import ( "go_dreamfactory/modules" ) +var _ comm.ISys = (*ModuleSys)(nil) + type ModuleSys struct { modules.ModuleBase api *apiComp configure *configureComp + + modelSys *ModelSys } func NewModule() core.IModule { @@ -19,9 +23,14 @@ func NewModule() core.IModule { func (this *ModuleSys) OnInstallComp() { this.ModuleBase.OnInstallComp() this.api = this.RegisterComp(new(apiComp)).(*apiComp) + this.modelSys = this.RegisterComp(new(ModelSys)).(*ModelSys) this.configure = this.RegisterComp(new(configureComp)).(*configureComp) } func (this *ModuleSys) GetType() core.M_Modules { return comm.ModuleSys } + +func (this *ModuleSys) IsAccess(funcName string, userLv int32) bool { + return this.modelSys.IsAccess(funcName, userLv) +}