add 拉霸游戏时长
This commit is contained in:
parent
142b2f0ba5
commit
68f51d0c5d
|
|
@ -231,6 +231,7 @@ type LabaLog struct {
|
|||
PlayerListLog *SaveGamePlayerListLogCopy
|
||||
GameDetailLog *SaveGameDetailedCopy
|
||||
CacheTime time.Time // 缓存时间
|
||||
noEmpty bool
|
||||
}
|
||||
|
||||
// Cache 临时缓存
|
||||
|
|
@ -238,17 +239,30 @@ func (l *LabaLog) Cache(s *Scene, detailLog *SaveGameDetailedParam, playerListLo
|
|||
if s == nil {
|
||||
return
|
||||
}
|
||||
|
||||
l.Save(2) // 如果没有收到结束消息,算2秒游戏时长
|
||||
|
||||
detailLog.OnlyLog = true
|
||||
playerListLog.OnlyLog = true
|
||||
l.GameDetailLog = s.SaveGameDetailedLog(detailLog)
|
||||
l.PlayerListLog = s.SaveGamePlayerListLog(playerListLog)
|
||||
l.CacheTime = time.Now()
|
||||
l.noEmpty = true
|
||||
}
|
||||
|
||||
// Save 保存
|
||||
// second 为0时,自动计算时间,从开始转动计时
|
||||
func (l *LabaLog) Save(second int32) {
|
||||
if !l.noEmpty {
|
||||
return
|
||||
}
|
||||
if second <= 0 {
|
||||
second = int32(time.Now().Sub(l.CacheTime).Seconds())
|
||||
sub := time.Now().Sub(l.CacheTime).Milliseconds()
|
||||
if sub <= 1000 {
|
||||
second = 1
|
||||
} else {
|
||||
second = int32(sub / 1000)
|
||||
}
|
||||
}
|
||||
|
||||
if l.PlayerListLog != nil {
|
||||
|
|
@ -272,6 +286,7 @@ func (l *LabaLog) Save(second int32) {
|
|||
|
||||
// Clear 清空
|
||||
func (l *LabaLog) Clear() {
|
||||
l.noEmpty = false
|
||||
l.PlayerListLog = nil
|
||||
l.GameDetailLog = nil
|
||||
l.CacheTime = time.Time{}
|
||||
|
|
|
|||
|
|
@ -8,6 +8,7 @@ import (
|
|||
|
||||
type FortuneDragonPlayerData struct {
|
||||
*base.Player
|
||||
base.LabaLog
|
||||
leaveTime int32 //离开时间
|
||||
SlotsSession *base.SlotsSession
|
||||
|
||||
|
|
@ -31,6 +32,7 @@ func (p *FortuneDragonPlayerData) Clear() {
|
|||
p.taxCoin = 0
|
||||
p.winCoin = 0
|
||||
p.currentLogId = ""
|
||||
p.LabaLog.Clear()
|
||||
}
|
||||
|
||||
// 需要带到world上进行数据处理
|
||||
|
|
|
|||
|
|
@ -112,6 +112,7 @@ func (this *ScenePolicyFortuneDragon) OnPlayerLeave(s *base.Scene, p *base.Playe
|
|||
}
|
||||
logger.Logger.Trace("(this *ScenePolicyFortuneDragon) OnPlayerLeave, sceneId=", s.GetSceneId(), " player=", p.SnId)
|
||||
if playerEx, ok := p.ExtraData.(*FortuneDragonPlayerData); ok {
|
||||
playerEx.Save(2)
|
||||
m := playerEx.PushPlayer()
|
||||
if m != nil && len(m) > 0 {
|
||||
b, err := json.Marshal(m)
|
||||
|
|
@ -476,6 +477,8 @@ func (this *SceneStateStartFortuneDragon) OnPlayerOp(s *base.Scene, p *base.Play
|
|||
|
||||
// 记录本次操作
|
||||
FortuneDragonAndSaveLog(sceneEx, playerEx, data)
|
||||
case 1000:
|
||||
playerEx.Save(0)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -520,11 +523,6 @@ func FortuneDragonAndSaveLog(sceneEx *FortuneDragonSceneData, playerEx *FortuneD
|
|||
if err == nil {
|
||||
logid, _ := model.AutoIncGameLogId()
|
||||
playerEx.currentLogId = logid
|
||||
sceneEx.SaveGameDetailedLog(&base.SaveGameDetailedParam{
|
||||
LogId: logid,
|
||||
Detail: info,
|
||||
GameTime: 2,
|
||||
})
|
||||
var totalin, totalout int64
|
||||
if data.Results[0].FreeStatus == 1 || data.Results[0].FreeNumMax == 0 {
|
||||
totalin = playerEx.totalBet
|
||||
|
|
@ -532,7 +530,10 @@ func FortuneDragonAndSaveLog(sceneEx *FortuneDragonSceneData, playerEx *FortuneD
|
|||
if data.Results[0].FreeStatus == 3 || data.Results[0].FreeNumMax == 0 {
|
||||
totalout = int64(data.RoundReward) + playerEx.taxCoin
|
||||
}
|
||||
sceneEx.SaveGamePlayerListLog(&base.SaveGamePlayerListLogParam{
|
||||
playerEx.Cache(sceneEx.Scene, &base.SaveGameDetailedParam{
|
||||
LogId: logid,
|
||||
Detail: info,
|
||||
}, &base.SaveGamePlayerListLogParam{
|
||||
LogId: logid,
|
||||
Platform: playerEx.Platform,
|
||||
Snid: playerEx.SnId,
|
||||
|
|
@ -544,7 +545,6 @@ func FortuneDragonAndSaveLog(sceneEx *FortuneDragonSceneData, playerEx *FortuneD
|
|||
WinAmountNoAnyTax: totalout - totalin - playerEx.taxCoin,
|
||||
IsFirstGame: sceneEx.IsPlayerFirst(playerEx.Player),
|
||||
IsFree: playerEx.isFree,
|
||||
GameTime: 2,
|
||||
})
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -8,6 +8,7 @@ import (
|
|||
|
||||
type FortuneMousePlayerData struct {
|
||||
*base.Player
|
||||
base.LabaLog
|
||||
leaveTime int32 //离开时间
|
||||
SlotsSession *base.SlotsSession
|
||||
|
||||
|
|
@ -37,6 +38,7 @@ func (p *FortuneMousePlayerData) Clear() {
|
|||
p.taxCoin = 0
|
||||
p.winCoin = 0
|
||||
p.currentLogId = ""
|
||||
p.LabaLog.Clear()
|
||||
}
|
||||
|
||||
// 需要带到world上进行数据处理
|
||||
|
|
|
|||
|
|
@ -111,6 +111,7 @@ func (this *ScenePolicyFortuneMouse) OnPlayerLeave(s *base.Scene, p *base.Player
|
|||
}
|
||||
logger.Logger.Trace("(this *ScenePolicyFortuneMouse) OnPlayerLeave, sceneId=", s.GetSceneId(), " player=", p.SnId)
|
||||
if playerEx, ok := p.ExtraData.(*FortuneMousePlayerData); ok {
|
||||
playerEx.Save(2)
|
||||
m := playerEx.PushPlayer()
|
||||
if m != nil && len(m) > 0 {
|
||||
b, err := json.Marshal(m)
|
||||
|
|
@ -480,6 +481,8 @@ func (this *SceneStateStartFortuneMouse) OnPlayerOp(s *base.Scene, p *base.Playe
|
|||
|
||||
// 记录本次操作
|
||||
FortuneMouseAndSaveLog(sceneEx, playerEx, data)
|
||||
case 1000:
|
||||
playerEx.Save(0)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -531,11 +534,6 @@ func FortuneMouseAndSaveLog(sceneEx *FortuneMouseSceneData, playerEx *FortuneMou
|
|||
if err == nil {
|
||||
logid, _ := model.AutoIncGameLogId()
|
||||
playerEx.currentLogId = logid
|
||||
sceneEx.SaveGameDetailedLog(&base.SaveGameDetailedParam{
|
||||
LogId: logid,
|
||||
Detail: info,
|
||||
GameTime: 2,
|
||||
})
|
||||
var totalin, totalout int64
|
||||
if respinStatus == 0 || respinStatus == 1 {
|
||||
totalin = playerEx.totalBet
|
||||
|
|
@ -543,7 +541,10 @@ func FortuneMouseAndSaveLog(sceneEx *FortuneMouseSceneData, playerEx *FortuneMou
|
|||
if respinStatus == 0 || respinStatus == 3 {
|
||||
totalout = int64(data.RoundReward) + playerEx.taxCoin
|
||||
}
|
||||
sceneEx.SaveGamePlayerListLog(&base.SaveGamePlayerListLogParam{
|
||||
playerEx.Cache(sceneEx.Scene, &base.SaveGameDetailedParam{
|
||||
LogId: logid,
|
||||
Detail: info,
|
||||
}, &base.SaveGamePlayerListLogParam{
|
||||
LogId: logid,
|
||||
Platform: playerEx.Platform,
|
||||
Snid: playerEx.SnId,
|
||||
|
|
@ -551,11 +552,10 @@ func FortuneMouseAndSaveLog(sceneEx *FortuneMouseSceneData, playerEx *FortuneMou
|
|||
TotalIn: totalin,
|
||||
TotalOut: totalout,
|
||||
TaxCoin: playerEx.taxCoin,
|
||||
BetAmount: playerEx.totalBet,
|
||||
BetAmount: totalin,
|
||||
WinAmountNoAnyTax: totalout - totalin - playerEx.taxCoin,
|
||||
IsFirstGame: sceneEx.IsPlayerFirst(playerEx.Player),
|
||||
IsFree: totalin == 0,
|
||||
GameTime: 2,
|
||||
})
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -8,6 +8,7 @@ import (
|
|||
|
||||
type FortuneOxPlayerData struct {
|
||||
*base.Player
|
||||
base.LabaLog
|
||||
leaveTime int32 //离开时间
|
||||
SlotsSession *base.SlotsSession
|
||||
|
||||
|
|
@ -37,6 +38,7 @@ func (p *FortuneOxPlayerData) Clear() {
|
|||
p.taxCoin = 0
|
||||
p.winCoin = 0
|
||||
p.currentLogId = ""
|
||||
p.LabaLog.Clear()
|
||||
}
|
||||
|
||||
// 需要带到world上进行数据处理
|
||||
|
|
|
|||
|
|
@ -111,6 +111,7 @@ func (this *ScenePolicyFortuneOx) OnPlayerLeave(s *base.Scene, p *base.Player, r
|
|||
}
|
||||
logger.Logger.Trace("(this *ScenePolicyFortuneOx) OnPlayerLeave, sceneId=", s.GetSceneId(), " player=", p.SnId)
|
||||
if playerEx, ok := p.ExtraData.(*FortuneOxPlayerData); ok {
|
||||
playerEx.Save(2)
|
||||
m := playerEx.PushPlayer()
|
||||
if m != nil && len(m) > 0 {
|
||||
b, err := json.Marshal(m)
|
||||
|
|
@ -480,6 +481,8 @@ func (this *SceneStateStartFortuneOx) OnPlayerOp(s *base.Scene, p *base.Player,
|
|||
|
||||
// 记录本次操作
|
||||
FortuneOxAndSaveLog(sceneEx, playerEx, data)
|
||||
case 1000:
|
||||
playerEx.Save(0)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -531,11 +534,6 @@ func FortuneOxAndSaveLog(sceneEx *FortuneOxSceneData, playerEx *FortuneOxPlayerD
|
|||
if err == nil {
|
||||
logid, _ := model.AutoIncGameLogId()
|
||||
playerEx.currentLogId = logid
|
||||
sceneEx.SaveGameDetailedLog(&base.SaveGameDetailedParam{
|
||||
LogId: logid,
|
||||
Detail: info,
|
||||
GameTime: 2,
|
||||
})
|
||||
var totalin, totalout int64
|
||||
if respinStatus == 0 || respinStatus == 1 {
|
||||
totalin = playerEx.totalBet
|
||||
|
|
@ -543,7 +541,10 @@ func FortuneOxAndSaveLog(sceneEx *FortuneOxSceneData, playerEx *FortuneOxPlayerD
|
|||
if respinStatus == 0 || respinStatus == 3 {
|
||||
totalout = int64(data.RoundReward) + playerEx.taxCoin
|
||||
}
|
||||
sceneEx.SaveGamePlayerListLog(&base.SaveGamePlayerListLogParam{
|
||||
playerEx.Cache(sceneEx.Scene, &base.SaveGameDetailedParam{
|
||||
LogId: logid,
|
||||
Detail: info,
|
||||
}, &base.SaveGamePlayerListLogParam{
|
||||
LogId: logid,
|
||||
Platform: playerEx.Platform,
|
||||
Snid: playerEx.SnId,
|
||||
|
|
@ -555,7 +556,6 @@ func FortuneOxAndSaveLog(sceneEx *FortuneOxSceneData, playerEx *FortuneOxPlayerD
|
|||
WinAmountNoAnyTax: totalout - totalin - playerEx.taxCoin,
|
||||
IsFirstGame: sceneEx.IsPlayerFirst(playerEx.Player),
|
||||
IsFree: totalin == 0,
|
||||
GameTime: 2,
|
||||
})
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -8,6 +8,7 @@ import (
|
|||
|
||||
type FortuneRabbitPlayerData struct {
|
||||
*base.Player
|
||||
base.LabaLog
|
||||
leaveTime int32 //离开时间
|
||||
SlotsSession *base.SlotsSession
|
||||
|
||||
|
|
@ -31,6 +32,7 @@ func (p *FortuneRabbitPlayerData) Clear() {
|
|||
p.taxCoin = 0
|
||||
p.winCoin = 0
|
||||
p.currentLogId = ""
|
||||
p.LabaLog.Clear()
|
||||
}
|
||||
|
||||
// 需要带到world上进行数据处理
|
||||
|
|
|
|||
|
|
@ -111,6 +111,7 @@ func (this *ScenePolicyFortuneRabbit) OnPlayerLeave(s *base.Scene, p *base.Playe
|
|||
}
|
||||
logger.Logger.Trace("(this *ScenePolicyFortuneRabbit) OnPlayerLeave, sceneId=", s.GetSceneId(), " player=", p.SnId)
|
||||
if playerEx, ok := p.ExtraData.(*FortuneRabbitPlayerData); ok {
|
||||
playerEx.LabaLog.Save(2) // 没有收到结束消息,算2秒游戏时长
|
||||
m := playerEx.PushPlayer()
|
||||
if m != nil && len(m) > 0 {
|
||||
b, err := json.Marshal(m)
|
||||
|
|
@ -474,6 +475,9 @@ func (this *SceneStateStartFortuneRabbit) OnPlayerOp(s *base.Scene, p *base.Play
|
|||
|
||||
// 记录本次操作
|
||||
FortuneRabbitAndSaveLog(sceneEx, playerEx, data)
|
||||
|
||||
case 1000:
|
||||
playerEx.Save(0)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -518,11 +522,6 @@ func FortuneRabbitAndSaveLog(sceneEx *FortuneRabbitSceneData, playerEx *FortuneR
|
|||
if err == nil {
|
||||
logid, _ := model.AutoIncGameLogId()
|
||||
playerEx.currentLogId = logid
|
||||
sceneEx.SaveGameDetailedLog(&base.SaveGameDetailedParam{
|
||||
LogId: logid,
|
||||
Detail: info,
|
||||
GameTime: 2,
|
||||
})
|
||||
var totalin, totalout int64
|
||||
if data.Results[0].FreeStatus == 1 || data.Results[0].FreeNumMax == 0 {
|
||||
totalin = playerEx.totalBet
|
||||
|
|
@ -530,7 +529,10 @@ func FortuneRabbitAndSaveLog(sceneEx *FortuneRabbitSceneData, playerEx *FortuneR
|
|||
if data.Results[0].FreeStatus == 3 || data.Results[0].FreeNumMax == 0 {
|
||||
totalout = int64(data.RoundReward) + playerEx.taxCoin
|
||||
}
|
||||
sceneEx.SaveGamePlayerListLog(&base.SaveGamePlayerListLogParam{
|
||||
playerEx.Cache(sceneEx.Scene, &base.SaveGameDetailedParam{
|
||||
LogId: logid,
|
||||
Detail: info,
|
||||
}, &base.SaveGamePlayerListLogParam{
|
||||
LogId: logid,
|
||||
Platform: playerEx.Platform,
|
||||
Snid: playerEx.SnId,
|
||||
|
|
@ -542,7 +544,6 @@ func FortuneRabbitAndSaveLog(sceneEx *FortuneRabbitSceneData, playerEx *FortuneR
|
|||
WinAmountNoAnyTax: totalout - totalin - playerEx.taxCoin,
|
||||
IsFirstGame: sceneEx.IsPlayerFirst(playerEx.Player),
|
||||
IsFree: playerEx.isFree,
|
||||
GameTime: 2,
|
||||
})
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -8,6 +8,7 @@ import (
|
|||
|
||||
type FortuneTigerPlayerData struct {
|
||||
*base.Player
|
||||
base.LabaLog
|
||||
leaveTime int32 //离开时间
|
||||
SlotsSession *base.SlotsSession
|
||||
|
||||
|
|
@ -40,6 +41,7 @@ func (p *FortuneTigerPlayerData) Clear() {
|
|||
p.taxCoin = 0
|
||||
p.winCoin = 0
|
||||
p.currentLogId = ""
|
||||
p.LabaLog.Clear()
|
||||
}
|
||||
|
||||
// 需要带到world上进行数据处理
|
||||
|
|
|
|||
|
|
@ -111,6 +111,7 @@ func (this *ScenePolicyFortuneTiger) OnPlayerLeave(s *base.Scene, p *base.Player
|
|||
}
|
||||
logger.Logger.Trace("(this *ScenePolicyFortuneTiger) OnPlayerLeave, sceneId=", s.GetSceneId(), " player=", p.SnId)
|
||||
if playerEx, ok := p.ExtraData.(*FortuneTigerPlayerData); ok {
|
||||
playerEx.LabaLog.Save(2) // 没有收到结束消息,算2秒游戏时长
|
||||
m := playerEx.PushPlayer()
|
||||
if m != nil && len(m) > 0 {
|
||||
b, err := json.Marshal(m)
|
||||
|
|
@ -480,6 +481,9 @@ func (this *SceneStateStartFortuneTiger) OnPlayerOp(s *base.Scene, p *base.Playe
|
|||
|
||||
// 记录本次操作
|
||||
FortuneTigerAndSaveLog(sceneEx, playerEx, data)
|
||||
|
||||
case 1000:
|
||||
playerEx.Save(0)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -531,11 +535,6 @@ func FortuneTigerAndSaveLog(sceneEx *FortuneTigerSceneData, playerEx *FortuneTig
|
|||
if err == nil {
|
||||
logid, _ := model.AutoIncGameLogId()
|
||||
playerEx.currentLogId = logid
|
||||
sceneEx.SaveGameDetailedLog(&base.SaveGameDetailedParam{
|
||||
LogId: logid,
|
||||
Detail: info,
|
||||
GameTime: 2,
|
||||
})
|
||||
var totalin, totalout int64
|
||||
if data.Results[0].FreeStatus == 1 || data.Results[0].FreeNumMax == 0 {
|
||||
totalin = playerEx.totalBet
|
||||
|
|
@ -543,7 +542,10 @@ func FortuneTigerAndSaveLog(sceneEx *FortuneTigerSceneData, playerEx *FortuneTig
|
|||
if data.Results[0].FreeStatus == 3 || data.Results[0].FreeNumMax == 0 {
|
||||
totalout = int64(data.RoundReward) + playerEx.taxCoin
|
||||
}
|
||||
sceneEx.SaveGamePlayerListLog(&base.SaveGamePlayerListLogParam{
|
||||
playerEx.Cache(sceneEx.Scene, &base.SaveGameDetailedParam{
|
||||
LogId: logid,
|
||||
Detail: info,
|
||||
}, &base.SaveGamePlayerListLogParam{
|
||||
LogId: logid,
|
||||
Platform: playerEx.Platform,
|
||||
Snid: playerEx.SnId,
|
||||
|
|
@ -555,7 +557,6 @@ func FortuneTigerAndSaveLog(sceneEx *FortuneTigerSceneData, playerEx *FortuneTig
|
|||
WinAmountNoAnyTax: totalout - totalin - playerEx.taxCoin,
|
||||
IsFirstGame: sceneEx.IsPlayerFirst(playerEx.Player),
|
||||
IsFree: totalin == 0,
|
||||
GameTime: 2,
|
||||
})
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue