创建游戏对局记录缓存对象

This commit is contained in:
sk 2024-12-03 15:08:08 +08:00
parent 801200f4bd
commit 3f35e67a40
6 changed files with 270 additions and 507 deletions

View File

@ -1,6 +0,0 @@
package base
// 提供税收和流水,根据代理需求后台进行分账
func ProfitDistribution(p *Player, tax, taxex, validFlow int64) {
//LogChannelSingleton.WriteMQData(model.GenerateTaxDivide(p.SnId, p.Platform, p.Channel, p.BeUnderAgentCode, p.PackageID, tax, taxex, validFlow, p.scene.GameId, p.scene.GameMode, p.scene.GetDBGameFree().GetId(), p.PromoterTree))
}

255
gamesrv/base/gamedetail.go Normal file
View File

@ -0,0 +1,255 @@
package base
import (
"time"
"github.com/globalsign/mgo/bson"
"mongo.games.com/game/model"
"mongo.games.com/game/mq"
)
/*
记录游戏对局记录
*/
type SaveGameDetailedParam struct {
LogId string // 日志id
Detail string // 游戏详细信息
GameTime int64 // 游戏时长
Trend20Lately string // 最近20局开奖结果
CtrlType int // 调控类型 1控赢 2控输
PlayerPool map[int]int // 个人水池分
OnlyLog bool // 只返回日志,不保存
}
// SaveGameDetailedLog 保存游戏详细记录
func (this *Scene) SaveGameDetailedLog(param *SaveGameDetailedParam) *SaveGameDetailedCopy {
if this == nil || param == nil {
return nil
}
if param.GameTime <= 0 {
param.GameTime = int64(time.Now().Sub(this.GameNowTime).Seconds())
}
if param.GameTime < 0 {
param.GameTime = 0
}
now := time.Now()
var ret SaveGameDetailedCopy
ret.Param = param
f := func(plt string) {
log := &model.GameDetailedLog{
Id: bson.NewObjectId(),
LogId: param.LogId,
GameId: this.GameId,
Platform: plt,
MatchId: this.GetMatch().GetMatchSortId(),
SceneId: this.SceneId,
GameMode: this.GameMode,
GameFreeid: this.GetGameFreeId(),
PlayerCount: int32(len(this.Players)),
GameTiming: int32(param.GameTime),
GameBaseBet: this.GetBaseScore(),
GameDetailedNote: param.Detail,
GameDetailVer: GameDetailedVer[int(this.GameId)],
CpCtx: this.CpCtx,
Time: now,
Trend20Lately: param.Trend20Lately,
Ts: now.Unix(),
CtrlType: param.CtrlType,
PlayerPool: make(map[int]int),
CycleId: this.CycleID,
}
for k, v := range param.PlayerPool {
log.PlayerPool[k] = v
}
if param.OnlyLog {
ret.Log = append(ret.Log, log)
} else {
mq.Write(log)
}
}
switch {
case this.IsCoinScene():
mapPlatform := make(map[string]bool)
for _, v := range this.Players {
if v == nil {
continue
}
if _, ok := mapPlatform[v.Platform]; ok {
continue
}
mapPlatform[v.Platform] = true
f(v.Platform)
}
default:
f(this.Platform)
}
return &ret
}
type SaveGamePlayerListLogParam struct {
LogId string // 详情日志id
Platform string // 平台
Snid int32 // 玩家id
PlayerName string // 玩家名字
Channel string // 渠道
ChannelId string // 推广渠道
TotalIn int64 // 总投入
TotalOut int64 // 总产出(税前)
TaxCoin int64 // 总税收
BetAmount int64 // 下注量
WinAmountNoAnyTax int64 // 税后赢取额(净利润,正负值)
IsFirstGame bool // 是否第一次游戏
IsFree bool // 拉霸专用 是否免费
WinSmallGame int64 // 拉霸专用 小游戏奖励
WinTotal int64 // 拉霸专用 本局输赢
GameTime int64 // 游戏时长
OnlyLog bool // 只返回日志,不保存
}
// SaveGamePlayerListLog 保存玩家对局记录
func (this *Scene) SaveGamePlayerListLog(param *SaveGamePlayerListLogParam) *SaveGamePlayerListLogCopy {
if this == nil {
return nil
}
if param == nil {
return nil
}
p := this.GetPlayer(param.Snid)
if p == nil {
return nil
}
if param.PlayerName == "" {
param.PlayerName = p.Name
}
var ret SaveGamePlayerListLogCopy
ret.Param = param
baseScore := this.GetBaseScore()
// 上报玩家游戏记录
if !p.IsRob && (param.IsFree || param.TotalIn != 0 || param.TotalOut != 0) {
e := p.ReportGameEvent(&ReportGameEventParam{
Tax: param.TaxCoin,
Change: param.WinAmountNoAnyTax,
In: param.TotalIn,
Out: param.TotalOut,
GameTime: param.GameTime,
OnlyLog: param.OnlyLog,
})
if e != nil {
ret.UpLog = e
}
}
// 保存玩家游戏日志
now := time.Now()
log := &model.GamePlayerListLog{
LogId: bson.NewObjectId(),
SnId: p.SnId,
Name: param.PlayerName,
GameId: this.GameId,
BaseScore: baseScore,
TaxCoin: param.TaxCoin,
Platform: param.Platform,
Channel: param.Channel,
SceneId: this.SceneId,
GameMode: this.GameMode,
GameFreeid: this.GetGameFreeId(),
GameDetailedLogId: param.LogId,
IsFirstGame: param.IsFirstGame,
BetAmount: param.BetAmount,
WinAmountNoAnyTax: param.WinAmountNoAnyTax,
TotalIn: param.TotalIn,
TotalOut: param.TotalOut,
Time: now,
RoomType: this.SceneMode,
GameDif: this.GetDBGameFree().GetGameDif(),
GameClass: this.GetDBGameFree().GetGameClass(),
MatchId: this.GetMatch().GetMatchSortId(),
MatchType: int64(this.GetMatch().GetMatchType()),
Ts: now.Unix(),
IsFree: param.IsFree,
WinSmallGame: param.WinSmallGame,
WinTotal: param.WinTotal,
CycleId: this.CycleID,
}
if param.OnlyLog {
ret.Log = append(ret.Log, log)
} else {
mq.Write(log)
}
return &ret
}
// SaveGamePlayerListLogCopy 临时记录
// 为了拉霸统计游戏时长,需要临时缓存游戏记录
type SaveGamePlayerListLogCopy struct {
Param *SaveGamePlayerListLogParam
Log []*model.GamePlayerListLog
UpLog *ReportGameEventOnly // mq上报数据
}
func (s *SaveGamePlayerListLogCopy) Save() {
for _, v := range s.Log {
mq.Write(v)
}
if s.UpLog != nil {
for _, v := range s.UpLog.Log {
mq.Write(v, mq.BackGameRecord)
}
}
}
// SaveGameDetailedCopy 临时记录
// 为了拉霸统计游戏时长,需要临时缓存游戏记录
type SaveGameDetailedCopy struct {
Param *SaveGameDetailedParam
Log []*model.GameDetailedLog
}
func (s *SaveGameDetailedCopy) Save() {
for _, v := range s.Log {
mq.Write(v)
}
}
// LabaLog 拉霸缓存游戏记录
type LabaLog struct {
PlayerListLog *SaveGamePlayerListLogCopy
GameDetailLog *SaveGameDetailedCopy
}
// Cache 临时缓存
func (l *LabaLog) Cache(s *Scene, detailLog *SaveGameDetailedParam, playerListLog *SaveGamePlayerListLogParam) {
if s == nil {
return
}
detailLog.OnlyLog = true
playerListLog.OnlyLog = true
l.GameDetailLog = s.SaveGameDetailedLog(detailLog)
l.PlayerListLog = s.SaveGamePlayerListLog(playerListLog)
}
// Save 保存
func (l *LabaLog) Save(f func(log *LabaLog)) {
f(l)
l.PlayerListLog.Save()
l.GameDetailLog.Save()
l.Clear()
}
// Clear 清空
func (l *LabaLog) Clear() {
l.PlayerListLog = nil
l.GameDetailLog = nil
}

View File

@ -68,27 +68,6 @@ func NewGameWarning(param string) {
}), nil, "NewGameWarning").Start() }), nil, "NewGameWarning").Start()
} }
// func WarningLoseCoin(gameFreeId int32, snid int32, loseCoin int64) {
// if model.GameParamData.WarningLoseLimit == 0 {
// return
// }
// if loseCoin < model.GameParamData.WarningLoseLimit {
// return
// }
// NewGameWarning(fmt.Sprintf(`{"WarningType":%v,"WarningGame":%v,"WarningSnid":%v,"LoseCoin":%v}`,
// Warning_LoseCoinLimit, gameFreeId, snid, loseCoin))
//
//func WarningBetCoinCheck(sceneId, gameFreeId int32, snid int32, betCoin int64) {
// if model.GameParamData.WarningBetMax == 0 {
// return
// }
// if betCoin > model.GameParamData.WarningBetMax {
// NewGameWarning(fmt.Sprintf(`{"WarningType":%v,"WarningSnid":%v,"WarningGame":%v,"WarningScene":%v}`,
// Warning_BetCoinMax, snid, gameFreeId, sceneId))
// }
//}
func WarningCoinPool(warnType int, gameFreeId int32) { func WarningCoinPool(warnType int, gameFreeId int32) {
NewGameWarning(fmt.Sprintf(`{"WarningType":%v,"WarningGame":%v}`, NewGameWarning(fmt.Sprintf(`{"WarningType":%v,"WarningGame":%v}`,
warnType, gameFreeId)) warnType, gameFreeId))
@ -97,24 +76,3 @@ func WarningBlackPlayer(snid, gameFreeId int32) {
NewGameWarning(fmt.Sprintf(`{"WarningType":%v,"WarningSnid":%v,"WarningGame":%v}`, NewGameWarning(fmt.Sprintf(`{"WarningType":%v,"WarningSnid":%v,"WarningGame":%v}`,
Warning_BlackPlayer, snid, gameFreeId)) Warning_BlackPlayer, snid, gameFreeId))
} }
//func WarningWinnerRate(snid int32, winCoin, loseCoin int64) {
// if model.GameParamData.WarningWinRate == 0 {
// return
// }
// if (winCoin+1)/(loseCoin+1) < model.GameParamData.WarningWinRate {
// return
// }
// NewGameWarning(fmt.Sprintf(`{"WarningType":%v,"WarningSnid":%v,"WarningRate":%v,"WinCoin":%v,"LoseCoin":%v}`,
// Warning_WinRate, snid, (winCoin+1)/(loseCoin+1), winCoin, loseCoin))
//}
//func WarningWinnerCoin(snid int32, winCoin, loseCoin int64) {
// if model.GameParamData.WarningWinMoney == 0 {
// return
// }
// if (winCoin - loseCoin) < model.GameParamData.WarningWinMoney {
// return
// }
// NewGameWarning(fmt.Sprintf(`{"WarningType":%v,"WarningSnid":%v,"WarningCoin":%v,"WinCoin":%v,"LoseCoin":%v}`,
// Warning_WinCoin, snid, (winCoin - loseCoin), winCoin, loseCoin))
//}

View File

@ -1,300 +0,0 @@
package base
import (
"fmt"
"strconv"
"strings"
"time"
"mongo.games.com/game/model"
"github.com/globalsign/mgo/bson"
"mongo.games.com/goserver/core/basic"
"mongo.games.com/goserver/core/logger"
"mongo.games.com/goserver/core/module"
"mongo.games.com/goserver/core/task"
)
// HundredJackListManager 排行榜 key: platform+gamefreeId
type HundredJackListManager struct {
HundredJackTsList map[string][]*HundredJackInfo
HundredJackSortList map[string][]*HundredJackInfo
}
// HundredJackListMgr 实例化
var HundredJackListMgr = &HundredJackListManager{
HundredJackTsList: make(map[string][]*HundredJackInfo),
HundredJackSortList: make(map[string][]*HundredJackInfo),
}
// HundredJackInfo 数据结构
type HundredJackInfo struct {
model.HundredjackpotLog
linkSnids []int32 //点赞人数
}
// ModuleName .
func (hm *HundredJackListManager) ModuleName() string {
return "HundredJackListManager"
}
// Init .
func (hm *HundredJackListManager) Init() {
//data := model.
}
// Update .
func (hm *HundredJackListManager) Update() {
}
// Shutdown .
func (hm *HundredJackListManager) Shutdown() {
module.UnregisteModule(hm)
}
// ISInitJackInfo 仅初始化一次
var ISInitJackInfo bool
// InitTsJackInfo 初始化TsJackInfo
func (hm *HundredJackListManager) InitTsJackInfo(platform string, freeID int32) {
key := fmt.Sprintf("%v-%v", platform, freeID)
task.New(nil, task.CallableWrapper(func(o *basic.Object) interface{} {
datas, err := model.GetHundredjackpotLogTsByPlatformAndGameFreeID(platform, freeID)
if err != nil {
logger.Logger.Error("HundredJackListManager DelOneJackInfo ", err)
return nil
}
return datas
}), task.CompleteNotifyWrapper(func(data interface{}, tt task.Task) {
datas := data.([]model.HundredjackpotLog)
if data != nil && datas != nil {
for i := range datas {
if i == model.HundredjackpotLogMaxLimitPerQuery {
break
}
data := &HundredJackInfo{
HundredjackpotLog: datas[i],
}
strlikeSnids := strings.Split(datas[i].LinkeSnids, "|")
for _, v := range strlikeSnids {
if v == "" {
break
}
snid, err := strconv.Atoi(v)
if err == nil {
data.linkSnids = append(data.linkSnids, int32(snid))
}
}
hm.HundredJackTsList[key] = append(hm.HundredJackTsList[key], data)
}
// logger.Logger.Warnf("InitTsJackInfo data:%v", datas)
} else {
hm.HundredJackTsList[key] = []*HundredJackInfo{}
}
return
}), "InitTsJackInfo").Start()
}
// InitSortJackInfo 初始化SortJackInfo
func (hm *HundredJackListManager) InitSortJackInfo(platform string, freeID int32) {
key := fmt.Sprintf("%v-%v", platform, freeID)
task.New(nil, task.CallableWrapper(func(o *basic.Object) interface{} {
datas, err := model.GetHundredjackpotLogCoinByPlatformAndGameFreeID(platform, freeID)
if err != nil {
logger.Logger.Error("HundredJackListManager DelOneJackInfo ", err)
return nil
}
return datas
}), task.CompleteNotifyWrapper(func(data interface{}, tt task.Task) {
datas := data.([]model.HundredjackpotLog)
if data != nil && datas != nil {
for i := range datas {
if i == model.HundredjackpotLogMaxLimitPerQuery {
break
}
data := &HundredJackInfo{
HundredjackpotLog: datas[i],
}
strlikeSnids := strings.Split(datas[i].LinkeSnids, "|")
for _, v := range strlikeSnids {
snid, err := strconv.Atoi(v)
if err == nil {
data.linkSnids = append(data.linkSnids, int32(snid))
}
}
hm.HundredJackSortList[key] = append(hm.HundredJackSortList[key], data)
}
// logger.Logger.Warnf("InitSortJackInfo data:%v", datas)
} else {
hm.HundredJackSortList[key] = []*HundredJackInfo{}
}
return
}), "InitSortJackInfo").Start()
}
// InitHundredJackListInfo 初始化 HundredJackListInfo
func (hm *HundredJackListManager) InitHundredJackListInfo(platform string, freeID int32) {
if ISInitJackInfo {
return
}
key := fmt.Sprintf("%v-%v", platform, freeID)
if _, exist := hm.HundredJackTsList[key]; !exist {
hm.InitTsJackInfo(platform, freeID)
}
if _, exist := hm.HundredJackSortList[key]; !exist {
hm.InitSortJackInfo(platform, freeID)
}
ISInitJackInfo = true
return
}
// GetJackTsInfo 返回TsInfo
func (hm *HundredJackListManager) GetJackTsInfo(platform string, freeID int32) []*HundredJackInfo {
key := fmt.Sprintf("%v-%v", platform, freeID)
if _, exist := hm.HundredJackTsList[key]; !exist { // 玩家进入scene 已经初始化
hm.InitTsJackInfo(platform, freeID)
}
return hm.HundredJackTsList[key]
}
// GetJackSortInfo 返回SortInfo
func (hm *HundredJackListManager) GetJackSortInfo(platform string, freeID int32) []*HundredJackInfo {
key := fmt.Sprintf("%v-%v", platform, freeID)
if _, exist := hm.HundredJackSortList[key]; !exist {
hm.InitSortJackInfo(platform, freeID)
}
return hm.HundredJackSortList[key]
}
// Insert 插入
func (hm *HundredJackListManager) Insert(coin, turncoin int64, snid, roomid, jackType, inGame, vip int32, platform, channel, name string, gamedata []string) {
key := fmt.Sprintf("%v-%v", platform, roomid)
log := model.NewHundredjackpotLogEx(snid, coin, turncoin, roomid, jackType, inGame, vip, platform, channel, name, gamedata)
///////////////////实际不走这里
if _, exist := hm.HundredJackTsList[key]; !exist {
hm.InitTsJackInfo(platform, roomid)
}
if _, exist := hm.HundredJackSortList[key]; !exist {
hm.InitSortJackInfo(platform, roomid)
}
/////////////////////
hm.InsertLog(log)
data := &HundredJackInfo{
HundredjackpotLog: *log,
}
/*logger.Logger.Trace("HundredJackListManager log 1 ", log.SnID, log.LogID, data.GameData)
for _, v := range hm.HundredJackTsList[key] {
logger.Logger.Trace("HundredJackListManager log 2 ", v.SnID, v.LogID, v.GameData)
}*/
for i, v := range hm.HundredJackSortList[key] { // 插入
if v.Coin < log.Coin {
d1 := append([]*HundredJackInfo{}, hm.HundredJackSortList[key][i:]...)
hm.HundredJackSortList[key] = append(hm.HundredJackSortList[key][:i], data)
hm.HundredJackSortList[key] = append(hm.HundredJackSortList[key], d1...)
goto Exit
}
}
if len(hm.HundredJackSortList[key]) < model.HundredjackpotLogMaxLimitPerQuery {
hm.HundredJackSortList[key] = append(hm.HundredJackSortList[key], data)
}
Exit:
d1 := append([]*HundredJackInfo{}, hm.HundredJackTsList[key][0:]...)
hm.HundredJackTsList[key] = append(hm.HundredJackTsList[key][:0], data)
hm.HundredJackTsList[key] = append(hm.HundredJackTsList[key], d1...)
var delList []*HundredJackInfo
if len(hm.HundredJackTsList[key]) > model.HundredjackpotLogMaxLimitPerQuery {
delList = append(delList, hm.HundredJackTsList[key][model.HundredjackpotLogMaxLimitPerQuery:]...)
hm.HundredJackTsList[key] = hm.HundredJackTsList[key][:model.HundredjackpotLogMaxLimitPerQuery]
}
if len(hm.HundredJackSortList[key]) > model.HundredjackpotLogMaxLimitPerQuery {
delList = append(delList, hm.HundredJackSortList[key][model.HundredjackpotLogMaxLimitPerQuery:]...)
hm.HundredJackSortList[key] = hm.HundredJackSortList[key][:model.HundredjackpotLogMaxLimitPerQuery]
}
/*for _, v := range hm.HundredJackTsList[key] {
logger.Logger.Trace("HundredJackListManager log 3 ", v.SnID, v.LogID, v.GameData)
}*/
for _, v := range delList {
if hm.IsCanDel(v, hm.HundredJackTsList[key], hm.HundredJackSortList[key]) { // 两个排行帮都不包含
logger.Logger.Info("HundredJackListManager DelOneJackInfo ", v.LogID)
hm.DelOneJackInfo(v.Platform, v.LogID)
}
}
}
// IsCanDel 能否删除
func (hm *HundredJackListManager) IsCanDel(deldata *HundredJackInfo, tsList, sortList []*HundredJackInfo) bool {
for _, v := range tsList {
if v.LogID == deldata.LogID {
return false
}
}
for _, v := range sortList {
if v.LogID == deldata.LogID {
return false
}
}
return true
}
// InsertLog insert db
func (hm *HundredJackListManager) InsertLog(log *model.HundredjackpotLog) {
task.New(nil, task.CallableWrapper(func(o *basic.Object) interface{} {
err := model.InsertHundredjackpotLog(log)
if err != nil {
logger.Logger.Error("HundredJackListManager Insert ", err)
}
return err
}), nil, "InsertHundredJack").Start()
}
// UpdateLikeNum updata likenum
func (hm *HundredJackListManager) UpdateLikeNum(plt string, gid bson.ObjectId, like int32, likesnids string) {
task.New(nil, task.CallableWrapper(func(o *basic.Object) interface{} {
err := model.UpdateLikeNum(plt, gid, like, likesnids)
if err != nil {
logger.Logger.Error("HundredJackListManager UpdateHundredLikeNum ", err)
}
return err
}), nil, "UpdateHundredLikeNum").Start()
}
// UpdatePlayBlackNum updata playblacknum
func (hm *HundredJackListManager) UpdatePlayBlackNum(plt string, gid bson.ObjectId, playblack int32) []string {
var ret []string
task.New(nil, task.CallableWrapper(func(o *basic.Object) interface{} {
data, err := model.UpdatePlayBlackNum(plt, gid, playblack)
if err != nil {
logger.Logger.Error("HundredJackListManager DelOneJackInfo ", err)
return nil
}
return data
}), task.CompleteNotifyWrapper(func(data interface{}, tt task.Task) {
if data != nil {
ret = data.([]string)
logger.Logger.Warnf("UpdatePlayBlackNum data:%v", ret)
}
return
}), "UpdatePlayBlackNum").Start()
logger.Logger.Error("HundredJackListManager UpdatePlayBlackNum ", ret)
if len(ret) == 0 {
return ret
}
return nil
}
// DelOneJackInfo del
func (hm *HundredJackListManager) DelOneJackInfo(plt string, gid bson.ObjectId) {
task.New(nil, task.CallableWrapper(func(o *basic.Object) interface{} {
err := model.RemoveHundredjackpotLogOne(plt, gid)
if err != nil {
logger.Logger.Error("HundredJackListManager DelOneJackInfo ", err)
}
return err
}), nil, "DelOneJackInfo").Start()
}
func init() {
module.RegisteModule(HundredJackListMgr, time.Hour, 0)
}

View File

@ -627,9 +627,15 @@ type ReportGameEventParam struct {
Change int64 // 净输赢,正负值,不带税收 Change int64 // 净输赢,正负值,不带税收
In, Out int64 // 投入,产出(税前) In, Out int64 // 投入,产出(税前)
GameTime int64 // 游戏时长,秒 GameTime int64 // 游戏时长,秒
OnlyLog bool // 只返回数据,不上报
} }
func (this *Player) ReportGameEvent(param *ReportGameEventParam) { type ReportGameEventOnly struct {
Param *ReportGameEventParam
Log []*model.PlayerGameRecEvent
}
func (this *Player) ReportGameEvent(param *ReportGameEventParam) *ReportGameEventOnly {
// 记录玩家 首次参与该场次的游戏时间 游戏次数 // 记录玩家 首次参与该场次的游戏时间 游戏次数
var gameFirstTime, gameFreeFirstTime time.Time var gameFirstTime, gameFreeFirstTime time.Time
var gameTimes, gameFreeTimes int64 var gameTimes, gameFreeTimes int64
@ -659,6 +665,8 @@ func (this *Player) ReportGameEvent(param *ReportGameEventParam) {
param.GameTime = 0 param.GameTime = 0
} }
var ret ReportGameEventOnly
ret.Param = param
log := &model.PlayerGameRecEvent{ log := &model.PlayerGameRecEvent{
Platform: this.Platform, Platform: this.Platform,
RecordId: this.scene.GetRecordId(), RecordId: this.scene.GetRecordId(),
@ -685,8 +693,13 @@ func (this *Player) ReportGameEvent(param *ReportGameEventParam) {
LastLoginTime: this.LastLoginTime.Unix(), LastLoginTime: this.LastLoginTime.Unix(),
DeviceId: this.DeviceId, DeviceId: this.DeviceId,
} }
if param.OnlyLog {
ret.Log = append(ret.Log, log)
} else {
mq.Write(log, mq.BackGameRecord) mq.Write(log, mq.BackGameRecord)
} }
return &ret
}
// 汇总玩家该次游戏总产生的税收 // 汇总玩家该次游戏总产生的税收
// 数据用途: 平台和推广间分账用,确保数据计算无误, // 数据用途: 平台和推广间分账用,确保数据计算无误,

View File

@ -2,7 +2,6 @@ package base
import ( import (
"fmt" "fmt"
"github.com/globalsign/mgo/bson"
"math" "math"
"math/rand" "math/rand"
"strconv" "strconv"
@ -1457,162 +1456,6 @@ func (this *Scene) SaveFriendRecord(snid int32, isWin int32, billCoin int64, bas
} }
} }
type SaveGameDetailedParam struct {
LogId string // 日志id
Detail string // 游戏详细信息
GameTime int64 // 游戏时长
Trend20Lately string // 最近20局开奖结果
CtrlType int // 调控类型 1控赢 2控输
PlayerPool map[int]int // 个人水池分
}
func (this *Scene) SaveGameDetailedLog(param *SaveGameDetailedParam) {
if this == nil || param == nil {
return
}
if param.GameTime <= 0 {
param.GameTime = int64(time.Now().Sub(this.GameNowTime).Seconds())
}
if param.GameTime < 0 {
param.GameTime = 0
}
now := time.Now()
f := func(plt string) {
log := &model.GameDetailedLog{
Id: bson.NewObjectId(),
LogId: param.LogId,
GameId: this.GameId,
Platform: plt,
MatchId: this.GetMatch().GetMatchSortId(),
SceneId: this.SceneId,
GameMode: this.GameMode,
GameFreeid: this.GetGameFreeId(),
PlayerCount: int32(len(this.Players)),
GameTiming: int32(param.GameTime),
GameBaseBet: this.GetBaseScore(),
GameDetailedNote: param.Detail,
GameDetailVer: GameDetailedVer[int(this.GameId)],
CpCtx: this.CpCtx,
Time: now,
Trend20Lately: param.Trend20Lately,
Ts: now.Unix(),
CtrlType: param.CtrlType,
PlayerPool: make(map[int]int),
CycleId: this.CycleID,
}
for k, v := range param.PlayerPool {
log.PlayerPool[k] = v
}
mq.Write(log)
}
switch {
case this.IsCoinScene():
mapPlatform := make(map[string]bool)
for _, v := range this.Players {
if v == nil {
continue
}
if _, ok := mapPlatform[v.Platform]; ok {
continue
}
mapPlatform[v.Platform] = true
f(v.Platform)
}
default:
f(this.Platform)
}
}
type SaveGamePlayerListLogParam struct {
LogId string // 详情日志id
Platform string // 平台
Snid int32 // 玩家id
PlayerName string // 玩家名字
Channel string // 渠道
ChannelId string // 推广渠道
TotalIn int64 // 总投入
TotalOut int64 // 总产出(税前)
TaxCoin int64 // 总税收
BetAmount int64 // 下注量
WinAmountNoAnyTax int64 // 税后赢取额(净利润,正负值)
IsFirstGame bool // 是否第一次游戏
IsFree bool // 拉霸专用 是否免费
WinSmallGame int64 // 拉霸专用 小游戏奖励
WinTotal int64 // 拉霸专用 本局输赢
GameTime int64 // 游戏时长
}
// SaveGamePlayerListLog 保存玩家对局记录
func (this *Scene) SaveGamePlayerListLog(param *SaveGamePlayerListLogParam) {
if this == nil {
return
}
if param == nil {
return
}
p := this.GetPlayer(param.Snid)
if p == nil {
return
}
if param.PlayerName == "" {
param.PlayerName = p.Name
}
baseScore := this.GetBaseScore()
// 上报玩家游戏记录
if !p.IsRob && (param.IsFree || param.TotalIn != 0 || param.TotalOut != 0) {
p.ReportGameEvent(&ReportGameEventParam{
Tax: param.TaxCoin,
Change: param.WinAmountNoAnyTax,
In: param.TotalIn,
Out: param.TotalOut,
GameTime: param.GameTime,
})
}
// 保存玩家游戏日志
now := time.Now()
log := &model.GamePlayerListLog{
LogId: bson.NewObjectId(),
SnId: p.SnId,
Name: param.PlayerName,
GameId: this.GameId,
BaseScore: baseScore,
TaxCoin: param.TaxCoin,
Platform: param.Platform,
Channel: param.Channel,
SceneId: this.SceneId,
GameMode: this.GameMode,
GameFreeid: this.GetGameFreeId(),
GameDetailedLogId: param.LogId,
IsFirstGame: param.IsFirstGame,
BetAmount: param.BetAmount,
WinAmountNoAnyTax: param.WinAmountNoAnyTax,
TotalIn: param.TotalIn,
TotalOut: param.TotalOut,
Time: now,
RoomType: this.SceneMode,
GameDif: this.GetDBGameFree().GetGameDif(),
GameClass: this.GetDBGameFree().GetGameClass(),
MatchId: this.GetMatch().GetMatchSortId(),
MatchType: int64(this.GetMatch().GetMatchType()),
Ts: now.Unix(),
IsFree: param.IsFree,
WinSmallGame: param.WinSmallGame,
WinTotal: param.WinTotal,
CycleId: this.CycleID,
}
mq.Write(log)
}
func (this *Scene) IsPlayerFirst(p *Player) bool { func (this *Scene) IsPlayerFirst(p *Player) bool {
if p == nil { if p == nil {
return false return false