房卡场对局记录
This commit is contained in:
parent
bfdf500eec
commit
9ea57766a4
|
@ -0,0 +1,36 @@
|
|||
package mq
|
||||
|
||||
import (
|
||||
"encoding/json"
|
||||
|
||||
"mongo.games.com/goserver/core/broker"
|
||||
"mongo.games.com/goserver/core/broker/rabbitmq"
|
||||
|
||||
"mongo.games.com/game/dbproxy/svc"
|
||||
"mongo.games.com/game/model"
|
||||
"mongo.games.com/game/mq"
|
||||
)
|
||||
|
||||
func init() {
|
||||
mq.RegisterSubscriber(mq.DBCustomLog, func(e broker.Event) (err error) {
|
||||
msg := e.Message()
|
||||
if msg != nil {
|
||||
defer func() {
|
||||
e.Ack()
|
||||
}()
|
||||
|
||||
var log model.CustomLog
|
||||
err = json.Unmarshal(msg.Body, &log)
|
||||
if err != nil {
|
||||
return
|
||||
}
|
||||
|
||||
c := svc.DbCustomLogCollection(log.Platform)
|
||||
if c != nil {
|
||||
err = c.Insert(log)
|
||||
}
|
||||
return
|
||||
}
|
||||
return nil
|
||||
}, broker.Queue(mq.DBCustomLog), broker.DisableAutoAck(), rabbitmq.DurableQueue())
|
||||
}
|
|
@ -0,0 +1,25 @@
|
|||
package svc
|
||||
|
||||
import (
|
||||
"github.com/globalsign/mgo"
|
||||
"mongo.games.com/game/dbproxy/mongo"
|
||||
"mongo.games.com/game/model"
|
||||
)
|
||||
|
||||
func DbCustomLogCollection(plt string) *mongo.Collection {
|
||||
s := mongo.MgoSessionMgrSington.GetPltMgoSession(plt, model.DbCustomLogDBName)
|
||||
if s != nil {
|
||||
d, first := s.DB().C(model.DbCustomLogCollName)
|
||||
if first {
|
||||
d.EnsureIndex(mgo.Index{Key: []string{"cycleid"}, Background: true, Sparse: true})
|
||||
d.EnsureIndex(mgo.Index{Key: []string{"-startts", "cycleid"}, Background: true, Sparse: true})
|
||||
d.EnsureIndex(mgo.Index{Key: []string{"roomconfigid"}, Background: true, Sparse: true})
|
||||
d.EnsureIndex(mgo.Index{Key: []string{"roomid"}, Background: true, Sparse: true})
|
||||
d.EnsureIndex(mgo.Index{Key: []string{"startts"}, Background: true, Sparse: true})
|
||||
d.EnsureIndex(mgo.Index{Key: []string{"endts"}, Background: true, Sparse: true})
|
||||
d.EnsureIndex(mgo.Index{Key: []string{"-endts"}, Background: true, Sparse: true})
|
||||
}
|
||||
return d
|
||||
}
|
||||
return nil
|
||||
}
|
|
@ -28,6 +28,8 @@ func GameDetailedLogsCollection(plt string) *mongo.Collection {
|
|||
c_gamedetailed.EnsureIndex(mgo.Index{Key: []string{"matchid"}, Background: true, Sparse: true})
|
||||
c_gamedetailed.EnsureIndex(mgo.Index{Key: []string{"-ts", "gameid"}, Background: true, Sparse: true})
|
||||
c_gamedetailed.EnsureIndex(mgo.Index{Key: []string{"-ts", "gamefreeid"}, Background: true, Sparse: true})
|
||||
c_gamedetailed.EnsureIndex(mgo.Index{Key: []string{"-ts", "cycleid"}, Background: true, Sparse: true})
|
||||
c_gamedetailed.EnsureIndex(mgo.Index{Key: []string{"cycleid"}, Background: true, Sparse: true})
|
||||
}
|
||||
return c_gamedetailed
|
||||
}
|
||||
|
|
|
@ -41,6 +41,8 @@ func GamePlayerListLogsCollection(plt string) *mongo.Collection {
|
|||
c_gameplayerlistlog.EnsureIndex(mgo.Index{Key: []string{"-ts", "gamefreeid"}, Background: true, Sparse: true})
|
||||
c_gameplayerlistlog.EnsureIndex(mgo.Index{Key: []string{"-ts", "snid", "gameid"}, Background: true, Sparse: true})
|
||||
c_gameplayerlistlog.EnsureIndex(mgo.Index{Key: []string{"-ts", "snid", "gamefreeid"}, Background: true, Sparse: true})
|
||||
c_gameplayerlistlog.EnsureIndex(mgo.Index{Key: []string{"-ts", "cycleid"}, Background: true, Sparse: true})
|
||||
c_gameplayerlistlog.EnsureIndex(mgo.Index{Key: []string{"cycleid"}, Background: true, Sparse: true})
|
||||
}
|
||||
return c_gameplayerlistlog
|
||||
}
|
||||
|
|
|
@ -54,4 +54,5 @@ func init() {
|
|||
LogChannelSingleton.RegisterLogCName(model.GamePlayerListLogCollName, &model.GamePlayerListLog{})
|
||||
LogChannelSingleton.RegisterLogCName(model.FriendRecordLogCollName, &model.FriendRecord{})
|
||||
LogChannelSingleton.RegisterLogCName(model.ItemLogCollName, &model.ItemLog{})
|
||||
LogChannelSingleton.RegisterLogCName(mq.DBCustomLog, &model.CustomLog{})
|
||||
}
|
||||
|
|
|
@ -1441,6 +1441,7 @@ type GameDetailedParam struct {
|
|||
Trend20Lately string //最近20局开奖结果
|
||||
CtrlType int
|
||||
PlayerPool map[int]int
|
||||
CycleId string
|
||||
}
|
||||
|
||||
// 保存详细游戏日志
|
||||
|
@ -1461,7 +1462,7 @@ func (this *Scene) SaveGameDetailedLog(logid string, gamedetailednote string, ga
|
|||
this.GetDBGameFree().GetGameMode(), this.GetDBGameFree().Id, int32(len(this.Players)),
|
||||
int32(time.Now().Unix()-this.GameNowTime.Unix()), baseScore,
|
||||
gamedetailednote, p.Platform, this.ClubId, this.RoomId, this.CpCtx, GameDetailedVer[int(this.GameId)], trend20Lately,
|
||||
gameDetailedParam.CtrlType, gameDetailedParam.PlayerPool)
|
||||
gameDetailedParam.CtrlType, gameDetailedParam.PlayerPool, gameDetailedParam.CycleId)
|
||||
if log != nil {
|
||||
if this.IsMatchScene() {
|
||||
log.MatchId = this.GetMatch().GetMatchSortId()
|
||||
|
@ -1478,7 +1479,7 @@ func (this *Scene) SaveGameDetailedLog(logid string, gamedetailednote string, ga
|
|||
this.GetDBGameFree().GetGameMode(), this.GetDBGameFree().Id, int32(len(this.Players)),
|
||||
int32(time.Now().Unix()-this.GameNowTime.Unix()), baseScore,
|
||||
gamedetailednote, this.Platform, this.ClubId, this.RoomId, this.CpCtx, GameDetailedVer[int(this.GameId)], trend20Lately,
|
||||
gameDetailedParam.CtrlType, gameDetailedParam.PlayerPool)
|
||||
gameDetailedParam.CtrlType, gameDetailedParam.PlayerPool, gameDetailedParam.CycleId)
|
||||
if log != nil {
|
||||
if this.IsMatchScene() {
|
||||
log.MatchId = this.GetMatch().GetMatchSortId()
|
||||
|
@ -1516,6 +1517,7 @@ type SaveGamePlayerListLogParam struct {
|
|||
WinSmallGame int64 //拉霸专用 小游戏奖励
|
||||
WinTotal int64 //拉霸专用 本局输赢
|
||||
PlayerName string //玩家名字
|
||||
CycleId string // 房卡场对局id
|
||||
}
|
||||
|
||||
func GetSaveGamePlayerListLogParam(platform, channel, promoter, packageTag, logid string,
|
||||
|
@ -1594,7 +1596,7 @@ func (this *Scene) SaveGamePlayerListLog(snid int32, param *SaveGamePlayerListLo
|
|||
this.GameId, baseScore, this.SceneId, int32(this.GetGameMode()),
|
||||
this.GetGameFreeId(), param.TotalIn, param.TotalOut, this.ClubId, this.RoomId, param.TaxCoin, param.ClubPumpCoin, roomType,
|
||||
param.BetAmount, param.WinAmountNoAnyTax, this.KeyGameId, Name, this.GetDBGameFree().GetGameClass(),
|
||||
param.IsFirstGame, this.GetMatch().GetMatchSortId(), int64(this.GetMatch().GetMatchType()), param.IsFree, param.WinSmallGame, param.WinTotal)
|
||||
param.IsFirstGame, this.GetMatch().GetMatchSortId(), int64(this.GetMatch().GetMatchType()), param.IsFree, param.WinSmallGame, param.WinTotal, param.CycleId)
|
||||
if log != nil {
|
||||
LogChannelSingleton.WriteLog(log)
|
||||
}
|
||||
|
|
|
@ -27,6 +27,11 @@ type BilledInfo struct {
|
|||
Score int64 // 结算后积分
|
||||
}
|
||||
|
||||
type Item struct {
|
||||
Id int32
|
||||
Num int64
|
||||
}
|
||||
|
||||
// 房间上的额外数据
|
||||
type TienLenSceneData struct {
|
||||
*base.Scene //场景
|
||||
|
@ -65,6 +70,8 @@ type TienLenSceneData struct {
|
|||
BilledList map[int32]*[]*BilledInfo // 多轮结算记录, 玩家id:每局结算记录
|
||||
RoundEndTime []int64 // 每局结束时间
|
||||
RoundLogId []string // 每局牌局记录id
|
||||
CustomLogSave bool // 是否已经保存日志
|
||||
PlayerAward map[int32]*[]*model.Item // 房卡场最终奖励
|
||||
}
|
||||
|
||||
func NewTienLenSceneData(s *base.Scene) *TienLenSceneData {
|
||||
|
@ -73,6 +80,7 @@ func NewTienLenSceneData(s *base.Scene) *TienLenSceneData {
|
|||
poker: rule.NewPoker(),
|
||||
players: make(map[int32]*TienLenPlayerData),
|
||||
BilledList: map[int32]*[]*BilledInfo{},
|
||||
PlayerAward: make(map[int32]*[]*model.Item),
|
||||
}
|
||||
sceneEx.Clear()
|
||||
return sceneEx
|
||||
|
@ -282,6 +290,7 @@ func (this *TienLenSceneData) OnPlayerLeave(p *base.Player, reason int) {
|
|||
}
|
||||
|
||||
func (this *TienLenSceneData) SceneDestroy(force bool) {
|
||||
this.SaveCustomLog()
|
||||
//销毁房间
|
||||
this.Scene.Destroy(force)
|
||||
}
|
||||
|
@ -2093,3 +2102,60 @@ func (this *TienLenSceneData) SendFirstGiveTimeItem(p *base.Player) {
|
|||
p.SendToClient(int(tienlen.TienLenPacketID_PACKET_SCTienLenFirstGiveItemItem), pack)
|
||||
}
|
||||
}
|
||||
|
||||
// SaveCustomLog 保存竞技馆对局记录
|
||||
func (this *TienLenSceneData) SaveCustomLog() {
|
||||
if this.CustomLogSave || !this.IsCustom() {
|
||||
return
|
||||
}
|
||||
this.CustomLogSave = true
|
||||
state := int32(0)
|
||||
if len(this.RoundEndTime) < int(this.TotalOfGames) {
|
||||
state = 1
|
||||
}
|
||||
log := &model.CustomLog{
|
||||
CycleId: this.CycleID,
|
||||
RoomConfigId: this.GetCustom().GetRoomConfigId(),
|
||||
RoomId: this.SceneId,
|
||||
StartTs: this.GameStartTime.Unix(),
|
||||
EndTs: time.Now().Unix(),
|
||||
State: state,
|
||||
GameFreeId: this.GetGameFreeId(),
|
||||
TotalRound: this.TotalOfGames,
|
||||
Password: this.GetCustom().GetPassword(),
|
||||
CostType: this.GetCustom().GetCostType(),
|
||||
Voice: this.GetCustom().GetVoice(),
|
||||
}
|
||||
for snid := range this.BilledList {
|
||||
var items []*model.Item
|
||||
if this.PlayerAward[snid] != nil {
|
||||
items = *this.PlayerAward[snid]
|
||||
}
|
||||
log.SnId = append(log.SnId, model.PlayerInfo{
|
||||
SnId: snid,
|
||||
Awards: items,
|
||||
})
|
||||
}
|
||||
|
||||
sort.Slice(log.SnId, func(i, j int) bool {
|
||||
p1 := base.PlayerMgrSington.GetPlayerBySnId(log.SnId[i].SnId)
|
||||
p2 := base.PlayerMgrSington.GetPlayerBySnId(log.SnId[j].SnId)
|
||||
return p1.GetCoin() > p2.GetCoin()
|
||||
})
|
||||
|
||||
for k, v := range this.RoundEndTime {
|
||||
score := make([]int64, len(this.BilledList))
|
||||
for kk, vv := range log.SnId {
|
||||
if k < len(*this.BilledList[vv.SnId]) {
|
||||
score[kk] = (*this.BilledList[vv.SnId])[k].ChangeScore
|
||||
}
|
||||
}
|
||||
log.List = append(log.List, model.RoundInfo{
|
||||
Round: int32(k + 1),
|
||||
Ts: v,
|
||||
Score: score,
|
||||
LogId: this.RoundLogId[k],
|
||||
})
|
||||
}
|
||||
base.LogChannelSingleton.WriteLog(log)
|
||||
}
|
||||
|
|
|
@ -2617,11 +2617,13 @@ func (this *SceneBilledStateTienLen) OnEnter(s *base.Scene) {
|
|||
GameId: int64(sceneEx.GameId),
|
||||
GameFreeId: int64(sceneEx.GetGameFreeId()),
|
||||
})
|
||||
sceneEx.PlayerAward[p.SnId] = &items
|
||||
}
|
||||
}
|
||||
}
|
||||
s.Broadcast(int(tienlen.TienLenPacketID_PACKET_SCTienLenCycleBilled), packBilled, 0)
|
||||
s.SyncSceneState(common.SceneStateEnd)
|
||||
sceneEx.SaveCustomLog()
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -2673,10 +2675,11 @@ func (this *SceneBilledStateTienLen) OnEnter(s *base.Scene) {
|
|||
})
|
||||
|
||||
// 保存玩家游戏记录
|
||||
sceneEx.SaveGamePlayerListLog(o_player.UserId,
|
||||
base.GetSaveGamePlayerListLogParam(o_player.Platform, o_player.Channel, o_player.Promoter,
|
||||
param := base.GetSaveGamePlayerListLogParam(o_player.Platform, o_player.Channel, o_player.Promoter,
|
||||
o_player.PackageTag, sceneEx.recordId, o_player.InviterId, totalin, totalout, o_player.BillTaxCoin,
|
||||
0, 0, o_player.GainCoin+o_player.BombCoin, validBet, validFlow, o_player.IsFirst, o_player.IsLeave))
|
||||
0, 0, o_player.GainCoin+o_player.BombCoin, validBet, validFlow, o_player.IsFirst, o_player.IsLeave)
|
||||
param.CycleId = sceneEx.CycleID
|
||||
sceneEx.SaveGamePlayerListLog(o_player.UserId, param)
|
||||
}
|
||||
}
|
||||
if isSave {
|
||||
|
@ -2685,6 +2688,7 @@ func (this *SceneBilledStateTienLen) OnEnter(s *base.Scene) {
|
|||
Trend20Lately: "",
|
||||
CtrlType: sceneEx.ctrlType,
|
||||
PlayerPool: tienlenType.PlayerPool,
|
||||
CycleId: sceneEx.CycleID,
|
||||
})
|
||||
}
|
||||
}
|
||||
|
|
|
@ -0,0 +1,40 @@
|
|||
package model
|
||||
|
||||
import (
|
||||
"github.com/globalsign/mgo/bson"
|
||||
)
|
||||
|
||||
var (
|
||||
DbCustomLogDBName = "log"
|
||||
DbCustomLogCollName = "log_custom"
|
||||
)
|
||||
|
||||
type PlayerInfo struct {
|
||||
SnId int32 // 玩家id
|
||||
Awards []*Item // 奖品
|
||||
}
|
||||
|
||||
type RoundInfo struct {
|
||||
Round int32 // 第几局
|
||||
Ts int64 // 结算时间
|
||||
Score []int64 // 分数
|
||||
LogId string // 牌局记录id
|
||||
}
|
||||
|
||||
type CustomLog struct {
|
||||
Id bson.ObjectId `bson:"_id"`
|
||||
Platform string `bson:"-"`
|
||||
CycleId string // 本轮id,多局游戏属于同一轮
|
||||
RoomConfigId int32 // 房间配置id
|
||||
GameFreeId int32 // 场次id
|
||||
TotalRound int32 // 总局数
|
||||
PlayerNum int32 // 最大人数
|
||||
Password string // 密码
|
||||
CostType int32 // 付费方式 1房主 2AA
|
||||
Voice int32 // 是否开启语音 1开启
|
||||
RoomId int32 // 房间id
|
||||
SnId []PlayerInfo // 所有玩家
|
||||
List []RoundInfo // 对局记录
|
||||
StartTs, EndTs int64 // 开始,结束时间
|
||||
State int32 // 0正常结束 1后台中途解散
|
||||
}
|
|
@ -66,7 +66,8 @@ func NewGameDetailedLog() *GameDetailedLog {
|
|||
}
|
||||
|
||||
func NewGameDetailedLogEx(logid string, gameid, sceneid, gamemode, gamefreeid, playercount, gametiming, gamebasebet int32,
|
||||
gamedetailednote string, platform string, clubId int32, clubRoom string, cpCtx CoinPoolCtx, ver int32, trend20Lately string, ctrlType int, playerPool map[int]int) *GameDetailedLog {
|
||||
gamedetailednote string, platform string, clubId int32, clubRoom string, cpCtx CoinPoolCtx, ver int32,
|
||||
trend20Lately string, ctrlType int, playerPool map[int]int, cycleId string) *GameDetailedLog {
|
||||
cl := NewGameDetailedLog()
|
||||
cl.LogId = logid
|
||||
cl.GameId = gameid
|
||||
|
@ -88,6 +89,7 @@ func NewGameDetailedLogEx(logid string, gameid, sceneid, gamemode, gamefreeid, p
|
|||
cl.Ts = time.Now().Unix()
|
||||
cl.CtrlType = ctrlType
|
||||
cl.PlayerPool = playerPool
|
||||
cl.CycleId = cycleId
|
||||
return cl
|
||||
}
|
||||
|
||||
|
|
|
@ -55,6 +55,7 @@ type GamePlayerListLog struct {
|
|||
IsFree bool //拉霸专用 是否免费
|
||||
WinSmallGame int64 //拉霸专用 小游戏奖励
|
||||
WinTotal int64 //拉霸专用 输赢
|
||||
CycleId string // 本轮id,打一轮有多局
|
||||
}
|
||||
|
||||
func NewGamePlayerListLog() *GamePlayerListLog {
|
||||
|
@ -64,7 +65,7 @@ func NewGamePlayerListLog() *GamePlayerListLog {
|
|||
func NewGamePlayerListLogEx(snid int32, gamedetailedlogid string, platform, channel, promoter, packageTag string, gameid, baseScore,
|
||||
sceneid, gamemode, gamefreeid int32, totalin, totalout int64, clubId int32, clubRoom string, taxCoin, pumpCoin int64, roomType int32,
|
||||
betAmount, winAmountNoAnyTax int64, key, name string, gameClass int32, isFirst bool, matchid, matchType int64,
|
||||
isFree bool, winSmallGame, winTotal int64) *GamePlayerListLog {
|
||||
isFree bool, winSmallGame, winTotal int64, cycleId string) *GamePlayerListLog {
|
||||
cl := NewGamePlayerListLog()
|
||||
cl.SnId = snid
|
||||
cl.GameDetailedLogId = gamedetailedlogid
|
||||
|
|
|
@ -23,4 +23,5 @@ const (
|
|||
|
||||
const (
|
||||
DBVipGiftLog = "db_vipgift"
|
||||
DBCustomLog = "db_customlog" // 房卡场对局记录
|
||||
)
|
||||
|
|
|
@ -168,7 +168,7 @@ func (m *SceneMgr) GetMatchRoom(sortId int64) []*Scene {
|
|||
// MarshalAllRoom 获取房间列表
|
||||
// 返回 房间列表,总页数,总条数
|
||||
func (m *SceneMgr) MarshalAllRoom(platform string, groupId, gameId int, gameMode, clubId, sceneMode, sceneId int,
|
||||
gameFreeId, snId int32, start, end, pageSize int32) ([]*webapiproto.RoomInfo, int32, int32) {
|
||||
gameFreeId, snId int32, isCustom bool, roomConfigId int32, start, end, pageSize int32) ([]*webapiproto.RoomInfo, int32, int32) {
|
||||
roomInfo := make([]*webapiproto.RoomInfo, 0, len(m.scenes))
|
||||
var isNeedFindAll = false
|
||||
if model.GameParamData.IsFindRoomByGroup && platform != "" && snId != 0 && gameId == 0 &&
|
||||
|
@ -183,7 +183,9 @@ func (m *SceneMgr) MarshalAllRoom(platform string, groupId, gameId int, gameMode
|
|||
((s.gameId == gameId && s.gameMode == gameMode) || gameId == 0) &&
|
||||
(s.sceneId == sceneId || sceneId == 0) && (s.groupId == int32(groupId) || groupId == 0) &&
|
||||
(s.dbGameFree.GetId() == gameFreeId || gameFreeId == 0) &&
|
||||
(s.sceneMode == sceneMode || sceneMode == -1)) || isNeedFindAll {
|
||||
(s.sceneMode == sceneMode || sceneMode == -1)) || isNeedFindAll &&
|
||||
((s.IsCustom() && isCustom) || !isCustom) &&
|
||||
(s.GetRoomConfigId() == roomConfigId || roomConfigId == 0) {
|
||||
var platformName string
|
||||
if s.limitPlatform != nil {
|
||||
platformName = s.limitPlatform.IdStr
|
||||
|
@ -204,6 +206,11 @@ func (m *SceneMgr) MarshalAllRoom(platform string, groupId, gameId int, gameMode
|
|||
CreateTime: s.createTime.Unix(),
|
||||
BaseScore: s.dbGameFree.BaseScore,
|
||||
GameFreeId: s.dbGameFree.GetId(),
|
||||
MaxRound: s.totalRound,
|
||||
Password: s.GetPassword(),
|
||||
CostType: s.GetCostType(),
|
||||
Voice: s.GetVoice(),
|
||||
CurrRound: s.currRound,
|
||||
}
|
||||
if s.starting {
|
||||
si.Start = 1
|
||||
|
|
|
@ -1720,7 +1720,8 @@ func init() {
|
|||
start := (pageNo - 1) * pageSize
|
||||
end := pageNo * pageSize
|
||||
roomList, count, roomSum := SceneMgrSingleton.MarshalAllRoom(msg.GetPlatform(), int(msg.GetGroupId()), int(msg.GetGameId()),
|
||||
int(msg.GetGameMode()), int(msg.GetClubId()), int(msg.GetRoomType()), int(msg.GetSceneId()), msg.GamefreeId, msg.GetSnId(), start, end, pageSize)
|
||||
int(msg.GetGameMode()), int(msg.GetClubId()), int(msg.GetRoomType()), int(msg.GetSceneId()),
|
||||
msg.GamefreeId, msg.GetSnId(), msg.GetIsCustom() == 1, msg.GetRoomConfigId(), start, end, pageSize)
|
||||
if count < pageNo {
|
||||
pageNo = 1
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue