功能开启主线校验
This commit is contained in:
parent
35b050eb2c
commit
be0037cd3b
@ -398,7 +398,7 @@ const ( //Rpc
|
||||
Rpc_ModuleCaravanSettlement core.Rpc_Key = "Rpc_ModuleCaravanSettlement" //商队比赛结算信息
|
||||
|
||||
Rpc_ModuleBuriedTrigger core.Rpc_Key = "Rpc_ModuleBuriedTrigger" //埋点跨服触发通知
|
||||
Rpc_OpendCond core.Rpc_Key = "Rpc_OpendCond"
|
||||
|
||||
//战令结算事件
|
||||
Rpc_ModuleWarorderSettlement core.Rpc_Key = "Rpc_ModuleWarorderSettlement"
|
||||
//工会boos战结算 事件
|
||||
|
@ -41,14 +41,9 @@ type (
|
||||
|
||||
type (
|
||||
ISys interface {
|
||||
IsAccess(funcName string, uid string) (errdata *pb.ErrorData)
|
||||
ValidCond(uid string, conf *cfg.GameOpencondData) string
|
||||
CheckLvUpCond(session IUserSession, lv int32)
|
||||
CheckTaskCond(session IUserSession, id int32)
|
||||
CheckMlineCond(session IUserSession, id int32)
|
||||
|
||||
// 校验好友数量判断功能是否开启
|
||||
CheckFriendCond(session IUserSession, num int32)
|
||||
// 查询opencond 配置
|
||||
CheckOpenCondCfgById(uid string, id string) (bOpen bool, errdata *pb.ErrorData)
|
||||
QueryOpenCondData(uid string) (data map[string]int32, errdata *pb.ErrorData) // 查询玩家当前已开启的功能
|
||||
|
@ -14,7 +14,8 @@ import (
|
||||
type ModelSys struct {
|
||||
modules.MCompModel
|
||||
moduleSys *ModuleSys
|
||||
service core.IService
|
||||
|
||||
service core.IService
|
||||
}
|
||||
|
||||
func (this *ModelSys) Init(service core.IService, module core.IModule, comp core.IModuleComp, options core.IModuleOptions) (err error) {
|
||||
@ -25,28 +26,6 @@ func (this *ModelSys) Init(service core.IService, module core.IModule, comp core
|
||||
return
|
||||
}
|
||||
|
||||
// 是否允许访问功能,条件:玩家等级
|
||||
func (this *ModelSys) IsAccess(funName string, uid string) (errdata *pb.ErrorData) {
|
||||
// user := this.moduleSys.ModuleUser.GetUser(uid)
|
||||
// if user != nil {
|
||||
// if conf := this.moduleSys.configure.getFuncCfg(funName); conf != nil {
|
||||
// if conf.ActivateType == 1 { // 已经手动激活过
|
||||
// list, _ := this.GetOpenCondList(uid)
|
||||
// if v, ok := list.Cond[funName]; ok && v == 1 {
|
||||
// return
|
||||
// }
|
||||
// } else {
|
||||
// if id := this.validCond(uid, conf); id != "" { // 条件满足已经激活
|
||||
// return
|
||||
// }
|
||||
// }
|
||||
|
||||
// }
|
||||
// }
|
||||
//code = pb.ErrorCode_OpenCondErr
|
||||
return
|
||||
}
|
||||
|
||||
func (this *ModelSys) validCond(uid string, condData *cfg.GameOpencondData) string {
|
||||
for _, conf := range condData.Main {
|
||||
switch conf.Key {
|
||||
@ -62,42 +41,21 @@ func (this *ModelSys) validCond(uid string, condData *cfg.GameOpencondData) stri
|
||||
|
||||
case 2: //关卡ID
|
||||
// 查询主线进度
|
||||
module, err := this.service.GetModule(comm.ModuleMainline)
|
||||
if err != nil {
|
||||
this.moduleSys.Debugln(err)
|
||||
return ""
|
||||
}
|
||||
if m, ok := module.(comm.IMainline); ok {
|
||||
if levels := m.InquireMainLinePassLevel(uid); len(levels) > 0 {
|
||||
if _, ok := levels[conf.Param]; ok {
|
||||
return condData.Id
|
||||
} else {
|
||||
return ""
|
||||
}
|
||||
if levels := this.moduleSys.mainline.InquireMainLinePassLevel(uid); len(levels) > 0 {
|
||||
if _, ok := levels[conf.Param]; ok {
|
||||
return condData.Id
|
||||
} else {
|
||||
return ""
|
||||
}
|
||||
}
|
||||
case 3: //世界任务ID
|
||||
module, err := this.service.GetModule(comm.ModuleWtask)
|
||||
if err != nil {
|
||||
this.moduleSys.Debugln(err)
|
||||
return ""
|
||||
}
|
||||
if i, ok := module.(comm.IWtask); ok {
|
||||
d := i.InquireCompletes(uid)
|
||||
bFound := false
|
||||
for _, taskId := range d {
|
||||
if taskId == conf.Param {
|
||||
bFound = true
|
||||
break
|
||||
}
|
||||
d := this.moduleSys.wtask.InquireCompletes(uid)
|
||||
for _, taskId := range d {
|
||||
if taskId == conf.Param {
|
||||
return condData.Id
|
||||
}
|
||||
if !bFound {
|
||||
return ""
|
||||
}
|
||||
} else {
|
||||
return ""
|
||||
}
|
||||
|
||||
return ""
|
||||
case 4:
|
||||
module, err := this.service.GetModule(comm.ModuleFriend)
|
||||
if err != nil {
|
||||
|
@ -1,7 +1,6 @@
|
||||
package sys
|
||||
|
||||
import (
|
||||
"context"
|
||||
"go_dreamfactory/comm"
|
||||
"go_dreamfactory/lego/base"
|
||||
"go_dreamfactory/lego/core"
|
||||
@ -9,7 +8,6 @@ import (
|
||||
"go_dreamfactory/modules"
|
||||
"go_dreamfactory/pb"
|
||||
cfg "go_dreamfactory/sys/configure/structs"
|
||||
"time"
|
||||
)
|
||||
|
||||
var _ comm.ISys = (*ModuleSys)(nil)
|
||||
@ -21,6 +19,7 @@ type ModuleSys struct {
|
||||
configure *configureComp
|
||||
service base.IRPCXService
|
||||
modelSys *ModelSys
|
||||
mainline comm.IMainline
|
||||
}
|
||||
|
||||
func NewModule() core.IModule {
|
||||
@ -49,7 +48,12 @@ func (this *ModuleSys) Start() (err error) {
|
||||
return
|
||||
}
|
||||
this.wtask = module.(comm.IWtask)
|
||||
this.service.RegisterFunctionName(string(comm.Rpc_OpendCond), this.OpenCond)
|
||||
|
||||
if module, err = this.service.GetModule(comm.ModuleMainline); err != nil {
|
||||
|
||||
return
|
||||
}
|
||||
this.mainline = module.(comm.IMainline)
|
||||
return
|
||||
}
|
||||
|
||||
@ -57,10 +61,6 @@ 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)
|
||||
}
|
||||
@ -71,35 +71,6 @@ func (this *ModuleSys) CheckLvUpCond(session comm.IUserSession, lv int32) {
|
||||
}
|
||||
}
|
||||
|
||||
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) CheckFriendCond(session comm.IUserSession, num int32) {
|
||||
if cond := this.configure.getFriendTask(num); len(cond) > 0 {
|
||||
// 通知本服
|
||||
ctx, _ := context.WithTimeout(context.Background(), time.Second*5)
|
||||
_, err := this.service.RpcGo(
|
||||
ctx,
|
||||
comm.Service_Worker,
|
||||
string(comm.Rpc_OpendCond),
|
||||
&pb.RPCFriendNumReq{Uid: session.GetUserId(), Cond: cond},
|
||||
nil)
|
||||
if err != nil {
|
||||
this.Errorln(err)
|
||||
return
|
||||
}
|
||||
this.AutoActivate(session, cond)
|
||||
}
|
||||
}
|
||||
|
||||
// 自动激活
|
||||
func (this *ModuleSys) AutoActivate(session comm.IUserSession, cids []string) bool {
|
||||
var (
|
||||
@ -151,19 +122,6 @@ func (this *ModuleSys) CheckOpenCondCfgById(uid string, id string) (bOpen bool,
|
||||
}
|
||||
return
|
||||
}
|
||||
func (this *ModuleSys) OpenCond(ctx context.Context, req *pb.RPCFriendNumReq, resp interface{}) (err error) {
|
||||
if session, ok := this.GetUserSession(req.Uid); ok {
|
||||
this.AutoActivate(session, req.Cond)
|
||||
if err = session.Push(); err != nil {
|
||||
this.Errorln(err)
|
||||
}
|
||||
this.PutUserSession(session)
|
||||
} else {
|
||||
this.PutUserSession(session)
|
||||
}
|
||||
|
||||
return
|
||||
}
|
||||
|
||||
func (this *ModuleSys) FriendCountChange(uid string, count int32) {
|
||||
if cond := this.configure.getFriendTask(count); len(cond) > 0 {
|
||||
|
Loading…
Reference in New Issue
Block a user