锦标赛优化,0点多进行一次分组

This commit is contained in:
hahwu 2026-03-06 14:55:25 +08:00
parent ed981184d3
commit ed7e2d7625

View File

@ -94,7 +94,7 @@ func (c *ChampshipMgr) Init() {
Remain1 := 1800 - Remain%1800
c.mDispatr.AfterFunc(time.Duration(Remain1)*time.Second, func() { // 30分钟后重新分组
c.group()
c.group(false)
})
c.mDispatr.AfterFunc(time.Duration(60)*time.Second, func() {
@ -116,6 +116,7 @@ func (c *ChampshipMgr) NotifyAll() (interface{}, error) {
}
func (c *ChampshipMgr) ZeroUpdate() (interface{}, error) {
c.group(true)
log.Debug("ChampshipMgr ZeroUpdate")
data := c.getData()
data.mu.Lock()
@ -365,15 +366,15 @@ func (c *ChampshipMgr) GetRankMsg(Uid int) *proto.ResChampshipRank {
}
// 分组
func (c *ChampshipMgr) group() (interface{}, error) {
c.mDispatr.AfterFunc(time.Duration(1800)*time.Second, func() { // 30分钟后重新分组
c.group()
})
func (c *ChampshipMgr) group(iszero bool) (interface{}, error) {
Now := GoUtil.Now()
Zero := GoUtil.ZeroTimestamp()
if Now-Zero < 1800 { // 0点30分钟内不分组
if Now-Zero < 1800 && !iszero { // 0点30分钟内不分组
return nil, nil
}
c.mDispatr.AfterFunc(time.Duration(1800)*time.Second, func() { // 30分钟后重新分组
c.group(false)
})
ChampshipData := c.getData()
ChampshipData.mu.Lock()
defer ChampshipData.mu.Unlock()