Merge branch 'release' into develop
This commit is contained in:
commit
8021f554f2
|
@ -27,6 +27,19 @@ import (
|
||||||
登录及机器人账号更新
|
登录及机器人账号更新
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
func init() {
|
||||||
|
common.RegisterClockFunc(&common.ClockFunc{
|
||||||
|
OnHourTimerFunc: func() {
|
||||||
|
ClientMgrSingleton.HourChange()
|
||||||
|
|
||||||
|
logger.Logger.Infof("client state: %+v", ClientMgrSingleton.GetState())
|
||||||
|
},
|
||||||
|
OnDayTimerFunc: func() {
|
||||||
|
ClientMgrSingleton.DayChange()
|
||||||
|
},
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
var ClientMgrSingleton = &ClientMgr{
|
var ClientMgrSingleton = &ClientMgr{
|
||||||
sessionPool: make(map[string]*netlib.Session),
|
sessionPool: make(map[string]*netlib.Session),
|
||||||
Running: true,
|
Running: true,
|
||||||
|
@ -182,3 +195,19 @@ func (this *ClientMgr) DayChange() {
|
||||||
this.CycleTimeEvent[timePoint] = eventArr
|
this.CycleTimeEvent[timePoint] = eventArr
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
type ClientState struct {
|
||||||
|
SessionNum int
|
||||||
|
Event map[int]int
|
||||||
|
}
|
||||||
|
|
||||||
|
func (this *ClientMgr) GetState() *ClientState {
|
||||||
|
ret := &ClientState{
|
||||||
|
SessionNum: len(this.sessionPool),
|
||||||
|
Event: make(map[int]int),
|
||||||
|
}
|
||||||
|
for k, v := range this.CycleTimeEvent {
|
||||||
|
ret.Event[k] = len(v)
|
||||||
|
}
|
||||||
|
return ret
|
||||||
|
}
|
||||||
|
|
|
@ -1,90 +0,0 @@
|
||||||
package base
|
|
||||||
|
|
||||||
import (
|
|
||||||
"time"
|
|
||||||
|
|
||||||
"mongo.games.com/goserver/core/module"
|
|
||||||
)
|
|
||||||
|
|
||||||
/*
|
|
||||||
计时器
|
|
||||||
*/
|
|
||||||
|
|
||||||
var ClockMgrSingleton = &ClockMgr{
|
|
||||||
LastHour: -1,
|
|
||||||
LastDay: -1,
|
|
||||||
}
|
|
||||||
|
|
||||||
type ClockMgr struct {
|
|
||||||
LastTime time.Time
|
|
||||||
LastMonth time.Month
|
|
||||||
LastWeek int
|
|
||||||
LastDay int
|
|
||||||
LastHour int
|
|
||||||
LastMini int
|
|
||||||
LastSec int
|
|
||||||
}
|
|
||||||
|
|
||||||
func (this *ClockMgr) ModuleName() string {
|
|
||||||
return "ClockMgr"
|
|
||||||
}
|
|
||||||
|
|
||||||
func (this *ClockMgr) Init() {
|
|
||||||
tNow := time.Now().Local()
|
|
||||||
this.LastTime = tNow
|
|
||||||
_, this.LastMonth, this.LastDay = tNow.Date()
|
|
||||||
this.LastHour, this.LastMini, this.LastSec = tNow.Hour(), tNow.Minute(), tNow.Second()
|
|
||||||
_, this.LastWeek = tNow.ISOWeek()
|
|
||||||
}
|
|
||||||
|
|
||||||
func (this *ClockMgr) Update() {
|
|
||||||
tNow := time.Now().Local()
|
|
||||||
sec := tNow.Second()
|
|
||||||
if sec != this.LastSec {
|
|
||||||
this.LastSec = sec
|
|
||||||
// 秒
|
|
||||||
PlayerMgrSingleton.OnSecondTimer()
|
|
||||||
|
|
||||||
min := tNow.Minute()
|
|
||||||
if min != this.LastMini {
|
|
||||||
this.LastMini = min
|
|
||||||
// 分
|
|
||||||
PlayerMgrSingleton.OnMiniTimer()
|
|
||||||
|
|
||||||
hour := tNow.Hour()
|
|
||||||
if hour != this.LastHour {
|
|
||||||
// 时
|
|
||||||
ClientMgrSingleton.HourChange()
|
|
||||||
|
|
||||||
this.LastHour = hour
|
|
||||||
day := tNow.Day()
|
|
||||||
if day != this.LastDay {
|
|
||||||
// 天
|
|
||||||
ClientMgrSingleton.DayChange()
|
|
||||||
|
|
||||||
this.LastDay = day
|
|
||||||
_, week := tNow.ISOWeek()
|
|
||||||
if week != this.LastWeek {
|
|
||||||
// 周
|
|
||||||
|
|
||||||
this.LastWeek = week
|
|
||||||
}
|
|
||||||
month := tNow.Month()
|
|
||||||
if month != this.LastMonth {
|
|
||||||
// 月
|
|
||||||
|
|
||||||
this.LastMonth = month
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
func (this *ClockMgr) Shutdown() {
|
|
||||||
module.UnregisteModule(this)
|
|
||||||
}
|
|
||||||
|
|
||||||
func init() {
|
|
||||||
module.RegisteModule(ClockMgrSingleton, time.Millisecond*500, 0)
|
|
||||||
}
|
|
|
@ -2,6 +2,7 @@ package base
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"math/rand"
|
"math/rand"
|
||||||
|
"mongo.games.com/game/common"
|
||||||
|
|
||||||
"mongo.games.com/goserver/core/logger"
|
"mongo.games.com/goserver/core/logger"
|
||||||
"mongo.games.com/goserver/core/netlib"
|
"mongo.games.com/goserver/core/netlib"
|
||||||
|
@ -11,6 +12,17 @@ import (
|
||||||
player_proto "mongo.games.com/game/protocol/player"
|
player_proto "mongo.games.com/game/protocol/player"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
func init() {
|
||||||
|
common.RegisterClockFunc(&common.ClockFunc{
|
||||||
|
OnSecTimerFunc: func() {
|
||||||
|
PlayerMgrSingleton.OnSecondTimer()
|
||||||
|
},
|
||||||
|
OnMiniTimerFunc: func() {
|
||||||
|
PlayerMgrSingleton.OnMiniTimer()
|
||||||
|
},
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
var PlayerMgrSingleton = &PlayerMgr{
|
var PlayerMgrSingleton = &PlayerMgr{
|
||||||
playersMapSnId: make(map[int32]*player_proto.SCPlayerData),
|
playersMapSnId: make(map[int32]*player_proto.SCPlayerData),
|
||||||
playersSession: make(map[int32]*netlib.Session),
|
playersSession: make(map[int32]*netlib.Session),
|
||||||
|
|
|
@ -3,12 +3,28 @@ package base
|
||||||
import (
|
import (
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
|
"mongo.games.com/goserver/core/logger"
|
||||||
"mongo.games.com/goserver/core/module"
|
"mongo.games.com/goserver/core/module"
|
||||||
|
|
||||||
|
"mongo.games.com/game/common"
|
||||||
server_proto "mongo.games.com/game/protocol/server"
|
server_proto "mongo.games.com/game/protocol/server"
|
||||||
"mongo.games.com/game/srvdata"
|
"mongo.games.com/game/srvdata"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
func init() {
|
||||||
|
module.RegisteModule(SceneMgrSingleton, time.Millisecond*100, 0)
|
||||||
|
|
||||||
|
common.RegisterClockFunc(&common.ClockFunc{
|
||||||
|
OnHourTimerFunc: func() {
|
||||||
|
sceneState := map[int32]int{}
|
||||||
|
for _, v := range SceneMgrSingleton.Scenes {
|
||||||
|
sceneState[v.GetGameId()]++
|
||||||
|
}
|
||||||
|
logger.Logger.Infof("sceneState: %v", sceneState)
|
||||||
|
},
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
var SceneMgrSingleton = &SceneMgr{
|
var SceneMgrSingleton = &SceneMgr{
|
||||||
Scenes: make(map[int32]IScene),
|
Scenes: make(map[int32]IScene),
|
||||||
sceneDBGameFree: make(map[int32]*server_proto.DB_GameFree),
|
sceneDBGameFree: make(map[int32]*server_proto.DB_GameFree),
|
||||||
|
@ -47,6 +63,7 @@ func (sm *SceneMgr) GetSceneDBGameFree(sceneId, gamefreeId int32) *server_proto.
|
||||||
return srvdata.PBDB_GameFreeMgr.GetData(gamefreeId)
|
return srvdata.PBDB_GameFreeMgr.GetData(gamefreeId)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// IsFreeMode 是否是自由桌
|
||||||
func (sm *SceneMgr) IsFreeMode(sceneId int32) bool {
|
func (sm *SceneMgr) IsFreeMode(sceneId int32) bool {
|
||||||
if data, exist := sm.sceneDBGameFree[sceneId]; exist {
|
if data, exist := sm.sceneDBGameFree[sceneId]; exist {
|
||||||
return data.GetFreeMode() == 1
|
return data.GetFreeMode() == 1
|
||||||
|
@ -74,7 +91,3 @@ func (sm *SceneMgr) ModuleName() string {
|
||||||
func (sm *SceneMgr) Shutdown() {
|
func (sm *SceneMgr) Shutdown() {
|
||||||
module.UnregisteModule(sm)
|
module.UnregisteModule(sm)
|
||||||
}
|
}
|
||||||
|
|
||||||
func init() {
|
|
||||||
module.RegisteModule(SceneMgrSingleton, time.Millisecond*100, 0)
|
|
||||||
}
|
|
||||||
|
|
|
@ -1310,8 +1310,6 @@ func (this *Player) UnmarshalData(data []byte, scene *Scene) {
|
||||||
this.PlayerData.TotalFlow = pd.TotalFlow
|
this.PlayerData.TotalFlow = pd.TotalFlow
|
||||||
if this.WelfData != nil && this.WelfData.PigBank != nil && pd.WelfData != nil && pd.WelfData.PigBank != nil {
|
if this.WelfData != nil && this.WelfData.PigBank != nil && pd.WelfData != nil && pd.WelfData.PigBank != nil {
|
||||||
this.WelfData.PigBank.BankCoin = pd.WelfData.PigBank.BankCoin
|
this.WelfData.PigBank.BankCoin = pd.WelfData.PigBank.BankCoin
|
||||||
this.WelfData.PigBank.TakeTimes = pd.WelfData.PigBank.TakeTimes
|
|
||||||
this.WelfData.PigBank.DayBuyTimes = pd.WelfData.PigBank.DayBuyTimes
|
|
||||||
}
|
}
|
||||||
this.ItemRecExpireTime = pd.ItemRecExpireTime
|
this.ItemRecExpireTime = pd.ItemRecExpireTime
|
||||||
this.IsTakeExpireItem = pd.IsTakeExpireItem
|
this.IsTakeExpireItem = pd.IsTakeExpireItem
|
||||||
|
|
|
@ -1118,7 +1118,7 @@ func (this *WelfareMgr) BlindBoxInfo(p *Player, bid int32) {
|
||||||
if cyc == 1 || blindBox.Cycle == model.WelfareOpen {
|
if cyc == 1 || blindBox.Cycle == model.WelfareOpen {
|
||||||
p.WelfData.BlindBoxId = 0
|
p.WelfData.BlindBoxId = 0
|
||||||
}
|
}
|
||||||
} // == 1代表当日循环
|
} // == 1代表当日循环
|
||||||
if p.WelfData.BlindBoxId == 0 { // 未领取过发随机Date
|
if p.WelfData.BlindBoxId == 0 { // 未领取过发随机Date
|
||||||
|
|
||||||
idx := bid
|
idx := bid
|
||||||
|
|
Loading…
Reference in New Issue