房卡场游戏

This commit is contained in:
sk 2024-08-26 16:54:07 +08:00
parent 4e6b92cd33
commit 904982158a
48 changed files with 5260 additions and 56756 deletions

View File

@ -309,6 +309,7 @@ const (
GainWayItemFenGain = 103 // 道具分解获得 GainWayItemFenGain = 103 // 道具分解获得
GainWayGuide = 104 //新手引导奖励 GainWayGuide = 104 //新手引导奖励
GainWayVipGift9 = 105 //vip等级礼包 GainWayVipGift9 = 105 //vip等级礼包
GainWayRoomCost = 106 //房费消耗
) )
// 后台选择 金币变化类型 的充值 类型id号起始 // 后台选择 金币变化类型 的充值 类型id号起始
@ -867,3 +868,10 @@ const (
DataConfigSprite = 1 // 精灵配置 DataConfigSprite = 1 // 精灵配置
DataConfigMatchAudience = 2 // 赛事观战开关 DataConfigMatchAudience = 2 // 赛事观战开关
) )
// 房间状态
const (
SceneStateWaite = 0 // 等待
SceneStateStart = 1 // 开始
SceneStateEnd = 2 // 结束
)

Binary file not shown.

View File

@ -71,7 +71,7 @@
"Name": "十三张(四人场)", "Name": "十三张(四人场)",
"GameId": 211, "GameId": 211,
"Params": [ "Params": [
0, 4,
0, 0,
30, 30,
50, 50,
@ -84,7 +84,7 @@
"Name": "十三张(八人场)", "Name": "十三张(八人场)",
"GameId": 212, "GameId": 212,
"Params": [ "Params": [
1, 8,
0, 0,
30, 30,
50, 50,
@ -97,7 +97,7 @@
"Name": "十三张(自由场经典场)", "Name": "十三张(自由场经典场)",
"GameId": 213, "GameId": 213,
"Params": [ "Params": [
1, 8,
0, 0,
30, 30,
50, 50,
@ -110,7 +110,7 @@
"Name": "十三张(自由场癞子场)", "Name": "十三张(自由场癞子场)",
"GameId": 214, "GameId": 214,
"Params": [ "Params": [
1, 8,
0, 0,
30, 30,
50, 50,

Binary file not shown.

Binary file not shown.

View File

@ -42,6 +42,10 @@ func (this *CSDestroyRoomHandler) Process(s *netlib.Session, packetid int, data
logger.Logger.Warn("CSDestroyRoomHandler s.creator != p.AccountId") logger.Logger.Warn("CSDestroyRoomHandler s.creator != p.AccountId")
return nil return nil
} }
// 房卡场开始后不能解散
if scene.IsCustom() && scene.NumOfGames > 0 {
return nil
}
scene.Destroy(true) scene.Destroy(true)
return nil return nil
} }

View File

@ -467,9 +467,6 @@ func (this *Player) AddCoin(num int64, gainWay int32, syncFlag int, oper, remark
if this.Coin < 0 { if this.Coin < 0 {
this.Coin = 0 this.Coin = 0
} }
if this.scene.IsHundredScene() {
this.scene.NewBigCoinNotice(this, int64(num), 5)
}
} }
//增加玩家经验 //增加玩家经验
if num > 0 { if num > 0 {

View File

@ -24,12 +24,6 @@ import (
"mongo.games.com/game/srvdata" "mongo.games.com/game/srvdata"
) )
const (
SCENE_STATE_INITED int = iota
SCENE_STATE_RUNNING
SCENE_STATE_OVER
)
const ReplayIdTf = "20060102150405" const ReplayIdTf = "20060102150405"
var sceneRandSeed = time.Now().UnixNano() var sceneRandSeed = time.Now().UnixNano()
@ -119,10 +113,6 @@ type Scene struct {
matchChgData *SceneMatchChgData //比赛变化数据 matchChgData *SceneMatchChgData //比赛变化数据
ChessRank []int32 ChessRank []int32
LoopNum int // 循环计数
results []int // 本局游戏结果
WebUser string // 操作人
resultHistory [][]int // 记录数 [控制结果,局数...]
BaseScore int32 //tienlen游戏底分 BaseScore int32 //tienlen游戏底分
MatchId int64 //标记本次比赛的id并不是后台id MatchId int64 //标记本次比赛的id并不是后台id
MatchFinals bool //比赛场决赛 MatchFinals bool //比赛场决赛
@ -130,11 +120,8 @@ type Scene struct {
MatchCurPlayerNum int64 MatchCurPlayerNum int64
MatchNextNeed int64 MatchNextNeed int64
MatchType int64 // 0.普通场 1.锦标赛 2.冠军赛 3.vip专属 MatchType int64 // 0.普通场 1.锦标赛 2.冠军赛 3.vip专属
MatchStop bool
RealCtrl bool RealCtrl bool
Novice bool CycleID string
Welfare bool
KillPoints bool
} }
func NewScene(ws *netlib.Session, sceneId, gameMode, sceneMode, gameId int, platform string, params []int64, func NewScene(ws *netlib.Session, sceneId, gameMode, sceneMode, gameId int, platform string, params []int64,
@ -168,11 +155,11 @@ func NewScene(ws *netlib.Session, sceneId, gameMode, sceneMode, gameId int, plat
GroupId: groupId, GroupId: groupId,
bEnterAfterStart: bEnterAfterStart, bEnterAfterStart: bEnterAfterStart,
TotalOfGames: int(totalOfGames), TotalOfGames: int(totalOfGames),
results: make([]int, common.MaxLoopNum),
BaseScore: baseScore, BaseScore: baseScore,
playerNum: playerNum, playerNum: playerNum,
ChessRank: cherank, ChessRank: cherank,
} }
s.CycleID, _ = model.AutoIncGameLogId()
if s != nil && s.init() { if s != nil && s.init() {
logger.Logger.Trace("NewScene init success.") logger.Logger.Trace("NewScene init success.")
if !s.Testing { if !s.Testing {
@ -227,6 +214,7 @@ func (this *Scene) RebindPlayerSnId(oldSnId, newSnId int32) {
func (this *Scene) GetInit() bool { func (this *Scene) GetInit() bool {
return this.init() return this.init()
} }
func (this *Scene) init() bool { func (this *Scene) init() bool {
tNow := time.Now() tNow := time.Now()
sceneRandSeed++ sceneRandSeed++
@ -237,19 +225,6 @@ func (this *Scene) init() bool {
this.KeyGameId = strconv.Itoa(int(this.DbGameFree.GetGameId())) this.KeyGameId = strconv.Itoa(int(this.DbGameFree.GetGameId()))
this.KeyGamefreeId = strconv.Itoa(int(this.DbGameFree.GetId())) this.KeyGamefreeId = strconv.Itoa(int(this.DbGameFree.GetId()))
this.KeyGameDif = this.DbGameFree.GetGameDif() this.KeyGameDif = this.DbGameFree.GetGameDif()
// test
//for i := 0; i < 100; i++ {
// n := this.rand.Intn(10)
// r := this.rand.Intn(3) + 1
// str := fmt.Sprint(this.rand.Intn(1000), ":", r)
// for j := 0; j < n; j++ {
// str += fmt.Sprint(",", this.rand.Intn(1000), ":", r)
// }
// logger.Logger.Trace("--> str ", str)
// this.ParserResults1(str, "")
//}
// test
return true return true
} }
@ -875,6 +850,7 @@ func (this *Scene) RobotBroadcast(packetid int, msg rawproto.Message) {
} }
} }
} }
func (this *Scene) BroadcastToAudience(packetid int, msg rawproto.Message) { func (this *Scene) BroadcastToAudience(packetid int, msg rawproto.Message) {
if len(this.audiences) > 0 { if len(this.audiences) > 0 {
mgs := make(map[*netlib.Session][]*srvlibproto.MCSessionUnion) mgs := make(map[*netlib.Session][]*srvlibproto.MCSessionUnion)
@ -933,7 +909,7 @@ func (this *Scene) ChangeSceneState(stateid int) {
logger.Logger.Tracef("(this *Scene) [%v] ChangeSceneState -> %v", this.SceneId, state.GetState()) logger.Logger.Tracef("(this *Scene) [%v] ChangeSceneState -> %v", this.SceneId, state.GetState())
this.SceneState = state this.SceneState = state
this.SceneState.OnEnter(this) this.SceneState.OnEnter(this)
//this.NotifySceneState(stateid) //this.SyncSceneState(stateid)
} }
if this.aiMgr != nil { if this.aiMgr != nil {
@ -1024,6 +1000,10 @@ func (this *Scene) IsMatchScene() bool {
return this.SceneId >= common.MatchSceneStartId && this.SceneId <= common.MatchSceneMaxId return this.SceneId >= common.MatchSceneStartId && this.SceneId <= common.MatchSceneMaxId
} }
func (this *Scene) IsCustom() bool {
return this.GetDBGameFree().GetIsCustom() > 0
}
func (this *Scene) IsFull() bool { func (this *Scene) IsFull() bool {
return len(this.Players) >= this.playerNum return len(this.Players) >= this.playerNum
} }
@ -1288,14 +1268,15 @@ func (this *Scene) SyncPlayerCoin() {
// this.SendToWorld(int(server.SSPacketID_PACKET_GW_SYNCPLAYERCOIN), pack) // this.SendToWorld(int(server.SSPacketID_PACKET_GW_SYNCPLAYERCOIN), pack)
//} //}
} }
func (this *Scene) NotifySceneStateFishing(state int) {
func (this *Scene) SyncSceneState(state int) {
pack := &server.GWSceneState{ pack := &server.GWSceneState{
RoomId: proto.Int(this.SceneId), RoomId: int32(this.SceneId),
Fishing: proto.Int32(int32(state)), RoomState: int32(state),
} }
proto.SetDefaults(pack)
this.SendToWorld(int(server.SSPacketID_PACKET_GW_SCENESTATE), pack) this.SendToWorld(int(server.SSPacketID_PACKET_GW_SCENESTATE), pack)
} }
func (this *Scene) NotifySceneRoundStart(round int) { func (this *Scene) NotifySceneRoundStart(round int) {
pack := &server.GWSceneStart{ pack := &server.GWSceneStart{
RoomId: proto.Int(this.SceneId), RoomId: proto.Int(this.SceneId),
@ -1317,6 +1298,7 @@ func (this *Scene) NotifySceneRoundPause() {
proto.SetDefaults(pack) proto.SetDefaults(pack)
this.SendToWorld(int(server.SSPacketID_PACKET_GW_SCENESTART), pack) this.SendToWorld(int(server.SSPacketID_PACKET_GW_SCENESTART), pack)
} }
func (this *Scene) SyncGameState(sec, bl int) { func (this *Scene) SyncGameState(sec, bl int) {
if this.SceneState != nil { if this.SceneState != nil {
pack := &server.GWGameState{ pack := &server.GWGameState{
@ -1331,7 +1313,7 @@ func (this *Scene) SyncGameState(sec, bl int) {
} }
} }
// 游戏开始的时候同步防伙牌数据 // SyncScenePlayer 游戏开始的时候同步防伙牌数据
func (this *Scene) SyncScenePlayer() { func (this *Scene) SyncScenePlayer() {
pack := &server.GWScenePlayerLog{ pack := &server.GWScenePlayerLog{
GameId: proto.Int(this.GameId), GameId: proto.Int(this.GameId),
@ -1342,23 +1324,10 @@ func (this *Scene) SyncScenePlayer() {
continue continue
} }
pack.Snids = append(pack.Snids, value.SnId) pack.Snids = append(pack.Snids, value.SnId)
pack.IsGameing = append(pack.IsGameing, value.IsGameing())
} }
this.SendToWorld(int(server.SSPacketID_PACKET_GW_SCENEPLAYERLOG), pack) this.SendToWorld(int(server.SSPacketID_PACKET_GW_SCENEPLAYERLOG), pack)
} }
// 防伙牌换桌
func (this *Scene) ChangeSceneEvent() {
timer.StartTimer(timer.TimerActionWrapper(func(h timer.TimerHandle, ud interface{}) bool {
if this.DbGameFree.GetMatchMode() == 1 {
return true
}
this.SendToWorld(int(server.SSPacketID_PACKET_GW_CHANGESCENEEVENT), &server.GWChangeSceneEvent{
SceneId: proto.Int(this.SceneId),
})
return true
}), nil, time.Second*3, 1)
}
func (this *Scene) RecordReplayStart() { func (this *Scene) RecordReplayStart() {
if !this.IsHundredScene() && !this.IsMatchScene() { if !this.IsHundredScene() && !this.IsMatchScene() {
logger.Logger.Trace("RecordReplayStart-----", this.replayCode, this.NumOfGames, this.replayAddId) logger.Logger.Trace("RecordReplayStart-----", this.replayCode, this.NumOfGames, this.replayAddId)
@ -1473,6 +1442,7 @@ func (this *Scene) CreateGameRecPacket() *server.GWGameRec {
GameTime: proto.Int(int(time.Now().Sub(this.GameStartTime) / time.Second)), GameTime: proto.Int(int(time.Now().Sub(this.GameStartTime) / time.Second)),
} }
} }
func (this *Scene) IsAllReady() bool { func (this *Scene) IsAllReady() bool {
for _, p := range this.Players { for _, p := range this.Players {
if !p.IsOnLine() || !p.IsReady() { if !p.IsOnLine() || !p.IsReady() {
@ -1547,6 +1517,7 @@ func (this *Scene) CoinPoolCanOut() bool {
return int32(noRobotPlayerCount) >= this.dbGameFree.GetMinOutPlayerNum() return int32(noRobotPlayerCount) >= this.dbGameFree.GetMinOutPlayerNum()
*/ */
} }
func (this *Scene) ClearAutoPlayer() { func (this *Scene) ClearAutoPlayer() {
for _, p := range this.Players { for _, p := range this.Players {
if p.IsAuto() { if p.IsAuto() {
@ -1556,31 +1527,6 @@ func (this *Scene) ClearAutoPlayer() {
} }
} }
func (this *Scene) NewBigCoinNotice(player *Player, num int64, msgType int64) {
//if !this.Testing && !this.IsMatchScene() {
// if num < model.GameParamData.NoticeCoinMin || model.GameParamData.NoticeCoinMax < num {
// return
// }
// start := time.Now().Add(time.Second * 30).Unix()
// content := fmt.Sprintf("%v|%v|%v", player.GetName(), this.GetHundredSceneName(), num)
// pack := &server.GWNewNotice{
// Ch: proto.String(""),
// Content: proto.String(content),
// Start: proto.Int64(start),
// Interval: proto.Int64(0),
// Count: proto.Int64(1),
// Msgtype: proto.Int64(msgType),
// Platform: proto.String(player.Platform),
// Isrob: proto.Bool(player.IsRob),
// Priority: proto.Int32(int32(num)),
// }
// if common.HorseRaceLampPriority_Rand == model.GameParamData.NoticePolicy {
// pack.Priority = proto.Int32(rand.Int31n(100))
// }
// this.SendToWorld(int(server.SSPacketID_PACKET_GW_NEWNOTICE), pack)
//}
}
type GameDetailedParam struct { type GameDetailedParam struct {
Trend20Lately string //最近20局开奖结果 Trend20Lately string //最近20局开奖结果
CtrlType int CtrlType int
@ -1610,6 +1556,9 @@ func (this *Scene) SaveGameDetailedLog(logid string, gamedetailednote string, ga
if this.IsMatchScene() { if this.IsMatchScene() {
log.MatchId = this.MatchId log.MatchId = this.MatchId
} }
if this.IsCustom() {
log.CycleId = this.CycleID
}
LogChannelSingleton.WriteLog(log) LogChannelSingleton.WriteLog(log)
} }
} }
@ -1624,6 +1573,9 @@ func (this *Scene) SaveGameDetailedLog(logid string, gamedetailednote string, ga
if this.IsMatchScene() { if this.IsMatchScene() {
log.MatchId = this.MatchId log.MatchId = this.MatchId
} }
if this.IsCustom() {
log.CycleId = this.CycleID
}
newLog := new(model.GameDetailedLog) newLog := new(model.GameDetailedLog)
*newLog = *log *newLog = *log
LogChannelSingleton.WriteLog(log) LogChannelSingleton.WriteLog(log)
@ -1796,6 +1748,7 @@ func (this *Scene) RandRobotCnt() {
//logger.Logger.Tracef("===(this *Scene) RandRobotCnt() sceneid:%v gameid:%v mode:%v robotLimit:%v robotNum:%v", this.SceneId, this.GameId, this.GameMode, this.robotLimit, this.robotNum) //logger.Logger.Tracef("===(this *Scene) RandRobotCnt() sceneid:%v gameid:%v mode:%v robotLimit:%v robotNum:%v", this.SceneId, this.GameId, this.GameMode, this.robotLimit, this.robotNum)
} }
} }
func (this *Scene) GetRobotTime() int64 { func (this *Scene) GetRobotTime() int64 {
l := int64(common.RandInt(model.NormalParamData.RobotRandomTimeMin, model.NormalParamData.RobotRandomTimeMax)) l := int64(common.RandInt(model.NormalParamData.RobotRandomTimeMin, model.NormalParamData.RobotRandomTimeMax))
return l + time.Now().Unix() return l + time.Now().Unix()

View File

@ -21,6 +21,12 @@ import (
"mongo.games.com/game/srvdata" "mongo.games.com/game/srvdata"
) )
type BilledInfo struct {
Round int32 // 第几局
ChangeScore int64 // 积分变化
Score int64 // 结算后积分
}
// 房间上的额外数据 // 房间上的额外数据
type TienLenSceneData struct { type TienLenSceneData struct {
*base.Scene //场景 *base.Scene //场景
@ -56,6 +62,7 @@ type TienLenSceneData struct {
isCardsKu bool //是否是牌库 isCardsKu bool //是否是牌库
cardsKuId int32 //牌库ID cardsKuId int32 //牌库ID
ctrlType int // 1控赢 2控输 0不控 ctrlType int // 1控赢 2控输 0不控
BilledList map[int32]*[]*BilledInfo // 多轮结算记录, 玩家id:每局结算记录
} }
func NewTienLenSceneData(s *base.Scene) *TienLenSceneData { func NewTienLenSceneData(s *base.Scene) *TienLenSceneData {
@ -63,6 +70,7 @@ func NewTienLenSceneData(s *base.Scene) *TienLenSceneData {
Scene: s, Scene: s,
poker: rule.NewPoker(), poker: rule.NewPoker(),
players: make(map[int32]*TienLenPlayerData), players: make(map[int32]*TienLenPlayerData),
BilledList: map[int32]*[]*BilledInfo{},
} }
sceneEx.Clear() sceneEx.Clear()
return sceneEx return sceneEx
@ -143,6 +151,11 @@ func (this *TienLenSceneData) CanStart() bool {
return false return false
} }
} }
if this.IsCustom() {
return this.IsAllReady() && this.GetPlayerCnt() >= this.GetPlayerNum()
}
// 房间人数>=2开始,并且有真人或者是预创建房间,并且有房主 // 房间人数>=2开始,并且有真人或者是预创建房间,并且有房主
if nPlayerCount >= 2 && (this.GetRealPlayerNum() > 0 || this.IsPreCreateScene()) { //人数>=2开始 if nPlayerCount >= 2 && (this.GetRealPlayerNum() > 0 || this.IsPreCreateScene()) { //人数>=2开始
return true return true

View File

@ -953,13 +953,17 @@ func (this *SceneHandCardStateTienLen) OnEnter(s *base.Scene) {
s.NotifySceneRoundStart(s.NumOfGames) s.NotifySceneRoundStart(s.NumOfGames)
this.BroadcastRoomState(s, this.GetState(), int64(s.NumOfGames)) this.BroadcastRoomState(s, this.GetState(), int64(s.NumOfGames))
if s.IsCustom() && s.NumOfGames == 1 {
s.SyncSceneState(common.SceneStateStart)
}
//同步防伙牌数据 //同步防伙牌数据
sceneEx.SyncScenePlayer() sceneEx.SyncScenePlayer()
//发牌 //发牌
if rule.TestOpen { if rule.TestOpen {
sceneEx.SendHandCardTest() sceneEx.SendHandCardTest()
} else { } else {
if sceneEx.IsMatchScene() { if sceneEx.IsMatchScene() || sceneEx.IsCustom() {
sceneEx.SendHandCard_Match() sceneEx.SendHandCard_Match()
} else { } else {
sceneEx.SendHandCardOdds() sceneEx.SendHandCardOdds()
@ -1772,7 +1776,7 @@ func (this *SceneBilledStateTienLen) OnEnter(s *base.Scene) {
gainScore = losePlayerCoin gainScore = losePlayerCoin
} }
losePlayerScore = gainScore losePlayerScore = gainScore
if sceneEx.IsMatchScene() { //比赛场是积分,不应该增加账变 if sceneEx.IsMatchScene() || sceneEx.IsCustom() { //比赛场是积分,不应该增加账变
losePlayer.AddCoinNoLog(int64(-gainScore), 0) losePlayer.AddCoinNoLog(int64(-gainScore), 0)
} else { } else {
losePlayer.AddCoin(int64(-gainScore), common.GainWay_CoinSceneLost, 0, "system", s.GetSceneName()) losePlayer.AddCoin(int64(-gainScore), common.GainWay_CoinSceneLost, 0, "system", s.GetSceneName())
@ -1914,7 +1918,7 @@ func (this *SceneBilledStateTienLen) OnEnter(s *base.Scene) {
astWinGainScore = lastWinPlayerCoin astWinGainScore = lastWinPlayerCoin
} }
lastWinPlayerScore = astWinGainScore lastWinPlayerScore = astWinGainScore
if sceneEx.IsMatchScene() { if sceneEx.IsMatchScene() || sceneEx.IsCustom() {
lastWinPlayer.AddCoinNoLog(int64(-astWinGainScore), 0) lastWinPlayer.AddCoinNoLog(int64(-astWinGainScore), 0)
} else { } else {
lastWinPlayer.AddCoin(int64(-astWinGainScore), common.GainWay_CoinSceneLost, 0, "system", s.GetSceneName()) lastWinPlayer.AddCoin(int64(-astWinGainScore), common.GainWay_CoinSceneLost, 0, "system", s.GetSceneName())
@ -2027,7 +2031,7 @@ func (this *SceneBilledStateTienLen) OnEnter(s *base.Scene) {
gainTaxScore = losePlayerScore + lastWinPlayerScore - gainScore gainTaxScore = losePlayerScore + lastWinPlayerScore - gainScore
rankScore = loseRankScore + lastWinPlayerRankScore rankScore = loseRankScore + lastWinPlayerRankScore
} }
if sceneEx.IsMatchScene() { if sceneEx.IsMatchScene() || sceneEx.IsCustom() {
playerEx.AddCoinNoLog(int64(gainScore), 0) playerEx.AddCoinNoLog(int64(gainScore), 0)
} else { } else {
playerEx.AddCoin(gainScore, common.GainWay_CoinSceneWin, 0, "system", s.GetSceneName()) playerEx.AddCoin(gainScore, common.GainWay_CoinSceneWin, 0, "system", s.GetSceneName())
@ -2132,7 +2136,7 @@ func (this *SceneBilledStateTienLen) OnEnter(s *base.Scene) {
taxRate := sceneEx.DbGameFree.GetTaxRate() //万分比 taxRate := sceneEx.DbGameFree.GetTaxRate() //万分比
gainScore := int64(float64(lastWinPlayerScore) * float64(10000-taxRate) / 10000.0) //税后 gainScore := int64(float64(lastWinPlayerScore) * float64(10000-taxRate) / 10000.0) //税后
gainTaxScore := lastWinPlayerScore - gainScore gainTaxScore := lastWinPlayerScore - gainScore
if sceneEx.IsMatchScene() { if sceneEx.IsMatchScene() || sceneEx.IsCustom() {
playerEx.AddCoinNoLog(int64(gainScore), 0) playerEx.AddCoinNoLog(int64(gainScore), 0)
} else { } else {
playerEx.AddCoin(gainScore, common.GainWay_CoinSceneWin, 0, "system", s.GetSceneName()) playerEx.AddCoin(gainScore, common.GainWay_CoinSceneWin, 0, "system", s.GetSceneName())
@ -2274,7 +2278,7 @@ func (this *SceneBilledStateTienLen) OnEnter(s *base.Scene) {
gainScore = losePlayerCoin gainScore = losePlayerCoin
} }
winScore += gainScore winScore += gainScore
if sceneEx.IsMatchScene() { if sceneEx.IsMatchScene() || sceneEx.IsCustom() {
playerEx.AddCoinNoLog(int64(-gainScore), 0) playerEx.AddCoinNoLog(int64(-gainScore), 0)
} else { } else {
playerEx.AddCoin(int64(-gainScore), common.GainWay_CoinSceneLost, 0, "system", s.GetSceneName()) playerEx.AddCoin(int64(-gainScore), common.GainWay_CoinSceneLost, 0, "system", s.GetSceneName())
@ -2413,7 +2417,7 @@ func (this *SceneBilledStateTienLen) OnEnter(s *base.Scene) {
taxRate := sceneEx.DbGameFree.GetTaxRate() //万分比 taxRate := sceneEx.DbGameFree.GetTaxRate() //万分比
gainScore := int64(float64(winScore) * float64(10000-taxRate) / 10000.0) //税后 gainScore := int64(float64(winScore) * float64(10000-taxRate) / 10000.0) //税后
gainTaxScore := winScore - gainScore gainTaxScore := winScore - gainScore
if sceneEx.IsMatchScene() { if sceneEx.IsMatchScene() || sceneEx.IsCustom() {
playerEx.AddCoinNoLog(int64(gainScore), 0) playerEx.AddCoinNoLog(int64(gainScore), 0)
} else { } else {
playerEx.AddCoin(gainScore, common.GainWay_CoinSceneWin, 0, "system", s.GetSceneName()) playerEx.AddCoin(gainScore, common.GainWay_CoinSceneWin, 0, "system", s.GetSceneName())
@ -2530,6 +2534,39 @@ func (this *SceneBilledStateTienLen) OnEnter(s *base.Scene) {
s.Broadcast(int(tienlen.TienLenPacketID_PACKET_SCTienLenGameBilled), pack, 0) s.Broadcast(int(tienlen.TienLenPacketID_PACKET_SCTienLenGameBilled), pack, 0)
logger.Logger.Trace("TienLenPacketID_PACKET_SCTienLenGameBilled gameFreeId:", sceneEx.GetGameFreeId(), ";pack:", pack) logger.Logger.Trace("TienLenPacketID_PACKET_SCTienLenGameBilled gameFreeId:", sceneEx.GetGameFreeId(), ";pack:", pack)
for _, v := range tienlenType.PlayerData {
d := sceneEx.BilledList[v.UserId]
if d == nil {
arr := make([]*BilledInfo, 0)
d = &arr
sceneEx.BilledList[v.UserId] = d
}
*d = append(*d, &BilledInfo{
Round: int32(sceneEx.NumOfGames),
ChangeScore: v.BillCoin,
Score: base.PlayerMgrSington.GetPlayerBySnId(v.UserId).GetCoin(),
})
}
if sceneEx.NumOfGames >= sceneEx.TotalOfGames {
sceneEx.BilledList = make(map[int32]*[]*BilledInfo)
packBilled := &tienlen.SCTienLenCycleBilled{}
for snid, billedList := range sceneEx.BilledList {
info := &tienlen.TienLenCycleBilledInfo{
SnId: snid,
}
for _, bill := range *billedList {
info.RoundScore = append(info.RoundScore, bill.ChangeScore)
info.Score = 1000
}
packBilled.List = append(packBilled.List, info)
}
s.Broadcast(int(tienlen.TienLenPacketID_PACKET_SCTienLenCycleBilled), packBilled, 0)
if s.IsCustom() {
s.SyncSceneState(common.SceneStateEnd)
}
}
// 牌局记录 // 牌局记录
info, err := model.MarshalGameNoteByFIGHT(&tienlenType) info, err := model.MarshalGameNoteByFIGHT(&tienlenType)
if err == nil { if err == nil {
@ -2696,6 +2733,9 @@ func (this *SceneBilledStateTienLen) OnLeave(s *base.Scene) {
if s.CheckNeedDestroy() || (s.IsMatchScene() && (!s.MatchFinals || (s.MatchFinals && s.NumOfGames >= 2))) { // 非决赛打一场 决赛打两场 if s.CheckNeedDestroy() || (s.IsMatchScene() && (!s.MatchFinals || (s.MatchFinals && s.NumOfGames >= 2))) { // 非决赛打一场 决赛打两场
sceneEx.SceneDestroy(true) sceneEx.SceneDestroy(true)
} }
if s.TotalOfGames > 0 && s.NumOfGames >= s.TotalOfGames {
sceneEx.SceneDestroy(true)
}
s.RankMatchDestroy() s.RankMatchDestroy()
s.TryRelease() s.TryRelease()
} }

View File

@ -35,15 +35,15 @@ type GameDetailedLogType struct {
type GameDetailedLog struct { type GameDetailedLog struct {
Id bson.ObjectId `bson:"_id"` //记录ID Id bson.ObjectId `bson:"_id"` //记录ID
LogId string //记录ID LogId string //记录ID,每局游戏唯一
GameId int32 //游戏id GameId int32 //游戏id
ClubId int32 //俱乐部Id ClubId int32 //俱乐部Id
ClubRoom string //俱乐部包间 ClubRoom string //俱乐部包间
Platform string //平台id Platform string //平台id
Channel string //渠道 Channel string //渠道
Promoter string //推广员 Promoter string //推广员
MatchId int64 //比赛ID MatchId int64 //比赛ID,应该用字符串的
SceneId int32 //场景ID SceneId int32 //房间id会重复
GameMode int32 //游戏类型 GameMode int32 //游戏类型
GameFreeid int32 //游戏类型房间号 GameFreeid int32 //游戏类型房间号
PlayerCount int32 //玩家数量 PlayerCount int32 //玩家数量
@ -57,6 +57,7 @@ type GameDetailedLog struct {
Ts int64 //时间戳 Ts int64 //时间戳
CtrlType int // 1控赢 2控输 0不控 CtrlType int // 1控赢 2控输 0不控
PlayerPool map[int]int // 个人水池分 PlayerPool map[int]int // 个人水池分
CycleId string // 本轮id打一轮有多局
} }
func NewGameDetailedLog() *GameDetailedLog { func NewGameDetailedLog() *GameDetailedLog {

View File

@ -1,5 +0,0 @@
cd $CCC_CLIENT_DIR/protocol/gamehall
npx pbjs --dependency protobufjs/minimal.js --target static-module --wrap commonjs --out gamehall.js ./*.proto
npx pbts --main --out ./gamehall.d.ts ./gamehall.js
cp ./gamehall.d.ts ./gamehall.js $CCC_CLIENT_DIR/vietnam/assets/ScriptCore/protocol

View File

@ -1,4 +0,0 @@
# 将chesstitians目录拷贝到client工程目录下的protocol文件夹
echo WIN88_DIR=$WIN88_DIR
echo CCC_CLIENT_DIR=$CCC_CLIENT_DIR
cp -R $WIN88_DIR/protocol/gamehall $CCC_CLIENT_DIR/protocol

View File

@ -1,4 +0,0 @@
# 将chesstitians目录拷贝到client工程目录下的protocol文件夹
echo WIN88_DIR=$WIN88_DIR
echo CCC_CLIENT_DIR=$CCC_CLIENT_DIR
cp -R $CCC_CLIENT_DIR/protocol/gamehall $WIN88_DIR/protocol

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

View File

@ -439,8 +439,7 @@ message GWFishRecord {
//PACKET_GW_SCENESTATE //PACKET_GW_SCENESTATE
message GWSceneState { message GWSceneState {
int32 RoomId = 1; int32 RoomId = 1;
int32 CurrState = 2; int32 RoomState = 2;
int32 Fishing = 3;
} }
//PACKET_WR_INVITEROBOT //PACKET_WR_INVITEROBOT

View File

@ -93,6 +93,7 @@ const (
TienLenPacketID_PACKET_SCTienLenThinkLongCnt TienLenPacketID = 5385 // 长考次数 TienLenPacketID_PACKET_SCTienLenThinkLongCnt TienLenPacketID = 5385 // 长考次数
TienLenPacketID_PACKET_SCTienLenFirstGiveItemItem TienLenPacketID = 5386 // 第一次赠送记牌器道具 TienLenPacketID_PACKET_SCTienLenFirstGiveItemItem TienLenPacketID = 5386 // 第一次赠送记牌器道具
TienLenPacketID_PACKET_SCTienLenPetSkillRes TienLenPacketID = 5387 //宠物技能 TienLenPacketID_PACKET_SCTienLenPetSkillRes TienLenPacketID = 5387 //宠物技能
TienLenPacketID_PACKET_SCTienLenCycleBilled TienLenPacketID = 5388 // 大结算
) )
// Enum value maps for TienLenPacketID. // Enum value maps for TienLenPacketID.
@ -117,6 +118,7 @@ var (
5385: "PACKET_SCTienLenThinkLongCnt", 5385: "PACKET_SCTienLenThinkLongCnt",
5386: "PACKET_SCTienLenFirstGiveItemItem", 5386: "PACKET_SCTienLenFirstGiveItemItem",
5387: "PACKET_SCTienLenPetSkillRes", 5387: "PACKET_SCTienLenPetSkillRes",
5388: "PACKET_SCTienLenCycleBilled",
} }
TienLenPacketID_value = map[string]int32{ TienLenPacketID_value = map[string]int32{
"PACKET_TienLenZERO": 0, "PACKET_TienLenZERO": 0,
@ -138,6 +140,7 @@ var (
"PACKET_SCTienLenThinkLongCnt": 5385, "PACKET_SCTienLenThinkLongCnt": 5385,
"PACKET_SCTienLenFirstGiveItemItem": 5386, "PACKET_SCTienLenFirstGiveItemItem": 5386,
"PACKET_SCTienLenPetSkillRes": 5387, "PACKET_SCTienLenPetSkillRes": 5387,
"PACKET_SCTienLenCycleBilled": 5388,
} }
) )
@ -2291,6 +2294,117 @@ func (x *SCTienLenPetSkillRes) GetPetSkillRes() bool {
return false return false
} }
type TienLenCycleBilledInfo struct {
state protoimpl.MessageState
sizeCache protoimpl.SizeCache
unknownFields protoimpl.UnknownFields
SnId int32 `protobuf:"varint,1,opt,name=SnId,proto3" json:"SnId,omitempty"` // 玩家ID
RoundScore []int64 `protobuf:"varint,2,rep,packed,name=RoundScore,proto3" json:"RoundScore,omitempty"` // 每轮得分
Score int64 `protobuf:"varint,3,opt,name=Score,proto3" json:"Score,omitempty"` // 基础分
}
func (x *TienLenCycleBilledInfo) Reset() {
*x = TienLenCycleBilledInfo{}
if protoimpl.UnsafeEnabled {
mi := &file_tienlen_proto_msgTypes[24]
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
ms.StoreMessageInfo(mi)
}
}
func (x *TienLenCycleBilledInfo) String() string {
return protoimpl.X.MessageStringOf(x)
}
func (*TienLenCycleBilledInfo) ProtoMessage() {}
func (x *TienLenCycleBilledInfo) ProtoReflect() protoreflect.Message {
mi := &file_tienlen_proto_msgTypes[24]
if protoimpl.UnsafeEnabled && x != nil {
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
if ms.LoadMessageInfo() == nil {
ms.StoreMessageInfo(mi)
}
return ms
}
return mi.MessageOf(x)
}
// Deprecated: Use TienLenCycleBilledInfo.ProtoReflect.Descriptor instead.
func (*TienLenCycleBilledInfo) Descriptor() ([]byte, []int) {
return file_tienlen_proto_rawDescGZIP(), []int{24}
}
func (x *TienLenCycleBilledInfo) GetSnId() int32 {
if x != nil {
return x.SnId
}
return 0
}
func (x *TienLenCycleBilledInfo) GetRoundScore() []int64 {
if x != nil {
return x.RoundScore
}
return nil
}
func (x *TienLenCycleBilledInfo) GetScore() int64 {
if x != nil {
return x.Score
}
return 0
}
// PACKET_SCTienLenCycleBilled
type SCTienLenCycleBilled struct {
state protoimpl.MessageState
sizeCache protoimpl.SizeCache
unknownFields protoimpl.UnknownFields
List []*TienLenCycleBilledInfo `protobuf:"bytes,1,rep,name=List,proto3" json:"List,omitempty"`
}
func (x *SCTienLenCycleBilled) Reset() {
*x = SCTienLenCycleBilled{}
if protoimpl.UnsafeEnabled {
mi := &file_tienlen_proto_msgTypes[25]
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
ms.StoreMessageInfo(mi)
}
}
func (x *SCTienLenCycleBilled) String() string {
return protoimpl.X.MessageStringOf(x)
}
func (*SCTienLenCycleBilled) ProtoMessage() {}
func (x *SCTienLenCycleBilled) ProtoReflect() protoreflect.Message {
mi := &file_tienlen_proto_msgTypes[25]
if protoimpl.UnsafeEnabled && x != nil {
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
if ms.LoadMessageInfo() == nil {
ms.StoreMessageInfo(mi)
}
return ms
}
return mi.MessageOf(x)
}
// Deprecated: Use SCTienLenCycleBilled.ProtoReflect.Descriptor instead.
func (*SCTienLenCycleBilled) Descriptor() ([]byte, []int) {
return file_tienlen_proto_rawDescGZIP(), []int{25}
}
func (x *SCTienLenCycleBilled) GetList() []*TienLenCycleBilledInfo {
if x != nil {
return x.List
}
return nil
}
var File_tienlen_proto protoreflect.FileDescriptor var File_tienlen_proto protoreflect.FileDescriptor
var file_tienlen_proto_rawDesc = []byte{ var file_tienlen_proto_rawDesc = []byte{
@ -2611,54 +2725,68 @@ var file_tienlen_proto_rawDesc = []byte{
0x05, 0x52, 0x04, 0x53, 0x6e, 0x69, 0x64, 0x12, 0x10, 0x0a, 0x03, 0x50, 0x6f, 0x73, 0x18, 0x02, 0x05, 0x52, 0x04, 0x53, 0x6e, 0x69, 0x64, 0x12, 0x10, 0x0a, 0x03, 0x50, 0x6f, 0x73, 0x18, 0x02,
0x20, 0x01, 0x28, 0x05, 0x52, 0x03, 0x50, 0x6f, 0x73, 0x12, 0x20, 0x0a, 0x0b, 0x50, 0x65, 0x74, 0x20, 0x01, 0x28, 0x05, 0x52, 0x03, 0x50, 0x6f, 0x73, 0x12, 0x20, 0x0a, 0x0b, 0x50, 0x65, 0x74,
0x53, 0x6b, 0x69, 0x6c, 0x6c, 0x52, 0x65, 0x73, 0x18, 0x03, 0x20, 0x01, 0x28, 0x08, 0x52, 0x0b, 0x53, 0x6b, 0x69, 0x6c, 0x6c, 0x52, 0x65, 0x73, 0x18, 0x03, 0x20, 0x01, 0x28, 0x08, 0x52, 0x0b,
0x50, 0x65, 0x74, 0x53, 0x6b, 0x69, 0x6c, 0x6c, 0x52, 0x65, 0x73, 0x2a, 0x3e, 0x0a, 0x0c, 0x4f, 0x50, 0x65, 0x74, 0x53, 0x6b, 0x69, 0x6c, 0x6c, 0x52, 0x65, 0x73, 0x22, 0x62, 0x0a, 0x16, 0x54,
0x70, 0x52, 0x65, 0x73, 0x75, 0x6c, 0x74, 0x43, 0x6f, 0x64, 0x65, 0x12, 0x0f, 0x0a, 0x0b, 0x4f, 0x69, 0x65, 0x6e, 0x4c, 0x65, 0x6e, 0x43, 0x79, 0x63, 0x6c, 0x65, 0x42, 0x69, 0x6c, 0x6c, 0x65,
0x50, 0x52, 0x43, 0x5f, 0x53, 0x75, 0x63, 0x65, 0x73, 0x73, 0x10, 0x00, 0x12, 0x0e, 0x0a, 0x0a, 0x64, 0x49, 0x6e, 0x66, 0x6f, 0x12, 0x12, 0x0a, 0x04, 0x53, 0x6e, 0x49, 0x64, 0x18, 0x01, 0x20,
0x4f, 0x50, 0x52, 0x43, 0x5f, 0x45, 0x72, 0x72, 0x6f, 0x72, 0x10, 0x01, 0x12, 0x0d, 0x0a, 0x09, 0x01, 0x28, 0x05, 0x52, 0x04, 0x53, 0x6e, 0x49, 0x64, 0x12, 0x1e, 0x0a, 0x0a, 0x52, 0x6f, 0x75,
0x4f, 0x50, 0x52, 0x43, 0x5f, 0x48, 0x69, 0x6e, 0x74, 0x10, 0x02, 0x2a, 0x80, 0x05, 0x0a, 0x0f, 0x6e, 0x64, 0x53, 0x63, 0x6f, 0x72, 0x65, 0x18, 0x02, 0x20, 0x03, 0x28, 0x03, 0x52, 0x0a, 0x52,
0x54, 0x69, 0x65, 0x6e, 0x4c, 0x65, 0x6e, 0x50, 0x61, 0x63, 0x6b, 0x65, 0x74, 0x49, 0x44, 0x12, 0x6f, 0x75, 0x6e, 0x64, 0x53, 0x63, 0x6f, 0x72, 0x65, 0x12, 0x14, 0x0a, 0x05, 0x53, 0x63, 0x6f,
0x16, 0x0a, 0x12, 0x50, 0x41, 0x43, 0x4b, 0x45, 0x54, 0x5f, 0x54, 0x69, 0x65, 0x6e, 0x4c, 0x65, 0x72, 0x65, 0x18, 0x03, 0x20, 0x01, 0x28, 0x03, 0x52, 0x05, 0x53, 0x63, 0x6f, 0x72, 0x65, 0x22,
0x6e, 0x5a, 0x45, 0x52, 0x4f, 0x10, 0x00, 0x12, 0x1d, 0x0a, 0x18, 0x50, 0x41, 0x43, 0x4b, 0x45, 0x4b, 0x0a, 0x14, 0x53, 0x43, 0x54, 0x69, 0x65, 0x6e, 0x4c, 0x65, 0x6e, 0x43, 0x79, 0x63, 0x6c,
0x54, 0x5f, 0x53, 0x43, 0x54, 0x69, 0x65, 0x6e, 0x4c, 0x65, 0x6e, 0x52, 0x6f, 0x6f, 0x6d, 0x49, 0x65, 0x42, 0x69, 0x6c, 0x6c, 0x65, 0x64, 0x12, 0x33, 0x0a, 0x04, 0x4c, 0x69, 0x73, 0x74, 0x18,
0x6e, 0x66, 0x6f, 0x10, 0xfa, 0x29, 0x12, 0x1e, 0x0a, 0x19, 0x50, 0x41, 0x43, 0x4b, 0x45, 0x54, 0x01, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x1f, 0x2e, 0x74, 0x69, 0x65, 0x6e, 0x6c, 0x65, 0x6e, 0x2e,
0x5f, 0x53, 0x43, 0x54, 0x69, 0x65, 0x6e, 0x4c, 0x65, 0x6e, 0x52, 0x6f, 0x6f, 0x6d, 0x53, 0x74, 0x54, 0x69, 0x65, 0x6e, 0x4c, 0x65, 0x6e, 0x43, 0x79, 0x63, 0x6c, 0x65, 0x42, 0x69, 0x6c, 0x6c,
0x61, 0x74, 0x65, 0x10, 0xfb, 0x29, 0x12, 0x1d, 0x0a, 0x18, 0x50, 0x41, 0x43, 0x4b, 0x45, 0x54, 0x65, 0x64, 0x49, 0x6e, 0x66, 0x6f, 0x52, 0x04, 0x4c, 0x69, 0x73, 0x74, 0x2a, 0x3e, 0x0a, 0x0c,
0x5f, 0x43, 0x53, 0x54, 0x69, 0x65, 0x6e, 0x4c, 0x65, 0x6e, 0x50, 0x6c, 0x61, 0x79, 0x65, 0x72, 0x4f, 0x70, 0x52, 0x65, 0x73, 0x75, 0x6c, 0x74, 0x43, 0x6f, 0x64, 0x65, 0x12, 0x0f, 0x0a, 0x0b,
0x4f, 0x70, 0x10, 0xfc, 0x29, 0x12, 0x1d, 0x0a, 0x18, 0x50, 0x41, 0x43, 0x4b, 0x45, 0x54, 0x5f, 0x4f, 0x50, 0x52, 0x43, 0x5f, 0x53, 0x75, 0x63, 0x65, 0x73, 0x73, 0x10, 0x00, 0x12, 0x0e, 0x0a,
0x53, 0x43, 0x54, 0x69, 0x65, 0x6e, 0x4c, 0x65, 0x6e, 0x50, 0x6c, 0x61, 0x79, 0x65, 0x72, 0x4f, 0x0a, 0x4f, 0x50, 0x52, 0x43, 0x5f, 0x45, 0x72, 0x72, 0x6f, 0x72, 0x10, 0x01, 0x12, 0x0d, 0x0a,
0x70, 0x10, 0xfd, 0x29, 0x12, 0x20, 0x0a, 0x1b, 0x50, 0x41, 0x43, 0x4b, 0x45, 0x54, 0x5f, 0x53, 0x09, 0x4f, 0x50, 0x52, 0x43, 0x5f, 0x48, 0x69, 0x6e, 0x74, 0x10, 0x02, 0x2a, 0xa2, 0x05, 0x0a,
0x43, 0x54, 0x69, 0x65, 0x6e, 0x4c, 0x65, 0x6e, 0x50, 0x6c, 0x61, 0x79, 0x65, 0x72, 0x45, 0x6e, 0x0f, 0x54, 0x69, 0x65, 0x6e, 0x4c, 0x65, 0x6e, 0x50, 0x61, 0x63, 0x6b, 0x65, 0x74, 0x49, 0x44,
0x74, 0x65, 0x72, 0x10, 0xfe, 0x29, 0x12, 0x20, 0x0a, 0x1b, 0x50, 0x41, 0x43, 0x4b, 0x45, 0x54, 0x12, 0x16, 0x0a, 0x12, 0x50, 0x41, 0x43, 0x4b, 0x45, 0x54, 0x5f, 0x54, 0x69, 0x65, 0x6e, 0x4c,
0x65, 0x6e, 0x5a, 0x45, 0x52, 0x4f, 0x10, 0x00, 0x12, 0x1d, 0x0a, 0x18, 0x50, 0x41, 0x43, 0x4b,
0x45, 0x54, 0x5f, 0x53, 0x43, 0x54, 0x69, 0x65, 0x6e, 0x4c, 0x65, 0x6e, 0x52, 0x6f, 0x6f, 0x6d,
0x49, 0x6e, 0x66, 0x6f, 0x10, 0xfa, 0x29, 0x12, 0x1e, 0x0a, 0x19, 0x50, 0x41, 0x43, 0x4b, 0x45,
0x54, 0x5f, 0x53, 0x43, 0x54, 0x69, 0x65, 0x6e, 0x4c, 0x65, 0x6e, 0x52, 0x6f, 0x6f, 0x6d, 0x53,
0x74, 0x61, 0x74, 0x65, 0x10, 0xfb, 0x29, 0x12, 0x1d, 0x0a, 0x18, 0x50, 0x41, 0x43, 0x4b, 0x45,
0x54, 0x5f, 0x43, 0x53, 0x54, 0x69, 0x65, 0x6e, 0x4c, 0x65, 0x6e, 0x50, 0x6c, 0x61, 0x79, 0x65,
0x72, 0x4f, 0x70, 0x10, 0xfc, 0x29, 0x12, 0x1d, 0x0a, 0x18, 0x50, 0x41, 0x43, 0x4b, 0x45, 0x54,
0x5f, 0x53, 0x43, 0x54, 0x69, 0x65, 0x6e, 0x4c, 0x65, 0x6e, 0x50, 0x6c, 0x61, 0x79, 0x65, 0x72, 0x5f, 0x53, 0x43, 0x54, 0x69, 0x65, 0x6e, 0x4c, 0x65, 0x6e, 0x50, 0x6c, 0x61, 0x79, 0x65, 0x72,
0x4c, 0x65, 0x61, 0x76, 0x65, 0x10, 0xff, 0x29, 0x12, 0x19, 0x0a, 0x14, 0x50, 0x41, 0x43, 0x4b, 0x4f, 0x70, 0x10, 0xfd, 0x29, 0x12, 0x20, 0x0a, 0x1b, 0x50, 0x41, 0x43, 0x4b, 0x45, 0x54, 0x5f,
0x45, 0x54, 0x5f, 0x53, 0x43, 0x54, 0x69, 0x65, 0x6e, 0x4c, 0x65, 0x6e, 0x43, 0x61, 0x72, 0x64, 0x53, 0x43, 0x54, 0x69, 0x65, 0x6e, 0x4c, 0x65, 0x6e, 0x50, 0x6c, 0x61, 0x79, 0x65, 0x72, 0x45,
0x10, 0x80, 0x2a, 0x12, 0x1f, 0x0a, 0x1a, 0x50, 0x41, 0x43, 0x4b, 0x45, 0x54, 0x5f, 0x53, 0x43, 0x6e, 0x74, 0x65, 0x72, 0x10, 0xfe, 0x29, 0x12, 0x20, 0x0a, 0x1b, 0x50, 0x41, 0x43, 0x4b, 0x45,
0x54, 0x69, 0x65, 0x6e, 0x4c, 0x65, 0x6e, 0x47, 0x61, 0x6d, 0x65, 0x42, 0x69, 0x6c, 0x6c, 0x65, 0x54, 0x5f, 0x53, 0x43, 0x54, 0x69, 0x65, 0x6e, 0x4c, 0x65, 0x6e, 0x50, 0x6c, 0x61, 0x79, 0x65,
0x64, 0x10, 0x81, 0x2a, 0x12, 0x1d, 0x0a, 0x18, 0x50, 0x41, 0x43, 0x4b, 0x45, 0x54, 0x5f, 0x53, 0x72, 0x4c, 0x65, 0x61, 0x76, 0x65, 0x10, 0xff, 0x29, 0x12, 0x19, 0x0a, 0x14, 0x50, 0x41, 0x43,
0x43, 0x54, 0x69, 0x65, 0x6e, 0x4c, 0x65, 0x6e, 0x43, 0x75, 0x72, 0x4f, 0x70, 0x50, 0x6f, 0x73, 0x4b, 0x45, 0x54, 0x5f, 0x53, 0x43, 0x54, 0x69, 0x65, 0x6e, 0x4c, 0x65, 0x6e, 0x43, 0x61, 0x72,
0x10, 0x82, 0x2a, 0x12, 0x24, 0x0a, 0x1f, 0x50, 0x41, 0x43, 0x4b, 0x45, 0x54, 0x5f, 0x53, 0x43, 0x64, 0x10, 0x80, 0x2a, 0x12, 0x1f, 0x0a, 0x1a, 0x50, 0x41, 0x43, 0x4b, 0x45, 0x54, 0x5f, 0x53,
0x54, 0x69, 0x65, 0x6e, 0x4c, 0x65, 0x6e, 0x53, 0x6d, 0x61, 0x6c, 0x6c, 0x47, 0x61, 0x6d, 0x65, 0x43, 0x54, 0x69, 0x65, 0x6e, 0x4c, 0x65, 0x6e, 0x47, 0x61, 0x6d, 0x65, 0x42, 0x69, 0x6c, 0x6c,
0x42, 0x69, 0x6c, 0x6c, 0x65, 0x64, 0x10, 0x83, 0x2a, 0x12, 0x25, 0x0a, 0x20, 0x50, 0x41, 0x43, 0x65, 0x64, 0x10, 0x81, 0x2a, 0x12, 0x1d, 0x0a, 0x18, 0x50, 0x41, 0x43, 0x4b, 0x45, 0x54, 0x5f,
0x4b, 0x45, 0x54, 0x5f, 0x53, 0x43, 0x54, 0x69, 0x65, 0x6e, 0x4c, 0x65, 0x6e, 0x55, 0x70, 0x64, 0x53, 0x43, 0x54, 0x69, 0x65, 0x6e, 0x4c, 0x65, 0x6e, 0x43, 0x75, 0x72, 0x4f, 0x70, 0x50, 0x6f,
0x61, 0x74, 0x65, 0x4d, 0x61, 0x73, 0x74, 0x65, 0x72, 0x53, 0x6e, 0x69, 0x64, 0x10, 0x84, 0x2a, 0x73, 0x10, 0x82, 0x2a, 0x12, 0x24, 0x0a, 0x1f, 0x50, 0x41, 0x43, 0x4b, 0x45, 0x54, 0x5f, 0x53,
0x12, 0x26, 0x0a, 0x21, 0x50, 0x41, 0x43, 0x4b, 0x45, 0x54, 0x5f, 0x53, 0x43, 0x54, 0x69, 0x65, 0x43, 0x54, 0x69, 0x65, 0x6e, 0x4c, 0x65, 0x6e, 0x53, 0x6d, 0x61, 0x6c, 0x6c, 0x47, 0x61, 0x6d,
0x6e, 0x4c, 0x65, 0x6e, 0x55, 0x70, 0x64, 0x61, 0x74, 0x65, 0x41, 0x75, 0x64, 0x69, 0x65, 0x6e, 0x65, 0x42, 0x69, 0x6c, 0x6c, 0x65, 0x64, 0x10, 0x83, 0x2a, 0x12, 0x25, 0x0a, 0x20, 0x50, 0x41,
0x63, 0x65, 0x4e, 0x75, 0x6d, 0x10, 0x85, 0x2a, 0x12, 0x17, 0x0a, 0x12, 0x50, 0x41, 0x43, 0x4b, 0x43, 0x4b, 0x45, 0x54, 0x5f, 0x53, 0x43, 0x54, 0x69, 0x65, 0x6e, 0x4c, 0x65, 0x6e, 0x55, 0x70,
0x45, 0x54, 0x5f, 0x53, 0x43, 0x54, 0x69, 0x65, 0x6e, 0x4c, 0x65, 0x6e, 0x41, 0x49, 0x10, 0x86, 0x64, 0x61, 0x74, 0x65, 0x4d, 0x61, 0x73, 0x74, 0x65, 0x72, 0x53, 0x6e, 0x69, 0x64, 0x10, 0x84,
0x2a, 0x12, 0x1f, 0x0a, 0x1a, 0x50, 0x41, 0x43, 0x4b, 0x45, 0x54, 0x5f, 0x53, 0x43, 0x54, 0x69, 0x2a, 0x12, 0x26, 0x0a, 0x21, 0x50, 0x41, 0x43, 0x4b, 0x45, 0x54, 0x5f, 0x53, 0x43, 0x54, 0x69,
0x65, 0x6e, 0x4c, 0x65, 0x6e, 0x46, 0x69, 0x72, 0x73, 0x74, 0x4f, 0x70, 0x50, 0x6f, 0x73, 0x10, 0x65, 0x6e, 0x4c, 0x65, 0x6e, 0x55, 0x70, 0x64, 0x61, 0x74, 0x65, 0x41, 0x75, 0x64, 0x69, 0x65,
0x87, 0x2a, 0x12, 0x1d, 0x0a, 0x18, 0x50, 0x41, 0x43, 0x4b, 0x45, 0x54, 0x5f, 0x53, 0x43, 0x54, 0x6e, 0x63, 0x65, 0x4e, 0x75, 0x6d, 0x10, 0x85, 0x2a, 0x12, 0x17, 0x0a, 0x12, 0x50, 0x41, 0x43,
0x69, 0x65, 0x6e, 0x4c, 0x65, 0x6e, 0x43, 0x61, 0x72, 0x64, 0x54, 0x65, 0x73, 0x74, 0x10, 0x88, 0x4b, 0x45, 0x54, 0x5f, 0x53, 0x43, 0x54, 0x69, 0x65, 0x6e, 0x4c, 0x65, 0x6e, 0x41, 0x49, 0x10,
0x2a, 0x12, 0x21, 0x0a, 0x1c, 0x50, 0x41, 0x43, 0x4b, 0x45, 0x54, 0x5f, 0x53, 0x43, 0x54, 0x69, 0x86, 0x2a, 0x12, 0x1f, 0x0a, 0x1a, 0x50, 0x41, 0x43, 0x4b, 0x45, 0x54, 0x5f, 0x53, 0x43, 0x54,
0x65, 0x6e, 0x4c, 0x65, 0x6e, 0x54, 0x68, 0x69, 0x6e, 0x6b, 0x4c, 0x6f, 0x6e, 0x67, 0x43, 0x6e, 0x69, 0x65, 0x6e, 0x4c, 0x65, 0x6e, 0x46, 0x69, 0x72, 0x73, 0x74, 0x4f, 0x70, 0x50, 0x6f, 0x73,
0x74, 0x10, 0x89, 0x2a, 0x12, 0x26, 0x0a, 0x21, 0x50, 0x41, 0x43, 0x4b, 0x45, 0x54, 0x5f, 0x53, 0x10, 0x87, 0x2a, 0x12, 0x1d, 0x0a, 0x18, 0x50, 0x41, 0x43, 0x4b, 0x45, 0x54, 0x5f, 0x53, 0x43,
0x43, 0x54, 0x69, 0x65, 0x6e, 0x4c, 0x65, 0x6e, 0x46, 0x69, 0x72, 0x73, 0x74, 0x47, 0x69, 0x76, 0x54, 0x69, 0x65, 0x6e, 0x4c, 0x65, 0x6e, 0x43, 0x61, 0x72, 0x64, 0x54, 0x65, 0x73, 0x74, 0x10,
0x65, 0x49, 0x74, 0x65, 0x6d, 0x49, 0x74, 0x65, 0x6d, 0x10, 0x8a, 0x2a, 0x12, 0x20, 0x0a, 0x1b, 0x88, 0x2a, 0x12, 0x21, 0x0a, 0x1c, 0x50, 0x41, 0x43, 0x4b, 0x45, 0x54, 0x5f, 0x53, 0x43, 0x54,
0x50, 0x41, 0x43, 0x4b, 0x45, 0x54, 0x5f, 0x53, 0x43, 0x54, 0x69, 0x65, 0x6e, 0x4c, 0x65, 0x6e, 0x69, 0x65, 0x6e, 0x4c, 0x65, 0x6e, 0x54, 0x68, 0x69, 0x6e, 0x6b, 0x4c, 0x6f, 0x6e, 0x67, 0x43,
0x50, 0x65, 0x74, 0x53, 0x6b, 0x69, 0x6c, 0x6c, 0x52, 0x65, 0x73, 0x10, 0x8b, 0x2a, 0x42, 0x27, 0x6e, 0x74, 0x10, 0x89, 0x2a, 0x12, 0x26, 0x0a, 0x21, 0x50, 0x41, 0x43, 0x4b, 0x45, 0x54, 0x5f,
0x5a, 0x25, 0x6d, 0x6f, 0x6e, 0x67, 0x6f, 0x2e, 0x67, 0x61, 0x6d, 0x65, 0x73, 0x2e, 0x63, 0x6f, 0x53, 0x43, 0x54, 0x69, 0x65, 0x6e, 0x4c, 0x65, 0x6e, 0x46, 0x69, 0x72, 0x73, 0x74, 0x47, 0x69,
0x6d, 0x2f, 0x67, 0x61, 0x6d, 0x65, 0x2f, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x63, 0x6f, 0x6c, 0x2f, 0x76, 0x65, 0x49, 0x74, 0x65, 0x6d, 0x49, 0x74, 0x65, 0x6d, 0x10, 0x8a, 0x2a, 0x12, 0x20, 0x0a,
0x74, 0x69, 0x65, 0x6e, 0x6c, 0x65, 0x6e, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33, 0x1b, 0x50, 0x41, 0x43, 0x4b, 0x45, 0x54, 0x5f, 0x53, 0x43, 0x54, 0x69, 0x65, 0x6e, 0x4c, 0x65,
0x6e, 0x50, 0x65, 0x74, 0x53, 0x6b, 0x69, 0x6c, 0x6c, 0x52, 0x65, 0x73, 0x10, 0x8b, 0x2a, 0x12,
0x20, 0x0a, 0x1b, 0x50, 0x41, 0x43, 0x4b, 0x45, 0x54, 0x5f, 0x53, 0x43, 0x54, 0x69, 0x65, 0x6e,
0x4c, 0x65, 0x6e, 0x43, 0x79, 0x63, 0x6c, 0x65, 0x42, 0x69, 0x6c, 0x6c, 0x65, 0x64, 0x10, 0x8c,
0x2a, 0x42, 0x27, 0x5a, 0x25, 0x6d, 0x6f, 0x6e, 0x67, 0x6f, 0x2e, 0x67, 0x61, 0x6d, 0x65, 0x73,
0x2e, 0x63, 0x6f, 0x6d, 0x2f, 0x67, 0x61, 0x6d, 0x65, 0x2f, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x63,
0x6f, 0x6c, 0x2f, 0x74, 0x69, 0x65, 0x6e, 0x6c, 0x65, 0x6e, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74,
0x6f, 0x33,
} }
var ( var (
@ -2674,7 +2802,7 @@ func file_tienlen_proto_rawDescGZIP() []byte {
} }
var file_tienlen_proto_enumTypes = make([]protoimpl.EnumInfo, 2) var file_tienlen_proto_enumTypes = make([]protoimpl.EnumInfo, 2)
var file_tienlen_proto_msgTypes = make([]protoimpl.MessageInfo, 26) var file_tienlen_proto_msgTypes = make([]protoimpl.MessageInfo, 28)
var file_tienlen_proto_goTypes = []interface{}{ var file_tienlen_proto_goTypes = []interface{}{
(OpResultCode)(0), // 0: tienlen.OpResultCode (OpResultCode)(0), // 0: tienlen.OpResultCode
(TienLenPacketID)(0), // 1: tienlen.TienLenPacketID (TienLenPacketID)(0), // 1: tienlen.TienLenPacketID
@ -2702,11 +2830,13 @@ var file_tienlen_proto_goTypes = []interface{}{
(*SCTienLenPlayerThinkLongCnt)(nil), // 23: tienlen.SCTienLenPlayerThinkLongCnt (*SCTienLenPlayerThinkLongCnt)(nil), // 23: tienlen.SCTienLenPlayerThinkLongCnt
(*SCTienLenPlayerFirstGiveItemItem)(nil), // 24: tienlen.SCTienLenPlayerFirstGiveItemItem (*SCTienLenPlayerFirstGiveItemItem)(nil), // 24: tienlen.SCTienLenPlayerFirstGiveItemItem
(*SCTienLenPetSkillRes)(nil), // 25: tienlen.SCTienLenPetSkillRes (*SCTienLenPetSkillRes)(nil), // 25: tienlen.SCTienLenPetSkillRes
nil, // 26: tienlen.TienLenPlayerData.ItemsEntry (*TienLenCycleBilledInfo)(nil), // 26: tienlen.TienLenCycleBilledInfo
nil, // 27: tienlen.SCTienLenCardTest.GradesEntry (*SCTienLenCycleBilled)(nil), // 27: tienlen.SCTienLenCycleBilled
nil, // 28: tienlen.TienLenPlayerData.ItemsEntry
nil, // 29: tienlen.SCTienLenCardTest.GradesEntry
} }
var file_tienlen_proto_depIdxs = []int32{ var file_tienlen_proto_depIdxs = []int32{
26, // 0: tienlen.TienLenPlayerData.Items:type_name -> tienlen.TienLenPlayerData.ItemsEntry 28, // 0: tienlen.TienLenPlayerData.Items:type_name -> tienlen.TienLenPlayerData.ItemsEntry
3, // 1: tienlen.TienLenPlayerData.SkillInfo:type_name -> tienlen.PetSkillInfo 3, // 1: tienlen.TienLenPlayerData.SkillInfo:type_name -> tienlen.PetSkillInfo
4, // 2: tienlen.PetSkillInfo.SkillData:type_name -> tienlen.SkillInfo 4, // 2: tienlen.PetSkillInfo.SkillData:type_name -> tienlen.SkillInfo
2, // 3: tienlen.SCTienLenRoomInfo.Players:type_name -> tienlen.TienLenPlayerData 2, // 3: tienlen.SCTienLenRoomInfo.Players:type_name -> tienlen.TienLenPlayerData
@ -2715,12 +2845,13 @@ var file_tienlen_proto_depIdxs = []int32{
2, // 6: tienlen.SCTienLenPlayerEnter.Data:type_name -> tienlen.TienLenPlayerData 2, // 6: tienlen.SCTienLenPlayerEnter.Data:type_name -> tienlen.TienLenPlayerData
12, // 7: tienlen.TienLenPlayerGameBilled.AddItems:type_name -> tienlen.AddItem 12, // 7: tienlen.TienLenPlayerGameBilled.AddItems:type_name -> tienlen.AddItem
13, // 8: tienlen.SCTienLenGameBilled.Datas:type_name -> tienlen.TienLenPlayerGameBilled 13, // 8: tienlen.SCTienLenGameBilled.Datas:type_name -> tienlen.TienLenPlayerGameBilled
27, // 9: tienlen.SCTienLenCardTest.Grades:type_name -> tienlen.SCTienLenCardTest.GradesEntry 29, // 9: tienlen.SCTienLenCardTest.Grades:type_name -> tienlen.SCTienLenCardTest.GradesEntry
10, // [10:10] is the sub-list for method output_type 26, // 10: tienlen.SCTienLenCycleBilled.List:type_name -> tienlen.TienLenCycleBilledInfo
10, // [10:10] is the sub-list for method input_type 11, // [11:11] is the sub-list for method output_type
10, // [10:10] is the sub-list for extension type_name 11, // [11:11] is the sub-list for method input_type
10, // [10:10] is the sub-list for extension extendee 11, // [11:11] is the sub-list for extension type_name
0, // [0:10] is the sub-list for field type_name 11, // [11:11] is the sub-list for extension extendee
0, // [0:11] is the sub-list for field type_name
} }
func init() { file_tienlen_proto_init() } func init() { file_tienlen_proto_init() }
@ -3017,6 +3148,30 @@ func file_tienlen_proto_init() {
return nil return nil
} }
} }
file_tienlen_proto_msgTypes[24].Exporter = func(v interface{}, i int) interface{} {
switch v := v.(*TienLenCycleBilledInfo); i {
case 0:
return &v.state
case 1:
return &v.sizeCache
case 2:
return &v.unknownFields
default:
return nil
}
}
file_tienlen_proto_msgTypes[25].Exporter = func(v interface{}, i int) interface{} {
switch v := v.(*SCTienLenCycleBilled); i {
case 0:
return &v.state
case 1:
return &v.sizeCache
case 2:
return &v.unknownFields
default:
return nil
}
}
} }
type x struct{} type x struct{}
out := protoimpl.TypeBuilder{ out := protoimpl.TypeBuilder{
@ -3024,7 +3179,7 @@ func file_tienlen_proto_init() {
GoPackagePath: reflect.TypeOf(x{}).PkgPath(), GoPackagePath: reflect.TypeOf(x{}).PkgPath(),
RawDescriptor: file_tienlen_proto_rawDesc, RawDescriptor: file_tienlen_proto_rawDesc,
NumEnums: 2, NumEnums: 2,
NumMessages: 26, NumMessages: 28,
NumExtensions: 0, NumExtensions: 0,
NumServices: 0, NumServices: 0,
}, },

View File

@ -30,6 +30,7 @@ enum TienLenPacketID {
PACKET_SCTienLenThinkLongCnt = 5385; // PACKET_SCTienLenThinkLongCnt = 5385; //
PACKET_SCTienLenFirstGiveItemItem = 5386; // PACKET_SCTienLenFirstGiveItemItem = 5386; //
PACKET_SCTienLenPetSkillRes = 5387; // PACKET_SCTienLenPetSkillRes = 5387; //
PACKET_SCTienLenCycleBilled = 5388; //
} }
@ -266,3 +267,15 @@ message SCTienLenPetSkillRes{
int32 Pos = 2; int32 Pos = 2;
bool PetSkillRes = 3; //true生效 bool PetSkillRes = 3; //true生效
} }
message TienLenCycleBilledInfo {
int32 SnId = 1; // ID
repeated int64 RoundScore = 2; //
int64 Score = 3; //
// = RoundScore + Score
}
// PACKET_SCTienLenCycleBilled
message SCTienLenCycleBilled {
repeated TienLenCycleBilledInfo List = 1;
}

View File

@ -319,7 +319,7 @@ func CSUpBagInfo(s *netlib.Session, packetid int, data interface{}, sid int64) e
GainWay: common.GainWayItemChange, GainWay: common.GainWayItemChange,
Operator: "system", Operator: "system",
Remark: "背包内使用兑换", Remark: "背包内使用兑换",
noLog: false, NoLog: false,
}) })
if isF { if isF {
pack.RetCode = bag.OpResultCode_OPRC_Sucess pack.RetCode = bag.OpResultCode_OPRC_Sucess
@ -344,7 +344,7 @@ func CSUpBagInfo(s *netlib.Session, packetid int, data interface{}, sid int64) e
GainWay: common.GainWayItemFen, GainWay: common.GainWayItemFen,
Operator: "system", Operator: "system",
Remark: fmt.Sprintf("道具分解%v", msg.GetItemId()), Remark: fmt.Sprintf("道具分解%v", msg.GetItemId()),
noLog: false, NoLog: false,
}) })
if isF { if isF {
pack.RetCode = bag.OpResultCode_OPRC_Sucess pack.RetCode = bag.OpResultCode_OPRC_Sucess

View File

@ -492,7 +492,7 @@ func (this *CSInviteFriendOpHandler) Process(s *netlib.Session, packetid int, da
dbGameFree := scene.dbGameFree dbGameFree := scene.dbGameFree
if dbGameFree != nil { if dbGameFree != nil {
limitCoin := srvdata.CreateRoomMgrSington.GetLimitCoinByBaseScore(int32(scene.gameId), int32(scene.gameSite), scene.BaseScore) limitCoin := srvdata.CreateRoomMgrSington.GetLimitCoinByBaseScore(int32(scene.gameId), scene.dbGameFree.GetSceneType(), scene.BaseScore)
if p.Coin < limitCoin { if p.Coin < limitCoin {
logger.Logger.Warn("CSInviteFriendHandler player limitCoin") logger.Logger.Warn("CSInviteFriendHandler player limitCoin")
opRetCode = friend.OpResultCode_OPRC_InviteFriend_CoinLimit //金币不足 opRetCode = friend.OpResultCode_OPRC_InviteFriend_CoinLimit //金币不足

View File

@ -3,6 +3,7 @@ package main
import ( import (
"fmt" "fmt"
"math/rand" "math/rand"
"slices"
"time" "time"
"mongo.games.com/goserver/core/basic" "mongo.games.com/goserver/core/basic"
@ -96,11 +97,18 @@ func (this *CSEnterRoomHandler) Process(s *netlib.Session, packetid int, data in
goto failed goto failed
} }
// 密码是否正确
if scene.password != "" && scene.password != msg.GetPassword() {
code = gamehall.OpResultCode_Game_OPRC_PasswordError
logger.Logger.Trace("CSEnterRoomHandler scene is closed")
goto failed
}
dbGameFree = scene.dbGameFree dbGameFree = scene.dbGameFree
if dbGameFree != nil { if dbGameFree != nil {
if common.IsLocalGame(scene.gameId) { if common.IsLocalGame(scene.gameId) {
if !p.IsRob { if !p.IsRob {
limitCoin := srvdata.CreateRoomMgrSington.GetLimitCoinByBaseScore(int32(scene.gameId), int32(scene.gameSite), scene.BaseScore) limitCoin := srvdata.CreateRoomMgrSington.GetLimitCoinByBaseScore(int32(scene.gameId), scene.dbGameFree.GetSceneType(), scene.BaseScore)
if p.Coin < limitCoin { if p.Coin < limitCoin {
code = gamehall.OpResultCode_Game_OPRC_CoinNotEnough_Game code = gamehall.OpResultCode_Game_OPRC_CoinNotEnough_Game
logger.Logger.Trace("CSEnterRoomHandler scene is closed") logger.Logger.Trace("CSEnterRoomHandler scene is closed")
@ -304,7 +312,7 @@ func (this *CSQueryRoomInfoHandler) ProcessLocalGame(s *netlib.Session, packetid
} }
if p.Platform == scene.limitPlatform.IdStr || isShow { if p.Platform == scene.limitPlatform.IdStr || isShow {
if scene.sceneMode == int(msg.GetSceneMode()) && len(scene.players) != 0 { if scene.sceneMode == int(msg.GetSceneMode()) && len(scene.players) != 0 {
if scene.gameId == int(gameid) && scene.gameSite == int(msg.GetGameSite()) { if scene.gameId == int(gameid) && scene.dbGameFree.GetSceneType() == msg.GetGameSite() {
// 私人房需要是好友 // 私人房需要是好友
if scene.sceneMode == common.SceneMode_Private { if scene.sceneMode == common.SceneMode_Private {
@ -854,6 +862,15 @@ func (this *CSCreateRoomHandler) ProcessLocalGame(s *netlib.Session, packetid in
maxPlayerNum = 0 maxPlayerNum = 0
} }
if srvdata.GameFreeMgr.IsGameDif(dbGameFree.GetGameId(), common.GameDifThirteen) {
switch msg.GetMaxPlayerNum() {
case 1:
maxPlayerNum = 8
default:
maxPlayerNum = 4
}
}
//创建房间 //创建房间
csp = CoinSceneMgrSingleton.GetCoinScenePool(p.GetPlatform().IdStr, dbGameFree.GetId()) csp = CoinSceneMgrSingleton.GetCoinScenePool(p.GetPlatform().IdStr, dbGameFree.GetId())
roomId = SceneMgrSingleton.GenOneCoinSceneId() roomId = SceneMgrSingleton.GenOneCoinSceneId()
@ -862,123 +879,28 @@ func (this *CSCreateRoomHandler) ProcessLocalGame(s *netlib.Session, packetid in
logger.Logger.Tracef("CSCreateRoomHandler SnId:%v GameId:%v sceneId == -1 ", p.SnId, gameId) logger.Logger.Tracef("CSCreateRoomHandler SnId:%v GameId:%v sceneId == -1 ", p.SnId, gameId)
goto failed goto failed
} }
scene, code = p.CreateLocalGameScene(roomId, int(gameId), int(gameSite), int(msg.GetSceneMode()), maxPlayerNum,
params, dbGameFree, baseScore, 0) scene = SceneMgrSingleton.CreateScene(&CreateSceneParam{
if scene != nil && code == gamehall.OpResultCode_Game_OPRC_Sucess_Game { CreateId: p.SnId,
RoomId: roomId,
SceneMode: int(msg.GetSceneMode()),
Params: params,
Platform: p.GetPlatform(),
GF: dbGameFree,
PlayerNum: int32(maxPlayerNum),
BaseScore: baseScore,
})
if scene == nil {
logger.Logger.Tracef("CSCreateRoomHandler CreateScene fail SnId:%v GameId:%v", p.SnId, gameId)
code = gamehall.OpResultCode_Game_OPRC_Error_Game
goto failed
}
logger.Logger.Tracef("CSCreateRoomHandler SnId:%v Create Sucess GameId:%v", p.SnId, gameId) logger.Logger.Tracef("CSCreateRoomHandler SnId:%v Create Sucess GameId:%v", p.SnId, gameId)
csp.AddScene(scene) csp.AddScene(scene)
if !scene.PlayerEnter(p, -1, true) { if !scene.PlayerEnter(p, -1, true) {
code = gamehall.OpResultCode_Game_OPRC_Error_Game code = gamehall.OpResultCode_Game_OPRC_Error_Game
} }
}
failed:
resp := &gamehall.SCCreateRoom{
GameId: msg.GetGameId(),
BaseCoin: msg.GetBaseCoin(),
SceneMode: msg.GetSceneMode(),
MaxPlayerNum: msg.GetMaxPlayerNum(),
Params: msg.GetParams(),
OpRetCode: code,
}
proto.SetDefaults(resp)
p.SendToClient(int(gamehall.GameHallPacketID_PACKET_SC_CREATEROOM), resp)
return nil
}
func (this *CSCreateRoomHandler) ProcessThirteen(s *netlib.Session, packetid int, data interface{}, sid int64) error {
msg, ok := data.(*gamehall.CSCreateRoom)
if !ok {
return nil
}
p := PlayerMgrSington.GetPlayer(sid)
if p == nil {
return nil
}
var code gamehall.OpResultCode_Game
var dbGameFree *server.DB_GameFree
var dbGameRule *server.DB_GameRule
var params = common.CopySliceInt32ToInt64(msg.GetParams())
var baseScore = msg.GetBaseCoin()
var sp ScenePolicy
var gamefreeId = msg.GetId()
var gps *webapiproto.GameFree
var maxPlayerNum = int(msg.GetMaxPlayerNum())
var csp *CoinScenePool
var roomId int
var scene *Scene
var gameId = gamefreeId / 10000
var spd *ScenePolicyData
gps = PlatformMgrSingleton.GetGameFree(p.Platform, gamefreeId)
if gps == nil {
code = gamehall.OpResultCode_Game_OPRC_GameNotExist_Game
logger.Logger.Tracef("CSCreateRoomHandler SnId:%v GameFreeId:%v not exist", p.SnId, gamefreeId)
goto failed
}
dbGameFree = gps.DbGameFree
if dbGameFree == nil {
code = gamehall.OpResultCode_Game_OPRC_GameNotExist_Game
logger.Logger.Tracef("CSCreateRoomHandler SnId:%v GameFreeId:%v not exist", p.SnId, gamefreeId)
goto failed
}
//检测房间状态是否开启
if !PlatformMgrSingleton.CheckGameState(p.Platform, dbGameFree.Id) {
code = gamehall.OpResultCode_Game_OPRC_GameHadClosed
logger.Logger.Tracef("CSCreateRoomHandler SnId:%v GameFreeId:%v GameHadClosed", p.SnId, gamefreeId)
goto failed
}
dbGameRule = srvdata.PBDB_GameRuleMgr.GetData(dbGameFree.GetGameRule())
if dbGameRule == nil {
code = gamehall.OpResultCode_Game_OPRC_GameNotExist_Game
logger.Logger.Tracef("CSCreateRoomHandler SnId:%v GameFreeId:%v gamerule not exist", p.SnId, gamefreeId)
goto failed
}
sp = GetScenePolicy(int(gameId), 0)
if sp == nil {
code = gamehall.OpResultCode_Game_OPRC_GameNotExist_Game
logger.Logger.Tracef("CSCreateRoomHandler SnId:%v GameFreeId:%v not exist", p.SnId, gamefreeId)
goto failed
}
spd, ok = sp.(*ScenePolicyData)
if ok {
//todo 参数校验
_ = spd
}
if p.scene != nil {
code = gamehall.OpResultCode_Game_OPRC_RoomHadExist_Game
logger.Logger.Tracef("CSCreateRoomHandler had scene(%d)", p.scene.sceneId)
goto failed
}
//创建房间
csp = CoinSceneMgrSingleton.GetCoinScenePool(p.GetPlatform().IdStr, dbGameFree.GetId())
roomId = SceneMgrSingleton.GenOneCoinSceneId()
if roomId == common.RANDID_INVALID {
code = gamehall.OpResultCode_Game_OPRC_AllocRoomIdFailed_Game
logger.Logger.Tracef("CSCreateRoomHandler SnId:%v GameId:%v sceneId == -1 ", p.SnId, gameId)
goto failed
}
scene, code = p.CreateLocalGameScene(roomId, int(gameId), int(dbGameFree.GetSceneType()), int(msg.GetSceneMode()),
maxPlayerNum, params, dbGameFree, baseScore, 0)
if scene != nil {
if code == gamehall.OpResultCode_Game_OPRC_Sucess_Game {
logger.Logger.Tracef("CSCreateRoomHandler SnId:%v Create Sucess GameId:%v", p.SnId, gameId)
// try enter scene
csp.scenes[scene.sceneId] = scene
scene.csp = csp
if !scene.PlayerEnter(p, -1, true) {
code = gamehall.OpResultCode_Game_OPRC_Error_Game
}
}
}
failed: failed:
resp := &gamehall.SCCreateRoom{ resp := &gamehall.SCCreateRoom{
@ -1028,7 +950,7 @@ func (this *CSAudienceSitHandler) Process(s *netlib.Session, packetid int, data
} }
if !p.scene.IsTestScene() { if !p.scene.IsTestScene() {
// 入场限额检查 // 入场限额检查
limitCoin := srvdata.CreateRoomMgrSington.GetLimitCoinByBaseScore(int32(p.scene.gameId), int32(p.scene.gameSite), p.scene.BaseScore) limitCoin := srvdata.CreateRoomMgrSington.GetLimitCoinByBaseScore(int32(p.scene.gameId), p.scene.dbGameFree.GetSceneType(), p.scene.BaseScore)
if p.Coin < limitCoin { if p.Coin < limitCoin {
pack.OpCode = gamehall.OpResultCode_Game_OPRC_MoneyNotEnough_Game pack.OpCode = gamehall.OpResultCode_Game_OPRC_MoneyNotEnough_Game
newPlayer.SendToClient(int(gamehall.GameHallPacketID_PACKET_SC_AUDIENCESIT), pack) newPlayer.SendToClient(int(gamehall.GameHallPacketID_PACKET_SC_AUDIENCESIT), pack)
@ -1235,6 +1157,261 @@ failed:
return nil return nil
} }
func CSRoomConfigHandler(s *netlib.Session, packetId int, data interface{}, sid int64) error {
logger.Logger.Trace("CSRoomConfigHandler Process recv ", data)
_, ok := data.(*gamehall.CSRoomConfig)
if !ok {
return nil
}
p := PlayerMgrSington.GetPlayer(sid)
if p == nil {
return nil
}
pack := PlatformMgrSingleton.GetRoomConfig(p.Platform)
p.SendToClient(int(gamehall.GameHallPacketID_PACKET_SCRoomConfig), pack)
logger.Logger.Tracef("SCRoomConfig: %v", pack)
return nil
}
func CSCreatePrivateRoomHandler(s *netlib.Session, packetId int, data interface{}, sid int64) error {
logger.Logger.Trace("CSCreatePrivateRoomHandler Process recv ", data)
msg, ok := data.(*gamehall.CSCreatePrivateRoom)
if !ok {
return nil
}
p := PlayerMgrSington.GetPlayer(sid)
if p == nil {
return nil
}
var needPwd, costType, voice int64
var password string
code := gamehall.OpResultCode_Game_OPRC_Error_Game
pack := &gamehall.SCCreatePrivateRoom{}
send := func() {
pack.OpRetCode = code
p.SendToClient(int(gamehall.GameHallPacketID_PACKET_SC_CREATEPRIVATEROOM), pack)
logger.Logger.Tracef("SCCreatePrivateRoom: %v", pack)
}
// 参数校验
cfg := PlatformMgrSingleton.GetConfig(p.Platform).RoomConfig[msg.GetRoomConfigId()]
if cfg == nil {
send()
return nil
}
// 场次
if !slices.Contains(cfg.GetGameFreeId(), msg.GetGameFreeId()) {
send()
return nil
}
// 局数
if !slices.Contains(cfg.GetRound(), msg.GetRound()) {
send()
return nil
}
// 玩家数量
if !slices.Contains(cfg.GetPlayerNum(), msg.GetPlayerNum()) {
send()
return nil
}
// 密码
if cfg.GetNeedPassword() != 3 {
needPwd = int64(cfg.GetNeedPassword())
} else {
needPwd = int64(msg.GetNeedPassword())
}
if needPwd < 1 || needPwd > 2 {
needPwd = 2 // 默认不需要密码
}
// 房费类型
if cfg.GetCostType() != 3 {
costType = int64(cfg.GetCostType())
} else {
costType = int64(msg.GetCostType())
}
if costType < 1 || costType > 2 {
costType = 1 // 默认房主支付
}
// 语音
if cfg.GetVoice() != 3 {
voice = int64(cfg.GetVoice())
} else {
voice = int64(msg.GetVoice())
}
if voice < 1 || voice > 2 {
voice = 1 // 默认开启语音
}
// 场次是否存在
gf := PlatformMgrSingleton.GetGameFree(p.Platform, msg.GetGameFreeId())
if gf == nil {
code = gamehall.OpResultCode_Game_OPRC_GameHadClosed
send()
return nil
}
sp := GetScenePolicy(int(gf.GetDbGameFree().GetGameId()), int(gf.GetDbGameFree().GetGameMode()))
if sp == nil {
code = gamehall.OpResultCode_Game_OPRC_GameHadClosed
send()
return nil
}
// 游戏是否开启
if cfg.GetOn() != common.On || gf.GetStatus() {
code = gamehall.OpResultCode_Game_OPRC_GameHadClosed
send()
return nil
}
if p.scene != nil {
code = gamehall.OpResultCode_Game_OPRC_RoomHadExist_Game
send()
return nil
}
// 密码
if needPwd == 1 {
password = SceneMgrSingleton.GenPassword()
}
// 费用是否充足
if len(cfg.GetCost()) > 0 && !sp.CostEnough(int(costType), int(msg.GetPlayerNum()), cfg, p) {
code = gamehall.OpResultCode_Game_OPRC_CostNotEnough
send()
return nil
}
// 创建房间
csp := CoinSceneMgrSingleton.GetCoinScenePool(p.GetPlatform().IdStr, msg.GetGameFreeId())
roomId := SceneMgrSingleton.GenOnePrivateSceneId()
scene := SceneMgrSingleton.CreateScene(&CreateSceneParam{
CreateId: p.SnId,
RoomId: roomId,
SceneMode: common.SceneMode_Private,
CycleTimes: 0,
TotalRound: int(msg.GetRound()),
Params: common.CopySliceInt32ToInt64(csp.dbGameRule.GetParams()),
GS: nil,
Platform: PlatformMgrSingleton.GetPlatform(p.Platform),
GF: csp.dbGameFree,
PlayerNum: msg.GetPlayerNum(),
Password: password,
Voice: int32(voice),
Channel: cfg.GetOnChannelName(),
RoomType: PlatformMgrSingleton.GetConfig(p.Platform).RoomType[cfg.GetRoomType()],
RoomConfig: cfg,
RoomCostType: int(msg.GetCostType()),
})
if scene == nil {
code = gamehall.OpResultCode_Game_OPRC_SceneServerMaintain_Game
send()
return nil
}
csp.AddScene(scene)
if !scene.PlayerEnter(p, -1, true) {
send()
return nil
}
pack = &gamehall.SCCreatePrivateRoom{
OpRetCode: gamehall.OpResultCode_Game_OPRC_Sucess_Game,
GameFreeId: msg.GetGameFreeId(),
RoomTypeId: msg.GetRoomTypeId(),
RoomConfigId: msg.GetRoomConfigId(),
Round: msg.GetRound(),
PlayerNum: msg.GetPlayerNum(),
NeedPassword: int32(needPwd),
CostType: int32(costType),
Voice: int32(voice),
RoomId: int32(roomId),
Password: password,
}
send()
return nil
}
func CSGetPrivateRoomListHandler(s *netlib.Session, packetId int, data interface{}, sid int64) error {
logger.Logger.Trace("CSGetPrivateRoomListHandler Process recv ", data)
_, ok := data.(*gamehall.CSGetPrivateRoomList)
if !ok {
return nil
}
p := PlayerMgrSington.GetPlayer(sid)
if p == nil {
return nil
}
pack := &gamehall.SCGetPrivateRoomList{}
scenes := SceneMgrSingleton.FindRoomList(&FindRoomParam{
Platform: p.Platform,
GameId: nil,
GameMode: nil,
SceneMode: nil,
RoomId: 0,
IsCustom: 1,
IsFree: 0,
GameFreeId: nil,
SnId: 0,
IsMatch: false,
IsRankMatch: false,
Channel: []string{p.LastChannel},
})
for _, v := range scenes {
needPassword := 0
if v.password != "" {
needPassword = 1
}
var players []*gamehall.PrivatePlayerInfo
for _, vv := range v.players {
players = append(players, &gamehall.PrivatePlayerInfo{
SnId: vv.GetSnId(),
Name: vv.GetName(),
UseRoleId: vv.GetRoleId(),
})
}
d := &gamehall.PrivateRoomInfo{
GameFreeId: v.dbGameFree.GetId(),
GameId: v.dbGameFree.GetGameId(),
RoomTypeId: v.RoomType.GetId(),
RoomConfigId: v.RoomConfig.GetId(),
RoomId: int32(v.sceneId),
NeedPassword: int32(needPassword),
CurrRound: v.currRound,
MaxRound: v.totalRound,
CurrNum: int32(v.GetPlayerCnt()),
MaxPlayer: int32(v.playerNum),
CreateTs: v.createTime.Unix(),
State: v.SceneState,
Players: players,
}
pack.Datas = append(pack.Datas, d)
}
p.SendToClient(int(gamehall.GameHallPacketID_PACKET_SC_GETPRIVATEROOMLIST), pack)
logger.Logger.Tracef("SCGetPrivateRoomList: %v", pack)
return nil
}
func CSTouchTypeHandler(s *netlib.Session, packetId int, data interface{}, sid int64) error {
logger.Logger.Trace("CSTouchTypeHandler Process recv ", data)
_, ok := data.(*gamehall.CSTouchType)
if !ok {
return nil
}
p := PlayerMgrSington.GetPlayer(sid)
if p == nil {
return nil
}
return nil
}
func init() { func init() {
// 返回房间 // 返回房间
common.RegisterHandler(int(gamehall.GameHallPacketID_PACKET_CS_RETURNROOM), &CSReturnRoomHandler{}) common.RegisterHandler(int(gamehall.GameHallPacketID_PACKET_CS_RETURNROOM), &CSReturnRoomHandler{})
@ -1266,4 +1443,12 @@ func init() {
// 观众进入房间 // 观众进入房间
common.Register(int(gamehall.GameHallPacketID_PACKET_CS_AUDIENCE_ENTERROOM), &gamehall.CSEnterRoom{}, CSAudienceEnterRoomHandler) common.Register(int(gamehall.GameHallPacketID_PACKET_CS_AUDIENCE_ENTERROOM), &gamehall.CSEnterRoom{}, CSAudienceEnterRoomHandler)
// 竞技馆房间配置列表
common.Register(int(gamehall.GameHallPacketID_PACKET_CSRoomConfig), &gamehall.CSRoomConfig{}, CSRoomConfigHandler)
// 创建竞技馆房间
common.Register(int(gamehall.GameHallPacketID_PACKET_CS_CREATEPRIVATEROOM), &gamehall.CSCreatePrivateRoom{}, CSCreatePrivateRoomHandler)
// 竞技馆房间列表
common.Register(int(gamehall.GameHallPacketID_PACKET_CS_GETPRIVATEROOMLIST), &gamehall.CSGetPrivateRoomList{}, CSGetPrivateRoomListHandler)
// 保持刷新
common.Register(int(gamehall.GameHallPacketID_PACKET_CSTouchType), &gamehall.CSTouchType{}, CSTouchTypeHandler)
} }

View File

@ -550,7 +550,7 @@ func CSSkinUpgrade(s *netlib.Session, packetid int, data interface{}, sid int64)
GainWay: common.GainWaySkinUpGrade, GainWay: common.GainWaySkinUpGrade,
Operator: "system", Operator: "system",
Remark: "皮肤升级消耗", Remark: "皮肤升级消耗",
noLog: false, NoLog: false,
}) })
if !ok { if !ok {
logger.Logger.Errorf("CSSkinUpgrade upgrade error") logger.Logger.Errorf("CSSkinUpgrade upgrade error")
@ -604,7 +604,7 @@ func SkinUnLock(p *Player, id int32) (*pets.SkinInfo, pets.OpResultCode) {
GainWay: common.GainWaySkinUnLock, GainWay: common.GainWaySkinUnLock,
Operator: "system", Operator: "system",
Remark: "皮肤解锁消耗", Remark: "皮肤解锁消耗",
noLog: false, NoLog: false,
}) })
if !ok { if !ok {
logger.Logger.Errorf("CSSKinUnLock Unlock error") logger.Logger.Errorf("CSSKinUnLock Unlock error")

View File

@ -402,9 +402,9 @@ func (this *CSDiamondLotteryHandler) Process(s *netlib.Session, packetid int, da
GainWay: common.GainWayDiamondLottery, GainWay: common.GainWayDiamondLottery,
Operator: "system", Operator: "system",
Remark: "钻石抽奖", Remark: "钻石抽奖",
gameId: 0, GameId: 0,
gameFreeId: 0, GameFreeId: 0,
noLog: false, NoLog: false,
}) })
pack.LuckyScore = p.DiamondLotteryScore pack.LuckyScore = p.DiamondLotteryScore
p.SendToClient(int(player_proto.PlayerPacketID_PACKET_SC_DiamondLottery), pack) p.SendToClient(int(player_proto.PlayerPacketID_PACKET_SC_DiamondLottery), pack)

View File

@ -24,7 +24,6 @@ import (
"mongo.games.com/game/common" "mongo.games.com/game/common"
"mongo.games.com/game/model" "mongo.games.com/game/model"
"mongo.games.com/game/proto" "mongo.games.com/game/proto"
gamehall_proto "mongo.games.com/game/protocol/gamehall"
player_proto "mongo.games.com/game/protocol/player" player_proto "mongo.games.com/game/protocol/player"
webapi_proto "mongo.games.com/game/protocol/webapi" webapi_proto "mongo.games.com/game/protocol/webapi"
"mongo.games.com/game/webapi" "mongo.games.com/game/webapi"
@ -2059,13 +2058,13 @@ func CSPlayerData(s *netlib.Session, packetid int, data interface{}, sid int64)
} }
// 给玩家发送三方余额状态 // 给玩家发送三方余额状态
statePack := &gamehall_proto.SCThridGameBalanceUpdateState{} //statePack := &gamehall_proto.SCThridGameBalanceUpdateState{}
if player.thridBalanceReqIsSucces { //if player.thridBalanceReqIsSucces {
statePack.OpRetCode = gamehall_proto.OpResultCode_Game_OPRC_Sucess_Game // statePack.OpRetCode = gamehall_proto.OpResultCode_Game_OPRC_Sucess_Game
} else { //} else {
statePack.OpRetCode = gamehall_proto.OpResultCode_Game_OPRC_Error_Game // statePack.OpRetCode = gamehall_proto.OpResultCode_Game_OPRC_Error_Game
} //}
player.SendRawToClientIncOffLine(sid, s, int(gamehall_proto.GameHallPacketID_PACKET_SC_THRIDGAMEBALANCEUPDATESTATE), statePack) //player.SendRawToClientIncOffLine(sid, s, int(gamehall_proto.GameHallPacketID_PACKET_SC_THRIDGAMEBALANCEUPDATESTATE), statePack)
//抽奖次数兼容老玩家 //抽奖次数兼容老玩家
if !player.IsRob && !player.InitLotteryStatus && WelfareMgrSington.GetPhoneLotteryStatus(player.Platform) == model.WelfareOpen { if !player.IsRob && !player.InitLotteryStatus && WelfareMgrSington.GetPhoneLotteryStatus(player.Platform) == model.WelfareOpen {

View File

@ -73,22 +73,8 @@ func init() {
p.SnId, scene.sceneId, scene.gameId, scene.gameMode) p.SnId, scene.sceneId, scene.gameId, scene.gameMode)
} }
default: default:
if scene.ClubId > 0 {
//if club, ok := clubManager.clubList[scene.ClubId]; ok {
// if cp, ok1 := club.memberList[p.SnId]; ok1 {
// cp.GameCount += msg.GetGameTimes()
// cp.DayCoin += msg.GetTotalConvertibleFlow() - p.TotalConvertibleFlow
// }
//}
//if !ClubSceneMgrSington.PlayerLeave(p, int(msg.GetReason())) {
// logger.Logger.Warnf("Club leave room msg snid:%v sceneid:%v gameid:%v modeid:%v [coinscene]",
// p.SnId, scene.sceneId, scene.gameId, scene.mode)
// scene.PlayerLeave(p, int(msg.GetReason()))
//}
} else {
scene.PlayerLeave(p, int(msg.GetReason())) scene.PlayerLeave(p, int(msg.GetReason()))
} }
}
if p.scene != nil { if p.scene != nil {
logger.Logger.Warnf("after GWPlayerLeave found snid:%v sceneid:%v gameid:%v modeid:%v", p.SnId, p.scene.sceneId, p.scene.gameId, p.scene.gameMode) logger.Logger.Warnf("after GWPlayerLeave found snid:%v sceneid:%v gameid:%v modeid:%v", p.SnId, p.scene.sceneId, p.scene.gameId, p.scene.gameMode)
@ -129,7 +115,7 @@ func init() {
Platform: p.Platform, Platform: p.Platform,
}) })
//比赛场不处理下面的内容 //比赛场不处理下面的内容
if !scene.IsMatchScene() { if !scene.IsMatchScene() && !scene.IsCustom() {
// 破产检测 // 破产检测
sdata := srvdata.PBDB_GameSubsidyMgr.GetData(GameSubsidyid) sdata := srvdata.PBDB_GameSubsidyMgr.GetData(GameSubsidyid)
if sdata != nil { if sdata != nil {
@ -301,7 +287,6 @@ func init() {
})) }))
// 房间游戏状态 // 房间游戏状态
// 捕鱼
netlib.RegisterFactory(int(serverproto.SSPacketID_PACKET_GW_SCENESTATE), netlib.PacketFactoryWrapper(func() interface{} { netlib.RegisterFactory(int(serverproto.SSPacketID_PACKET_GW_SCENESTATE), netlib.PacketFactoryWrapper(func() interface{} {
return &serverproto.GWSceneState{} return &serverproto.GWSceneState{}
})) }))
@ -310,8 +295,7 @@ func init() {
if msg, ok := pack.(*serverproto.GWSceneState); ok { if msg, ok := pack.(*serverproto.GWSceneState); ok {
scene := SceneMgrSingleton.GetScene(int(msg.GetRoomId())) scene := SceneMgrSingleton.GetScene(int(msg.GetRoomId()))
if scene != nil { if scene != nil {
scene.state = msg.GetCurrState() scene.sp.OnSceneState(scene, int(msg.GetRoomState()))
scene.fishing = msg.GetFishing()
} }
} }
return nil return nil
@ -600,8 +584,8 @@ func init() {
Ts: proto.Int64(leftTime), Ts: proto.Int64(leftTime),
Sec: proto.Int32(scene.StateSec), Sec: proto.Int32(scene.StateSec),
}) })
gameStateMgr.BrodcastGameState(int32(scene.gameId), scene.limitPlatform.IdStr, gameStateMgr.BrodcastGameState(
int(gamehallproto.GameHallPacketID_PACKET_SC_GAMESTATE), pack) int32(scene.gameId), scene.limitPlatform.IdStr, int(gamehallproto.GameHallPacketID_PACKET_SC_GAMESTATE), pack)
} }
} }
} }

View File

@ -1093,9 +1093,9 @@ func CSPermitExchange(s *netlib.Session, packetid int, data interface{}, sid int
GainWay: common.GainWayPermitExchangeGain, GainWay: common.GainWayPermitExchangeGain,
Operator: "system", Operator: "system",
Remark: "赛季通行证兑换获得", Remark: "赛季通行证兑换获得",
gameId: 0, GameId: 0,
gameFreeId: 0, GameFreeId: 0,
noLog: false, NoLog: false,
}) })
p.WelfData.PermitExchange[msg.GetId()] = append(p.WelfData.PermitExchange[msg.GetId()], now.Unix()) p.WelfData.PermitExchange[msg.GetId()] = append(p.WelfData.PermitExchange[msg.GetId()], now.Unix())
// 兑换记录 // 兑换记录

View File

@ -149,8 +149,8 @@ type ItemParam struct {
Add int64 // 加成数量 Add int64 // 加成数量
GainWay int32 // 记录类型 GainWay int32 // 记录类型
Operator, Remark string // 操作人,备注 Operator, Remark string // 操作人,备注
gameId, gameFreeId int64 // 游戏id,场次id GameId, GameFreeId int64 // 游戏id,场次id
noLog bool // 是否不记录日志 NoLog bool // 是否不记录日志
LogId string // 撤销的id,道具兑换失败 LogId string // 撤销的id,道具兑换失败
} }
@ -160,7 +160,7 @@ type AddItemParam struct {
} }
func (this *BagMgr) AddItemsV2(args *ItemParam) (*BagInfo, bag.OpResultCode, bool) { func (this *BagMgr) AddItemsV2(args *ItemParam) (*BagInfo, bag.OpResultCode, bool) {
return this.AddItems(args.P, args.Change, args.Add, args.GainWay, args.Operator, args.Remark, args.gameId, args.gameFreeId, args.noLog, AddItemParam{ return this.AddItems(args.P, args.Change, args.Add, args.GainWay, args.Operator, args.Remark, args.GameId, args.GameFreeId, args.NoLog, AddItemParam{
Cost: args.Cost, Cost: args.Cost,
LogId: args.LogId, LogId: args.LogId,
}) })
@ -173,7 +173,7 @@ func (this *BagMgr) AddItemsV2(args *ItemParam) (*BagInfo, bag.OpResultCode, boo
// remark 备注 // remark 备注
// gameId 游戏id // gameId 游戏id
// gameFreeId 场次id // gameFreeId 场次id
// noLog 是否不记录日志 // NoLog 是否不记录日志
// Deprecated: use [ AddItemsV2 ] instead // Deprecated: use [ AddItemsV2 ] instead
func (this *BagMgr) AddItems(p *Player, addItems []*Item, add int64, gainWay int32, operator, remark string, func (this *BagMgr) AddItems(p *Player, addItems []*Item, add int64, gainWay int32, operator, remark string,
gameId, gameFreeId int64, noLog bool, params ...AddItemParam) (*BagInfo, bag.OpResultCode, bool) { gameId, gameFreeId int64, noLog bool, params ...AddItemParam) (*BagInfo, bag.OpResultCode, bool) {
@ -758,9 +758,9 @@ func (this *BagMgr) ItemExchangeCard(p *Player, itemId int32, money, cardType in
GainWay: common.GainWayItemChange, GainWay: common.GainWayItemChange,
Operator: "system", Operator: "system",
Remark: "背包内使用兑换失败", Remark: "背包内使用兑换失败",
gameId: 0, GameId: 0,
gameFreeId: 0, GameFreeId: 0,
noLog: false, NoLog: false,
LogId: logId, LogId: logId,
}) })
logger.Logger.Errorf("获取兑换码失败 snid:%v itemID:%v res:%v err:%v", p.SnId, itemId, res, err) logger.Logger.Errorf("获取兑换码失败 snid:%v itemID:%v res:%v err:%v", p.SnId, itemId, res, err)

View File

@ -3,8 +3,6 @@ package main
import ( import (
"sort" "sort"
"mongo.games.com/goserver/core/logger"
"mongo.games.com/game/common" "mongo.games.com/game/common"
"mongo.games.com/game/model" "mongo.games.com/game/model"
"mongo.games.com/game/protocol/gamehall" "mongo.games.com/game/protocol/gamehall"
@ -211,14 +209,6 @@ func (this *BaseCoinScenePool) AudienceLeave(pool *CoinScenePool, p *Player, rea
func (this *BaseCoinScenePool) OnPlayerLeave(pool *CoinScenePool, s *Scene, p *Player) {} func (this *BaseCoinScenePool) OnPlayerLeave(pool *CoinScenePool, s *Scene, p *Player) {}
func (this *BaseCoinScenePool) NewScene(pool *CoinScenePool, p *Player) *Scene { func (this *BaseCoinScenePool) NewScene(pool *CoinScenePool, p *Player) *Scene {
gameId := int(pool.dbGameFree.GetGameId())
gs := GameSessMgrSington.GetMinLoadSess(gameId)
if gs == nil {
logger.Logger.Warnf("Get %v game min session failed.", gameId)
return nil
}
gameMode := pool.dbGameFree.GetGameMode()
params := common.CopySliceInt32ToInt64(pool.dbGameRule.GetParams()) params := common.CopySliceInt32ToInt64(pool.dbGameRule.GetParams())
limitPlatform := PlatformMgrSingleton.GetPlatform(pool.platform) limitPlatform := PlatformMgrSingleton.GetPlatform(pool.platform)
if limitPlatform == nil || !limitPlatform.Isolated { if limitPlatform == nil || !limitPlatform.Isolated {
@ -226,9 +216,14 @@ func (this *BaseCoinScenePool) NewScene(pool *CoinScenePool, p *Player) *Scene {
} }
sceneId := SceneMgrSingleton.GenOneCoinSceneId() sceneId := SceneMgrSingleton.GenOneCoinSceneId()
scene := SceneMgrSingleton.CreateScene(&CreateSceneParam{
scene := SceneMgrSingleton.CreateScene(0, 0, sceneId, gameId, int(gameMode), common.SceneMode_Public, RoomId: sceneId,
1, -1, params, gs, limitPlatform, 0, pool.dbGameFree, pool.ID()) SceneMode: common.SceneMode_Public,
Params: params,
GS: nil,
Platform: limitPlatform,
GF: pool.dbGameFree,
})
return scene return scene
} }

View File

@ -20,10 +20,10 @@ func init() {
RegisterCoinScenePool(common.GameId_TienLen_yl, local) RegisterCoinScenePool(common.GameId_TienLen_yl, local)
RegisterCoinScenePool(common.GameId_TienLen_toend, local) RegisterCoinScenePool(common.GameId_TienLen_toend, local)
RegisterCoinScenePool(common.GameId_TienLen_yl_toend, local) RegisterCoinScenePool(common.GameId_TienLen_yl_toend, local)
RegisterCoinScenePool(common.GameId_TaLa, local)
RegisterCoinScenePool(common.GameId_SamLoc, local)
RegisterCoinScenePool(common.GameID_ThirteenFree, local) RegisterCoinScenePool(common.GameID_ThirteenFree, local)
RegisterCoinScenePool(common.GameID_ThirteenFreeLaiZi, local) RegisterCoinScenePool(common.GameID_ThirteenFreeLaiZi, local)
//RegisterCoinScenePool(common.GameId_TaLa, local)
//RegisterCoinScenePool(common.GameId_SamLoc, local)
} }
type CoinScenePoolLocal struct { type CoinScenePoolLocal struct {
@ -187,14 +187,7 @@ func (l *CoinScenePoolLocal) PlayerEnter(pool *CoinScenePool, p *Player, exclude
func (l *CoinScenePoolLocal) NewScene(pool *CoinScenePool, p *Player) *Scene { func (l *CoinScenePoolLocal) NewScene(pool *CoinScenePool, p *Player) *Scene {
gameId := int(pool.dbGameFree.GetGameId()) gameId := int(pool.dbGameFree.GetGameId())
gs := GameSessMgrSington.GetMinLoadSess(gameId)
if gs == nil {
logger.Logger.Errorf("Get %v game min session failed.", gameId)
return nil
}
sceneId := SceneMgrSingleton.GenOneCoinSceneId() sceneId := SceneMgrSingleton.GenOneCoinSceneId()
params := pool.dbGameRule.GetParams() params := pool.dbGameRule.GetParams()
limitPlatform := PlatformMgrSingleton.GetPlatform(pool.platform) limitPlatform := PlatformMgrSingleton.GetPlatform(pool.platform)
if limitPlatform == nil || !limitPlatform.Isolated { if limitPlatform == nil || !limitPlatform.Isolated {
@ -203,7 +196,6 @@ func (l *CoinScenePoolLocal) NewScene(pool *CoinScenePool, p *Player) *Scene {
//根据携带金额取可创房间 DB_Createroom //根据携带金额取可创房间 DB_Createroom
baseScore := int32(0) baseScore := int32(0)
gameSite := 0
playerTakeCoin := p.Coin playerTakeCoin := p.Coin
var dbCreateRoom *serverproto.DB_Createroom var dbCreateRoom *serverproto.DB_Createroom
arrs := srvdata.PBDB_CreateroomMgr.Datas.Arr arrs := srvdata.PBDB_CreateroomMgr.Datas.Arr
@ -225,26 +217,26 @@ func (l *CoinScenePoolLocal) NewScene(pool *CoinScenePool, p *Player) *Scene {
} }
if len(dbCreateRoom.GetBetRange()) != 0 && dbCreateRoom.GetBetRange()[0] != 0 { if len(dbCreateRoom.GetBetRange()) != 0 && dbCreateRoom.GetBetRange()[0] != 0 {
baseScore = common.RandInt32Slice(dbCreateRoom.GetBetRange()) baseScore = common.RandInt32Slice(dbCreateRoom.GetBetRange())
gameSite = int(dbCreateRoom.GetGameSite())
} }
if baseScore == 0 { if baseScore == 0 {
logger.Logger.Tracef("CoinScenePool CreateLocalGameNewScene failed! baseScore==0") logger.Logger.Tracef("CoinScenePool CreateLocalGameNewScene failed! baseScore==0")
return nil return nil
} }
scene := SceneMgrSingleton.CreateScene(&CreateSceneParam{
scene := SceneMgrSingleton.CreateLocalGameScene(p.SnId, sceneId, gameId, gameSite, common.SceneMode_Public, 1, common.CopySliceInt32ToInt64(params), CreateId: p.SnId,
gs, limitPlatform, 0, pool.dbGameFree, baseScore, 0, pool.ID()) RoomId: sceneId,
SceneMode: common.SceneMode_Public,
Params: common.CopySliceInt32ToInt64(params),
GS: nil,
Platform: limitPlatform,
GF: pool.dbGameFree,
BaseScore: baseScore,
})
return scene return scene
} }
func (l *CoinScenePoolLocal) NewPreCreateScene(pool *CoinScenePool) *Scene { func (l *CoinScenePoolLocal) NewPreCreateScene(pool *CoinScenePool) *Scene {
gameId := int(pool.dbGameRule.GetGameId()) gameId := int(pool.dbGameRule.GetGameId())
gs := GameSessMgrSington.GetMinLoadSess(gameId)
if gs == nil {
logger.Logger.Warnf("Get %v game min session failed.", gameId)
return nil
}
sceneId := SceneMgrSingleton.GenOneCoinSceneId() sceneId := SceneMgrSingleton.GenOneCoinSceneId()
params := pool.dbGameRule.GetParams() params := pool.dbGameRule.GetParams()
@ -261,7 +253,6 @@ func (l *CoinScenePoolLocal) NewPreCreateScene(pool *CoinScenePool) *Scene {
} }
//根据SceneType随机可创房间 DB_Createroom //根据SceneType随机可创房间 DB_Createroom
baseScore := int32(0) baseScore := int32(0)
gameSite := 0
var dbCreateRooms []*serverproto.DB_Createroom var dbCreateRooms []*serverproto.DB_Createroom
arrs := srvdata.PBDB_CreateroomMgr.Datas.Arr arrs := srvdata.PBDB_CreateroomMgr.Datas.Arr
for i := len(arrs) - 1; i >= 0; i-- { for i := len(arrs) - 1; i >= 0; i-- {
@ -281,13 +272,19 @@ func (l *CoinScenePoolLocal) NewPreCreateScene(pool *CoinScenePool) *Scene {
dbCreateRoom := dbCreateRooms[randIdx] dbCreateRoom := dbCreateRooms[randIdx]
if len(dbCreateRoom.GetBetRange()) != 0 && dbCreateRoom.GetBetRange()[0] != 0 { if len(dbCreateRoom.GetBetRange()) != 0 && dbCreateRoom.GetBetRange()[0] != 0 {
baseScore = common.RandInt32Slice(dbCreateRoom.GetBetRange()) baseScore = common.RandInt32Slice(dbCreateRoom.GetBetRange())
gameSite = int(dbCreateRoom.GetGameSite())
} }
if baseScore != 0 { if baseScore != 0 {
scene = SceneMgrSingleton.CreateLocalGameScene(0, sceneId, gameId, gameSite, common.SceneMode_Public, 1, common.CopySliceInt32ToInt64(params), scene = SceneMgrSingleton.CreateScene(&CreateSceneParam{
gs, limitPlatform, playerNum, pool.dbGameFree, baseScore, 0, pool.ID()) RoomId: sceneId,
SceneMode: common.SceneMode_Public,
Params: common.CopySliceInt32ToInt64(params),
Platform: limitPlatform,
GF: pool.dbGameFree,
PlayerNum: int32(playerNum),
BaseScore: baseScore,
})
if scene != nil { if scene != nil {
logger.Logger.Tracef("CreateLocalGameScene success.gameId:%v gameSite:%v baseScore:%v randIdx:%v", scene.gameId, scene.gameSite, baseScore, randIdx) logger.Logger.Tracef("CreateLocalGameScene success.gameId:%v gameSite:%v baseScore:%v randIdx:%v", scene.gameId, scene.dbGameFree.GetSceneType(), baseScore, randIdx)
} }
} }
} }

View File

@ -141,7 +141,7 @@ func init() {
}) })
PlatformMgrSingleton.UpdateRoomConfig(&webapi.RoomConfig{ PlatformMgrSingleton.UpdateRoomConfig(&webapi.RoomConfig{
Platform: "1", Platform: "1",
Id: 1, Id: 2,
Name: "{\"zh\":\"2元话费赛\",\"kh\":\"2元话费赛\",\"vi\":\"2元话费赛\",\"en\":\"2元话费赛\"}", Name: "{\"zh\":\"2元话费赛\",\"kh\":\"2元话费赛\",\"vi\":\"2元话费赛\",\"en\":\"2元话费赛\"}",
RoomType: 1, RoomType: 1,
On: 1, On: 1,

View File

@ -124,11 +124,7 @@ func UpdateGameConfigPolicy(fullPath string) error {
} }
if err == nil && spd.Init() { if err == nil && spd.Init() {
for _, m := range spd.GameMode { for _, m := range spd.GameMode {
//logger.Logger.Info("New game config ver:", spd.ConfigVer) RegisterScenePolicy(int(spd.GameId), int(m), spd)
if !CheckGameConfigVer(spd.ConfigVer, spd.GameId, m) {
//TeaHouseMgr.UpdateGameConfigVer(spd.ConfigVer, spd.GameId, m)
}
RegisteScenePolicy(int(spd.GameId), int(m), spd)
} }
} }
return err return err

View File

@ -160,56 +160,24 @@ func (this *GameSession) AddScene(s *Scene) {
GameMode: proto.Int(s.gameMode), GameMode: proto.Int(s.gameMode),
SceneMode: proto.Int(s.sceneMode), SceneMode: proto.Int(s.sceneMode),
Params: s.params, Params: s.params,
ParamsEx: s.paramsEx,
Creator: proto.Int32(s.creator), Creator: proto.Int32(s.creator),
Agentor: proto.Int32(s.agentor),
HallId: proto.Int32(s.hallId), HallId: proto.Int32(s.hallId),
ReplayCode: proto.String(s.replayCode), ReplayCode: proto.String(s.replayCode),
GroupId: proto.Int32(s.groupId), GroupId: proto.Int32(s.groupId),
TotalOfGames: proto.Int32(s.totalRound), TotalOfGames: proto.Int32(s.totalRound),
BaseScore: proto.Int32(s.BaseScore), BaseScore: proto.Int32(s.BaseScore),
PlayerNum: proto.Int(s.playerNum), PlayerNum: proto.Int(s.playerNum),
} DBGameFree: s.dbGameFree,
var platform *Platform Platform: s.limitPlatform.IdStr,
if s.limitPlatform != nil {
msg.Platform = proto.String(s.limitPlatform.IdStr)
platform = s.limitPlatform
} else {
msg.Platform = proto.String(DefaultPlatform)
platform = PlatformMgrSingleton.GetPlatform(DefaultPlatform)
}
if s.dbGameFree != nil {
msg.DBGameFree = s.dbGameFree
} else if platform != nil {
gps := PlatformMgrSingleton.GetGameFree(platform.IdStr, s.paramsEx[0])
if gps != nil {
if gps.GroupId == 0 {
msg.DBGameFree = gps.DbGameFree
} else {
pgg := PlatformGameGroupMgrSington.GetGameGroup(gps.GroupId)
if pgg != nil {
msg.DBGameFree = pgg.DbGameFree
}
}
}
} }
if s.IsCoinScene() { if s.IsCoinScene() {
if sp, ok := s.sp.(*ScenePolicyData); ok { if sp, ok := s.sp.(*ScenePolicyData); ok {
msg.EnterAfterStart = proto.Bool(sp.EnterAfterStart) msg.EnterAfterStart = proto.Bool(sp.EnterAfterStart)
} }
} }
//if s.ClubId > 0 {
// msg.Club = proto.Int32(s.ClubId)
// msg.ClubRoomId = proto.String(s.clubRoomID)
// msg.ClubRoomPos = proto.Int32(s.clubRoomPos)
// msg.ClubRate = proto.Int32(s.clubRoomTax)
//}
if s.IsHundredScene() {
//msg.RealCtrl = WBCtrlCfgMgr.GetRealCtrl(s.limitPlatform.IdStr)
}
// 象棋游戏添加段位配置 // 象棋游戏添加段位配置
if s.dbGameFree != nil && s.dbGameFree.GameDif == common.GameDifChess && platform != nil { if s.dbGameFree != nil && s.dbGameFree.GameDif == common.GameDifChess {
msg.ChessRank = ChessRankMgrSington.GetChessRankArr(platform.Name, int32(s.gameId)) msg.ChessRank = ChessRankMgrSington.GetChessRankArr(s.limitPlatform.Name, int32(s.gameId))
} }
proto.SetDefaults(msg) proto.SetDefaults(msg)
this.Send(int(server_proto.SSPacketID_PACKET_WG_CREATESCENE), msg) this.Send(int(server_proto.SSPacketID_PACKET_WG_CREATESCENE), msg)

View File

@ -201,12 +201,15 @@ func (this *HundredSceneMgr) CreateNewScene(id, groupId int32, limitPlatform *Pl
dbGameRule := srvdata.PBDB_GameRuleMgr.GetData(dbGameFree.GetGameRule()) dbGameRule := srvdata.PBDB_GameRuleMgr.GetData(dbGameFree.GetGameRule())
if dbGameRule != nil { if dbGameRule != nil {
gameId := int(dbGameRule.GetGameId()) gameId := int(dbGameRule.GetGameId())
gs := GameSessMgrSington.GetMinLoadSess(gameId)
if gs != nil {
sceneId := SceneMgrSingleton.GenOneHundredSceneId() sceneId := SceneMgrSingleton.GenOneHundredSceneId()
gameMode := dbGameRule.GetGameMode()
params := common.CopySliceInt32ToInt64(dbGameRule.GetParams()) params := common.CopySliceInt32ToInt64(dbGameRule.GetParams())
scene := SceneMgrSingleton.CreateScene(0, 0, sceneId, gameId, int(gameMode), common.SceneMode_Public, 1, -1, params, gs, limitPlatform, groupId, dbGameFree, id) scene := SceneMgrSingleton.CreateScene(&CreateSceneParam{
RoomId: sceneId,
SceneMode: common.SceneMode_Public,
Params: params,
Platform: limitPlatform,
GF: dbGameFree,
})
if scene != nil { if scene != nil {
logger.Logger.Infof("Create hundred scene %v-%v success.", gameId, sceneId) logger.Logger.Infof("Create hundred scene %v-%v success.", gameId, sceneId)
scene.hallId = id scene.hallId = id
@ -215,9 +218,6 @@ func (this *HundredSceneMgr) CreateNewScene(id, groupId int32, limitPlatform *Pl
} else { } else {
logger.Logger.Errorf("Create hundred scene %v-%v failed.", gameId, sceneId) logger.Logger.Errorf("Create hundred scene %v-%v failed.", gameId, sceneId)
} }
} else {
logger.Logger.Errorf("Game %v server session no found.", gameId)
}
} else { } else {
logger.Logger.Errorf("Game rule data %v no found.", dbGameFree.GetGameRule()) logger.Logger.Errorf("Game rule data %v no found.", dbGameFree.GetGameRule())
} }

View File

@ -23,20 +23,12 @@ type MatchSceneMgr struct {
// isFinals 是否决赛 // isFinals 是否决赛
// round 第几轮 // round 第几轮
func (ms *MatchSceneMgr) NewScene(tm *TmMatch, isFinals bool, round int32) *Scene { func (ms *MatchSceneMgr) NewScene(tm *TmMatch, isFinals bool, round int32) *Scene {
sceneId := SceneMgrSingleton.GenOneMatchSceneId()
gameId := int(tm.dbGameFree.GameId)
gameMode := tm.dbGameFree.GetGameMode()
// 获取游戏服务器
gs := GameSessMgrSington.GetMinLoadSess(gameId)
if gs == nil {
logger.Logger.Warn("not found game server, gameid: ", gameId)
return nil
}
// 平台 // 平台
limitPlatform := PlatformMgrSingleton.GetPlatform(tm.Platform) limitPlatform := PlatformMgrSingleton.GetPlatform(tm.Platform)
if limitPlatform == nil || !limitPlatform.Isolated { if limitPlatform == nil || !limitPlatform.Isolated {
limitPlatform = PlatformMgrSingleton.GetPlatform(DefaultPlatform) limitPlatform = PlatformMgrSingleton.GetPlatform(DefaultPlatform)
} }
sceneId := SceneMgrSingleton.GenOneMatchSceneId()
// 是否决赛 // 是否决赛
finals := int32(0) finals := int32(0)
if isFinals { if isFinals {
@ -54,13 +46,16 @@ func (ms *MatchSceneMgr) NewScene(tm *TmMatch, isFinals bool, round int32) *Scen
nextNeed = tm.gmd.MatchPromotion[round] nextNeed = tm.gmd.MatchPromotion[round]
} }
} }
groupId := PlatformMgrSingleton.GetGameFreeGroup(tm.Platform, tm.dbGameFree.Id)
// 建房参数 // 建房参数
// 比赛唯一索引,是否决赛,第几轮,本轮总人数,下一轮总人数,赛制类型 // 比赛唯一索引,是否决赛,第几轮,本轮总人数,下一轮总人数,赛制类型
params := []int64{tm.SortId, int64(finals), int64(round), int64(curPlayerNum), int64(nextNeed), int64(tm.gmd.MatchType)} params := []int64{tm.SortId, int64(finals), int64(round), int64(curPlayerNum), int64(nextNeed), int64(tm.gmd.MatchType)}
scene := SceneMgrSingleton.CreateScene(&CreateSceneParam{
scene := SceneMgrSingleton.CreateScene(0, 0, sceneId, gameId, int(gameMode), common.SceneMode_Match, 1, RoomId: sceneId,
0, params, gs, limitPlatform, groupId, tm.dbGameFree, tm.dbGameFree.GetId()) SceneMode: common.SceneMode_Match,
Params: params,
Platform: limitPlatform,
GF: tm.dbGameFree,
})
if scene != nil { if scene != nil {
scene.matchId = tm.SortId scene.matchId = tm.SortId
return scene return scene

View File

@ -53,8 +53,6 @@ type Platform struct {
Name string // 平台名称 Name string // 平台名称
Isolated bool // 是否孤立(别的平台看不到) Isolated bool // 是否孤立(别的平台看不到)
Disable bool // 是否禁用 Disable bool // 是否禁用
Halls map[int32]*PlatformGameHall //厅
GamePlayerNum map[int32]*PlatformGamePlayerNum //游戏人数
dirty bool // dirty bool //
ServiceUrl string //客服地址 ServiceUrl string //客服地址
BindOption int32 //绑定选项 BindOption int32 //绑定选项
@ -182,8 +180,6 @@ func NewPlatform(id int32, isolated bool) *Platform {
Id: id, Id: id,
IdStr: strconv.Itoa(int(id)), IdStr: strconv.Itoa(int(id)),
Isolated: isolated, Isolated: isolated,
Halls: make(map[int32]*PlatformGameHall),
GamePlayerNum: make(map[int32]*PlatformGamePlayerNum),
ClubConfig: &ClubConfig{}, ClubConfig: &ClubConfig{},
GameConfig: &GameList{ GameConfig: &GameList{
gameFreeId: make(map[int32]*webapiproto.GameFree), gameFreeId: make(map[int32]*webapiproto.GameFree),

View File

@ -1,71 +0,0 @@
package main
import (
"mongo.games.com/game/proto"
"mongo.games.com/game/protocol/gamehall"
"mongo.games.com/game/protocol/server"
)
type PlatformGameHall struct {
HallId int32 //游戏厅id
Scenes map[int]*Scene //游戏房间列表
Players map[int32]*Player //大厅中的玩家
p *Platform //所属平台
dbGameFree *server.DB_GameFree //厅配置数据(这里都是模板值,非后台实例数据)
dbGameRule *server.DB_GameRule //游戏配置数据(这里都是模板值,非后台实例数据)
}
func (pgh *PlatformGameHall) PlayerLeave(p *Player) {
delete(pgh.Players, p.SnId)
if p.hallId == pgh.HallId {
p.hallId = 0
}
}
func (p *Player) CreateRoomPlayerInfoProtocol() *gamehall.RoomPlayerInfo {
pack := &gamehall.RoomPlayerInfo{
SnId: proto.Int32(p.SnId),
Head: proto.Int32(p.Head),
Sex: proto.Int32(p.Sex),
Name: proto.String(p.Name),
Pos: proto.Int(p.pos),
Flag: proto.Int32(p.flag),
HeadOutLine: proto.Int32(p.HeadOutLine),
VIP: proto.Int32(p.VIP),
}
return pack
}
func (pgh *PlatformGameHall) OnPlayerEnterScene(scene *Scene, player *Player) {
delete(pgh.Players, player.SnId)
pack := &gamehall.SCRoomPlayerEnter{
RoomId: proto.Int(scene.sceneId),
Player: player.CreateRoomPlayerInfoProtocol(),
}
proto.SetDefaults(pack)
pgh.Broadcast(int(gamehall.GameHallPacketID_PACKET_SC_ROOMPLAYERENTER), pack, player.SnId)
}
func (pgh *PlatformGameHall) OnPlayerLeaveScene(scene *Scene, player *Player) {
pack := &gamehall.SCRoomPlayerLeave{
RoomId: proto.Int(scene.sceneId),
Pos: proto.Int(player.pos),
}
proto.SetDefaults(pack)
pgh.Broadcast(int(gamehall.GameHallPacketID_PACKET_SC_ROOMPLAYERLEAVE), pack, player.SnId)
}
func (pgh *PlatformGameHall) OnDestroyScene(scene *Scene) {
delete(pgh.Scenes, scene.sceneId)
pack := &gamehall.SCDestroyRoom{
RoomId: proto.Int(scene.sceneId),
OpRetCode: gamehall.OpResultCode_Game_OPRC_Sucess_Game,
IsForce: proto.Int(1),
}
proto.SetDefaults(pack)
pgh.Broadcast(int(gamehall.GameHallPacketID_PACKET_SC_DESTROYROOM), pack, 0)
}
func (pgh *PlatformGameHall) Broadcast(packetid int, packet interface{}, exclude int32) {
PlatformMgrSingleton.Broadcast(packetid, packet, pgh.Players, exclude)
}

View File

@ -2415,23 +2415,6 @@ func (this *Player) GetIP() string {
return this.Ip return this.Ip
} }
func (this *Player) CreateLocalGameScene(sceneId, gameId, gameSite, sceneMode, playerNum int, params []int64,
dbGameFree *serverproto.DB_GameFree, baseScore, groupId int32) (*Scene, hallproto.OpResultCode_Game) {
gs := GameSessMgrSington.GetMinLoadSess(gameId)
if gs == nil {
logger.Logger.Warnf("(this *Player) CreateLocalGameScene %v, %v GameSessMgrSington.GetMinLoadSess() = nil ", this.SnId, gameId)
return nil, hallproto.OpResultCode_Game_OPRC_SceneServerMaintain_Game
}
s := SceneMgrSingleton.CreateLocalGameScene(this.SnId, sceneId, gameId, gameSite, sceneMode, 1, params, gs,
this.GetPlatform(), playerNum, dbGameFree, baseScore, groupId, dbGameFree.GetId())
if s == nil {
logger.Logger.Tracef("(this *Player) EnterScene %v, SceneMgrSingleton.CreateScene() = nil ", this.SnId)
return nil, hallproto.OpResultCode_Game_OPRC_Error_Game
}
return s, hallproto.OpResultCode_Game_OPRC_Sucess_Game
}
func (this *Player) ReturnScene(isLoaded bool) *Scene { func (this *Player) ReturnScene(isLoaded bool) *Scene {
logger.Logger.Tracef("(this *Player) ReturnScene %v", this.SnId) logger.Logger.Tracef("(this *Player) ReturnScene %v", this.SnId)
if this.scene == nil { if this.scene == nil {

View File

@ -1,7 +1,6 @@
package main package main
import ( import (
"math"
"math/rand" "math/rand"
"strconv" "strconv"
"time" "time"
@ -19,15 +18,10 @@ import (
"mongo.games.com/game/proto" "mongo.games.com/game/proto"
hallproto "mongo.games.com/game/protocol/gamehall" hallproto "mongo.games.com/game/protocol/gamehall"
serverproto "mongo.games.com/game/protocol/server" serverproto "mongo.games.com/game/protocol/server"
webapiproto "mongo.games.com/game/protocol/webapi"
"mongo.games.com/game/srvdata" "mongo.games.com/game/srvdata"
) )
const (
MatchSceneState_Waiting = iota //等待状态
MatchSceneState_Running //进行状态
MatchSceneState_Billed //结算状态
)
const ( const (
// PlayerHistoryModel . // PlayerHistoryModel .
PlayerHistoryModel = iota + 1 PlayerHistoryModel = iota + 1
@ -45,30 +39,39 @@ type PlayerGameCtx struct {
totalConvertibleFlow int64 //进房时玩家身上的总流水 totalConvertibleFlow int64 //进房时玩家身上的总流水
} }
// MatchParams 比赛场配置
type MatchParams struct {
MatchId int64 // 比赛场id
}
// CustomParams 房卡场配置
type CustomParams struct {
RoomType *webapiproto.RoomType // 房卡场房间类型id
RoomConfig *webapiproto.RoomConfig // 房卡场房间配置id
RoomCostType int // 房卡收费方式
}
// Scene 场景(房间) // Scene 场景(房间)
// todo 结构优化
type Scene struct { type Scene struct {
sceneId int // 场景id sceneId int // 场景id
gameId int // 游戏id gameId int // 游戏id
gameMode int // 游戏模式(玩法) gameMode int // 游戏模式(玩法)
sceneMode int // 房间模式,参考common.SceneMode_XXX sceneMode int // 房间模式,参考common.SceneMode_XXX
params []int64 // 场景参数 params []int64 // 场景参数
paramsEx []int32 //其他扩展参数
playerNum int // 房间最大人数 playerNum int // 房间最大人数
robotNum int // 机器人数量 robotNum int // 机器人数量
robotLimit int // 最大限制机器人数量 robotLimit int // 最大限制机器人数量
preInviteRobNum int // 准备邀请机器人的数量 preInviteRobNum int // 准备邀请机器人的数量
creator int32 // 创建者账号id creator int32 // 创建者账号id
agentor int32 //代理者id
replayCode string // 回放码 replayCode string // 回放码
currRound int32 // 当前第几轮 currRound int32 // 当前第几轮
totalRound int32 //总共几轮 totalRound int32 // 总共几小于等于0表示无限
clycleTimes int32 //循环次数 cycleTimes int32 // 循环次数
deleting bool // 正在删除 deleting bool // 正在删除
starting bool // 正在开始 starting bool // 正在开始
closed bool // 房间已关闭 closed bool // 房间已关闭
force bool // 强制删除 force bool // 强制删除
hadCost bool //是否已经扣过房卡
inTeahourse bool //是否在棋牌馆
players map[int32]*Player // 玩家 players map[int32]*Player // 玩家
audiences map[int32]*Player // 观众 audiences map[int32]*Player // 观众
seats [9]*Player // 座位 seats [9]*Player // 座位
@ -77,126 +80,100 @@ type Scene struct {
createTime time.Time // 创建时间 createTime time.Time // 创建时间
lastTime time.Time // 最后活跃时间 lastTime time.Time // 最后活跃时间
startTime time.Time // 开始时间 startTime time.Time // 开始时间
dirty bool //脏标记
applyTimes map[int32]int32 // 申请坐下次数 applyTimes map[int32]int32 // 申请坐下次数
limitPlatform *Platform // 限制平台 limitPlatform *Platform // 限制平台
groupId int32 // 组id groupId int32 // 组id
hallId int32 // 厅id hallId int32 // 厅id
state int32 //场景当前状态 dbGameFree *serverproto.DB_GameFree // 场次配置
fishing int32 //渔场的鱼潮状态
gameCtx map[int32]*PlayerGameCtx // 进入房间的环境 gameCtx map[int32]*PlayerGameCtx // 进入房间的环境
dbGameFree *serverproto.DB_GameFree // BaseScore int32 // 游戏底分,优先级,创建参数>本地配置>场次配置
ClubId int32 SceneState int32 // 房间当前状态
clubRoomID string //俱乐部包间ID
clubRoomPos int32 //
clubRoomTax int32 //
createFee int32 //创建房间的费用
GameLog []int32 //游戏服务器同步的录单
JackPotFund int64 //游戏服务器同步的奖池
State int32 // 当前游戏状态后期放到ScenePolicy里去处理 State int32 // 当前游戏状态后期放到ScenePolicy里去处理
StateTs int64 // 切换到当前状态的时间 StateTs int64 // 切换到当前状态的时间
StateSec int32 // 押注状态的秒数 StateSec int32 // 押注状态的秒数
password string // 密码
channel []string // 渠道,房卡场有渠道限制
voice int32 // 是否开启语音 1开启
matchId int64 // 比赛场id
fishing int32 // 渔场的鱼潮状态
GameLog []int32 // 游戏服务器同步的录单
BankerListNum int32 // 庄家列表数量 BankerListNum int32 // 庄家列表数量
matchParams []int32 // 比赛参数 matchParams []int32 // 比赛参数
matchState int // 比赛状态 matchState int // 比赛状态
quitMatchSnids []int32 //退赛玩家id
gameSite int //tienlen游戏场次区分 1.初级 2.中级 3.高级场 CustomParams // 房卡场参数
BaseScore int32 //tienlen游戏底分
matchId int64 //比赛场id
csp *CoinScenePool // 所在场景池 csp *CoinScenePool // 所在场景池
hp *HundredSceneMgr // 百人场房间池 hp *HundredSceneMgr // 百人场房间池
} }
// NewScene 创建房间 // NewScene 创建房间
func NewScene(agentor, creator int32, id, gameId, gameMode, sceneMode int, clycleTimes, numOfGames int32, params []int64, func NewScene(args *CreateSceneParam) *Scene {
gs *GameSession, limitPlatform *Platform, groupId int32, dbGameFree *serverproto.DB_GameFree, paramsEx ...int32) *Scene { gameId := int(args.GF.GetGameId())
gameMode := int(args.GF.GetGameMode())
gameFreeId := args.GF.GetId()
sp := GetScenePolicy(gameId, gameMode) sp := GetScenePolicy(gameId, gameMode)
if sp == nil { if sp == nil {
logger.Logger.Errorf("NewScene sp == nil, gameId=%v gameMode=%v", gameId, gameMode) logger.Logger.Errorf("NewScene sp == nil, gameId=%v gameMode=%v", gameId, gameMode)
return nil return nil
} }
s := &Scene{ s := &Scene{
sceneId: id, sceneId: args.RoomId,
hallId: dbGameFree.Id, hallId: gameFreeId,
playerNum: 0, playerNum: int(args.PlayerNum),
creator: creator, creator: args.CreateId,
agentor: agentor,
gameId: gameId, gameId: gameId,
gameMode: gameMode, gameMode: gameMode,
sceneMode: sceneMode, sceneMode: args.SceneMode,
params: params, params: args.Params,
paramsEx: paramsEx, cycleTimes: int32(args.CycleTimes),
clycleTimes: clycleTimes,
players: make(map[int32]*Player), players: make(map[int32]*Player),
audiences: make(map[int32]*Player), audiences: make(map[int32]*Player),
gameSess: gs, gameSess: args.GS,
sp: sp, sp: sp,
createTime: time.Now(), createTime: time.Now(),
limitPlatform: limitPlatform, limitPlatform: args.Platform,
groupId: groupId, groupId: 0,
gameCtx: make(map[int32]*PlayerGameCtx), //进入房间的环境 gameCtx: make(map[int32]*PlayerGameCtx), //进入房间的环境
dbGameFree: dbGameFree, dbGameFree: args.GF,
currRound: 0, currRound: 0,
totalRound: numOfGames, totalRound: int32(args.TotalRound),
password: args.Password,
voice: args.Voice,
channel: args.Channel,
BaseScore: args.BaseScore,
CustomParams: CustomParams{
RoomType: args.RoomType,
RoomConfig: args.RoomConfig,
RoomCostType: args.RoomCostType,
},
}
// 最大房间人数
if s.playerNum <= 0 {
s.playerNum = sp.GetPlayerNum()
}
// 底分
if s.BaseScore <= 0 {
s.BaseScore = int32(sp.GetBaseScore())
}
if s.BaseScore <= 0 {
s.BaseScore = s.dbGameFree.GetBaseScore()
}
if s.cycleTimes <= 0 {
s.cycleTimes = 1
}
if s.totalRound <= 0 {
s.totalRound = 1
} }
// 从房间配置参数获取,最大房间人数
s.playerNum = int(sp.GetPlayerNum(s))
s.lastTime = s.createTime s.lastTime = s.createTime
s.replayCode = SceneMgrSingleton.AllocReplayCode()
if s.IsCoinScene() {
code := SceneMgrSingleton.AllocReplayCode()
s.replayCode = code
}
if s.dbGameFree.GetMatchMode() == 0 { if s.dbGameFree.GetMatchMode() == 0 {
s.RandRobotCnt() s.RandRobotCnt()
} }
if s.IsMatchScene() {
s.BaseScore = 10
}
s.sp.OnStart(s)
return s
}
func NewLocalGameScene(creator int32, sceneId, gameId, gameSite, sceneMode int, clycleTimes int32, params []int64,
gs *GameSession, limitPlatform *Platform, playerNum int, dbGameFree *serverproto.DB_GameFree, baseScore, groupId int32, paramsEx ...int32) *Scene {
sp := GetScenePolicy(gameId, 0)
if sp == nil {
logger.Logger.Errorf("NewLocalGameScene sp == nil, gameId=%v ", gameId)
return nil
}
s := &Scene{
sceneId: sceneId,
hallId: dbGameFree.Id,
playerNum: playerNum,
creator: creator,
gameId: gameId,
sceneMode: sceneMode,
params: params,
paramsEx: paramsEx,
clycleTimes: clycleTimes,
players: make(map[int32]*Player),
audiences: make(map[int32]*Player),
gameSess: gs,
sp: sp,
createTime: time.Now(),
limitPlatform: limitPlatform,
groupId: groupId,
gameCtx: make(map[int32]*PlayerGameCtx), //进入房间的环境
dbGameFree: dbGameFree,
gameSite: gameSite,
BaseScore: baseScore,
}
if s.playerNum <= 0 {
s.playerNum = int(sp.GetPlayerNum(s))
}
if s.BaseScore <= 0 {
s.BaseScore = int32(sp.GetBaseCoin(s))
}
s.lastTime = s.createTime
code := SceneMgrSingleton.AllocReplayCode()
s.replayCode = code
s.sp.OnStart(s) s.sp.OnStart(s)
return s return s
} }
@ -205,9 +182,6 @@ func (this *Scene) RebindPlayerSnId(oldSnId, newSnId int32) {
if this.creator == oldSnId { if this.creator == oldSnId {
this.creator = newSnId this.creator = newSnId
} }
if this.agentor == oldSnId {
this.agentor = newSnId
}
if p, exist := this.players[oldSnId]; exist { if p, exist := this.players[oldSnId]; exist {
delete(this.players, oldSnId) delete(this.players, oldSnId)
this.players[newSnId] = p this.players[newSnId] = p
@ -234,20 +208,18 @@ func (this *Scene) GetPlayerGameCtx(snid int32) *PlayerGameCtx {
return nil return nil
} }
// PlayerEnter 玩家进入场景
// todo 优化
func (this *Scene) PlayerEnter(p *Player, pos int, ischangeroom bool) bool { func (this *Scene) PlayerEnter(p *Player, pos int, ischangeroom bool) bool {
logger.Logger.Infof("(this *Scene:%v) PlayerEnter(%v, %v) ", this.sceneId, p.SnId, pos) logger.Logger.Infof("(this *Scene:%v) PlayerEnter(%v, %v) ", this.sceneId, p.SnId, pos)
if p.IsRob { // 机器人数量限制
if this.robotLimit != 0 { if p.IsRobot() && this.robotLimit != 0 {
if !model.GameParamData.IsRobFightTest {
//增加所有机器人对战场的
if this.robotNum+1 > this.robotLimit { if this.robotNum+1 > this.robotLimit {
logger.Logger.Warnf("(this *Scene:%v) PlayerEnter(%v) robot num limit(%v)", this.sceneId, p.SnId, this.robotLimit) logger.Logger.Warnf("(this *Scene:%v) PlayerEnter(%v) robot num limit(%v)", this.sceneId, p.SnId, this.robotLimit)
return false return false
} }
} }
}
}
// 非百人,设置座位 // 非百人,设置座位
if !this.IsHundredScene() { if !this.IsHundredScene() {
@ -275,10 +247,6 @@ func (this *Scene) PlayerEnter(p *Player, pos int, ischangeroom bool) bool {
} }
} }
p.scene = this
this.players[p.SnId] = p
this.gameSess.AddPlayer(p)
// 如果正在等待比赛,退赛 // 如果正在等待比赛,退赛
if !this.IsMatchScene() { if !this.IsMatchScene() {
isWaiting, tmid := TournamentMgr.IsMatchWaiting(p.Platform, p.SnId) isWaiting, tmid := TournamentMgr.IsMatchWaiting(p.Platform, p.SnId)
@ -287,10 +255,14 @@ func (this *Scene) PlayerEnter(p *Player, pos int, ischangeroom bool) bool {
} }
} }
p.scene = this
this.players[p.SnId] = p
this.gameSess.AddPlayer(p)
takeCoin := p.Coin takeCoin := p.Coin
leaveCoin := int64(0) leaveCoin := int64(0)
gameTimes := rand.Int31n(100) gameTimes := rand.Int31n(100)
matchParams := []int32{} //排名、段位、假snid、假角色、假皮肤 var matchParams []int32 //排名、段位、假snid、假角色、假皮肤
if this.IsMatchScene() && p.matchCtx != nil { if this.IsMatchScene() && p.matchCtx != nil {
takeCoin = int64(p.matchCtx.grade) takeCoin = int64(p.matchCtx.grade)
@ -303,19 +275,17 @@ func (this *Scene) PlayerEnter(p *Player, pos int, ischangeroom bool) bool {
matchParams = append(matchParams, p.matchCtx.copySnid) //假snid matchParams = append(matchParams, p.matchCtx.copySnid) //假snid
matchParams = append(matchParams, p.matchCtx.copyRoleId) //假RoleId matchParams = append(matchParams, p.matchCtx.copyRoleId) //假RoleId
matchParams = append(matchParams, p.matchCtx.copySkinId) //假SkinId matchParams = append(matchParams, p.matchCtx.copySkinId) //假SkinId
} else {
if p.IsRob {
if len(this.paramsEx) > 0 { //机器人携带金币动态调整
gps := PlatformMgrSingleton.GetGameFree(this.limitPlatform.IdStr, this.paramsEx[0])
if gps != nil {
dbGameFree := gps.DbGameFree
if gps.GroupId != 0 {
pgg := PlatformGameGroupMgrSington.GetGameGroup(gps.GroupId)
if pgg != nil {
dbGameFree = pgg.DbGameFree
}
} }
if this.IsCustom() {
takeCoin = 1000
}
if p.IsRob && !this.IsMatchScene() && !this.IsCustom() {
if this.dbGameFree != nil { //机器人携带金币动态调整
gps := PlatformMgrSingleton.GetGameFree(this.limitPlatform.IdStr, this.dbGameFree.GetId())
if gps != nil {
dbGameFree := gps.DbGameFree
flag := false flag := false
if common.IsLocalGame(this.gameId) { if common.IsLocalGame(this.gameId) {
baseScore := this.BaseScore baseScore := this.BaseScore
@ -323,7 +293,7 @@ func (this *Scene) PlayerEnter(p *Player, pos int, ischangeroom bool) bool {
tmpIds := []int32{} tmpIds := []int32{}
for i := 0; i < len(arrs); i++ { for i := 0; i < len(arrs); i++ {
arr := arrs[i] arr := arrs[i]
if int(arr.GameId) == this.gameId && int(arr.GameSite) == this.gameSite { if int(arr.GameId) == this.gameId && arr.GameSite == this.dbGameFree.GetSceneType() {
betRange := arr.GetBetRange() betRange := arr.GetBetRange()
if len(betRange) == 0 { if len(betRange) == 0 {
continue continue
@ -357,7 +327,7 @@ func (this *Scene) PlayerEnter(p *Player, pos int, ischangeroom bool) bool {
} }
} }
} else { } else {
logger.Logger.Warn("gameId: ", this.gameId, " gameSite: ", this.gameSite, " baseScore: ", baseScore) logger.Logger.Warn("gameId: ", this.gameId, " gameSite: ", this.dbGameFree.GetSceneType(), " baseScore: ", baseScore)
} }
if leaveCoin > takeCoin { if leaveCoin > takeCoin {
logger.Logger.Warn("robotSnId: ", p.SnId, " baseScore: ", baseScore, " takeCoin: ", takeCoin, " leaveCoin: ", leaveCoin) logger.Logger.Warn("robotSnId: ", p.SnId, " baseScore: ", baseScore, " takeCoin: ", takeCoin, " leaveCoin: ", leaveCoin)
@ -366,21 +336,6 @@ func (this *Scene) PlayerEnter(p *Player, pos int, ischangeroom bool) bool {
p.Coin = takeCoin p.Coin = takeCoin
} }
} }
//if !flag && this.IsCoinScene() && !this.IsTestScene() {
// if expectEnterCoin, expectLeaveCoin, ExpectGameTime, ok := RobotCarryMgrEx.RandOneCarry(dbGameFree.GetId()); ok && expectEnterCoin > dbGameFree.GetLimitCoin() && expectEnterCoin < dbGameFree.GetMaxCoinLimit() {
// takeCoin = int64(expectEnterCoin)
// leaveCoin = int64(expectLeaveCoin)
// //如果带入金币和离开金币比较接近,就调整离开金币值
// var delta = takeCoin - leaveCoin
// if math.Abs(float64(delta)) < float64(takeCoin/50) {
// if leaveCoin = takeCoin + delta*(10+rand.Int63n(50)); leaveCoin < 0 {
// leaveCoin = 0
// }
// }
// gameTimes = ExpectGameTime * 2
// flag = true
// }
//}
if !flag { if !flag {
takerng := dbGameFree.GetRobotTakeCoin() takerng := dbGameFree.GetRobotTakeCoin()
@ -417,33 +372,12 @@ func (this *Scene) PlayerEnter(p *Player, pos int, ischangeroom bool) bool {
p.ChessGrade = int64(common.RandInt(int(chessScore[0]), int(chessScore[1]))) p.ChessGrade = int64(common.RandInt(int(chessScore[0]), int(chessScore[1])))
} }
bankerLimit := this.dbGameFree.GetBanker()
if bankerLimit != 0 {
//上庄AI携带
if /*this.gameId == common.GameId_HundredBull ||*/
this.gameId == common.GameId_RollCoin ||
this.gameId == common.GameId_RollAnimals ||
this.gameId == common.GameId_DragonVsTiger ||
this.gameId == common.GameId_Baccarat {
if this.BankerListNum < 3 {
if rand.Intn(100) < 5 {
randCoin := int64(math.Floor(float64(bankerLimit) * 1 / float64(this.dbGameFree.GetSceneType())))
takeCoin = rand.Int63n(randCoin) + int64(bankerLimit)
if takeCoin > p.Coin {
//加钱速度慢 暂时不用
//ExePMCmd(p.gateSess, fmt.Sprintf("%v%v%v", common.PMCmd_AddCoin, common.PMCmd_SplitToken, takeCoin))
}
}
}
}
}
if takeCoin > p.Coin { if takeCoin > p.Coin {
p.Coin = takeCoin p.Coin = takeCoin
} }
} }
} }
} }
}
if p.IsRob { if p.IsRob {
this.robotNum++ this.robotNum++
@ -464,13 +398,6 @@ func (this *Scene) PlayerEnter(p *Player, pos int, ischangeroom bool) bool {
gateSid = sessionId.Get() gateSid = sessionId.Get()
} }
} }
isQuMin := false
//if !p.IsRob {
// pt := PlatformMgrSingleton.GetPackageTag(p.PackageID)
// if pt != nil && pt.SpreadTag == 1 {
// isQuMin = true
// }
//}
msg := &serverproto.WGPlayerEnter{ msg := &serverproto.WGPlayerEnter{
Sid: proto.Int64(p.sid), Sid: proto.Int64(p.sid),
SnId: proto.Int32(p.SnId), SnId: proto.Int32(p.SnId),
@ -478,17 +405,9 @@ func (this *Scene) PlayerEnter(p *Player, pos int, ischangeroom bool) bool {
SceneId: proto.Int(this.sceneId), SceneId: proto.Int(this.sceneId),
PlayerData: data, PlayerData: data,
IsLoaded: proto.Bool(ischangeroom), IsLoaded: proto.Bool(ischangeroom),
IsQM: proto.Bool(isQuMin),
IParams: p.MarshalIParam(), IParams: p.MarshalIParam(),
SParams: p.MarshalSParam(), SParams: p.MarshalSParam(),
CParams: p.MarshalCParam(), CParams: p.MarshalCParam(),
}
//sa, err2 := p.MarshalSingleAdjustData(this.dbGameFree.Id)
//if err2 == nil && sa != nil {
// msg.SingleAdjust = sa
//}
if this.ClubId != 0 {
} }
p.takeCoin = takeCoin p.takeCoin = takeCoin
p.sceneCoin = takeCoin p.sceneCoin = takeCoin
@ -880,6 +799,14 @@ func (this *Scene) IsPrivateScene() bool {
return this.sceneId >= common.PrivateSceneStartId && this.sceneId < common.PrivateSceneMaxId || this.sceneMode == common.SceneMode_Private return this.sceneId >= common.PrivateSceneStartId && this.sceneId < common.PrivateSceneMaxId || this.sceneMode == common.SceneMode_Private
} }
// IsCustom 房卡场房间
func (this *Scene) IsCustom() bool {
if this.dbGameFree == nil {
return false
}
return this.dbGameFree.IsCustom > 0
}
// IsSceneMode 房间模式 // IsSceneMode 房间模式
func (this *Scene) IsSceneMode(mode int) bool { func (this *Scene) IsSceneMode(mode int) bool {
return this.sceneMode == mode return this.sceneMode == mode
@ -898,12 +825,6 @@ func (this *Scene) IsTestScene() bool {
if this.dbGameFree != nil { if this.dbGameFree != nil {
return this.dbGameFree.GetSceneType() == -1 return this.dbGameFree.GetSceneType() == -1
} }
if len(this.paramsEx) > 0 {
dbGameFree := srvdata.PBDB_GameFreeMgr.GetData(this.paramsEx[0])
if dbGameFree != nil {
return dbGameFree.GetSceneType() == -1
}
}
return false return false
} }
@ -911,12 +832,6 @@ func (this *Scene) GetSceneName() string {
if this.dbGameFree != nil { if this.dbGameFree != nil {
return this.dbGameFree.GetName() + this.dbGameFree.GetTitle() return this.dbGameFree.GetName() + this.dbGameFree.GetTitle()
} }
if len(this.paramsEx) > 0 {
dbGameFree := srvdata.PBDB_GameFreeMgr.GetData(this.paramsEx[0])
if dbGameFree != nil {
return dbGameFree.GetName() + dbGameFree.GetTitle()
}
}
return "[unknow scene name]" return "[unknow scene name]"
} }
@ -935,30 +850,6 @@ func (this *Scene) RandRobotCnt() {
} }
return return
} }
if len(this.paramsEx) > 0 {
gps := PlatformMgrSingleton.GetGameFree(this.limitPlatform.IdStr, this.paramsEx[0])
if gps != nil {
dbGameFree := gps.DbGameFree
if gps.GroupId != 0 {
pgg := PlatformGameGroupMgrSington.GetGameGroup(gps.GroupId)
if pgg != nil {
dbGameFree = pgg.DbGameFree
}
}
numrng := dbGameFree.GetRobotNumRng()
if len(numrng) >= 2 {
if numrng[1] == numrng[0] {
this.robotLimit = int(numrng[0])
} else {
if numrng[1] < numrng[0] {
numrng[1], numrng[0] = numrng[0], numrng[1]
}
this.robotLimit = int(numrng[1]) //int(numrng[0] + rand.Int31n(numrng[1]-numrng[0]) + 1)
}
}
}
}
} }
func (this *Scene) IsPlatform(platform string) bool { func (this *Scene) IsPlatform(platform string) bool {
@ -1075,21 +966,6 @@ func (this *Scene) IsPreCreateScene() bool {
return this.dbGameFree.GetCreateRoomNum() > 0 return this.dbGameFree.GetCreateRoomNum() > 0
} }
func (this *Scene) GetParamEx(idx int) int32 {
if idx < 0 || idx > len(this.paramsEx) {
return -1
}
return this.paramsEx[idx]
}
func (this *Scene) SetParamEx(idx int, val int32) {
cnt := len(this.paramsEx)
if idx >= 0 && idx < cnt {
this.paramsEx[idx] = val
}
}
func (this *Scene) TryForceDeleteMatchInfo() { func (this *Scene) TryForceDeleteMatchInfo() {
if !this.IsMatchScene() { if !this.IsMatchScene() {
return return

View File

@ -2,7 +2,9 @@ package main
import ( import (
"math" "math"
"slices"
"sort" "sort"
"strconv"
"mongo.games.com/goserver/core/logger" "mongo.games.com/goserver/core/logger"
"mongo.games.com/goserver/srvlib" "mongo.games.com/goserver/srvlib"
@ -24,6 +26,7 @@ var SceneMgrSingleton = &SceneMgr{
matchAutoId: common.MatchSceneStartId, matchAutoId: common.MatchSceneStartId,
coinSceneAutoId: common.CoinSceneStartId, coinSceneAutoId: common.CoinSceneStartId,
hundredSceneAutoId: common.HundredSceneStartId, hundredSceneAutoId: common.HundredSceneStartId,
password: make(map[string]struct{}),
} }
// SceneMgr 房间管理器 // SceneMgr 房间管理器
@ -35,6 +38,7 @@ type SceneMgr struct {
matchAutoId int // 比赛场房间号 matchAutoId int // 比赛场房间号
coinSceneAutoId int // 金币场房间号 coinSceneAutoId int // 金币场房间号
hundredSceneAutoId int // 百人场房间号 hundredSceneAutoId int // 百人场房间号
password map[string]struct{} // 密码
} }
// AllocReplayCode 获取回访码 // AllocReplayCode 获取回访码
@ -79,6 +83,29 @@ func (m *SceneMgr) GenOneMatchSceneId() int {
return m.matchAutoId return m.matchAutoId
} }
func (m *SceneMgr) GenPassword() string {
for i := 0; i < 100; i++ {
s := strconv.Itoa(common.RandInt(10000, 100000))
if _, ok := m.password[s]; !ok {
m.password[s] = struct{}{}
return s
}
}
return ""
}
func (m *SceneMgr) GenPasswordInt32() int32 {
for i := 0; i < 100; i++ {
s := strconv.Itoa(common.RandInt(10000, 100000))
if _, ok := m.password[s]; !ok {
m.password[s] = struct{}{}
n, _ := strconv.Atoi(s)
return int32(n)
}
}
return 0
}
func (m *SceneMgr) GetPlatformBySceneId(sceneId int) string { func (m *SceneMgr) GetPlatformBySceneId(sceneId int) string {
s := m.GetScene(sceneId) s := m.GetScene(sceneId)
if s != nil && s.limitPlatform != nil { if s != nil && s.limitPlatform != nil {
@ -145,7 +172,7 @@ func (m *SceneMgr) MarshalAllRoom(platform string, groupId, gameId int, gameMode
roomInfo := make([]*webapiproto.RoomInfo, 0, len(m.scenes)) roomInfo := make([]*webapiproto.RoomInfo, 0, len(m.scenes))
var isNeedFindAll = false var isNeedFindAll = false
if model.GameParamData.IsFindRoomByGroup && platform != "" && snId != 0 && gameId == 0 && if model.GameParamData.IsFindRoomByGroup && platform != "" && snId != 0 && gameId == 0 &&
gameMode == 0 && sceneId == -1 && groupId == 0 && clubId == 0 && sceneMode == 0 { gameMode == 0 && sceneId == -1 && groupId == 0 && sceneMode == 0 {
p := PlayerMgrSington.GetPlayerBySnId(snId) p := PlayerMgrSington.GetPlayerBySnId(snId)
if p != nil && p.Platform == platform { if p != nil && p.Platform == platform {
isNeedFindAll = true isNeedFindAll = true
@ -155,7 +182,7 @@ func (m *SceneMgr) MarshalAllRoom(platform string, groupId, gameId int, gameMode
if (((s.limitPlatform != nil && s.limitPlatform.IdStr == platform) || platform == "") && if (((s.limitPlatform != nil && s.limitPlatform.IdStr == platform) || platform == "") &&
((s.gameId == gameId && s.gameMode == gameMode) || gameId == 0) && ((s.gameId == gameId && s.gameMode == gameMode) || gameId == 0) &&
(s.sceneId == sceneId || sceneId == 0) && (s.groupId == int32(groupId) || groupId == 0) && (s.sceneId == sceneId || sceneId == 0) && (s.groupId == int32(groupId) || groupId == 0) &&
(s.ClubId == int32(clubId) || clubId == 0) && (s.dbGameFree.GetId() == gameFreeId || gameFreeId == 0) && (s.dbGameFree.GetId() == gameFreeId || gameFreeId == 0) &&
(s.sceneMode == sceneMode || sceneMode == -1)) || isNeedFindAll { (s.sceneMode == sceneMode || sceneMode == -1)) || isNeedFindAll {
var platformName string var platformName string
if s.limitPlatform != nil { if s.limitPlatform != nil {
@ -170,19 +197,13 @@ func (m *SceneMgr) MarshalAllRoom(platform string, groupId, gameId int, gameMode
SceneMode: int32(s.sceneMode), SceneMode: int32(s.sceneMode),
GroupId: s.groupId, GroupId: s.groupId,
Creator: s.creator, Creator: s.creator,
Agentor: s.agentor,
ReplayCode: s.replayCode, ReplayCode: s.replayCode,
Params: common.CopySliceInt64ToInt32(s.params), Params: common.CopySliceInt64ToInt32(s.params),
PlayerCnt: int32(len(s.players) - s.robotNum), PlayerCnt: int32(len(s.players) - s.robotNum),
RobotCnt: int32(s.robotNum), RobotCnt: int32(s.robotNum),
CreateTime: s.createTime.Unix(), CreateTime: s.createTime.Unix(),
BaseScore: s.dbGameFree.BaseScore, BaseScore: s.dbGameFree.BaseScore,
} GameFreeId: s.dbGameFree.GetId(),
if common.IsLocalGame(s.gameId) {
si.BaseScore = s.BaseScore
}
if s.paramsEx != nil && len(s.paramsEx) > 0 {
si.GameFreeId = s.paramsEx[0]
} }
if s.starting { if s.starting {
si.Start = 1 si.Start = 1
@ -264,54 +285,138 @@ func (m *SceneMgr) MarshalAllRoom(platform string, groupId, gameId int, gameMode
return nil, 0, int32(roomSum) return nil, 0, int32(roomSum)
} }
type FindRoomParam struct {
Platform string
GameId []int
GameMode []int
SceneMode []int
RoomId int32
IsCustom int32 // 房卡场
IsFree int32 // 自由桌
GameFreeId []int32 // 场次id
SnId int32 // 玩家id
IsMatch bool // 比赛场
IsRankMatch bool // 排位赛
Channel []string // 渠道
}
func (m *SceneMgr) FindRoomList(args *FindRoomParam) []*Scene {
ret := make([]*Scene, 0)
for _, v := range m.scenes {
if args.Platform != "" && v.limitPlatform.IdStr != args.Platform {
continue
}
if len(args.GameId) > 0 {
if !slices.Contains(args.GameId, int(v.dbGameFree.GetGameId())) {
continue
}
}
if len(args.GameMode) > 0 {
if !slices.Contains(args.GameMode, int(v.dbGameFree.GetGameMode())) {
continue
}
}
if len(args.SceneMode) > 0 {
if !slices.Contains(args.SceneMode, v.sceneMode) {
continue
}
}
if args.RoomId > 0 && v.sceneId != int(args.RoomId) {
continue
}
if args.IsCustom == 1 && v.dbGameFree.GetIsCustom() != args.IsCustom {
continue
}
if args.IsFree == 1 && v.dbGameFree.GetFreeMode() != args.IsFree {
continue
}
if len(args.GameFreeId) > 0 {
if !slices.Contains(args.GameFreeId, v.dbGameFree.GetId()) {
continue
}
}
if args.SnId > 0 && v.GetPlayer(args.SnId) == nil {
continue
}
if args.IsMatch && !v.IsMatchScene() {
continue
}
if args.IsRankMatch && !v.IsRankMatch() {
continue
}
if len(args.Channel) > 0 {
has := false
for _, vv := range args.Channel {
if slices.Contains(v.channel, vv) {
has = true
break
}
}
if !has {
continue
}
}
if v.deleting || v.closed || v.force {
continue
}
ret = append(ret, v)
}
return ret
}
type CreateSceneParam struct {
CreateId int32 // 创建者id
RoomId int // 房间id
SceneMode int // 公共,私人,赛事
CycleTimes int // 循环次数
TotalRound int // 总轮数
Params []int64 // 房间参数
GS *GameSession
Platform *Platform
GF *serverproto.DB_GameFree
PlayerNum int32 // 玩家最大数量
Password string
Voice int32 // 1开启
Channel []string
RoomType *webapiproto.RoomType
RoomConfig *webapiproto.RoomConfig
BaseScore int32
RoomCostType int
}
// CreateScene 创建房间 // CreateScene 创建房间
func (m *SceneMgr) CreateScene(agentor, creator int32, sceneId, gameId, gameMode, sceneMode int, clycleTimes int32, func (m *SceneMgr) CreateScene(args *CreateSceneParam) *Scene {
numOfGames int32, params []int64, gs *GameSession, limitPlatform *Platform, groupId int32, dbGameFree *serverproto.DB_GameFree, logger.Logger.Tracef("SceneMgr NewScene %v", args)
paramsEx ...int32) *Scene { if args.GF == nil {
logger.Logger.Trace("(this *SceneMgr) CreateScene ") return nil
}
if args.Platform == nil {
return nil
}
if args.GS == nil {
args.GS = GameSessMgrSington.GetMinLoadSess(int(args.GF.GetGameId()))
}
if args.GS == nil {
return nil
}
// 创建房间 // 创建房间
s := NewScene(agentor, creator, sceneId, gameId, gameMode, sceneMode, clycleTimes, numOfGames, params, gs, limitPlatform, groupId, s := NewScene(args)
dbGameFree, paramsEx...)
if s == nil { if s == nil {
return nil return nil
} }
m.scenes[sceneId] = s m.scenes[args.RoomId] = s
// 添加到游戏服记录中
args.GS.AddScene(s)
logger.Logger.Infof("SceneMgr NewScene Platform:%v %+v", args.Platform.IdStr, args)
// 创建水池 // 创建水池
if !s.IsMatchScene() && dbGameFree != nil && limitPlatform != nil { if !s.IsMatchScene() && s.dbGameFree != nil && s.limitPlatform != nil {
//平台水池设置 //平台水池设置
gs.DetectCoinPoolSetting(limitPlatform.IdStr, dbGameFree.GetId(), s.groupId) args.GS.DetectCoinPoolSetting(s.limitPlatform.IdStr, s.dbGameFree.GetId(), s.groupId)
} }
// 添加到游戏服记录中
gs.AddScene(s)
var platformName string
if limitPlatform != nil {
platformName = limitPlatform.IdStr
}
logger.Logger.Infof("(this *SceneMgr) CreateScene (gameId=%v, mode=%v), SceneId=%v groupid=%v platform=%v",
gameId, gameMode, sceneId, groupId, platformName)
return s
}
// CreateLocalGameScene 创建本地游戏房间
func (m *SceneMgr) CreateLocalGameScene(creator int32, sceneId, gameId, gameSite, sceneMode int, clycleTimes int32, params []int64,
gs *GameSession, limitPlatform *Platform, playerNum int, dbGameFree *serverproto.DB_GameFree, baseScore, groupId int32,
paramsEx ...int32) *Scene {
logger.Logger.Trace("(this *SceneMgr) CreateLocalGameScene gameSite: ", gameSite, " sceneMode: ", sceneMode)
s := NewLocalGameScene(creator, sceneId, gameId, gameSite, sceneMode, clycleTimes, params, gs, limitPlatform, playerNum, dbGameFree,
baseScore, groupId, paramsEx...)
if s == nil {
return nil
}
m.scenes[sceneId] = s
gs.AddScene(s)
var platformName string
if limitPlatform != nil {
platformName = limitPlatform.IdStr
}
logger.Logger.Infof("(this *SceneMgr) CreateScene (gameId=%v), SceneId=%v platform=%v", gameId, sceneId, platformName)
return s return s
} }
@ -338,6 +443,7 @@ func (m *SceneMgr) DestroyScene(sceneId int, isCompleted bool) {
s.gameSess.DelScene(s) s.gameSess.DelScene(s)
s.OnClose() s.OnClose()
delete(m.scenes, s.sceneId) delete(m.scenes, s.sceneId)
delete(m.password, s.password)
logger.Logger.Infof("(this *SceneMgr) DestroyScene, SceneId=%v", sceneId) logger.Logger.Infof("(this *SceneMgr) DestroyScene, SceneId=%v", sceneId)
} }

View File

@ -1,50 +1,45 @@
package main package main
import "mongo.games.com/goserver/core/logger" import "mongo.games.com/game/protocol/webapi"
// 根据不同的房间模式,选择不同的房间业务策略 // ScenePolicyPool 根据不同的房间模式,选择不同的房间业务策略
var ScenePolicyPool map[int]map[int]ScenePolicy = make(map[int]map[int]ScenePolicy) var ScenePolicyPool = make(map[int]map[int]ScenePolicy)
type ScenePolicy interface { type ScenePolicy interface {
//场景开启事件 // OnStart 场景开启事件
OnStart(s *Scene) OnStart(s *Scene)
//场景关闭事件 // OnStop 场景关闭事件
OnStop(s *Scene) OnStop(s *Scene)
//场景心跳事件 // OnTick 场景心跳事件
OnTick(s *Scene) OnTick(s *Scene)
//玩家进入事件 // OnPlayerEnter 玩家进入事件
OnPlayerEnter(s *Scene, p *Player) OnPlayerEnter(s *Scene, p *Player)
//玩家离开事件 // OnPlayerLeave 玩家离开事件
OnPlayerLeave(s *Scene, p *Player) OnPlayerLeave(s *Scene, p *Player)
//系统维护关闭事件 // OnShutdown 系统维护关闭事件
OnShutdown(s *Scene) OnShutdown(s *Scene)
//获得场景的匹配因子(值越大越优先选择) // OnSceneState 房间状态变更
GetFitFactor(s *Scene, p *Player) int OnSceneState(s *Scene, state int)
//能否创建 // OnGameState 游戏状态变更
CanCreate(s *Scene, p *Player, mode, sceneType int, params []int32, isAgent bool) (bool, []int32) OnGameState(s *Scene, state int)
//能否进入
// CanEnter 能否进入
CanEnter(s *Scene, p *Player) int CanEnter(s *Scene, p *Player) int
//房间座位是否已满 // GetBetState 获取下注状态
IsFull(s *Scene, p *Player, num int32) bool
//是否可以强制开始
IsCanForceStart(s *Scene) bool
//结算房卡
BilledRoomCard(s *Scene, snid []int32)
//需要几张房卡
GetNeedRoomCardCnt(s *Scene) int32
//房费模式
GetRoomFeeMode(s *Scene) int32
//游戏人数
GetPlayerNum(s *Scene) int32
//游戏底分
GetBaseCoin(s *Scene) int
//游戏总局数
GetTotalOfGames(s *Scene) int32
//
GetNeedRoomCardCntDependentPlayerCnt(s *Scene) int32
//
GetBetState() int32 GetBetState() int32
GetViewLogLen() int32 // GetPlayerNum 获取玩家数量
GetPlayerNum() int
// GetBaseScore 获取底分
GetBaseScore() int
// CostEnough 房费是否足够
// costType 付费方式
// playerNum 玩家数量
// roomConfig 房间配置
CostEnough(costType, playerNum int, roomConfig *webapi.RoomConfig, p *Player) bool
// CostPayment 房费支付
CostPayment(s *Scene, p *Player) bool
} }
func GetScenePolicy(gameId, mode int) ScenePolicy { func GetScenePolicy(gameId, mode int) ScenePolicy {
@ -56,7 +51,7 @@ func GetScenePolicy(gameId, mode int) ScenePolicy {
return nil return nil
} }
func RegisteScenePolicy(gameId, mode int, sp ScenePolicy) { func RegisterScenePolicy(gameId, mode int, sp ScenePolicy) {
pool := ScenePolicyPool[gameId] pool := ScenePolicyPool[gameId]
if pool == nil { if pool == nil {
pool = make(map[int]ScenePolicy) pool = make(map[int]ScenePolicy)
@ -66,21 +61,3 @@ func RegisteScenePolicy(gameId, mode int, sp ScenePolicy) {
pool[mode] = sp pool[mode] = sp
} }
} }
func CheckGameConfigVer(ver int32, gameid int32, modeid int32) bool {
v := GetGameConfigVer(gameid, modeid)
logger.Logger.Info("Old game config ver:", v)
return ver == v
}
func GetGameConfigVer(gameid int32, modeid int32) int32 {
sp := GetScenePolicy(int(gameid), int(modeid))
if sp == nil {
return 0
}
spd, ok := sp.(*ScenePolicyData)
if !ok {
return 0
}
return spd.ConfigVer
}

View File

@ -1,158 +1,27 @@
package main package main
import ( import (
"time" "math"
"mongo.games.com/game/common" "mongo.games.com/game/common"
hall_proto "mongo.games.com/game/protocol/gamehall" hallproto "mongo.games.com/game/protocol/gamehall"
"mongo.games.com/goserver/core/logger" "mongo.games.com/game/protocol/webapi"
) )
const (
SPDPCustomIndex_GamesOfCard int = iota //局数选项
SPDPCustomIndex_PlayerNum //人数选项
SPDPCustomIndex_RoomFeeMode //房费模式选项
SPDPCustomIndex_LimitOption //新手限制选项
SPDPCustomIndex_DoorOption //中途不可进选项
SPDPCustomIndex_SameIPForbid //同IP不可进
SPDPCustomIndex_BaseCoin //房间底分
)
// 创建房间选项
const (
CreateRoomParam_NumOfGames int = iota //局数选项
CreateRoomParam_DoorOption //中途允许加入选项
CreateRoomParam_SameIPForbid //同IP不可进
CreateRoomParam_Max
)
type ScenePolicyDataParam struct {
Name string
AliasName string
Desc string
Min int32
Max int32
Default int32
Value []int32
Value2 []int32
CustomIndex int32
index int
}
type ScenePolicyData struct { type ScenePolicyData struct {
GameName string GameName string
GameId int32 GameId int32
GameMode []int32 GameMode []int32
CanForceStart bool
MinPlayerCnt int32
DefaultPlayerCnt int32 DefaultPlayerCnt int32
MaxIndex int32
TimeFreeStart int32
TimeFreeEnd int32
DependentPlayerCnt bool
EnterAfterStart bool EnterAfterStart bool
ConfigVer int32
PerGameTakeCard int32
ViewLogCnt int32
BetState int32 BetState int32
Params []ScenePolicyDataParam BaseScore int
nameMap map[string]*ScenePolicyDataParam
aliasNameMap map[string]*ScenePolicyDataParam
customIndexParams []*ScenePolicyDataParam
} }
func (spd *ScenePolicyData) Init() bool { func (spd *ScenePolicyData) Init() bool {
spd.nameMap = make(map[string]*ScenePolicyDataParam)
spd.aliasNameMap = make(map[string]*ScenePolicyDataParam)
if spd.MaxIndex > 0 {
spd.customIndexParams = make([]*ScenePolicyDataParam, spd.MaxIndex)
}
for i := 0; i < len(spd.Params); i++ {
spd.nameMap[spd.Params[i].Name] = &spd.Params[i]
spd.Params[i].index = i
spd.aliasNameMap[spd.Params[i].AliasName] = &spd.Params[i]
if spd.Params[i].CustomIndex >= 0 && spd.MaxIndex > 0 {
spd.customIndexParams[spd.Params[i].CustomIndex] = &spd.Params[i]
}
}
return true return true
} }
func (spd *ScenePolicyData) GetParam(idx int) *ScenePolicyDataParam { func (spd *ScenePolicyData) OnStart(s *Scene) {}
if idx >= 0 && idx < len(spd.Params) {
return &spd.Params[idx]
}
return nil
}
func (spd *ScenePolicyData) GetParamByIndex(idx int) *ScenePolicyDataParam {
if idx >= 0 && idx < len(spd.customIndexParams) {
return spd.customIndexParams[idx]
}
return nil
}
func (spd *ScenePolicyData) GetParamByName(name string) *ScenePolicyDataParam {
if spdp, exist := spd.nameMap[name]; exist {
return spdp
}
return nil
}
func (spd *ScenePolicyData) GetParamByAliasName(name string) *ScenePolicyDataParam {
if spdp, exist := spd.aliasNameMap[name]; exist {
return spdp
}
return nil
}
func (spd *ScenePolicyData) IsTimeFree(mode int) bool {
//是否限时免费
ts := int32(time.Now().Unix())
if ts >= spd.TimeFreeStart && ts < spd.TimeFreeEnd {
return true
}
return false
}
func (spd *ScenePolicyData) IsEnoughRoomCardCnt(s *Scene, p *Player, roomFeeParam, needCardCnt, playerNum int32, isAgent bool) bool {
return true
}
func (spd *ScenePolicyData) CostRoomCard(s *Scene, roomFeeParam, needCardCnt, playerNum int32, snid []int32) {
}
func (spd *ScenePolicyData) UpRoomCard(s *Scene, roomFeeParam, needCardCnt, playerNum int32) {
}
//ScenePolicy interface
// 能否进入
func (spd *ScenePolicyData) CanCreate(s *Scene, p *Player, mode, sceneType int, params []int32, isAgent bool) (bool, []int32) {
//参数容错处理
if len(params) < len(spd.Params) {
logger.Logger.Infof("ScenePolicyData.CanCreate param count not enough, need:%v get:%v", len(spd.Params), len(params))
for i := len(params); i < len(spd.Params); i++ {
params = append(params, spd.Params[i].Default)
}
}
//确保参数正确
for i := 0; i < len(params); i++ {
if params[i] < spd.Params[i].Min || params[i] > spd.Params[i].Max {
params[i] = spd.Params[i].Default
}
}
return true, params
}
func (spd *ScenePolicyData) OnStart(s *Scene) {
}
func (spd *ScenePolicyData) ReturnRoomCard(s *Scene, roomFeeParam, needCardCnt, playerNum int32) {
}
// 场景关闭事件 // 场景关闭事件
func (spd *ScenePolicyData) OnStop(s *Scene) { func (spd *ScenePolicyData) OnStop(s *Scene) {
@ -178,162 +47,100 @@ func (spd *ScenePolicyData) OnShutdown(s *Scene) {
} }
// 获得场景的匹配因子(值越大越优先选择) func (spd *ScenePolicyData) OnSceneState(s *Scene, state int) {
func (spd *ScenePolicyData) GetFitFactor(s *Scene, p *Player) int { s.SceneState = int32(state)
return len(s.players) switch state {
case common.SceneStateWaite:
case common.SceneStateStart:
if s.IsCustom() {
for _, v := range s.players {
spd.CostPayment(s, v)
}
} }
// 是否满座了 case common.SceneStateEnd:
func (spd *ScenePolicyData) IsFull(s *Scene, p *Player, num int32) bool {
if s.HasPlayer(p) {
return false
} }
return s.GetPlayerCnt() >= int(num)
} }
// 是否可以强制开始 func (spd *ScenePolicyData) OnGameState(s *Scene, state int) {
func (spd *ScenePolicyData) IsCanForceStart(s *Scene) bool {
return spd.CanForceStart && s.GetPlayerCnt() >= int(spd.MinPlayerCnt)
}
// 结算房卡
func (spd *ScenePolicyData) BilledRoomCard(s *Scene, snid []int32) {
//spd.CostRoomCard(s, spd.GetRoomFeeMode(s), spd.GetNeedRoomCardCnt(s), int32(len(s.players)), snid)
}
func (spd *ScenePolicyData) getNeedRoomCardCnt(params []int32) int32 {
return 0
}
// 需求房卡数量
func (spd *ScenePolicyData) GetNeedRoomCardCnt(s *Scene) int32 {
return 0
}
//func (spd *ScenePolicyData) getRoomFeeMode(params []int32) int32 {
// //if len(params) > 0 {
// // param := spd.GetParamByIndex(SPDPCustomIndex_RoomFeeMode)
// // if param != nil && param.index >= 0 && param.index < len(params) {
// // return params[param.index]
// // }
// //}
// return common.RoomFee_Owner
//}
// 收费方式(AA|房主付费)
func (spd *ScenePolicyData) GetRoomFeeMode(s *Scene) int32 {
//if s != nil {
// return spd.getRoomFeeMode(s.params)
//}
return 0
}
func (spd *ScenePolicyData) GetNeedRoomCardCntDependentPlayerCnt(s *Scene) int32 {
return 0
} }
// 能否进入 // 能否进入
func (spd *ScenePolicyData) CanEnter(s *Scene, p *Player) int { func (spd *ScenePolicyData) CanEnter(s *Scene, p *Player) int {
param := spd.GetParamByIndex(SPDPCustomIndex_SameIPForbid)
if param != nil && len(s.params) <= param.index {
logger.Logger.Errorf("game param len too long %v", s.gameId)
}
if param != nil && len(s.params) > param.index && s.params[param.index] != 0 {
ip := p.GetIP()
for i := 0; i < s.playerNum; i++ {
pp := s.seats[i]
if pp != nil && pp.GetIP() == ip {
return int(hall_proto.OpResultCode_Game_OPRC_SameIpForbid_Game)
}
}
}
if !spd.EnterAfterStart { if !spd.EnterAfterStart {
if s.starting { if s.starting {
return int(hall_proto.OpResultCode_Game_OPRC_GameStarting_Game) return int(hallproto.OpResultCode_Game_OPRC_GameStarting_Game)
}
}
if spd.EnterAfterStart {
if s.starting {
param := spd.GetParamByIndex(SPDPCustomIndex_DoorOption)
if param != nil && s.params[param.index] != 0 {
return int(hall_proto.OpResultCode_Game_OPRC_GameStarting_Game)
//} else {
// return int(hall_proto.OpResultCode_OPRC_SceneEnterForWatcher)
}
} }
} }
return 0 return 0
} }
// 人数 func (spd *ScenePolicyData) costEnough(costType, playerNum int, roomConfig *webapi.RoomConfig, p *Player, f func(items []*Item)) bool {
func (spd *ScenePolicyData) getPlayerNum(params []int32) int32 { isEnough := true
if len(params) > 0 { var items []*Item
param := spd.GetParamByIndex(SPDPCustomIndex_PlayerNum) if costType == 1 {
if param != nil { // 房主
idx := int(params[param.index]) for _, v := range roomConfig.GetCost() {
if idx >= 0 && idx < len(param.Value) { if item := BagMgrSingleton.GetItem(p.SnId, v.GetItemId()); item == nil || item.ItemNum < v.GetItemNum() {
val := param.Value[idx] isEnough = false
return val break
} else {
items = append(items, &Item{
ItemId: v.GetItemId(),
ItemNum: v.GetItemNum(),
})
}
}
} else {
// AA
for _, v := range roomConfig.GetCost() {
n := int64(math.Ceil(float64(v.GetItemNum()) / float64(playerNum)))
if item := BagMgrSingleton.GetItem(p.SnId, v.GetItemId()); item == nil || item.ItemNum < n {
isEnough = false
break
} else {
items = append(items, &Item{
ItemId: v.GetItemId(),
ItemNum: v.GetItemNum(),
})
} }
} }
} }
return spd.DefaultPlayerCnt if isEnough {
f(items)
}
return isEnough
} }
func (spd *ScenePolicyData) GetPlayerNum(s *Scene) int32 { func (spd *ScenePolicyData) CostEnough(costType, playerNum int, roomConfig *webapi.RoomConfig, p *Player) bool {
if s != nil { return spd.costEnough(costType, playerNum, roomConfig, p, func(items []*Item) {})
return spd.getPlayerNum(common.CopySliceInt64ToInt32(s.params))
}
return spd.DefaultPlayerCnt
} }
func (spd *ScenePolicyData) getBaseCoin(params []int32) int { func (spd *ScenePolicyData) CostPayment(s *Scene, p *Player) bool {
if len(params) > 0 { return spd.costEnough(s.RoomCostType, s.playerNum, s.RoomConfig, p, func(items []*Item) {
param := spd.GetParamByIndex(SPDPCustomIndex_BaseCoin) BagMgrSingleton.AddItemsV2(&ItemParam{
if param != nil { P: p,
idx := int(params[param.index]) Change: items,
if idx >= 0 && idx < len(param.Value) { GainWay: common.GainWayRoomCost,
val := param.Value[idx] Operator: "system",
return int(val) Remark: "竞技馆进房费用",
} GameId: int64(s.gameId),
} GameFreeId: int64(s.dbGameFree.GetId()),
} })
return 0 })
}
func (spd *ScenePolicyData) GetBaseCoin(s *Scene) int {
if s != nil {
return spd.getBaseCoin(common.CopySliceInt64ToInt32(s.params))
}
return 0
}
// 局数
func (spd *ScenePolicyData) GetTotalOfGames(s *Scene) int32 {
//if len(s.params) > 0 {
// param := spd.GetParamByIndex(SPDPCustomIndex_GamesOfCard)
// if param != nil {
// cardCostIdx := int(s.params[param.index])
// if cardCostIdx >= 0 && cardCostIdx < len(param.Value) {
// costCardNum := param.Value[cardCostIdx]
// return costCardNum
// } else if int32(cardCostIdx) >= common.CUSTOM_PER_GAME_INDEX_BEG { //自定义局数
// totalOfGames := int32(cardCostIdx) - common.CUSTOM_PER_GAME_INDEX_BEG + 1
// return totalOfGames
// }
// }
//}
//return 4
return s.totalRound
} }
func (spd *ScenePolicyData) GetBetState() int32 { func (spd *ScenePolicyData) GetBetState() int32 {
return spd.BetState return spd.BetState
} }
func (spd *ScenePolicyData) GetViewLogLen() int32 { func (spd *ScenePolicyData) GetPlayerNum() int {
return spd.ViewLogCnt return int(spd.DefaultPlayerCnt)
}
func (spd *ScenePolicyData) GetBaseScore() int {
return int(spd.BaseScore)
} }

View File

@ -1636,6 +1636,10 @@ func init() {
pack.Msg = "no found" pack.Msg = "no found"
return common.ResponseTag_NoData, pack return common.ResponseTag_NoData, pack
} else { } else {
gameFreeId := int32(0)
if s.dbGameFree != nil {
gameFreeId = s.dbGameFree.GetId()
}
si := &webapiproto.RoomInfo{ si := &webapiproto.RoomInfo{
Platform: s.limitPlatform.Name, Platform: s.limitPlatform.Name,
SceneId: int32(s.sceneId), SceneId: int32(s.sceneId),
@ -1643,9 +1647,8 @@ func init() {
GameMode: int32(s.gameMode), GameMode: int32(s.gameMode),
SceneMode: int32(s.sceneMode), SceneMode: int32(s.sceneMode),
GroupId: s.groupId, GroupId: s.groupId,
GameFreeId: s.paramsEx[0], GameFreeId: gameFreeId,
Creator: s.creator, Creator: s.creator,
Agentor: s.agentor,
ReplayCode: s.replayCode, ReplayCode: s.replayCode,
Params: common.CopySliceInt64ToInt32(s.params), Params: common.CopySliceInt64ToInt32(s.params),
PlayerCnt: int32(len(s.players) - s.robotNum), PlayerCnt: int32(len(s.players) - s.robotNum),

View File

@ -895,9 +895,9 @@ func (this *WelfareMgr) GetAddUp2Award(p *Player, day int32) {
GainWay: common.GainWaySign7Add, GainWay: common.GainWaySign7Add,
Operator: "system", Operator: "system",
Remark: "累计签到进阶奖励获得", Remark: "累计签到进阶奖励获得",
gameId: 0, GameId: 0,
gameFreeId: 0, GameFreeId: 0,
noLog: false, NoLog: false,
}) })
} }
//通知客户端 //通知客户端

Binary file not shown.