review
This commit is contained in:
parent
7222426469
commit
4e6b92cd33
|
@ -2,8 +2,6 @@ package main
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"fmt"
|
"fmt"
|
||||||
"time"
|
|
||||||
|
|
||||||
"mongo.games.com/goserver/core/logger"
|
"mongo.games.com/goserver/core/logger"
|
||||||
"mongo.games.com/goserver/core/netlib"
|
"mongo.games.com/goserver/core/netlib"
|
||||||
|
|
||||||
|
@ -201,290 +199,10 @@ func (this *CSHundredSceneOpHandler) Process(s *netlib.Session, packetid int, da
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
type CSGameObservePacketFactory struct {
|
|
||||||
}
|
|
||||||
type CSGameObserveHandler struct {
|
|
||||||
}
|
|
||||||
|
|
||||||
func (this *CSGameObservePacketFactory) CreatePacket() interface{} {
|
|
||||||
pack := &gamehall.CSGameObserve{}
|
|
||||||
return pack
|
|
||||||
}
|
|
||||||
|
|
||||||
func (this *CSGameObserveHandler) Process(s *netlib.Session, packetid int, data interface{}, sid int64) error {
|
|
||||||
logger.Logger.Trace("CSGameObserveHandler Process recv ", data)
|
|
||||||
if msg, ok := data.(*gamehall.CSGameObserve); ok {
|
|
||||||
p := PlayerMgrSington.GetPlayer(sid)
|
|
||||||
if p != nil {
|
|
||||||
if msg.GetStartOrEnd() {
|
|
||||||
gameStateMgr.PlayerRegiste(p, msg.GetGameId(), msg.GetStartOrEnd())
|
|
||||||
pack := &gamehall.SCGameSubList{}
|
|
||||||
statePack := &gamehall.SCGameState{}
|
|
||||||
scenes := HundredSceneMgrSingleton.GetPlatformScene(p.Platform, msg.GetGameId())
|
|
||||||
for _, value := range scenes {
|
|
||||||
pack.List = append(pack.List, &gamehall.GameSubRecord{
|
|
||||||
GameFreeId: proto.Int32(value.dbGameFree.GetId()),
|
|
||||||
NewLog: proto.Int32(-1),
|
|
||||||
LogCnt: proto.Int(len(value.GameLog)),
|
|
||||||
TotleLog: value.GameLog,
|
|
||||||
})
|
|
||||||
leftTime := int64(value.StateSec) - (time.Now().Unix() - value.StateTs)
|
|
||||||
if leftTime < 0 {
|
|
||||||
leftTime = 0
|
|
||||||
}
|
|
||||||
statePack.List = append(statePack.List, &gamehall.GameState{
|
|
||||||
GameFreeId: proto.Int32(value.dbGameFree.GetId()),
|
|
||||||
Ts: proto.Int64(leftTime),
|
|
||||||
Sec: proto.Int32(value.StateSec),
|
|
||||||
})
|
|
||||||
}
|
|
||||||
p.SendToClient(int(gamehall.GameHallPacketID_PACKET_SC_GAMESUBLIST), pack)
|
|
||||||
logger.Logger.Trace("SCGameSubList:", pack)
|
|
||||||
p.SendToClient(int(gamehall.GameHallPacketID_PACKET_SC_GAMESTATE), statePack)
|
|
||||||
logger.Logger.Trace("SCGameState:", statePack)
|
|
||||||
} else {
|
|
||||||
gameStateMgr.PlayerClear(p)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return nil
|
|
||||||
}
|
|
||||||
|
|
||||||
//type CSHundredSceneGetGameJackpotPacketFactory struct {
|
|
||||||
//}
|
|
||||||
//type CSHundredSceneGetGameJackpotHandler struct {
|
|
||||||
//}
|
|
||||||
//
|
|
||||||
//func (this *CSHundredSceneGetGameJackpotPacketFactory) CreatePacket() interface{} {
|
|
||||||
// pack := &gamehall.CSHundredSceneGetPlayerNum{}
|
|
||||||
// return pack
|
|
||||||
//}
|
|
||||||
//
|
|
||||||
//func (this *CSHundredSceneGetGameJackpotHandler) Process(s *netlib.Session, packetid int, data interface{}, sid int64) error {
|
|
||||||
// logger.Logger.Trace("CSHundredSceneGetGameJackpotHandler Process recv ", data)
|
|
||||||
// if _, ok := data.(*gamehall.CSHundredSceneGetPlayerNum); ok {
|
|
||||||
// p := PlayerMgrSington.GetPlayer(sid)
|
|
||||||
// if p != nil {
|
|
||||||
// //gameid := int(msg.GetGameId())
|
|
||||||
// //// 冰河世纪, 百战成神, 财神, 复仇者联盟, 复活岛
|
|
||||||
// //if gameid == common.GameId_IceAge || gameid == common.GameId_TamQuoc || gameid == common.GameId_CaiShen ||
|
|
||||||
// // gameid == common.GameId_Avengers || gameid == common.GameId_EasterIsland {
|
|
||||||
// // gameStateMgr.PlayerRegiste(p, msg.GetGameId(), true)
|
|
||||||
// // pack := &gamehall.SCHundredSceneGetGameJackpot{}
|
|
||||||
// // scenes := HundredSceneMgrSingleton.GetPlatformScene(p.Platform, msg.GetGameId())
|
|
||||||
// // for _, v := range scenes {
|
|
||||||
// // jpfi := &gamehall.GameJackpotFundInfo{
|
|
||||||
// // GameFreeId: proto.Int32(v.dbGameFree.GetId()),
|
|
||||||
// // JackPotFund: proto.Int64(v.JackPotFund),
|
|
||||||
// // }
|
|
||||||
// // pack.GameJackpotFund = append(pack.GameJackpotFund, jpfi)
|
|
||||||
// // }
|
|
||||||
// // proto.SetDefaults(pack)
|
|
||||||
// // p.SendToClient(int(gamehall.HundredScenePacketID_PACKET_SC_GAMEJACKPOT), pack)
|
|
||||||
// // logger.Logger.Trace("SCHundredSceneGetGameJackpot:", pack)
|
|
||||||
// //}
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
// return nil
|
|
||||||
//}
|
|
||||||
//
|
|
||||||
//type CSHundredSceneGetGameHistoryInfoPacketFactory struct {
|
|
||||||
//}
|
|
||||||
//type CSHundredSceneGetGameHistoryInfoHandler struct {
|
|
||||||
//}
|
|
||||||
//
|
|
||||||
//func (this *CSHundredSceneGetGameHistoryInfoPacketFactory) CreatePacket() interface{} {
|
|
||||||
// pack := &gamehall.CSHundredSceneGetHistoryInfo{}
|
|
||||||
// return pack
|
|
||||||
//}
|
|
||||||
//
|
|
||||||
//func (this *CSHundredSceneGetGameHistoryInfoHandler) Process(s *netlib.Session, packetid int, data interface{}, sid int64) error {
|
|
||||||
// logger.Logger.Trace("World CSHundredSceneGetGameHistoryInfoHandler Process recv ", data)
|
|
||||||
// if msg, ok := data.(*gamehall.CSHundredSceneGetHistoryInfo); ok {
|
|
||||||
// gameid := int(msg.GetGameId())
|
|
||||||
// historyModel := msg.GetGameHistoryModel()
|
|
||||||
// p := PlayerMgrSington.GetPlayer(sid)
|
|
||||||
// if p != nil {
|
|
||||||
// switch historyModel {
|
|
||||||
// case PLAYER_HISTORY_MODEL: // 历史记录
|
|
||||||
// task.New(nil, task.CallableWrapper(func(o *basic.Object) interface{} {
|
|
||||||
// var genPlayerHistoryInfo = func(spinID string, isFree bool, createdTime, totalBetValue, totalPriceValue, totalBonusValue, multiple int64, player *gamehall.PlayerHistoryInfo) {
|
|
||||||
// player.SpinID = proto.String(spinID)
|
|
||||||
// player.CreatedTime = proto.Int64(createdTime)
|
|
||||||
// player.TotalBetValue = proto.Int64(totalBetValue)
|
|
||||||
// player.TotalPriceValue = proto.Int64(totalPriceValue)
|
|
||||||
// player.IsFree = proto.Bool(isFree)
|
|
||||||
// player.TotalBonusValue = proto.Int64(totalBonusValue)
|
|
||||||
// player.Multiple = proto.Int64(multiple)
|
|
||||||
// }
|
|
||||||
//
|
|
||||||
// var genPlayerHistoryInfoMsg = func(spinid string, v *model.NeedGameRecord, gdl *model.GameDetailedLog, player *gamehall.PlayerHistoryInfo) {
|
|
||||||
// switch gameid {
|
|
||||||
// //case common.GameId_IceAge:
|
|
||||||
// // data, err := model.UnMarshalIceAgeGameNote(gdl.GameDetailedNote)
|
|
||||||
// // if err != nil {
|
|
||||||
// // logger.Logger.Errorf("World UnMarshalIceAgeGameNote error:%v", err)
|
|
||||||
// // }
|
|
||||||
// // gnd := data.(*model.IceAgeType)
|
|
||||||
// // genPlayerHistoryInfo(spinid, gnd.IsFree, int64(v.Ts), int64(gnd.Score), gnd.TotalPriceValue, gnd.TotalBonusValue, player)
|
|
||||||
// //case common.GameId_TamQuoc:
|
|
||||||
// // data, err := model.UnMarshalTamQuocGameNote(gdl.GameDetailedNote)
|
|
||||||
// // if err != nil {
|
|
||||||
// // logger.Logger.Errorf("World UnMarshalTamQuocGameNote error:%v", err)
|
|
||||||
// // }
|
|
||||||
// // gnd := data.(*model.TamQuocType)
|
|
||||||
// // genPlayerHistoryInfo(spinid, gnd.IsFree, int64(v.Ts), int64(gnd.Score), gnd.TotalPriceValue, gnd.TotalBonusValue, player)
|
|
||||||
// //case common.GameId_CaiShen:
|
|
||||||
// // data, err := model.UnMarshalCaiShenGameNote(gdl.GameDetailedNote)
|
|
||||||
// // if err != nil {
|
|
||||||
// // logger.Logger.Errorf("World UnMarshalCaiShenGameNote error:%v", err)
|
|
||||||
// // }
|
|
||||||
// // gnd := data.(*model.CaiShenType)
|
|
||||||
// // genPlayerHistoryInfo(spinid, gnd.IsFree, int64(v.Ts), int64(gnd.Score), gnd.TotalPriceValue, gnd.TotalBonusValue, player)
|
|
||||||
// case common.GameId_Crash:
|
|
||||||
// data, err := model.UnMarshalGameNoteByHUNDRED(gdl.GameDetailedNote)
|
|
||||||
// if err != nil {
|
|
||||||
// logger.Logger.Errorf("World UnMarshalAvengersGameNote error:%v", err)
|
|
||||||
// }
|
|
||||||
// jsonString, _ := json.Marshal(data)
|
|
||||||
//
|
|
||||||
// // convert json to struct
|
|
||||||
// gnd := model.CrashType{}
|
|
||||||
// json.Unmarshal(jsonString, &gnd)
|
|
||||||
//
|
|
||||||
// //gnd := data.(*model.CrashType)
|
|
||||||
// for _, curplayer := range gnd.PlayerData {
|
|
||||||
// if curplayer.UserId == p.SnId {
|
|
||||||
// genPlayerHistoryInfo(spinid, false, int64(v.Ts), int64(curplayer.UserBetTotal), curplayer.ChangeCoin, 0, int64(curplayer.UserMultiple), player)
|
|
||||||
// break
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
// case common.GameId_Avengers:
|
|
||||||
// data, err := model.UnMarshalAvengersGameNote(gdl.GameDetailedNote)
|
|
||||||
// if err != nil {
|
|
||||||
// logger.Logger.Errorf("World UnMarshalAvengersGameNote error:%v", err)
|
|
||||||
// }
|
|
||||||
// gnd := data.(*model.GameResultLog)
|
|
||||||
// genPlayerHistoryInfo(spinid, gnd.BaseResult.IsFree, int64(v.Ts), int64(gnd.BaseResult.TotalBet), gnd.BaseResult.WinTotal, gnd.BaseResult.WinSmallGame, 0, player)
|
|
||||||
// //case common.GameId_EasterIsland:
|
|
||||||
// // data, err := model.UnMarshalEasterIslandGameNote(gdl.GameDetailedNote)
|
|
||||||
// // if err != nil {
|
|
||||||
// // logger.Logger.Errorf("World UnMarshalEasterIslandGameNote error:%v", err)
|
|
||||||
// // }
|
|
||||||
// // gnd := data.(*model.EasterIslandType)
|
|
||||||
// // genPlayerHistoryInfo(spinid, gnd.IsFree, int64(v.Ts), int64(gnd.Score), gnd.TotalPriceValue, gnd.TotalBonusValue, player)
|
|
||||||
// default:
|
|
||||||
// logger.Logger.Errorf("World CSHundredSceneGetGameHistoryInfoHandler receive gameid(%v) error", gameid)
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
//
|
|
||||||
// gameclass := int32(2)
|
|
||||||
// spinid := strconv.FormatInt(int64(p.SnId), 10)
|
|
||||||
// dbGameFrees := srvdata.PBDB_GameFreeMgr.Datas.Arr //.GetData(data.DbGameFree.Id)
|
|
||||||
// roomtype := int32(0)
|
|
||||||
// for _, v := range dbGameFrees {
|
|
||||||
// if int32(gameid) == v.GetGameId() {
|
|
||||||
// gameclass = v.GetGameClass()
|
|
||||||
// roomtype = v.GetSceneType()
|
|
||||||
// break
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
//
|
|
||||||
// gpl := model.GetPlayerListByHallEx(p.SnId, p.Platform, 0, 50, 0, 0, roomtype, gameclass, gameid)
|
|
||||||
// pack := &gamehall.SCPlayerHistory{}
|
|
||||||
// for _, v := range gpl.Data {
|
|
||||||
// if v.GameDetailedLogId == "" {
|
|
||||||
// logger.Logger.Error("World PlayerHistory GameDetailedLogId is nil")
|
|
||||||
// break
|
|
||||||
// }
|
|
||||||
// gdl := model.GetPlayerHistory(p.Platform, v.GameDetailedLogId)
|
|
||||||
// player := &gamehall.PlayerHistoryInfo{}
|
|
||||||
// genPlayerHistoryInfoMsg(spinid, v, gdl, player)
|
|
||||||
// pack.PlayerHistory = append(pack.PlayerHistory, player)
|
|
||||||
// }
|
|
||||||
// proto.SetDefaults(pack)
|
|
||||||
// logger.Logger.Infof("World gameid:%v PlayerHistory:%v ", gameid, pack)
|
|
||||||
// return pack
|
|
||||||
// }), task.CompleteNotifyWrapper(func(data interface{}, t task.Task) {
|
|
||||||
// if data == nil {
|
|
||||||
// logger.Logger.Error("World PlayerHistory data is nil")
|
|
||||||
// return
|
|
||||||
// }
|
|
||||||
// p.SendToClient(int(gamehall.HundredScenePacketID_PACKET_SC_GAMEPLAYERHISTORY), data)
|
|
||||||
// }), "CSGetPlayerHistoryHandlerWorld").Start()
|
|
||||||
// case BIGWIN_HISTORY_MODEL: // 爆奖记录
|
|
||||||
// jackpotList := JackpotListMgrSington.GetJackpotList(gameid)
|
|
||||||
// //if len(jackpotList) < 1 {
|
|
||||||
// // JackpotListMgrSington.GenJackpot(gameid) // 初始化爆奖记录
|
|
||||||
// // JackpotListMgrSington.after(gameid) // 开启定时器
|
|
||||||
// // jackpotList = JackpotListMgrSington.GetJackpotList(gameid)
|
|
||||||
// //}
|
|
||||||
// pack := JackpotListMgrSington.GetStoCMsg(jackpotList)
|
|
||||||
// pack.GameId = msg.GetGameId()
|
|
||||||
// logger.Logger.Infof("World BigWinHistory: %v %v", gameid, pack)
|
|
||||||
// p.SendToClient(int(gamehall.HundredScenePacketID_PACKET_SC_GAMEBIGWINHISTORY), pack)
|
|
||||||
// case GAME_HISTORY_MODEL:
|
|
||||||
// task.New(nil, task.CallableWrapper(func(o *basic.Object) interface{} {
|
|
||||||
// var genGameHistoryInfo = func(gameNumber string, createdTime, multiple int64, hash string, gamehistory *gamehall.GameHistoryInfo) {
|
|
||||||
// gamehistory.GameNumber = proto.String(gameNumber)
|
|
||||||
// gamehistory.CreatedTime = proto.Int64(createdTime)
|
|
||||||
// gamehistory.Hash = proto.String(hash)
|
|
||||||
// gamehistory.Multiple = proto.Int64(multiple)
|
|
||||||
// }
|
|
||||||
//
|
|
||||||
// gls := model.GetAllGameDetailedLogsByGameIdAndTs(p.Platform, gameid, 20)
|
|
||||||
//
|
|
||||||
// pack := &gamehall.SCPlayerHistory{}
|
|
||||||
// for _, v := range gls {
|
|
||||||
//
|
|
||||||
// gamehistory := &gamehall.GameHistoryInfo{}
|
|
||||||
//
|
|
||||||
// data, err := model.UnMarshalGameNoteByHUNDRED(v.GameDetailedNote)
|
|
||||||
// if err != nil {
|
|
||||||
// logger.Logger.Errorf("World UnMarshalAvengersGameNote error:%v", err)
|
|
||||||
// }
|
|
||||||
// jsonString, _ := json.Marshal(data)
|
|
||||||
//
|
|
||||||
// // convert json to struct
|
|
||||||
// gnd := model.CrashType{}
|
|
||||||
// json.Unmarshal(jsonString, &gnd)
|
|
||||||
//
|
|
||||||
// genGameHistoryInfo(v.LogId, int64(v.Ts), int64(gnd.Rate), gnd.Hash, gamehistory)
|
|
||||||
// pack.GameHistory = append(pack.GameHistory, gamehistory)
|
|
||||||
// }
|
|
||||||
// proto.SetDefaults(pack)
|
|
||||||
// logger.Logger.Infof("World gameid:%v History:%v ", gameid, pack)
|
|
||||||
// return pack
|
|
||||||
// }), task.CompleteNotifyWrapper(func(data interface{}, t task.Task) {
|
|
||||||
// if data == nil {
|
|
||||||
// logger.Logger.Error("World GameHistory data is nil")
|
|
||||||
// return
|
|
||||||
// }
|
|
||||||
// p.SendToClient(int(gamehall.HundredScenePacketID_PACKET_SC_GAMEPLAYERHISTORY), data)
|
|
||||||
// }), "CSGetGameHistoryHandlerWorld").Start()
|
|
||||||
// default:
|
|
||||||
// logger.Logger.Errorf("World CSHundredSceneGetGameHistoryInfoHandler receive historyModel(%v) error", historyModel)
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
// return nil
|
|
||||||
//}
|
|
||||||
|
|
||||||
func init() {
|
func init() {
|
||||||
common.RegisterHandler(int(gamehall.HundredScenePacketID_PACKET_CS_HUNDREDSCENE_GETPLAYERNUM), &CSHundredSceneGetPlayerNumHandler{})
|
common.RegisterHandler(int(gamehall.HundredScenePacketID_PACKET_CS_HUNDREDSCENE_GETPLAYERNUM), &CSHundredSceneGetPlayerNumHandler{})
|
||||||
netlib.RegisterFactory(int(gamehall.HundredScenePacketID_PACKET_CS_HUNDREDSCENE_GETPLAYERNUM), &CSHundredSceneGetPlayerNumPacketFactory{})
|
netlib.RegisterFactory(int(gamehall.HundredScenePacketID_PACKET_CS_HUNDREDSCENE_GETPLAYERNUM), &CSHundredSceneGetPlayerNumPacketFactory{})
|
||||||
|
|
||||||
common.RegisterHandler(int(gamehall.HundredScenePacketID_PACKET_CS_HUNDREDSCENE_OP), &CSHundredSceneOpHandler{})
|
common.RegisterHandler(int(gamehall.HundredScenePacketID_PACKET_CS_HUNDREDSCENE_OP), &CSHundredSceneOpHandler{})
|
||||||
netlib.RegisterFactory(int(gamehall.HundredScenePacketID_PACKET_CS_HUNDREDSCENE_OP), &CSHundredSceneOpPacketFactory{})
|
netlib.RegisterFactory(int(gamehall.HundredScenePacketID_PACKET_CS_HUNDREDSCENE_OP), &CSHundredSceneOpPacketFactory{})
|
||||||
//请求游戏列表
|
|
||||||
common.RegisterHandler(int(gamehall.GameHallPacketID_PACKET_CS_GAMEOBSERVE), &CSGameObserveHandler{})
|
|
||||||
netlib.RegisterFactory(int(gamehall.GameHallPacketID_PACKET_CS_GAMEOBSERVE), &CSGameObservePacketFactory{})
|
|
||||||
|
|
||||||
//// 请求奖池信息
|
|
||||||
//common.RegisterHandler(int(gamehall.HundredScenePacketID_PACKET_CS_GAMEJACKPOT), &CSHundredSceneGetGameJackpotHandler{})
|
|
||||||
//netlib.RegisterFactory(int(gamehall.HundredScenePacketID_PACKET_CS_GAMEJACKPOT), &CSHundredSceneGetGameJackpotPacketFactory{})
|
|
||||||
|
|
||||||
////// 请求历史记录和爆奖记录
|
|
||||||
//common.RegisterHandler(int(gamehall.HundredScenePacketID_PACKET_CS_GAMEHISTORYINFO), &CSHundredSceneGetGameHistoryInfoHandler{})
|
|
||||||
//netlib.RegisterFactory(int(gamehall.HundredScenePacketID_PACKET_CS_GAMEHISTORYINFO), &CSHundredSceneGetGameHistoryInfoPacketFactory{})
|
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue