锦标赛优化

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.CatReturnGiftLogin()
// 赛季活动登录
p.ChampionshipLogin()
} }
// 发送活动邮件 // 发送活动邮件
@ -185,6 +187,11 @@ func (p *Player) CatReturnGiftLogin() {
p.CatReturnGiftZeroUpdate() p.CatReturnGiftZeroUpdate()
} }
func (p *Player) ChampionshipLogin() {
p.ChampionshipZeroUpdate()
p.BackChampship()
}
// 猫猫回礼0点更新 // 猫猫回礼0点更新
func (p *Player) CatReturnGiftZeroUpdate() { func (p *Player) CatReturnGiftZeroUpdate() {
activityInfo := p.GetActivityInfo(activity.ACT_TYPE_CAT_RETURN_GIFT) 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}) G_GameLogicPtr.NotifyAll(&Msg.Msg{Type: Msg.HANDLE_TYPE_ACTIVITY_RELOAD})
if G_GameLogicPtr.ChampshipMgr != nil {
G_GameLogicPtr.ChampshipMgr.ReloadActivity()
}
return nil return nil
} }

View File

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

View File

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