拉霸缓存游戏记录
This commit is contained in:
parent
b342e0ad61
commit
779d8a64a4
|
@ -223,10 +223,11 @@ func (s *SaveGameDetailedCopy) Save() {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// LabaLog 拉霸缓存游戏记录
|
// LabaLog 拉霸缓存游戏记录,为了统计游戏时长
|
||||||
type LabaLog struct {
|
type LabaLog struct {
|
||||||
PlayerListLog *SaveGamePlayerListLogCopy
|
PlayerListLog *SaveGamePlayerListLogCopy
|
||||||
GameDetailLog *SaveGameDetailedCopy
|
GameDetailLog *SaveGameDetailedCopy
|
||||||
|
CacheTime time.Time // 缓存时间
|
||||||
}
|
}
|
||||||
|
|
||||||
// Cache 临时缓存
|
// Cache 临时缓存
|
||||||
|
@ -238,13 +239,31 @@ func (l *LabaLog) Cache(s *Scene, detailLog *SaveGameDetailedParam, playerListLo
|
||||||
playerListLog.OnlyLog = true
|
playerListLog.OnlyLog = true
|
||||||
l.GameDetailLog = s.SaveGameDetailedLog(detailLog)
|
l.GameDetailLog = s.SaveGameDetailedLog(detailLog)
|
||||||
l.PlayerListLog = s.SaveGamePlayerListLog(playerListLog)
|
l.PlayerListLog = s.SaveGamePlayerListLog(playerListLog)
|
||||||
|
l.CacheTime = time.Now()
|
||||||
}
|
}
|
||||||
|
|
||||||
// Save 保存
|
// Save 保存
|
||||||
func (l *LabaLog) Save(f func(log *LabaLog)) {
|
func (l *LabaLog) Save(second int32) {
|
||||||
f(l)
|
if second <= 0 {
|
||||||
l.PlayerListLog.Save()
|
second = int32(time.Now().Sub(l.CacheTime).Seconds())
|
||||||
l.GameDetailLog.Save()
|
}
|
||||||
|
|
||||||
|
if l.PlayerListLog != nil {
|
||||||
|
if l.PlayerListLog.UpLog != nil {
|
||||||
|
for _, v := range l.PlayerListLog.UpLog.Log {
|
||||||
|
v.GamingTime = second
|
||||||
|
}
|
||||||
|
}
|
||||||
|
l.PlayerListLog.Save()
|
||||||
|
}
|
||||||
|
|
||||||
|
if l.GameDetailLog != nil {
|
||||||
|
for _, v := range l.GameDetailLog.Log {
|
||||||
|
v.GameTiming = second
|
||||||
|
}
|
||||||
|
l.GameDetailLog.Save()
|
||||||
|
}
|
||||||
|
|
||||||
l.Clear()
|
l.Clear()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -252,4 +271,5 @@ func (l *LabaLog) Save(f func(log *LabaLog)) {
|
||||||
func (l *LabaLog) Clear() {
|
func (l *LabaLog) Clear() {
|
||||||
l.PlayerListLog = nil
|
l.PlayerListLog = nil
|
||||||
l.GameDetailLog = nil
|
l.GameDetailLog = nil
|
||||||
|
l.CacheTime = time.Time{}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue