锦标赛优化

This commit is contained in:
hahwu 2026-04-16 15:25:51 +08:00
parent acbfd823e0
commit 4370238f94
4 changed files with 39 additions and 15 deletions

View File

@ -102,6 +102,8 @@ func (p *Player) ActivityLogin() {
// 猫猫回礼登录
p.CatReturnGiftLogin()
// 赛季活动登录
p.ChampionshipLogin()
}
// 发送活动邮件
@ -185,6 +187,11 @@ func (p *Player) CatReturnGiftLogin() {
p.CatReturnGiftZeroUpdate()
}
func (p *Player) ChampionshipLogin() {
p.ChampionshipZeroUpdate()
p.BackChampship()
}
// 猫猫回礼0点更新
func (p *Player) CatReturnGiftZeroUpdate() {
activityInfo := p.GetActivityInfo(activity.ACT_TYPE_CAT_RETURN_GIFT)

View File

@ -196,6 +196,9 @@ func (r *ActivityMgr) Reload() error {
}
}()
G_GameLogicPtr.NotifyAll(&Msg.Msg{Type: Msg.HANDLE_TYPE_ACTIVITY_RELOAD})
if G_GameLogicPtr.ChampshipMgr != nil {
G_GameLogicPtr.ChampshipMgr.ReloadActivity()
}
return nil
}

View File

@ -20,6 +20,7 @@ import (
"time"
"gitea.bywaystudios.com/pet_home/leaf/log"
"gitea.bywaystudios.com/pet_home/leaf/timer"
)
const (
@ -30,6 +31,8 @@ type ChampshipMgr struct {
*ServerMod
}
var dispterTimer map[string]*timer.Timer
type ChampshipData struct {
mu sync.RWMutex
AutoId int
@ -103,20 +106,18 @@ func (c *ChampshipMgr) Init() {
c.version()
now := GoUtil.Now()
zeroTime := GoUtil.ZeroTimestamp()
if c.getData().ZeroTime != zeroTime {
activityCfg := G_GameLogicPtr.ActivityMgr.GetActivityListByType(activity.ACT_TYPE_CHAMPION)
t := c.mDispatr.AfterFunc(time.Duration(activityCfg.Endtime-now)*time.Second, func() {
c.ZeroUpdate()
} else {
c.mDispatr.AfterFunc(time.Duration(GoUtil.NextZeroTimestampDuration())*time.Second, func() {
c.ZeroUpdate()
})
}
})
dispterTimer["zero"] = t
remain := now - zeroTime
remain1 := 1800 - remain%1800
c.mDispatr.AfterFunc(time.Duration(remain1)*time.Second, func() { // 30分钟后重新分组
c.group()
})
c.mDispatr.AfterFunc(time.Duration(60)*time.Second, func() {
c.ai()
})
@ -181,6 +182,24 @@ func (c *ChampshipMgr) ZeroNotifyAll() (interface{}, error) {
return nil, nil
}
func (c *ChampshipMgr) ReloadActivity() {
log.Debug("ChampshipMgr ReloadActivity")
activityCfg := G_GameLogicPtr.ActivityMgr.GetActivityListByType(activity.ACT_TYPE_CHAMPION)
if activityCfg.AId == 0 {
log.Debug("championship reload activity failed, no active, aid:%d", activityCfg.AId)
return
}
t := dispterTimer["zero"]
if t != nil {
t.Stop()
}
timeDuration := activityCfg.Endtime - GoUtil.Now()
t = c.mDispatr.AfterFunc(time.Duration(timeDuration)*time.Second, func() {
c.ZeroUpdate()
})
dispterTimer["zero"] = t
}
func (c *ChampshipMgr) ZeroUpdate() (interface{}, error) {
log.Debug("ChampshipMgr ZeroUpdate")
data := c.getData()
@ -221,14 +240,11 @@ func (c *ChampshipMgr) ZeroUpdate() (interface{}, error) {
c.SetRankCache(k)
}
data.mu.Unlock()
timeDuration := GoUtil.NextZeroTimestampDuration()
if timeDuration <= 0 {
log.Error("championship zero update error")
timeDuration = 24 * 3600
}
c.mDispatr.AfterFunc(time.Duration(timeDuration)*time.Second, func() {
timeDuration := activityCfg.Endtime - GoUtil.Now()
t := c.mDispatr.AfterFunc(time.Duration(timeDuration)*time.Second, func() {
c.ZeroUpdate()
})
dispterTimer["zero"] = t
c.mDispatr.AfterFunc(time.Duration(timeDuration+1800)*time.Second, func() {
c.ZeroNotifyAll()
})

View File

@ -420,8 +420,6 @@ func (p *Player) ZeroUpdate(a []interface{}) {
PlayroomMod.ResetWeeklyDiscount()
}
p.PlayroomBackData()
p.ChampionshipZeroUpdate()
p.BackChampship()
// p.InitActivity()
// p.ActivityZeroUpdate()