This commit is contained in:
liwei1dao 2022-09-16 11:14:40 +08:00
commit c56138e9dc
8 changed files with 83 additions and 81 deletions

View File

@ -66,6 +66,7 @@ const (
//数据表名定义处 //数据表名定义处
const ( const (
TableSys = "sys"
///数据日志表 ///数据日志表
TableModellog = "model_log" TableModellog = "model_log"
///用户会话数据表 ///用户会话数据表
@ -200,6 +201,12 @@ const (
ResTaskActive = "taskActive" //任务活跃度 ResTaskActive = "taskActive" //任务活跃度
) )
const (
Gold int32 = 1 //金币
Diamond int32 = 2 //钻石
)
type TaskType int32 type TaskType int32
// 日常任务事件类型 // 日常任务事件类型

View File

@ -15,6 +15,10 @@ type (
Describe string //调用描述 Describe string //调用描述
} }
ISys interface {
IsAccess(funcName string, userLv int32) bool
}
//邮件业务模块对外接口定义 提供给其他模块使用的 //邮件业务模块对外接口定义 提供给其他模块使用的
Imail interface { Imail interface {
CreateNewMail(session IUserSession, mail *pb.DBMailData) bool CreateNewMail(session IUserSession, mail *pb.DBMailData) bool

View File

@ -25,6 +25,7 @@ type ModuleBase struct {
options IOptions options IOptions
scomp comm.ISC_GateRouteComp //网关服务组件 scomp comm.ISC_GateRouteComp //网关服务组件
//常用的一些通用模块 在底层注册好 //常用的一些通用模块 在底层注册好
ModuleSys comm.ISys //系统
ModuleUser comm.IUser //用户模块 ModuleUser comm.IUser //用户模块
ModuleItems comm.IItems //道具背包模块 ModuleItems comm.IItems //道具背包模块
ModuleHero comm.IHero //英雄模块 ModuleHero comm.IHero //英雄模块
@ -62,6 +63,7 @@ func (this *ModuleBase) Start() (err error) {
if module, err = this.service.GetModule(comm.ModuleUser); err != nil { if module, err = this.service.GetModule(comm.ModuleUser); err != nil {
return return
} }
this.ModuleUser = module.(comm.IUser) this.ModuleUser = module.(comm.IUser)
if module, err = this.service.GetModule(comm.ModuleItems); err != nil { if module, err = this.service.GetModule(comm.ModuleItems); err != nil {
return return
@ -90,6 +92,11 @@ func (this *ModuleBase) Start() (err error) {
return return
} }
this.ModuleRtask = module.(comm.IRtask) this.ModuleRtask = module.(comm.IRtask)
if module, err = this.service.GetModule(comm.ModuleSys); err != nil {
return
}
this.ModuleSys = module.(comm.ISys)
return return
} }

View File

@ -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 { 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 code = pb.ErrorCode_RtaskCondiNoReach
return return
} }

View File

@ -125,13 +125,6 @@ func (this *ModuleRtask) initRtaskVerifyHandle() {
cfg: typeCfg, cfg: typeCfg,
verify: this.modelRtask.verfiyRtype10, 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: case comm.Rtype12, comm.Rtype13, comm.Rtype14, comm.Rtype15:
this.registerVerifyHandle(v.Id, &rtaskCondi{ this.registerVerifyHandle(v.Id, &rtaskCondi{
cfg: typeCfg, cfg: typeCfg,
@ -139,47 +132,22 @@ func (this *ModuleRtask) initRtaskVerifyHandle() {
verify: this.modelRtaskRecord.verifyFromDb, verify: this.modelRtaskRecord.verifyFromDb,
update: this.modelRtaskRecord.addUpdate, 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: case comm.Rtype20:
this.registerVerifyHandle(v.Id, &rtaskCondi{ this.registerVerifyHandle(v.Id, &rtaskCondi{
cfg: typeCfg, cfg: typeCfg,
verify: this.modelRtask.verifyRtype20, 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{ this.registerVerifyHandle(v.Id, &rtaskCondi{
cfg: typeCfg, cfg: typeCfg,
find: this.modelRtaskRecord.equalParams, find: this.modelRtaskRecord.equalParams,
verify: this.modelRtaskRecord.verifyFromDb, verify: this.modelRtaskRecord.verifyFromDb,
update: this.modelRtaskRecord.overrideUpdate, update: this.modelRtaskRecord.overrideUpdate,
}) })
case comm.Rtype22: case comm.Rtype18, comm.Rtype19, comm.Rtype23, comm.Rtype24,
this.registerVerifyHandle(v.Id, &rtaskCondi{ comm.Rtype25, comm.Rtype26, comm.Rtype27,
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,
comm.Rtype28, comm.Rtype29, comm.Rtype30, comm.Rtype31, comm.Rtype28, comm.Rtype29, comm.Rtype30, comm.Rtype31,
comm.Rtype32, comm.Rtype33, comm.Rtype34, comm.Rtype36, comm.Rtype32, comm.Rtype33, comm.Rtype34, comm.Rtype36,
comm.Rtype37, comm.Rtype38, comm.Rtype39, comm.Rtype41, 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.Rtype50, comm.Rtype51, comm.Rtype52, comm.Rtype53,
comm.Rtype54, comm.Rtype55, comm.Rtype56, comm.Rtype57, comm.Rtype54, comm.Rtype55, comm.Rtype56, comm.Rtype57,
comm.Rtype58, comm.Rtype60, comm.Rtype62, comm.Rtype64, 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{ this.registerVerifyHandle(v.Id, &rtaskCondi{
cfg: typeCfg, cfg: typeCfg,
find: this.modelRtaskRecord.lessThanParams, find: this.modelRtaskRecord.lessThanParams,
verify: this.modelRtaskRecord.verifyFromDb, verify: this.modelRtaskRecord.verifyFromDb,
update: this.modelRtaskRecord.addUpdate, 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: case comm.Rtype63:
this.registerVerifyHandle(v.Id, &rtaskCondi{ this.registerVerifyHandle(v.Id, &rtaskCondi{
cfg: typeCfg, cfg: typeCfg,
verify: this.modelRtask.verifyRtype63, 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: default:
log.Warnf("rtaskType[%v] not register", typeCfg.Type) log.Warnf("rtaskType[%v] not register", typeCfg.Type)
} }
@ -257,6 +183,12 @@ func (this *ModuleRtask) SendToRtask(session comm.IUserSession, rtaskType comm.T
condi *rtaskCondi condi *rtaskCondi
) )
user := this.ModuleUser.GetUser(session.GetUserId())
if user == nil {
code = pb.ErrorCode_UserSessionNobeing
return
}
for _, v := range this.handleMap { for _, v := range this.handleMap {
// 找到任务类型 // 找到任务类型
if int32(rtaskType) == v.cfg.Type { 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 { if condiId = v.find(v.cfg, params...); condiId == 0 {
continue continue
} else { } else {
//数据记录方式是1
// if v.cfg.Datatype == 1 ||
// v.cfg.Datatype == 2 && this.ModuleSys.IsAccess("task", user.Lv) {
condi = v condi = v
// }
break break
} }
} }

View File

@ -37,6 +37,15 @@ func (this *configureComp) getOpencondCfg() (data *cfg.GameOpencond, err error)
return 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) { func (this *configureComp) getOpencondList() (list []*cfg.GameOpencondData) {
if cfg, err := this.getOpencondCfg(); err != nil { if cfg, err := this.getOpencondCfg(); err != nil {
return nil return nil

30
modules/sys/model_sys.go Normal file
View File

@ -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
}

View File

@ -6,10 +6,14 @@ import (
"go_dreamfactory/modules" "go_dreamfactory/modules"
) )
var _ comm.ISys = (*ModuleSys)(nil)
type ModuleSys struct { type ModuleSys struct {
modules.ModuleBase modules.ModuleBase
api *apiComp api *apiComp
configure *configureComp configure *configureComp
modelSys *ModelSys
} }
func NewModule() core.IModule { func NewModule() core.IModule {
@ -19,9 +23,14 @@ func NewModule() core.IModule {
func (this *ModuleSys) OnInstallComp() { func (this *ModuleSys) OnInstallComp() {
this.ModuleBase.OnInstallComp() this.ModuleBase.OnInstallComp()
this.api = this.RegisterComp(new(apiComp)).(*apiComp) this.api = this.RegisterComp(new(apiComp)).(*apiComp)
this.modelSys = this.RegisterComp(new(ModelSys)).(*ModelSys)
this.configure = this.RegisterComp(new(configureComp)).(*configureComp) this.configure = this.RegisterComp(new(configureComp)).(*configureComp)
} }
func (this *ModuleSys) GetType() core.M_Modules { func (this *ModuleSys) GetType() core.M_Modules {
return comm.ModuleSys return comm.ModuleSys
} }
func (this *ModuleSys) IsAccess(funcName string, userLv int32) bool {
return this.modelSys.IsAccess(funcName, userLv)
}