优化功能开启功能
This commit is contained in:
parent
f499c8dc2b
commit
bbd4b54757
@ -13,6 +13,7 @@ import (
|
|||||||
const (
|
const (
|
||||||
game_annulartaskall = "game_annulartaskall.json"
|
game_annulartaskall = "game_annulartaskall.json"
|
||||||
game_annulartask_library = "game_annulartask_library.json"
|
game_annulartask_library = "game_annulartask_library.json"
|
||||||
|
game_opencond = "game_opencond.json"
|
||||||
)
|
)
|
||||||
|
|
||||||
type configureComp struct {
|
type configureComp struct {
|
||||||
@ -26,8 +27,8 @@ func (this *configureComp) Init(service core.IService, module core.IModule, comp
|
|||||||
err = this.MCompConfigure.Init(service, module, comp, options)
|
err = this.MCompConfigure.Init(service, module, comp, options)
|
||||||
this.module = module.(*Dailytask)
|
this.module = module.(*Dailytask)
|
||||||
err = this.LoadMultiConfigure(map[string]interface{}{
|
err = this.LoadMultiConfigure(map[string]interface{}{
|
||||||
game_annulartaskall: cfg.NewGameAnnulartaskAll,
|
game_annulartaskall: cfg.NewGameAnnulartaskAll,
|
||||||
game_annulartask_library: cfg.NewGameAnnulartask_Library,
|
game_opencond: cfg.NewGameOpencond,
|
||||||
})
|
})
|
||||||
configure.RegisterConfigure(game_annulartask_library, cfg.NewGameAnnulartask_Library, this.updateconfigure)
|
configure.RegisterConfigure(game_annulartask_library, cfg.NewGameAnnulartask_Library, this.updateconfigure)
|
||||||
return
|
return
|
||||||
@ -137,3 +138,19 @@ func (this *configureComp) getAnnulartaskLibrary(ulv, group int32) (results *cfg
|
|||||||
results = canuse[index]
|
results = canuse[index]
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (this *configureComp) getOpencondCfg(id string) (conf *cfg.GameOpencondData, err error) {
|
||||||
|
var (
|
||||||
|
v interface{}
|
||||||
|
ok bool
|
||||||
|
)
|
||||||
|
if v, err = this.GetConfigure(game_opencond); err == nil {
|
||||||
|
err = fmt.Errorf("%T no is *cfg.GameOpencond", v)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
if conf, ok = v.(*cfg.GameOpencond).GetDataMap()[id]; !ok {
|
||||||
|
err = comm.NewNotFoundConfErr(string(this.module.GetType()), game_opencond, id)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
return
|
||||||
|
}
|
||||||
|
@ -8,6 +8,7 @@ import (
|
|||||||
"go_dreamfactory/modules"
|
"go_dreamfactory/modules"
|
||||||
"go_dreamfactory/pb"
|
"go_dreamfactory/pb"
|
||||||
"go_dreamfactory/sys/configure"
|
"go_dreamfactory/sys/configure"
|
||||||
|
cfg "go_dreamfactory/sys/configure/structs"
|
||||||
"go_dreamfactory/sys/db"
|
"go_dreamfactory/sys/db"
|
||||||
"go_dreamfactory/utils"
|
"go_dreamfactory/utils"
|
||||||
)
|
)
|
||||||
@ -61,14 +62,18 @@ func (this *Dailytask) OnInstallComp() {
|
|||||||
// 用户登录
|
// 用户登录
|
||||||
func (this *Dailytask) EventUserLogin(session comm.IUserSession) {
|
func (this *Dailytask) EventUserLogin(session comm.IUserSession) {
|
||||||
var (
|
var (
|
||||||
isopen bool
|
conf *cfg.GameOpencondData
|
||||||
|
err error
|
||||||
|
ok bool
|
||||||
)
|
)
|
||||||
|
|
||||||
if db.IsCross() { //跨服不支持
|
if db.IsCross() { //跨服不支持
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
if conf, err = this.configure.getOpencondCfg("annulartask"); err != nil {
|
||||||
if isopen, _ = this.ModuleSys.CheckOpenCondCfgById(session.GetUserId(), "annulartask"); !isopen {
|
return
|
||||||
|
}
|
||||||
|
if ok, _, _ = this.ModuleBuried.CheckCondition(session, conf.Opencondi...); !ok {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
this.refreshtask(session)
|
this.refreshtask(session)
|
||||||
|
@ -209,30 +209,30 @@ func (this *Practice) TaskComplete(session comm.IUserSession, taskid ...int32) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (this *Practice) OpenCmdNotice(session comm.IUserSession, keys ...string) {
|
func (this *Practice) OpenCmdNotice(session comm.IUserSession, keys ...string) {
|
||||||
this.Debug("OpenCmdNotice",
|
// this.Debug("OpenCmdNotice",
|
||||||
log.Field{Key: "session", Value: session.GetUserId()},
|
// log.Field{Key: "session", Value: session.GetUserId()},
|
||||||
log.Field{Key: "key", Value: keys},
|
// log.Field{Key: "key", Value: keys},
|
||||||
)
|
// )
|
||||||
if !this.IsCross() {
|
// if !this.IsCross() {
|
||||||
for _, v := range keys {
|
// for _, v := range keys {
|
||||||
if v == "practice_ pillar1" || v == "practice_ pillar2" || v == "practice_ pillar3" {
|
// if v == "practice_ pillar1" || v == "practice_ pillar2" || v == "practice_ pillar3" {
|
||||||
err := this.service.AcrossClusterRpcCall(context.Background(), this.GetCrossTag(),
|
// err := this.service.AcrossClusterRpcCall(context.Background(), this.GetCrossTag(),
|
||||||
comm.Service_Worker, string(comm.RPC_ModulePracticeUnLockPillar),
|
// comm.Service_Worker, string(comm.RPC_ModulePracticeUnLockPillar),
|
||||||
&pb.RPCGeneralReqA2{Param1: session.GetUserId(), Param2: v}, &pb.EmptyResp{})
|
// &pb.RPCGeneralReqA2{Param1: session.GetUserId(), Param2: v}, &pb.EmptyResp{})
|
||||||
if err != nil {
|
// if err != nil {
|
||||||
this.Errorln(err)
|
// this.Errorln(err)
|
||||||
return
|
// return
|
||||||
}
|
// }
|
||||||
}
|
// }
|
||||||
}
|
// }
|
||||||
|
|
||||||
} else {
|
// } else {
|
||||||
for _, v := range keys {
|
// for _, v := range keys {
|
||||||
if v == "practice_ pillar1" || v == "practice_ pillar2" || v == "practice_ pillar3" {
|
// if v == "practice_ pillar1" || v == "practice_ pillar2" || v == "practice_ pillar3" {
|
||||||
this.RPC_ModulePracticeUnLockPillar(context.Background(), &pb.RPCGeneralReqA2{Param1: session.GetUserId(), Param2: v}, &pb.EmptyResp{})
|
// this.RPC_ModulePracticeUnLockPillar(context.Background(), &pb.RPCGeneralReqA2{Param1: session.GetUserId(), Param2: v}, &pb.EmptyResp{})
|
||||||
}
|
// }
|
||||||
}
|
// }
|
||||||
}
|
// }
|
||||||
}
|
}
|
||||||
|
|
||||||
func (this *Practice) ChallengeResults(bid, red, bule string, winSide int32) {
|
func (this *Practice) ChallengeResults(bid, red, bule string, winSide int32) {
|
||||||
|
@ -1,84 +1,87 @@
|
|||||||
package sys
|
package sys
|
||||||
|
|
||||||
import (
|
// import (
|
||||||
"go_dreamfactory/comm"
|
// "fmt"
|
||||||
"go_dreamfactory/lego/core"
|
// "go_dreamfactory/comm"
|
||||||
"go_dreamfactory/pb"
|
// "go_dreamfactory/lego/core"
|
||||||
)
|
// "go_dreamfactory/pb"
|
||||||
|
// cfg "go_dreamfactory/sys/configure/structs"
|
||||||
|
// )
|
||||||
|
|
||||||
func (this *apiComp) FuncActivateCheck(session comm.IUserSession, req *pb.SysFuncActivateReq) (errdata *pb.ErrorData) {
|
// func (this *apiComp) FuncActivateCheck(session comm.IUserSession, req *pb.SysFuncActivateReq) (errdata *pb.ErrorData) {
|
||||||
return
|
// return
|
||||||
}
|
// }
|
||||||
|
|
||||||
// cond 值 为0 表示功能未开启 1 功能开启 需要手动激活 2 功能开启并激活
|
// // cond 值 为0 表示功能未开启 1 功能开启 需要手动激活 2 功能开启并激活
|
||||||
func (this *apiComp) FuncActivate(session comm.IUserSession, req *pb.SysFuncActivateReq) (errdata *pb.ErrorData) {
|
// func (this *apiComp) FuncActivate(session comm.IUserSession, req *pb.SysFuncActivateReq) (errdata *pb.ErrorData) {
|
||||||
var (
|
// var (
|
||||||
list *pb.DBOpenCond
|
// conf *cfg.GameOpencondData
|
||||||
err error
|
// info *pb.DBOpenCond
|
||||||
)
|
// condis []*pb.ConIProgress
|
||||||
rsp := &pb.SysFuncActivateResp{}
|
// ok bool
|
||||||
opencfg, err := this.module.configure.GetOpenCondCfgById(req.Cid)
|
// err error
|
||||||
if err == nil {
|
// )
|
||||||
|
// rsp := &pb.SysFuncActivateResp{}
|
||||||
|
// if conf, err = this.module.configure.GetOpenCondCfgById(req.Cid); err != nil {
|
||||||
|
// errdata = &pb.ErrorData{
|
||||||
|
// Code: pb.ErrorCode_ConfigNoFound,
|
||||||
|
// Title: pb.ErrorCode_ConfigNoFound.ToString(),
|
||||||
|
// Message: req.Cid,
|
||||||
|
// }
|
||||||
|
// return
|
||||||
|
// }
|
||||||
|
|
||||||
if list, err = this.module.modelSys.GetOpenCondList(session.GetUserId()); err != nil {
|
// if info, err = this.module.modelSys.GetOpenCondList(session.GetUserId()); err != nil {
|
||||||
errdata = &pb.ErrorData{
|
// errdata = &pb.ErrorData{
|
||||||
Code: pb.ErrorCode_DBError,
|
// Code: pb.ErrorCode_DBError,
|
||||||
Title: pb.ErrorCode_DBError.ToString(),
|
// Title: pb.ErrorCode_DBError.ToString(),
|
||||||
Message: err.Error(),
|
// Message: err.Error(),
|
||||||
}
|
// }
|
||||||
return
|
// return
|
||||||
}
|
// }
|
||||||
if v, ok := list.Cond[req.Cid]; !ok || v != 1 {
|
// if v, ok := info.Cond[req.Cid]; !ok || v != 1 {
|
||||||
errdata = &pb.ErrorData{
|
// errdata = &pb.ErrorData{
|
||||||
Code: pb.ErrorCode_OpenCondActivate,
|
// Code: pb.ErrorCode_OpenCondActivate,
|
||||||
Title: pb.ErrorCode_OpenCondActivate.ToString(),
|
// Title: pb.ErrorCode_OpenCondActivate.ToString(),
|
||||||
}
|
// }
|
||||||
return
|
// return
|
||||||
}
|
// }
|
||||||
if id := this.module.modelSys.CheckValidCond(session.GetUserId(), opencfg, list); id == "" { // 条件不满足
|
// if ok, condis, _ = this.module.ModuleBuried.CheckCondition(session, conf.Opencondi...); !ok { // 条件不满足
|
||||||
errdata = &pb.ErrorData{
|
// errdata = &pb.ErrorData{
|
||||||
Code: pb.ErrorCode_OpenCondErr,
|
// Code: pb.ErrorCode_OpenCondErr,
|
||||||
Title: pb.ErrorCode_OpenCondErr.ToString(),
|
// Title: pb.ErrorCode_OpenCondErr.ToString(),
|
||||||
Message: req.Cid,
|
// Message: fmt.Sprintln(condis),
|
||||||
}
|
// }
|
||||||
return
|
// return
|
||||||
}
|
// }
|
||||||
} else {
|
|
||||||
errdata = &pb.ErrorData{
|
|
||||||
Code: pb.ErrorCode_ConfigNoFound,
|
|
||||||
Title: pb.ErrorCode_ConfigNoFound.ToString(),
|
|
||||||
Message: req.Cid,
|
|
||||||
}
|
|
||||||
return
|
|
||||||
}
|
|
||||||
|
|
||||||
list.Cond[req.Cid] = 2
|
// info.Cond[req.Cid] = 2
|
||||||
this.module.modelSys.ChangeOpenCondData(session.GetUserId(), map[string]interface{}{
|
// this.module.modelSys.ChangeOpenCondData(session.GetUserId(), map[string]interface{}{
|
||||||
"cond": list.Cond,
|
// "cond": info.Cond,
|
||||||
})
|
// })
|
||||||
rsp.Cid = req.Cid
|
// rsp.Cid = req.Cid
|
||||||
if err := session.SendMsg(string(this.module.GetType()), "funcactivate", rsp); err != nil {
|
// if err := session.SendMsg(string(this.module.GetType()), "funcactivate", rsp); err != nil {
|
||||||
errdata = &pb.ErrorData{
|
// errdata = &pb.ErrorData{
|
||||||
Code: pb.ErrorCode_SystemError,
|
// Code: pb.ErrorCode_SystemError,
|
||||||
Title: pb.ErrorCode_SystemError.ToString(),
|
// Title: pb.ErrorCode_SystemError.ToString(),
|
||||||
}
|
// Message: err.Error(),
|
||||||
return
|
// }
|
||||||
}
|
// return
|
||||||
|
// }
|
||||||
|
|
||||||
go this.module.AsynHandleSession(session.Clone(), func(session comm.IUserSession) {
|
// go this.module.AsynHandleSession(session.Clone(), func(session comm.IUserSession) {
|
||||||
//手动激活通知模块
|
// //手动激活通知模块
|
||||||
for _, m := range opencfg.Notify {
|
// for _, m := range conf.Notify {
|
||||||
i, err := this.service.GetModule(core.M_Modules(m))
|
// i, err := this.service.GetModule(core.M_Modules(m))
|
||||||
if err != nil {
|
// if err != nil {
|
||||||
this.module.Errorln(err)
|
// this.module.Errorln(err)
|
||||||
continue
|
// continue
|
||||||
}
|
// }
|
||||||
|
// if ic, ok := i.(comm.IOpenCmdNotice); ok {
|
||||||
|
// ic.OpenCmdNotice(session, req.Cid)
|
||||||
|
// }
|
||||||
|
// }
|
||||||
|
// })
|
||||||
|
|
||||||
if ic, ok := i.(comm.IOpenCmdNotice); ok {
|
// return
|
||||||
ic.OpenCmdNotice(session, req.Cid)
|
// }
|
||||||
}
|
|
||||||
}
|
|
||||||
})
|
|
||||||
|
|
||||||
return
|
|
||||||
}
|
|
||||||
|
@ -1,103 +1,28 @@
|
|||||||
package sys
|
package sys
|
||||||
|
|
||||||
import (
|
// import (
|
||||||
"go_dreamfactory/comm"
|
// "go_dreamfactory/comm"
|
||||||
"go_dreamfactory/lego/core"
|
// "go_dreamfactory/pb"
|
||||||
"go_dreamfactory/pb"
|
// )
|
||||||
)
|
|
||||||
|
|
||||||
func (this *apiComp) FuncGetListCheck(session comm.IUserSession, req *pb.SysFuncGetListReq) (errdata *pb.ErrorData) {
|
// func (this *apiComp) FuncGetListCheck(session comm.IUserSession, req *pb.SysFuncGetListReq) (errdata *pb.ErrorData) {
|
||||||
return
|
// return
|
||||||
}
|
// }
|
||||||
|
|
||||||
func (this *apiComp) FuncGetList(session comm.IUserSession, req *pb.SysFuncGetListReq) (errdata *pb.ErrorData) {
|
// func (this *apiComp) FuncGetList(session comm.IUserSession, req *pb.SysFuncGetListReq) (errdata *pb.ErrorData) {
|
||||||
|
|
||||||
var (
|
// var (
|
||||||
bChange bool
|
// info *pb.DBOpenCond
|
||||||
change []string = make([]string, 0)
|
// err error
|
||||||
list *pb.DBOpenCond
|
// )
|
||||||
)
|
// if info, err = this.module.modelSys.GetOpenCondList(session.GetUserId()); err != nil {
|
||||||
rsp := &pb.SysFuncGetListResp{}
|
// errdata = &pb.ErrorData{
|
||||||
rsp.Cond = make(map[string]int32, 0)
|
// Code: pb.ErrorCode_DBError,
|
||||||
opencfg, err := this.module.configure.getOpencondCfg()
|
// Title: pb.ErrorCode_DBError.ToString(),
|
||||||
if err != nil {
|
// Message: err.Error(),
|
||||||
errdata = &pb.ErrorData{
|
// }
|
||||||
Code: pb.ErrorCode_ConfigNoFound,
|
// return
|
||||||
Message: err.Error(),
|
// }
|
||||||
}
|
// session.SendMsg(string(this.module.GetType()), "funcgetlist", &pb.SysFuncGetListResp{Cond: info.Cond})
|
||||||
return
|
// return
|
||||||
}
|
// }
|
||||||
if list, err = this.module.modelSys.GetOpenCondList(session.GetUserId()); err != nil {
|
|
||||||
errdata = &pb.ErrorData{
|
|
||||||
Code: pb.ErrorCode_DBError,
|
|
||||||
Title: pb.ErrorCode_DBError.ToString(),
|
|
||||||
Message: err.Error(),
|
|
||||||
}
|
|
||||||
return
|
|
||||||
}
|
|
||||||
if len(req.Keys) == 0 {
|
|
||||||
for _, v := range opencfg.GetDataList() {
|
|
||||||
if list.Cond[v.Id] == 0 {
|
|
||||||
|
|
||||||
id := this.module.modelSys.CheckValidCond(session.GetUserId(), v, list)
|
|
||||||
if id != "" {
|
|
||||||
if v.ActivateType { // 需要手动激活的
|
|
||||||
list.Cond[id] = 1 //设置激活
|
|
||||||
} else {
|
|
||||||
list.Cond[id] = 2 //自动激活
|
|
||||||
change = append(change, id)
|
|
||||||
}
|
|
||||||
bChange = true
|
|
||||||
}
|
|
||||||
}
|
|
||||||
rsp.Cond[v.Id] = list.Cond[v.Id]
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
for _, key := range req.Keys {
|
|
||||||
if list.Cond[key] == 0 {
|
|
||||||
if conf, ok := opencfg.GetDataMap()[key]; ok {
|
|
||||||
id := this.module.modelSys.CheckValidCond(session.GetUserId(), conf, list)
|
|
||||||
if id != "" {
|
|
||||||
if conf.ActivateType { // 需要手动激活的
|
|
||||||
list.Cond[id] = 1 //设置激活
|
|
||||||
} else {
|
|
||||||
list.Cond[id] = 2 //自动激活
|
|
||||||
change = append(change, id)
|
|
||||||
}
|
|
||||||
bChange = true
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
rsp.Cond[key] = list.Cond[key]
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if bChange {
|
|
||||||
this.module.modelSys.ChangeOpenCondData(session.GetUserId(), map[string]interface{}{
|
|
||||||
"cond": list.Cond,
|
|
||||||
})
|
|
||||||
}
|
|
||||||
session.SendMsg(string(this.module.GetType()), "funcgetlist", rsp)
|
|
||||||
|
|
||||||
if len(change) > 0 {
|
|
||||||
go this.module.AsynHandleSession(session.Clone(), func(session comm.IUserSession) {
|
|
||||||
//手动激活通知模块
|
|
||||||
for _, m := range change {
|
|
||||||
opencfg, _ := this.module.configure.GetOpenCondCfgById(m)
|
|
||||||
for _, v := range opencfg.Notify {
|
|
||||||
i, err := this.service.GetModule(core.M_Modules(v))
|
|
||||||
if err != nil {
|
|
||||||
this.module.Errorln(err)
|
|
||||||
continue
|
|
||||||
}
|
|
||||||
if ic, ok := i.(comm.IOpenCmdNotice); ok {
|
|
||||||
ic.OpenCmdNotice(session, m)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
})
|
|
||||||
|
|
||||||
}
|
|
||||||
return
|
|
||||||
}
|
|
||||||
|
@ -5,7 +5,9 @@ import (
|
|||||||
"go_dreamfactory/comm"
|
"go_dreamfactory/comm"
|
||||||
"go_dreamfactory/lego/core"
|
"go_dreamfactory/lego/core"
|
||||||
"go_dreamfactory/modules"
|
"go_dreamfactory/modules"
|
||||||
|
"go_dreamfactory/sys/configure"
|
||||||
cfg "go_dreamfactory/sys/configure/structs"
|
cfg "go_dreamfactory/sys/configure/structs"
|
||||||
|
"sync"
|
||||||
)
|
)
|
||||||
|
|
||||||
const (
|
const (
|
||||||
@ -14,24 +16,50 @@ const (
|
|||||||
|
|
||||||
type configureComp struct {
|
type configureComp struct {
|
||||||
modules.MCompConfigure
|
modules.MCompConfigure
|
||||||
module *ModuleSys
|
module *ModuleSys
|
||||||
|
lock sync.RWMutex
|
||||||
|
condlTask map[int32][]*cfg.GameOpencondData
|
||||||
|
cmds map[string]*cfg.GameOpencondData
|
||||||
}
|
}
|
||||||
|
|
||||||
func (this *configureComp) Init(service core.IService, module core.IModule, comp core.IModuleComp, options core.IModuleOptions) (err error) {
|
func (this *configureComp) Init(service core.IService, module core.IModule, comp core.IModuleComp, options core.IModuleOptions) (err error) {
|
||||||
err = this.MCompConfigure.Init(service, module, comp, options)
|
err = this.MCompConfigure.Init(service, module, comp, options)
|
||||||
this.LoadConfigure(gameOpencond, cfg.NewGameOpencond)
|
// this.LoadConfigure(gameOpencond, cfg.NewGameOpencond)
|
||||||
|
configure.RegisterConfigure(gameOpencond, cfg.NewGameOpencond, this.updateconfigure)
|
||||||
this.module = module.(*ModuleSys)
|
this.module = module.(*ModuleSys)
|
||||||
|
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// 更新任务配置表
|
||||||
|
func (this *configureComp) updateconfigure() {
|
||||||
|
gwt, err := this.getOpencondCfg()
|
||||||
|
if err != nil {
|
||||||
|
this.module.Error("世界任务配置表异常!")
|
||||||
|
return
|
||||||
|
}
|
||||||
|
condlTask := make(map[int32][]*cfg.GameOpencondData)
|
||||||
|
cmds := make(map[string]*cfg.GameOpencondData)
|
||||||
|
for _, v := range gwt.GetDataList() {
|
||||||
|
cmds[v.Id] = v
|
||||||
|
for _, condi := range v.Opencondi {
|
||||||
|
if _, ok := condlTask[condi]; !ok {
|
||||||
|
condlTask[condi] = make([]*cfg.GameOpencondData, 0)
|
||||||
|
}
|
||||||
|
condlTask[condi] = append(condlTask[condi], v)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
this.lock.Lock()
|
||||||
|
this.condlTask = condlTask
|
||||||
|
this.cmds = cmds
|
||||||
|
this.lock.Unlock()
|
||||||
|
}
|
||||||
|
|
||||||
func (this *configureComp) getOpencondCfg() (data *cfg.GameOpencond, err error) {
|
func (this *configureComp) getOpencondCfg() (data *cfg.GameOpencond, err error) {
|
||||||
var (
|
var (
|
||||||
v interface{}
|
v interface{}
|
||||||
ok bool
|
ok bool
|
||||||
)
|
)
|
||||||
if v, err = this.GetConfigure(gameOpencond); err == nil {
|
if v, err = this.GetConfigure(gameOpencond); err == nil {
|
||||||
|
|
||||||
if data, ok = v.(*cfg.GameOpencond); !ok {
|
if data, ok = v.(*cfg.GameOpencond); !ok {
|
||||||
err = fmt.Errorf("%T no is *cfg.GameOpencond", v)
|
err = fmt.Errorf("%T no is *cfg.GameOpencond", v)
|
||||||
return
|
return
|
||||||
|
@ -5,7 +5,6 @@ import (
|
|||||||
"go_dreamfactory/lego/core"
|
"go_dreamfactory/lego/core"
|
||||||
"go_dreamfactory/modules"
|
"go_dreamfactory/modules"
|
||||||
"go_dreamfactory/pb"
|
"go_dreamfactory/pb"
|
||||||
cfg "go_dreamfactory/sys/configure/structs"
|
|
||||||
|
|
||||||
"go.mongodb.org/mongo-driver/bson/primitive"
|
"go.mongodb.org/mongo-driver/bson/primitive"
|
||||||
"go.mongodb.org/mongo-driver/mongo"
|
"go.mongodb.org/mongo-driver/mongo"
|
||||||
@ -56,40 +55,3 @@ func (this *ModelSys) ChangeOpenCondData(uid string, value map[string]interface{
|
|||||||
}
|
}
|
||||||
return this.Change(uid, value)
|
return this.Change(uid, value)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (this *ModelSys) CheckValidCond(uid string, condData *cfg.GameOpencondData, open *pb.DBOpenCond) string {
|
|
||||||
for _, conf := range condData.Main {
|
|
||||||
switch comm.OpencondType(conf.Key) {
|
|
||||||
case comm.OpencondTypePlatlv: //等级
|
|
||||||
if open.Lv < conf.Param {
|
|
||||||
return ""
|
|
||||||
}
|
|
||||||
case comm.OpencondTypeMaxmapid: //关卡ID
|
|
||||||
if _, ok := open.Mline[conf.Param]; !ok {
|
|
||||||
return ""
|
|
||||||
}
|
|
||||||
case comm.OpencondTypeWorldtaskid: //世界任务ID
|
|
||||||
if _, ok := open.Wtask[conf.Param]; !ok {
|
|
||||||
return ""
|
|
||||||
}
|
|
||||||
|
|
||||||
case comm.OpencondTypeFriend: // 好友数量
|
|
||||||
if open.Friend < conf.Param {
|
|
||||||
return ""
|
|
||||||
}
|
|
||||||
case comm.OpencondTypePagoda:
|
|
||||||
if _, ok := open.Pagoda[conf.Param]; !ok {
|
|
||||||
return ""
|
|
||||||
}
|
|
||||||
case comm.OpencondTypeSociaty: // 查询工会等级
|
|
||||||
if open.Sociaty < conf.Param {
|
|
||||||
return ""
|
|
||||||
}
|
|
||||||
case comm.OpencondTypeMoonLv:
|
|
||||||
if open.Moonlv < conf.Param {
|
|
||||||
return ""
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return condData.Id
|
|
||||||
}
|
|
||||||
|
@ -4,8 +4,10 @@ import (
|
|||||||
"go_dreamfactory/comm"
|
"go_dreamfactory/comm"
|
||||||
"go_dreamfactory/lego/base"
|
"go_dreamfactory/lego/base"
|
||||||
"go_dreamfactory/lego/core"
|
"go_dreamfactory/lego/core"
|
||||||
|
"go_dreamfactory/lego/sys/log"
|
||||||
"go_dreamfactory/modules"
|
"go_dreamfactory/modules"
|
||||||
"go_dreamfactory/pb"
|
"go_dreamfactory/pb"
|
||||||
|
cfg "go_dreamfactory/sys/configure/structs"
|
||||||
)
|
)
|
||||||
|
|
||||||
var _ comm.ISys = (*ModuleSys)(nil)
|
var _ comm.ISys = (*ModuleSys)(nil)
|
||||||
@ -111,17 +113,8 @@ func (this *ModuleSys) CheckOpenCond(session comm.IUserSession, itype comm.Openc
|
|||||||
func (this *ModuleSys) CheckOpenCondCfgById(uid string, id string) (bOpen bool, errdata *pb.ErrorData) {
|
func (this *ModuleSys) CheckOpenCondCfgById(uid string, id string) (bOpen bool, errdata *pb.ErrorData) {
|
||||||
var (
|
var (
|
||||||
list *pb.DBOpenCond
|
list *pb.DBOpenCond
|
||||||
|
err error
|
||||||
)
|
)
|
||||||
conf, err := this.configure.GetOpenCondCfgById(id)
|
|
||||||
if err != nil {
|
|
||||||
bOpen = false
|
|
||||||
errdata = &pb.ErrorData{
|
|
||||||
Code: pb.ErrorCode_ConfigNoFound,
|
|
||||||
Title: pb.ErrorCode_ConfigNoFound.ToString(),
|
|
||||||
Message: err.Error(),
|
|
||||||
}
|
|
||||||
return
|
|
||||||
}
|
|
||||||
|
|
||||||
if list, err = this.modelSys.GetOpenCondList(uid); err != nil {
|
if list, err = this.modelSys.GetOpenCondList(uid); err != nil {
|
||||||
return
|
return
|
||||||
@ -132,9 +125,6 @@ func (this *ModuleSys) CheckOpenCondCfgById(uid string, id string) (bOpen bool,
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if this.modelSys.CheckValidCond(uid, conf, list) != "" {
|
|
||||||
bOpen = true
|
|
||||||
}
|
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -181,3 +171,73 @@ func (this *ModuleSys) GMOpenAllCondition(uid string) {
|
|||||||
})
|
})
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//功能开启
|
||||||
|
func (this *ModuleSys) BuriedsNotify(session comm.IUserSession, condis []*pb.ConIProgress) {
|
||||||
|
this.Debug("收到子任务进度变化推送", log.Field{Key: "uid", Value: session.GetUserId()}, log.Field{Key: "condis", Value: condis})
|
||||||
|
var (
|
||||||
|
condlTask map[int32][]*cfg.GameOpencondData
|
||||||
|
condlidsMap map[int32]struct{} = make(map[int32]struct{})
|
||||||
|
confs map[string]*cfg.GameOpencondData
|
||||||
|
condlids []int32
|
||||||
|
condisSlice []*pb.ConIProgress
|
||||||
|
condisMap map[int32]*pb.ConIProgress
|
||||||
|
progress *pb.ConIProgress
|
||||||
|
notify []*cfg.GameOpencondData = make([]*cfg.GameOpencondData, 0)
|
||||||
|
ok bool
|
||||||
|
err error
|
||||||
|
)
|
||||||
|
condlTask = this.configure.condlTask
|
||||||
|
for _, v := range condis {
|
||||||
|
if _, ok = condlTask[v.Conid]; ok {
|
||||||
|
for _, cmd := range condlTask[v.Conid] {
|
||||||
|
if len(cmd.Notify) > 0 {
|
||||||
|
confs[cmd.Id] = cmd
|
||||||
|
for _, condi := range cmd.Opencondi {
|
||||||
|
condlidsMap[condi] = struct{}{}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if len(condlidsMap) < 0 {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
for k, _ := range condlidsMap {
|
||||||
|
condlids = append(condlids, k)
|
||||||
|
}
|
||||||
|
|
||||||
|
if _, condisSlice, err = this.ModuleBuried.CheckCondition(session, condlids...); err != nil {
|
||||||
|
this.Errorln(err)
|
||||||
|
}
|
||||||
|
for _, v := range condisSlice {
|
||||||
|
condisMap[v.Conid] = v
|
||||||
|
}
|
||||||
|
|
||||||
|
for _, conf := range confs {
|
||||||
|
ok = true
|
||||||
|
for _, v := range conf.Opencondi {
|
||||||
|
if progress, ok = condisMap[v]; !ok || progress.State == pb.BuriedItemFinishState_buried_unfinish {
|
||||||
|
ok = false
|
||||||
|
break
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if ok {
|
||||||
|
notify = append(notify, conf)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if len(notify) > 0 {
|
||||||
|
for _, conf := range notify {
|
||||||
|
for _, v := range conf.Notify {
|
||||||
|
i, err := this.service.GetModule(core.M_Modules(v))
|
||||||
|
if err != nil {
|
||||||
|
this.Errorln(err)
|
||||||
|
continue
|
||||||
|
}
|
||||||
|
if ic, ok := i.(comm.IOpenCmdNotice); ok {
|
||||||
|
ic.OpenCmdNotice(session, conf.Id)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
@ -13,7 +13,6 @@ import (
|
|||||||
const (
|
const (
|
||||||
game_signreset = "game_signreset.json"
|
game_signreset = "game_signreset.json"
|
||||||
game_sign = "game_sign.json"
|
game_sign = "game_sign.json"
|
||||||
gameOpencond = "game_opencond.json"
|
|
||||||
game_SignExtra = "game_signextra.json"
|
game_SignExtra = "game_signextra.json"
|
||||||
game_initial = "game_initial.json" //初始化表
|
game_initial = "game_initial.json" //初始化表
|
||||||
game_playerinfor_overview = "game_playerinfor_overview.json" //皮肤配置表
|
game_playerinfor_overview = "game_playerinfor_overview.json" //皮肤配置表
|
||||||
@ -37,7 +36,6 @@ func (this *configureComp) Init(service core.IService, module core.IModule, comp
|
|||||||
this._sign = make(map[int32]*cfg.GameSignData, 0)
|
this._sign = make(map[int32]*cfg.GameSignData, 0)
|
||||||
this._signExtra = make(map[int32]*cfg.GameSignExtraData, 0)
|
this._signExtra = make(map[int32]*cfg.GameSignExtraData, 0)
|
||||||
err = this.LoadConfigure(game_initial, cfg.NewGameInitial)
|
err = this.LoadConfigure(game_initial, cfg.NewGameInitial)
|
||||||
this.LoadConfigure(gameOpencond, cfg.NewGameOpencond)
|
|
||||||
this.LoadConfigure(game_restore, cfg.NewGameRestore)
|
this.LoadConfigure(game_restore, cfg.NewGameRestore)
|
||||||
configure.RegisterConfigure(game_sign, cfg.NewGameSign, this.LoadSignData)
|
configure.RegisterConfigure(game_sign, cfg.NewGameSign, this.LoadSignData)
|
||||||
configure.RegisterConfigure(game_SignExtra, cfg.NewGameSignExtra, this.LoadSignExtraData)
|
configure.RegisterConfigure(game_SignExtra, cfg.NewGameSignExtra, this.LoadSignExtraData)
|
||||||
@ -84,41 +82,6 @@ func (this *configureComp) LoadSignData() {
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
func (this *configureComp) GetOpenCondConf() []*cfg.GameOpencondData {
|
|
||||||
if v, err := this.GetConfigure(gameOpencond); err != nil {
|
|
||||||
return nil
|
|
||||||
} else {
|
|
||||||
data, ok := v.(*cfg.GameOpencond)
|
|
||||||
if !ok {
|
|
||||||
err = fmt.Errorf("%T no is *cfg.GameOpencond", v)
|
|
||||||
return nil
|
|
||||||
}
|
|
||||||
return data.GetDataList()
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
func (this *configureComp) FindFunc(lv int32) (funcIds []string) {
|
|
||||||
if v, err := this.GetConfigure(gameOpencond); err != nil {
|
|
||||||
return nil
|
|
||||||
} else {
|
|
||||||
data, ok := v.(*cfg.GameOpencond)
|
|
||||||
if !ok {
|
|
||||||
err = fmt.Errorf("%T no is *cfg.GameOpencond", v)
|
|
||||||
this.module.Errorln(err)
|
|
||||||
return nil
|
|
||||||
}
|
|
||||||
for _, d := range data.GetDataList() {
|
|
||||||
for _, v := range d.Main {
|
|
||||||
if v.Key == 1 && v.Param == lv {
|
|
||||||
funcIds = append(funcIds, d.Id)
|
|
||||||
continue
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return
|
|
||||||
}
|
|
||||||
|
|
||||||
func (this *configureComp) LoadSignExtraData() {
|
func (this *configureComp) LoadSignExtraData() {
|
||||||
if v, err := this.GetConfigure(game_SignExtra); err == nil {
|
if v, err := this.GetConfigure(game_SignExtra); err == nil {
|
||||||
if configure, ok := v.(*cfg.GameSignExtra); ok {
|
if configure, ok := v.(*cfg.GameSignExtra); ok {
|
||||||
|
Loading…
Reference in New Issue
Block a user