石阵秘境结算rpc 通知
This commit is contained in:
parent
fc50869af3
commit
696085bb7c
@ -394,6 +394,9 @@ const ( //Rpc
|
||||
Rpc_ModuleWarorderSettlement core.Rpc_Key = "Rpc_ModuleWarorderSettlement"
|
||||
//工会boos战结算 事件
|
||||
Rpc_ModuleGuildBossSettlement core.Rpc_Key = "Rpc_ModuleGuildBossSettlement"
|
||||
|
||||
// 石阵秘境结算
|
||||
Rpc_ModuleStoneBossSettlement core.Rpc_Key = "Rpc_ModuleStoneBossSettlement"
|
||||
)
|
||||
|
||||
// 事件类型定义处
|
||||
|
@ -8,6 +8,7 @@ import (
|
||||
"go_dreamfactory/lego/sys/cron"
|
||||
)
|
||||
|
||||
// "0 0 1 ? * 1"
|
||||
// 1. cron表达式格式:
|
||||
// {秒数} {分钟} {小时} {日期} {月份} {星期} {年份(可为空)}
|
||||
// 2. cron表达式各占位符解释:
|
||||
|
@ -7,7 +7,6 @@ import (
|
||||
"go_dreamfactory/lego/sys/mgo"
|
||||
"go_dreamfactory/modules"
|
||||
"go_dreamfactory/pb"
|
||||
"go_dreamfactory/sys/configure"
|
||||
"go_dreamfactory/utils"
|
||||
"sync"
|
||||
|
||||
@ -45,7 +44,7 @@ func (this *MStonehenge) Start() (err error) {
|
||||
err = this.MCompModel.Start()
|
||||
|
||||
event.RegisterGO(core.Event_ServiceStartEnd, func() {
|
||||
err = this.loadStoneBoos()
|
||||
err = this.reLoadStoneBoos()
|
||||
})
|
||||
|
||||
return
|
||||
@ -73,7 +72,7 @@ func (this *MStonehenge) ChangeStonehengeData(uid string, update map[string]inte
|
||||
return this.Change(uid, update)
|
||||
}
|
||||
|
||||
func (this *MStonehenge) loadStoneBoos() (err error) {
|
||||
func (this *MStonehenge) reLoadStoneBoos() (err error) {
|
||||
|
||||
s := &pb.DBStoneBoss{}
|
||||
this.module.ModuleTools.GetGlobalData(StoneBossKey, s)
|
||||
@ -83,7 +82,7 @@ func (this *MStonehenge) loadStoneBoos() (err error) {
|
||||
this.lock.Unlock()
|
||||
this.module.ModuleTools.UpdateGlobalData(StoneBossKey, map[string]interface{}{
|
||||
"BossStage": this.bossStage,
|
||||
"rtime": configure.Now().Unix(),
|
||||
"rtime": utils.WeekIntervalTime(0),
|
||||
})
|
||||
}
|
||||
|
||||
|
@ -1,10 +1,12 @@
|
||||
package stonehenge
|
||||
|
||||
import (
|
||||
"context"
|
||||
"go_dreamfactory/comm"
|
||||
"go_dreamfactory/lego/base"
|
||||
"go_dreamfactory/lego/core"
|
||||
"go_dreamfactory/modules"
|
||||
"go_dreamfactory/pb"
|
||||
)
|
||||
|
||||
const moduleName = "石阵秘境"
|
||||
@ -42,7 +44,7 @@ func (this *Stonehenge) Start() (err error) {
|
||||
return
|
||||
}
|
||||
this.battle = module.(comm.IBattle)
|
||||
|
||||
this.service.RegisterFunctionName(string(comm.Rpc_ModuleStoneBossSettlement), this.Rpc_ModuleStoneBossSettlement)
|
||||
return
|
||||
}
|
||||
|
||||
@ -53,3 +55,10 @@ func (this *Stonehenge) OnInstallComp() {
|
||||
this.modelStonehenge = this.RegisterComp(new(MStonehenge)).(*MStonehenge)
|
||||
this.configure = this.RegisterComp(new(configureComp)).(*configureComp)
|
||||
}
|
||||
|
||||
// 工会Boos战结算通知
|
||||
func (this *Stonehenge) Rpc_ModuleStoneBossSettlement(ctx context.Context, req *pb.EmptyReq, resp interface{}) (err error) {
|
||||
this.Debug("Rpc_ModuleStoneBossSettlement 石阵秘境Boos结算通知 !")
|
||||
this.modelStonehenge.reLoadStoneBoos()
|
||||
return
|
||||
}
|
||||
|
48
modules/timer/stoneboss.go
Normal file
48
modules/timer/stoneboss.go
Normal file
@ -0,0 +1,48 @@
|
||||
package timer
|
||||
|
||||
import (
|
||||
"context"
|
||||
"go_dreamfactory/comm"
|
||||
"go_dreamfactory/modules"
|
||||
"go_dreamfactory/pb"
|
||||
"go_dreamfactory/sys/db"
|
||||
|
||||
"go_dreamfactory/lego/base"
|
||||
"go_dreamfactory/lego/core"
|
||||
"go_dreamfactory/lego/sys/cron"
|
||||
)
|
||||
|
||||
type StoneComp struct {
|
||||
modules.MCompConfigure
|
||||
service base.IRPCXService
|
||||
module *Timer
|
||||
}
|
||||
|
||||
// 组件初始化接口
|
||||
func (this *StoneComp) Init(service core.IService, module core.IModule, comp core.IModuleComp, options core.IModuleOptions) (err error) {
|
||||
this.MCompConfigure.Init(service, module, comp, options)
|
||||
this.service = service.(base.IRPCXService)
|
||||
this.module = module.(*Timer)
|
||||
return
|
||||
}
|
||||
|
||||
func (this *StoneComp) Start() (err error) {
|
||||
err = this.MCompConfigure.Start()
|
||||
if !db.IsCross() {
|
||||
if _, err = cron.AddFunc("5 0 1 ? * 1", this.timer); err != nil { // 每周一1点触发
|
||||
this.module.Errorf("cron.AddFunc err:%v", err)
|
||||
}
|
||||
}
|
||||
return
|
||||
}
|
||||
|
||||
func (this *StoneComp) timer() {
|
||||
if _, err := this.service.RpcGo(context.Background(),
|
||||
comm.Service_Worker,
|
||||
string(comm.Rpc_ModuleStoneBossSettlement),
|
||||
pb.EmptyReq{},
|
||||
nil,
|
||||
); err != nil {
|
||||
this.module.Errorln(err)
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue
Block a user