锦标赛bug修复
This commit is contained in:
parent
f0c6b07c66
commit
5331ceea99
@ -29,6 +29,7 @@ type ChampshipData struct {
|
||||
PreGroupInfo map[int]int // 锦标赛分组信息 备份
|
||||
Robot map[int]*ChampshipRobot // 机器人
|
||||
PreRobot map[int]*ChampshipRobot // 机器人 备份
|
||||
ZeroTime int64
|
||||
}
|
||||
|
||||
type ChampshipRank struct {
|
||||
@ -87,6 +88,9 @@ func (c *ChampshipMgr) Init() {
|
||||
|
||||
Now := GoUtil.Now()
|
||||
ZeroTime := GoUtil.ZeroTimestamp()
|
||||
if c.getData().ZeroTime != ZeroTime {
|
||||
c.ZeroUpdate(&msg.Msg{})
|
||||
}
|
||||
Remain := Now - ZeroTime
|
||||
Remain1 := 1800 - Remain%1800
|
||||
|
||||
@ -101,6 +105,7 @@ func (c *ChampshipMgr) Init() {
|
||||
Type: msg.HANDLE_TYPE_CHAMPSHIP_AI,
|
||||
})
|
||||
})
|
||||
|
||||
c.mDispatr.AfterFunc(time.Duration(GoUtil.NextZeroTimestampDuration())*time.Second, func() {
|
||||
c.Send(&msg.Msg{
|
||||
Type: msg.SERVER_ZERO_UPDATE,
|
||||
@ -116,6 +121,7 @@ func (c *ChampshipMgr) NotifyAll(m *msg.Msg) (interface{}, error) {
|
||||
}
|
||||
|
||||
func (c *ChampshipMgr) ZeroUpdate(m *msg.Msg) (interface{}, error) {
|
||||
c.getData().ZeroTime = GoUtil.ZeroTimestamp()
|
||||
c.getData().PreRank = c.getData().Rank
|
||||
c.getData().PreRobot = c.getData().Robot
|
||||
c.getData().PreGroupInfo = c.getData().GroupInfo
|
||||
|
||||
@ -102,9 +102,9 @@ func (gl *GameLogic) ZeroFlush() {
|
||||
})
|
||||
var a1 = []interface{}{gl.DailyTaskTimestamp}
|
||||
GoUtil.CallEvent(MergeConst.Notify_Daily_Renew, a1)
|
||||
gl.RankMgrSend(MsgMod.MSG_ZERO_UPDATE) // 零点更新排行榜
|
||||
gl.ChampshipMgrSend(MsgMod.MSG_ZERO_UPDATE) // 零点更新锦标赛
|
||||
gl.VarMgrSend(MsgMod.MSG_ZERO_UPDATE) // 零点更新变量
|
||||
// gl.RankMgrSend(MsgMod.MSG_ZERO_UPDATE) // 零点更新排行榜
|
||||
// gl.ChampshipMgrSend(MsgMod.MSG_ZERO_UPDATE) // 零点更新锦标赛
|
||||
// gl.VarMgrSend(MsgMod.MSG_ZERO_UPDATE) // 零点更新变量
|
||||
gl.NotifyAll(MsgMod.MSG_ZERO_UPDATE)
|
||||
gl.CreateDailyLogFile()
|
||||
log.Debug("Server ZeroFlush")
|
||||
|
||||
@ -2,8 +2,10 @@ package game
|
||||
|
||||
import (
|
||||
"encoding/gob"
|
||||
"server/GoUtil"
|
||||
"server/game/mod/card"
|
||||
"server/game/mod/msg"
|
||||
"time"
|
||||
)
|
||||
|
||||
type VarMgr struct {
|
||||
@ -12,6 +14,7 @@ type VarMgr struct {
|
||||
|
||||
type VarData struct {
|
||||
Var map[string]interface{}
|
||||
ZeroTime int64
|
||||
}
|
||||
|
||||
const (
|
||||
@ -26,25 +29,22 @@ func (f *VarMgr) Init() {
|
||||
}
|
||||
// 注册处理函数
|
||||
f.init()
|
||||
f.initData()
|
||||
f.RegisterHandler(msg.SERVER_ZERO_UPDATE, f.ZeroUpdate)
|
||||
}
|
||||
|
||||
func (f *VarMgr) initData() {
|
||||
if f.getData().Var == nil {
|
||||
f.getData().Var = make(map[string]interface{})
|
||||
}
|
||||
GoldCard := f.GetVar(VAR_GOLD_CARD)
|
||||
if GoldCard == nil { // 随机生成两个金卡
|
||||
Card1, Card2 := card.RankGoldCard()
|
||||
f.SetVar(VAR_GOLD_CARD, &VarGoldCard{
|
||||
Four: Card1,
|
||||
Five: Card2,
|
||||
})
|
||||
if f.getData().ZeroTime == GoUtil.ZeroTimestamp() {
|
||||
f.ZeroUpdate(&msg.Msg{})
|
||||
}
|
||||
f.RegisterHandler(msg.SERVER_ZERO_UPDATE, f.ZeroUpdate)
|
||||
f.mDispatr.AfterFunc(time.Duration(GoUtil.NextZeroTimestampDuration())*time.Second, func() {
|
||||
f.Send(&msg.Msg{
|
||||
Type: msg.SERVER_ZERO_UPDATE,
|
||||
})
|
||||
})
|
||||
}
|
||||
|
||||
func (f *VarMgr) ZeroUpdate(m *msg.Msg) (interface{}, error) {
|
||||
f.getData().ZeroTime = GoUtil.ZeroTimestamp()
|
||||
// 随机生成两个金卡
|
||||
Card1, Card2 := card.RankGoldCard()
|
||||
f.SetVar(VAR_GOLD_CARD, &VarGoldCard{
|
||||
|
||||
Loading…
Reference in New Issue
Block a user