97 lines
2.4 KiB
Go
97 lines
2.4 KiB
Go
package sys
|
|
|
|
import (
|
|
"go_dreamfactory/comm"
|
|
"go_dreamfactory/lego/core"
|
|
"go_dreamfactory/modules"
|
|
"go_dreamfactory/pb"
|
|
cfg "go_dreamfactory/sys/configure/structs"
|
|
)
|
|
|
|
var _ comm.ISys = (*ModuleSys)(nil)
|
|
|
|
type ModuleSys struct {
|
|
modules.ModuleBase
|
|
api *apiComp
|
|
configure *configureComp
|
|
|
|
modelSys *ModelSys
|
|
}
|
|
|
|
func NewModule() core.IModule {
|
|
return &ModuleSys{}
|
|
}
|
|
|
|
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) Start() (err error) {
|
|
err = this.ModuleBase.Start()
|
|
return
|
|
}
|
|
|
|
func (this *ModuleSys) GetType() core.M_Modules {
|
|
return comm.ModuleSys
|
|
}
|
|
|
|
func (this *ModuleSys) IsAccess(funcName string, userId string) (errdata *pb.ErrorData) {
|
|
return this.modelSys.IsAccess(funcName, userId)
|
|
}
|
|
|
|
func (this *ModuleSys) ValidCond(uid string, conf *cfg.GameOpencondData) string {
|
|
return this.modelSys.validCond(uid, conf)
|
|
}
|
|
|
|
func (this *ModuleSys) CheckLvUpCond(session comm.IUserSession, lv int32) {
|
|
if cond := this.configure.GetOpencondLv(lv); len(cond) > 0 {
|
|
this.AutoActivate(session, cond)
|
|
}
|
|
}
|
|
func (this *ModuleSys) CheckMlineCond(session comm.IUserSession, id int32) {
|
|
if cond := this.configure.getOpencondMline(id); len(cond) > 0 {
|
|
this.AutoActivate(session, cond)
|
|
}
|
|
}
|
|
func (this *ModuleSys) CheckTaskCond(session comm.IUserSession, id int32) {
|
|
if cond := this.configure.getOpencondTask(id); len(cond) > 0 {
|
|
this.AutoActivate(session, cond)
|
|
}
|
|
}
|
|
|
|
// 自动激活
|
|
func (this *ModuleSys) AutoActivate(session comm.IUserSession, cids []string) bool {
|
|
var (
|
|
szOpen []string
|
|
)
|
|
list, _ := this.modelSys.GetOpenCondList(session.GetUserId())
|
|
for _, cid := range cids {
|
|
opencfg := this.configure.getOpencondCfgByCid(cid)
|
|
if opencfg != nil {
|
|
if id := this.modelSys.validCond(session.GetUserId(), opencfg); id == "" { // 条件不满足
|
|
break
|
|
}
|
|
}
|
|
for k, v := range list.Cond {
|
|
if k == cid && v != 0 {
|
|
list.Cond[cid] = 1
|
|
szOpen = append(szOpen, cid)
|
|
break
|
|
}
|
|
}
|
|
}
|
|
if len(szOpen) > 0 {
|
|
this.modelSys.ChangeOpenCondData(session.GetUserId(), map[string]interface{}{
|
|
"cond": list.Cond,
|
|
})
|
|
}
|
|
// 推送变化
|
|
session.SendMsg(string(this.GetType()), "open", &pb.SysFuncOpnePush{
|
|
Cid: szOpen,
|
|
})
|
|
return true
|
|
}
|