5
This commit is contained in:
parent
50c6c07140
commit
98fcc02e38
@ -81,36 +81,28 @@ func (c *ChampshipMgr) Init() {
|
||||
}
|
||||
// 注册处理函数
|
||||
c.init()
|
||||
c.RegisterHandler(msg.HANDLE_TYPE_CHAMPSHIP_GROUP, c.group)
|
||||
c.RegisterHandler(msg.HANDLE_TYPE_CHAMPSHIP_INRANK, c.inRank)
|
||||
c.RegisterHandler(msg.HANDLE_TYPE_CHAMPSHIP_AI, c.ai)
|
||||
c.RegisterHandler(msg.SERVER_ZERO_UPDATE, c.ZeroUpdate)
|
||||
c.RegisterHandler(msg.HANDLE_TYPE_CHAMPSHIP_NOTIFY2, c.NotifyAll)
|
||||
|
||||
Now := GoUtil.Now()
|
||||
ZeroTime := GoUtil.ZeroTimestamp()
|
||||
if c.getData().ZeroTime != ZeroTime {
|
||||
c.ZeroUpdate(&msg.Msg{})
|
||||
c.ZeroUpdate()
|
||||
}
|
||||
Remain := Now - ZeroTime
|
||||
Remain1 := 1800 - Remain%1800
|
||||
|
||||
c.mDispatr.AfterFunc(time.Duration(Remain1)*time.Second, func() { // 30分钟后重新分组
|
||||
c.Send(&msg.Msg{
|
||||
Type: msg.HANDLE_TYPE_CHAMPSHIP_GROUP,
|
||||
})
|
||||
c.group()
|
||||
})
|
||||
|
||||
c.mDispatr.AfterFunc(time.Duration(60)*time.Second, func() {
|
||||
c.Send(&msg.Msg{
|
||||
Type: msg.HANDLE_TYPE_CHAMPSHIP_AI,
|
||||
})
|
||||
c.ai()
|
||||
})
|
||||
|
||||
c.mDispatr.AfterFunc(time.Duration(GoUtil.NextZeroTimestampDuration())*time.Second, func() {
|
||||
c.Send(&msg.Msg{
|
||||
Type: msg.SERVER_ZERO_UPDATE,
|
||||
})
|
||||
c.ZeroUpdate()
|
||||
})
|
||||
}
|
||||
|
||||
@ -120,13 +112,14 @@ func (c *ChampshipMgr) NotifyAll(m *msg.Msg) (interface{}, error) {
|
||||
return nil, nil
|
||||
}
|
||||
|
||||
func (c *ChampshipMgr) ZeroUpdate(m *msg.Msg) (interface{}, error) {
|
||||
func (c *ChampshipMgr) ZeroUpdate() (interface{}, error) {
|
||||
log.Debug("ChampshipMgr ZeroUpdate")
|
||||
c.getData().ZeroTime = GoUtil.ZeroTimestamp()
|
||||
c.getData().PreRank = c.getData().Rank
|
||||
c.getData().PreRobot = c.getData().Robot
|
||||
c.getData().PreGroupInfo = c.getData().GroupInfo
|
||||
|
||||
c.getData().AutoId = 0
|
||||
c.getData().RobotId = 1
|
||||
c.getData().Robot = make(map[int]*ChampshipRobot, 0)
|
||||
c.getData().Rank = make(map[int][]*ChampshipRank, 0)
|
||||
c.getData().GroupInfo = make(map[int]int, 0)
|
||||
@ -138,9 +131,7 @@ func (c *ChampshipMgr) ZeroUpdate(m *msg.Msg) (interface{}, error) {
|
||||
})
|
||||
c.NotifyPlayer()
|
||||
c.mDispatr.AfterFunc(time.Duration(1800)*time.Second, func() {
|
||||
c.Send(&msg.Msg{
|
||||
Type: msg.HANDLE_TYPE_CHAMPSHIP_NOTIFY2,
|
||||
})
|
||||
c.ZeroUpdate()
|
||||
})
|
||||
return nil, nil
|
||||
}
|
||||
@ -157,7 +148,7 @@ func (c *ChampshipMgr) NotifyPlayer() {
|
||||
}
|
||||
}
|
||||
|
||||
func (c *ChampshipMgr) ai(m *msg.Msg) (interface{}, error) {
|
||||
func (c *ChampshipMgr) ai() (interface{}, error) {
|
||||
ChampshipData := c.getData()
|
||||
Now := GoUtil.Now()
|
||||
for k, v := range ChampshipData.Rank {
|
||||
@ -204,9 +195,7 @@ func (c *ChampshipMgr) ai(m *msg.Msg) (interface{}, error) {
|
||||
ChampshipData.Rank[k] = v
|
||||
}
|
||||
c.mDispatr.AfterFunc(time.Duration(60)*time.Second, func() {
|
||||
c.Send(&msg.Msg{
|
||||
Type: msg.HANDLE_TYPE_CHAMPSHIP_AI,
|
||||
})
|
||||
c.ai()
|
||||
})
|
||||
return nil, nil
|
||||
}
|
||||
@ -319,11 +308,9 @@ func (c *ChampshipMgr) GetRankMsg(Uid int) *proto.ResChampshipRank {
|
||||
}
|
||||
|
||||
// 分组
|
||||
func (c *ChampshipMgr) group(m *msg.Msg) (interface{}, error) {
|
||||
func (c *ChampshipMgr) group() (interface{}, error) {
|
||||
c.mDispatr.AfterFunc(time.Duration(1800)*time.Second, func() { // 30分钟后重新分组
|
||||
c.Send(&msg.Msg{
|
||||
Type: msg.HANDLE_TYPE_CHAMPSHIP_GROUP,
|
||||
})
|
||||
c.group()
|
||||
})
|
||||
Now := GoUtil.Now()
|
||||
Zero := GoUtil.ZeroTimestamp()
|
||||
|
||||
@ -1024,8 +1024,9 @@ func (p *Player) HandleInChampshipRank() {
|
||||
H: ChampshipMod.GetH(),
|
||||
N: ChampshipMod.GetN(),
|
||||
},
|
||||
HandleType: MsgMod.HANDLE_MDO_CHAMPSHIP_INRANK,
|
||||
}
|
||||
G_GameLogicPtr.ChampshipMgrSend(m)
|
||||
SendMsgToCenterAsync(m)
|
||||
}
|
||||
|
||||
func (p *Player) AddLog(Uid int, Type int, Param string, Time int64) {
|
||||
|
||||
Loading…
Reference in New Issue
Block a user