功能开发事件
This commit is contained in:
parent
32d11a3e82
commit
55d0ad643b
@ -272,6 +272,8 @@ const (
|
||||
EventTaskChanged core.Event_Key = "event_task_changed" //任务数据变化
|
||||
EventUserVipChanged core.Event_Key = "event_uservip_changed" //用户数据变化
|
||||
EventSociatyRankChanged core.Event_Key = "event_sociatyRank_changed" //公会数据变化
|
||||
|
||||
EventOpenCond core.Event_Key = "event_open_cond" //功能开放事件
|
||||
)
|
||||
|
||||
const (
|
||||
|
@ -3,6 +3,8 @@ package sys
|
||||
import (
|
||||
"go_dreamfactory/comm"
|
||||
"go_dreamfactory/lego/core"
|
||||
"go_dreamfactory/lego/sys/event"
|
||||
"go_dreamfactory/lego/sys/log"
|
||||
"go_dreamfactory/modules"
|
||||
"go_dreamfactory/pb"
|
||||
)
|
||||
@ -28,6 +30,12 @@ func (this *ModuleSys) OnInstallComp() {
|
||||
this.configure = this.RegisterComp(new(configureComp)).(*configureComp)
|
||||
}
|
||||
|
||||
func (this *ModuleSys) Start() (err error) {
|
||||
err = this.ModuleBase.Start()
|
||||
event.RegisterGO(comm.EventOpenCond, this.EventOpenCond)
|
||||
return
|
||||
}
|
||||
|
||||
func (this *ModuleSys) GetType() core.M_Modules {
|
||||
return comm.ModuleSys
|
||||
}
|
||||
@ -35,3 +43,7 @@ func (this *ModuleSys) GetType() core.M_Modules {
|
||||
func (this *ModuleSys) IsAccess(funcName string, userId string) (code pb.ErrorCode) {
|
||||
return this.modelSys.IsAccess(funcName, userId)
|
||||
}
|
||||
|
||||
func (this *ModuleSys) EventOpenCond(funcIds []string) {
|
||||
this.Debug("EventOpenCond", log.Field{Key: "funcIds", Value: funcIds})
|
||||
}
|
||||
|
@ -1,6 +1,7 @@
|
||||
package user
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"go_dreamfactory/lego/core"
|
||||
"go_dreamfactory/lego/sys/log"
|
||||
"go_dreamfactory/modules"
|
||||
@ -12,6 +13,7 @@ import (
|
||||
const (
|
||||
game_signreset = "game_signreset.json"
|
||||
game_sign = "game_sign.json"
|
||||
gameOpencond = "game_opencond.json"
|
||||
)
|
||||
|
||||
///配置管理基础组件
|
||||
@ -27,6 +29,7 @@ func (this *configureComp) Init(service core.IService, module core.IModule, comp
|
||||
|
||||
this._sign = make(map[int32]*cfg.GameSignData, 0)
|
||||
configure.RegisterConfigure(game_sign, cfg.NewGameSign, this.LoadSignData)
|
||||
this.LoadConfigure(gameOpencond, cfg.NewGameOpencond)
|
||||
return
|
||||
}
|
||||
|
||||
@ -64,3 +67,21 @@ func (this *configureComp) LoadSignData() {
|
||||
}
|
||||
return
|
||||
}
|
||||
|
||||
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)
|
||||
return nil
|
||||
}
|
||||
for _, d := range data.GetDataList() {
|
||||
if d.Main == lv {
|
||||
funcIds = append(funcIds, d.Id)
|
||||
}
|
||||
}
|
||||
}
|
||||
return
|
||||
}
|
||||
|
@ -4,6 +4,7 @@ import (
|
||||
"fmt"
|
||||
"go_dreamfactory/comm"
|
||||
"go_dreamfactory/lego/core"
|
||||
et "go_dreamfactory/lego/sys/event"
|
||||
event_v2 "go_dreamfactory/lego/sys/event/v2"
|
||||
"go_dreamfactory/lego/sys/log"
|
||||
"go_dreamfactory/modules"
|
||||
@ -272,6 +273,7 @@ func (this *ModelUser) ChangeLevel(event interface{}, next func(event interface{
|
||||
)
|
||||
return
|
||||
}
|
||||
et.TriggerEvent(comm.EventOpenCond, this.module.configure.FindFunc(curLv))
|
||||
if err := ul.session.SendMsg(string(this.module.GetType()), UserSubTypeLvChangedPush,
|
||||
&pb.UserLvChangedPush{Uid: ul.session.GetUserId(), Exp: curExp, Lv: curLv}); err != nil {
|
||||
this.module.Error("玩家等级变化 UserSubTypeLvChangedPush推送失败",
|
||||
|
Loading…
Reference in New Issue
Block a user