Merge branch 'dev' of http://git.legu.cc/liwei_3d/go_dreamfactory into dev
This commit is contained in:
commit
c56138e9dc
@ -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
|
||||
|
||||
// 日常任务事件类型
|
||||
|
@ -15,6 +15,10 @@ type (
|
||||
Describe string //调用描述
|
||||
}
|
||||
|
||||
ISys interface {
|
||||
IsAccess(funcName string, userLv int32) bool
|
||||
}
|
||||
|
||||
//邮件业务模块对外接口定义 提供给其他模块使用的
|
||||
Imail interface {
|
||||
CreateNewMail(session IUserSession, mail *pb.DBMailData) bool
|
||||
|
@ -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
|
||||
}
|
||||
|
||||
|
@ -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
|
||||
}
|
||||
|
@ -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
|
||||
}
|
||||
}
|
||||
|
@ -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
|
||||
|
30
modules/sys/model_sys.go
Normal file
30
modules/sys/model_sys.go
Normal 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
|
||||
}
|
@ -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)
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user