|
|
@ -3,6 +3,7 @@ package game |
|
|
|
import ( |
|
|
|
"base/log" |
|
|
|
"github.com/shopspring/decimal" |
|
|
|
"sort" |
|
|
|
"strconv" |
|
|
|
"time" |
|
|
|
"xgame/game/DZ/app/core/protocol" |
|
|
@ -43,14 +44,33 @@ func (rr *Room) OnUserOperate(uid int64, msg interface{}) { // 用户操作 |
|
|
|
return |
|
|
|
} |
|
|
|
|
|
|
|
if message.UserScore < 0 { |
|
|
|
log.Debug("玩家", ChairId, "个人下注总值", message.UserScore, " 拥有的钱: ", rr.PlayerMap[ChairId].Gold.IntPart()) |
|
|
|
OperateRes.Code = protocol.ErrorCodeOperateError |
|
|
|
OperateRes.CodeMsg = "下注额异常 " + strconv.Itoa(int(message.UserScore)) |
|
|
|
rr.Send(rr.PlayerMap[ChairId], route.OperateRes, OperateRes) |
|
|
|
return |
|
|
|
} |
|
|
|
|
|
|
|
player := rr.PlayerMap[ChairId] |
|
|
|
player.GameCurrenRoundState = message.OperateCode |
|
|
|
log.Debug(" 桌子号", rr.RId, " 当前操作玩家", rr.CurrOperationPlayer, " 操作(1跟2加3弃4All5过) ", message.OperateCode) |
|
|
|
log.Debug(" 桌子号", rr.RId, " 当前第几轮 ", rr.CurrGameRound, " 本轮需要下注", rr.CellScore, " 本轮下注 ", player.RoundScore, " 要加注的钱", message.UserScore) |
|
|
|
TempCellScore := int64(0) |
|
|
|
switch message.OperateCode { |
|
|
|
case protocol.OperateGen: |
|
|
|
rr.CanCheck = false |
|
|
|
|
|
|
|
TempCellScore = rr.CellScore - player.RoundScore |
|
|
|
|
|
|
|
// 判断和操作是否相符
|
|
|
|
if player.TableScore < TempCellScore || TempCellScore < 0 { |
|
|
|
log.Debug("玩家", ChairId, "桌子上的前", player.TableScore, " 要跟注的钱: ", TempCellScore) |
|
|
|
OperateRes.Code = protocol.ErrorCodeOperateError |
|
|
|
OperateRes.CodeMsg = "下注额异常 " + strconv.Itoa(int(player.TableScore)) |
|
|
|
rr.Send(rr.PlayerMap[ChairId], route.OperateRes, OperateRes) |
|
|
|
return |
|
|
|
} |
|
|
|
|
|
|
|
rr.CanCheck = false |
|
|
|
player.CellScore += TempCellScore |
|
|
|
player.RoundScore += TempCellScore |
|
|
|
|
|
|
@ -58,14 +78,29 @@ func (rr *Room) OnUserOperate(uid int64, msg interface{}) { // 用户操作 |
|
|
|
player.Gold = player.Gold.Sub(decimal.NewFromInt(TempCellScore)) |
|
|
|
|
|
|
|
if !player.IsRobot && (player.Ctx != nil) && (TempCellScore != 0) { |
|
|
|
AfterGold, BloodPool, StockNum := rr.WriteUserScore(player, 1, TempCellScore, 0, 0, rr.ReasonString, "", "", 0) |
|
|
|
AfterGold, BloodPool, StockNum := rr.WriteUserScore(player, 1, TempCellScore, 0, 0, rr.ReasonString, "", "", 0, 0) |
|
|
|
log.Debug(" 桌子号", rr.RId, " 跟注 WriteUserScore 后 AfterGold=", AfterGold, " BloodPool=", BloodPool, " StockNum=", StockNum) |
|
|
|
} |
|
|
|
rr.TableCurrentScore += TempCellScore |
|
|
|
|
|
|
|
player.TableScore -= TempCellScore |
|
|
|
log.Debug(" 桌子号", rr.RId, " 跟注 当前操作玩家", rr.CurrOperationPlayer, " TempCellScore ", TempCellScore, " TableScore ", player.TableScore) |
|
|
|
case protocol.OperateJia: |
|
|
|
rr.RoundSubBet = true |
|
|
|
TempCellScore = message.UserScore |
|
|
|
|
|
|
|
// 判断和操作是否相符
|
|
|
|
if player.TableScore < TempCellScore || TempCellScore <= 0 { |
|
|
|
log.Debug("玩家", ChairId, "桌子上的前", player.TableScore, " 要加注的钱: ", TempCellScore) |
|
|
|
OperateRes.Code = protocol.ErrorCodeOperateError |
|
|
|
OperateRes.CodeMsg = "下注额异常 " + strconv.Itoa(int(player.TableScore)) |
|
|
|
rr.Send(rr.PlayerMap[ChairId], route.OperateRes, OperateRes) |
|
|
|
return |
|
|
|
} |
|
|
|
|
|
|
|
rr.CanCheck = false |
|
|
|
|
|
|
|
rr.CellScore *= 2 |
|
|
|
TempCellScore = rr.CellScore - player.RoundScore |
|
|
|
rr.CellScore = player.RoundScore + message.UserScore |
|
|
|
player.CellScore += TempCellScore |
|
|
|
player.RoundScore += TempCellScore |
|
|
|
|
|
|
@ -73,52 +108,75 @@ func (rr *Room) OnUserOperate(uid int64, msg interface{}) { // 用户操作 |
|
|
|
player.Gold = player.Gold.Sub(decimal.NewFromInt(TempCellScore)) |
|
|
|
|
|
|
|
if !player.IsRobot && (player.Ctx != nil) { |
|
|
|
AfterGold, BloodPool, StockNum := rr.WriteUserScore(player, 1, TempCellScore, 0, 0, rr.ReasonString, "", "", 0) |
|
|
|
AfterGold, BloodPool, StockNum := rr.WriteUserScore(player, 1, TempCellScore, 0, 0, rr.ReasonString, "", "", 0, 0) |
|
|
|
log.Debug(" 桌子号", rr.RId, " 定庄后 下注 WriteUserScore 后 AfterGold=", AfterGold, " BloodPool=", BloodPool, " StockNum=", StockNum) |
|
|
|
} |
|
|
|
rr.TableCurrentScore += TempCellScore |
|
|
|
|
|
|
|
player.TableScore -= TempCellScore |
|
|
|
log.Debug(" 桌子号", rr.RId, " 加注 当前操作玩家", rr.CurrOperationPlayer, " TempCellScore ", TempCellScore, " TableScore ", player.TableScore) |
|
|
|
case protocol.OperateGaveUp: |
|
|
|
// 玩家标识为已放弃
|
|
|
|
player.GameState = 1 |
|
|
|
case protocol.OperateAll: |
|
|
|
rr.RoundSubBet = true |
|
|
|
rr.CanCheck = false |
|
|
|
rr.bUserAllIn = true |
|
|
|
player.GameState = 2 |
|
|
|
// TODO: 这儿怎么处理
|
|
|
|
TempCellScore = player.Gold.IntPart() |
|
|
|
TempCellScore = player.TableScore |
|
|
|
player.CellScore += TempCellScore |
|
|
|
player.RoundScore += TempCellScore |
|
|
|
|
|
|
|
if player.Gold.IntPart() > rr.CellScore { |
|
|
|
rr.CellScore *= 2 |
|
|
|
} |
|
|
|
|
|
|
|
// 计算分池
|
|
|
|
for _, tempPlayer := range rr.PlayerMap { |
|
|
|
if tempPlayer.CanBet { |
|
|
|
player.WinTableScore += tempPlayer.CellScore |
|
|
|
} |
|
|
|
if player.RoundScore > rr.CellScore { |
|
|
|
rr.CellScore = player.RoundScore |
|
|
|
} |
|
|
|
|
|
|
|
rr.UserScore[player.ChairId] = rr.UserScore[player.ChairId].Sub(decimal.NewFromInt(TempCellScore)) |
|
|
|
player.Gold = player.Gold.Sub(decimal.NewFromInt(TempCellScore)) |
|
|
|
|
|
|
|
if !player.IsRobot && (player.Ctx != nil) { |
|
|
|
AfterGold, BloodPool, StockNum := rr.WriteUserScore(player, 1, TempCellScore, 0, 0, rr.ReasonString, "", "", 0) |
|
|
|
AfterGold, BloodPool, StockNum := rr.WriteUserScore(player, 1, TempCellScore, 0, 0, rr.ReasonString, "", "", 0, 0) |
|
|
|
log.Debug(" 桌子号", rr.RId, " 定庄后 下注 WriteUserScore 后 AfterGold=", AfterGold, " BloodPool=", BloodPool, " StockNum=", StockNum) |
|
|
|
} |
|
|
|
rr.TableCurrentScore += TempCellScore |
|
|
|
|
|
|
|
player.TableScore -= TempCellScore |
|
|
|
log.Debug(" 桌子号", rr.RId, " ALLIn 当前操作玩家", rr.CurrOperationPlayer, " TempCellScore ", TempCellScore, " TableScore ", player.TableScore) |
|
|
|
case protocol.OperateCheck: |
|
|
|
// 不操作 切换下一家
|
|
|
|
} |
|
|
|
|
|
|
|
// 最后结束的玩家 弃牌或allin了 最后的人要变
|
|
|
|
if message.OperateCode == protocol.OperateGaveUp || message.OperateCode == protocol.OperateAll { |
|
|
|
if player.ChairId == rr.CurrEndUser { |
|
|
|
for i := int32(1); i < 6; i++ { |
|
|
|
tempChairId := rr.CurrEndUser - i |
|
|
|
if tempChairId < 0 { |
|
|
|
tempChairId += 6 |
|
|
|
} |
|
|
|
|
|
|
|
if _, exist := rr.PlayerMap[tempChairId]; exist { |
|
|
|
if rr.PlayerMap[tempChairId].CanBet && rr.PlayerMap[tempChairId].GameState == 0 { |
|
|
|
rr.CurrEndUser = tempChairId |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
OperateRes.OperateCode = message.OperateCode |
|
|
|
OperateRes.UserScore = TempCellScore |
|
|
|
OperateRes.RoundScore = player.RoundScore |
|
|
|
OperateRes.CellScore = player.CellScore |
|
|
|
OperateRes.TableScore = player.TableScore |
|
|
|
|
|
|
|
NotifyOperate.ChairID = ChairId |
|
|
|
NotifyOperate.OperateCode = message.OperateCode |
|
|
|
NotifyOperate.UserScore = TempCellScore |
|
|
|
NotifyOperate.RoundScore = player.RoundScore |
|
|
|
NotifyOperate.CellScore = player.CellScore |
|
|
|
NotifyOperate.TableScore = player.TableScore |
|
|
|
|
|
|
|
NoGameOverUserCount := 0 |
|
|
|
for _, TempPlayer := range rr.PlayerMap { |
|
|
@ -136,18 +194,7 @@ func (rr *Room) OnUserOperate(uid int64, msg interface{}) { // 用户操作 |
|
|
|
rr.Send(TempPlayer, route.NotifyOperate, NotifyOperate) |
|
|
|
} |
|
|
|
|
|
|
|
// 只剩最后一家
|
|
|
|
if NoGameOverUserCount == 1 { |
|
|
|
// 1秒后结算
|
|
|
|
go func() { |
|
|
|
time.Sleep(1000 * time.Millisecond) |
|
|
|
rr.OnEventGameConclude() |
|
|
|
}() |
|
|
|
|
|
|
|
return |
|
|
|
} |
|
|
|
|
|
|
|
log.Debug(" 用户 ", player.ChairId, " 当前轮数 ", rr.CurrGameRound, " 本轮需要下注 ", rr.CellScore, " 本轮已下注 ", player.RoundScore, " 总下注 ", player.CellScore) |
|
|
|
log.Debug(" 桌子号", rr.RId, " 用户 ", player.ChairId, " 当前轮数 ", rr.CurrGameRound, " 本轮需要下注 ", rr.CellScore, " 本轮已下注 ", player.RoundScore, " 总下注 ", player.CellScore) |
|
|
|
// 庄家判断
|
|
|
|
bNextRound := true |
|
|
|
|
|
|
@ -159,19 +206,43 @@ func (rr *Room) OnUserOperate(uid int64, msg interface{}) { // 用户操作 |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
// 只剩最后一家 且这家本轮已经操作完
|
|
|
|
if NoGameOverUserCount == 1 { |
|
|
|
bNextRound = true |
|
|
|
} |
|
|
|
|
|
|
|
CanGoOnUserCount := 0 |
|
|
|
// 计算还能继续玩的人数
|
|
|
|
for _, tempPlayer := range rr.PlayerMap { |
|
|
|
if tempPlayer.CanBet && tempPlayer.GameState == 0 { |
|
|
|
CanGoOnUserCount++ |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
// 最后一个操作完 且能操作的人数不足 才会结束这轮
|
|
|
|
if player.ChairId == rr.CurrEndUser && CanGoOnUserCount < 2 { |
|
|
|
bNextRound = true |
|
|
|
} |
|
|
|
|
|
|
|
if rr.CurrEndUser == player.ChairId { |
|
|
|
log.Debug(" 转了一轮 当前最后玩家 ", rr.CurrEndUser, " 当前庄家 ", rr.CurrBanker) |
|
|
|
log.Debug(" 桌子号", rr.RId, " 转了一轮 当前最后玩家 ", rr.CurrEndUser, " 当前庄家 ", rr.CurrBanker) |
|
|
|
// 转了一轮
|
|
|
|
|
|
|
|
// 全过也进入下一轮
|
|
|
|
if rr.CanCheck { |
|
|
|
log.Debug(" 全过进入下一轮 ") |
|
|
|
log.Debug(" 桌子号", rr.RId, " 全过进入下一轮 ") |
|
|
|
bNextRound = true |
|
|
|
} |
|
|
|
|
|
|
|
//// 有人All了也进入下一轮
|
|
|
|
//if rr.bUserAllIn {
|
|
|
|
// log.Debug(" 桌子号", rr.RId, " 有人All了进入下一轮 ")
|
|
|
|
// bNextRound = true
|
|
|
|
//}
|
|
|
|
|
|
|
|
// 不能进入下一阶段则进入补注阶段
|
|
|
|
if !bNextRound { |
|
|
|
log.Debug(" 进入补注阶段 ") |
|
|
|
log.Debug(" 桌子号", rr.RId, " 进入补注阶段 ") |
|
|
|
rr.BetCRF = 1 |
|
|
|
} |
|
|
|
//} else if rr.CurrEndUser == player.ChairId {
|
|
|
@ -184,39 +255,241 @@ func (rr *Room) OnUserOperate(uid int64, msg interface{}) { // 用户操作 |
|
|
|
//}
|
|
|
|
|
|
|
|
if bNextRound { |
|
|
|
log.Debug(" 进入下一轮 ") |
|
|
|
log.Debug(" 桌子号", rr.RId, " 进入下一轮 ") |
|
|
|
rr.BetCRF = 0 |
|
|
|
rr.CurrGameRound++ |
|
|
|
rr.CanCheck = true // 每一轮都可以check
|
|
|
|
|
|
|
|
if len(rr.TableScore) == 0 { |
|
|
|
log.Debug(" 桌子号", rr.RId, " 这里为什么是空的?") |
|
|
|
rr.TableScore = append(rr.TableScore, protocol.UserTableScore{Score: 0, Used: false}) |
|
|
|
} |
|
|
|
|
|
|
|
if rr.bUserAllIn { |
|
|
|
// 有人ALL 计算分池
|
|
|
|
var tempTableScore []protocol.UserTableScore |
|
|
|
var tempAllINScore []protocol.UserTableScore |
|
|
|
var tempAllScore int64 |
|
|
|
var CurrentRoundCount int |
|
|
|
for _, tempPlayer := range rr.PlayerMap { |
|
|
|
log.Debug(" 桌子号", rr.RId, " 有人all了 ChairId = ", tempPlayer.ChairId, " RoundScore = ", tempPlayer.RoundScore, " GameState = ", tempPlayer.GameState) |
|
|
|
log.Debug(" 桌子号", rr.RId, " 有人all了 tempPlayer = ", tempPlayer) |
|
|
|
if tempPlayer.CanBet { |
|
|
|
tempAllScore += tempPlayer.CellScore |
|
|
|
CurrentRoundCount++ |
|
|
|
if tempPlayer.GameState == 2 { |
|
|
|
tempAllINScore = append(tempAllINScore, protocol.UserTableScore{ |
|
|
|
ChairID: []int32{tempPlayer.ChairId}, |
|
|
|
Score: tempPlayer.CellScore, |
|
|
|
}) |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
sort.Slice(tempAllINScore, func(i, j int) bool { |
|
|
|
return tempAllINScore[i].Score < tempAllINScore[j].Score |
|
|
|
}) |
|
|
|
|
|
|
|
log.Debug(" 桌子号", rr.RId, " 有人all了 tempAllINScore = ", tempAllINScore) |
|
|
|
|
|
|
|
// 看分几个池子
|
|
|
|
for _, AllINScore := range tempAllINScore { |
|
|
|
CurrentTableScore := int64(0) |
|
|
|
for _, tempPlayer := range rr.PlayerMap { |
|
|
|
if tempPlayer.CanBet && tempPlayer.CellScore > 0 { |
|
|
|
if tempPlayer.CellScore <= AllINScore.Score { |
|
|
|
CurrentTableScore += tempPlayer.CellScore |
|
|
|
} else { |
|
|
|
CurrentTableScore += AllINScore.Score |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
tempTableScore = append(tempTableScore, protocol.UserTableScore{ |
|
|
|
ChairID: AllINScore.ChairID, |
|
|
|
Score: CurrentTableScore, |
|
|
|
}) |
|
|
|
} |
|
|
|
|
|
|
|
log.Debug(" 桌子号", rr.RId, " 有人all了 tempTableScore = ", tempTableScore) |
|
|
|
|
|
|
|
rr.TableScore = rr.TableScore[:0] |
|
|
|
for Index, TableScore := range tempTableScore { |
|
|
|
if Index == 0 { |
|
|
|
rr.TableScore = append(rr.TableScore, TableScore) |
|
|
|
} else { |
|
|
|
rr.TableScore = append(rr.TableScore, protocol.UserTableScore{ |
|
|
|
ChairID: TableScore.ChairID, |
|
|
|
Score: TableScore.Score - tempTableScore[Index-1].Score, |
|
|
|
}) |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
// 如果计算完了 还有剩余池子
|
|
|
|
if len(tempTableScore) > 0 && tempAllScore > tempTableScore[len(tempTableScore)-1].Score { |
|
|
|
//tempTableScore = append(tempTableScore, protocol.UserTableScore{
|
|
|
|
// Score: tempAllScore - tempTableScore[len(tempTableScore)-1].Score,
|
|
|
|
//})
|
|
|
|
rr.TableScore = append(rr.TableScore, protocol.UserTableScore{ |
|
|
|
Score: tempAllScore - tempTableScore[len(tempTableScore)-1].Score, |
|
|
|
}) |
|
|
|
} |
|
|
|
|
|
|
|
log.Debug(" 桌子号", rr.RId, " 有人all了 rr.TableScore = ", rr.TableScore) |
|
|
|
} |
|
|
|
|
|
|
|
// 开下一轮清空上一轮总投注
|
|
|
|
RoundTotalScore := int64(0) |
|
|
|
for index, _ := range rr.PlayerMap { |
|
|
|
rr.TableScore += rr.PlayerMap[index].RoundScore |
|
|
|
if !rr.bUserAllIn { |
|
|
|
rr.TableScore[len(rr.TableScore)-1].Score += rr.PlayerMap[index].RoundScore |
|
|
|
} |
|
|
|
rr.PlayerMap[index].RoundScore = 0 |
|
|
|
rr.PlayerMap[index].GameCurrenRoundState = 0 |
|
|
|
RoundTotalScore += rr.PlayerMap[index].CellScore |
|
|
|
} |
|
|
|
|
|
|
|
if rr.CurrGameRound == 3 { |
|
|
|
// 开下一轮重置本轮有人All的状态
|
|
|
|
rr.bUserAllIn = false |
|
|
|
|
|
|
|
log.Debug(" 桌子号", rr.RId, " 开下一轮清空上一轮总投注后 rr.TableScore = ", rr.TableScore) |
|
|
|
|
|
|
|
// 开下一轮重置底注
|
|
|
|
rr.CellScore = rr.Opt.MinBetAsset |
|
|
|
|
|
|
|
// 只剩最后一家 且这家本轮已经操作完
|
|
|
|
if NoGameOverUserCount == 1 { |
|
|
|
// 1秒后结算
|
|
|
|
go func() { |
|
|
|
time.Sleep(1000 * time.Millisecond) |
|
|
|
rr.OnEventGameConclude() |
|
|
|
rr.OnEventGameConclude(2) |
|
|
|
}() |
|
|
|
|
|
|
|
return |
|
|
|
} |
|
|
|
|
|
|
|
// 不够两个人 就开始结算了
|
|
|
|
if CanGoOnUserCount < 2 { |
|
|
|
log.Debug(" 桌子号", rr.RId, " 全部弃牌或AllIn 直接结算 ") |
|
|
|
//发牌
|
|
|
|
var SendPoker []int32 |
|
|
|
switch rr.CurrGameRound { |
|
|
|
case 1: |
|
|
|
////全发
|
|
|
|
//for i := 0; i < 5; i++ {
|
|
|
|
// SendPoker = append(SendPoker, int32(rr.HandPoker[i]))
|
|
|
|
//}
|
|
|
|
//发前三张牌
|
|
|
|
for i := 0; i < 3; i++ { |
|
|
|
SendPoker = append(SendPoker, int32(rr.HandPoker[i])) |
|
|
|
} |
|
|
|
|
|
|
|
NotifyPoker := &protocol.NotifyPoker{ |
|
|
|
Poker: SendPoker, |
|
|
|
} |
|
|
|
for _, tempTableScore := range rr.TableScore { |
|
|
|
NotifyPoker.TableScore = append(NotifyPoker.TableScore, tempTableScore.Score) |
|
|
|
} |
|
|
|
rr.SendAllMessage(route.NotifyPoker, NotifyPoker) |
|
|
|
|
|
|
|
for _, tempPlayer := range rr.PlayerMap { |
|
|
|
if tempPlayer.CanBet && tempPlayer.GameState != 1 { |
|
|
|
PokerType := int32(0) |
|
|
|
NotifyPokerType := &protocol.NotifyPokerType{} |
|
|
|
|
|
|
|
PokerType = int32(tempPlayer.ThreeKind.GetCardType()) |
|
|
|
log.Debug("UID ", tempPlayer.Uid, " PokerType=", PokerType, " tempPlayer.ThreeKind=", tempPlayer.ThreeKind) |
|
|
|
NotifyPokerType.PokerType = PokerType |
|
|
|
for _, poker := range tempPlayer.ThreeKind { |
|
|
|
NotifyPokerType.BestPoker = append(NotifyPokerType.BestPoker, int32(poker)) |
|
|
|
} |
|
|
|
|
|
|
|
rr.Send(tempPlayer, route.NotifyPokerType, NotifyPokerType) |
|
|
|
log.Debug("UID ", tempPlayer.Uid, " CurrGameRound=", rr.CurrGameRound, " PokerType=", NotifyPokerType.PokerType) |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
//发第四张
|
|
|
|
NotifyPoker2 := &protocol.NotifyPoker{ |
|
|
|
Poker: []int32{int32(rr.HandPoker[3])}, |
|
|
|
} |
|
|
|
for _, tempTableScore := range rr.TableScore { |
|
|
|
NotifyPoker2.TableScore = append(NotifyPoker2.TableScore, tempTableScore.Score) |
|
|
|
} |
|
|
|
rr.SendAllMessage(route.NotifyPoker, NotifyPoker2) |
|
|
|
case 2: |
|
|
|
////发第四 五张牌
|
|
|
|
//SendPoker = append(SendPoker, int32(rr.HandPoker[3]))
|
|
|
|
//SendPoker = append(SendPoker, int32(rr.HandPoker[4]))
|
|
|
|
//发第四张
|
|
|
|
SendPoker = append(SendPoker, int32(rr.HandPoker[3])) |
|
|
|
|
|
|
|
NotifyPoker := &protocol.NotifyPoker{ |
|
|
|
Poker: SendPoker, |
|
|
|
} |
|
|
|
for _, tempTableScore := range rr.TableScore { |
|
|
|
NotifyPoker.TableScore = append(NotifyPoker.TableScore, tempTableScore.Score) |
|
|
|
} |
|
|
|
rr.SendAllMessage(route.NotifyPoker, NotifyPoker) |
|
|
|
//case 3:
|
|
|
|
// //发第五张牌
|
|
|
|
// SendPoker = append(SendPoker, int32(rr.HandPoker[4]))
|
|
|
|
} |
|
|
|
|
|
|
|
for _, tempPlayer := range rr.PlayerMap { |
|
|
|
if tempPlayer.CanBet && tempPlayer.GameState != 1 { |
|
|
|
PokerType := int32(0) |
|
|
|
NotifyPokerType := &protocol.NotifyPokerType{} |
|
|
|
|
|
|
|
PokerType = int32(tempPlayer.FourKind.GetCardType()) |
|
|
|
log.Debug("UID ", tempPlayer.Uid, " PokerType=", PokerType, " tempPlayer.FourKind=", tempPlayer.FourKind) |
|
|
|
NotifyPokerType.PokerType = PokerType |
|
|
|
for _, poker := range tempPlayer.FourKind { |
|
|
|
NotifyPokerType.BestPoker = append(NotifyPokerType.BestPoker, int32(poker)) |
|
|
|
} |
|
|
|
|
|
|
|
rr.Send(tempPlayer, route.NotifyPokerType, NotifyPokerType) |
|
|
|
log.Debug("UID ", tempPlayer.Uid, " CurrGameRound=", rr.CurrGameRound, " PokerType=", NotifyPokerType.PokerType) |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
// 1秒后结算
|
|
|
|
go func() { |
|
|
|
time.Sleep(2000 * time.Millisecond) |
|
|
|
rr.OnEventGameConclude(1) |
|
|
|
}() |
|
|
|
|
|
|
|
return |
|
|
|
} |
|
|
|
|
|
|
|
if rr.CurrGameRound == 4 { |
|
|
|
// 1秒后结算
|
|
|
|
go func() { |
|
|
|
time.Sleep(1000 * time.Millisecond) |
|
|
|
rr.OnEventGameConclude(0) |
|
|
|
}() |
|
|
|
} else { |
|
|
|
//发牌
|
|
|
|
var SendPoker []int32 |
|
|
|
switch rr.CurrGameRound { |
|
|
|
case 1: |
|
|
|
//发前三张牌
|
|
|
|
for i := 0; i < 3; i++ { |
|
|
|
SendPoker = append(SendPoker, int32(rr.HandPoker[i])) |
|
|
|
} |
|
|
|
case 2: |
|
|
|
//发第四张牌
|
|
|
|
SendPoker = append(SendPoker, int32(rr.HandPoker[3])) |
|
|
|
case 2: |
|
|
|
case 3: |
|
|
|
//发第五张牌
|
|
|
|
SendPoker = append(SendPoker, int32(rr.HandPoker[4])) |
|
|
|
} |
|
|
|
|
|
|
|
NotifyPoker := &protocol.NotifyPoker{ |
|
|
|
Poker: SendPoker, |
|
|
|
TableScore: RoundTotalScore, |
|
|
|
Poker: SendPoker, |
|
|
|
} |
|
|
|
for _, tempTableScore := range rr.TableScore { |
|
|
|
NotifyPoker.TableScore = append(NotifyPoker.TableScore, tempTableScore.Score) |
|
|
|
} |
|
|
|
rr.SendAllMessage(route.NotifyPoker, NotifyPoker) |
|
|
|
|
|
|
@ -225,34 +498,43 @@ func (rr *Room) OnUserOperate(uid int64, msg interface{}) { // 用户操作 |
|
|
|
PokerType := int32(0) |
|
|
|
NotifyPokerType := &protocol.NotifyPokerType{} |
|
|
|
if rr.CurrGameRound == 1 { |
|
|
|
PokerType = int32(tempPlayer.ThreeKind.GetCardType()) |
|
|
|
log.Debug(" 桌子号", rr.RId, "UID ", tempPlayer.Uid, " PokerType=", PokerType, " tempPlayer.ThreeKind=", tempPlayer.ThreeKind) |
|
|
|
NotifyPokerType.PokerType = PokerType |
|
|
|
for _, poker := range tempPlayer.ThreeKind { |
|
|
|
NotifyPokerType.BestPoker = append(NotifyPokerType.BestPoker, int32(poker)) |
|
|
|
} |
|
|
|
} else if rr.CurrGameRound == 2 { |
|
|
|
PokerType = int32(tempPlayer.FourKind.GetCardType()) |
|
|
|
log.Debug("UID ", tempPlayer.Uid, " PokerType=", PokerType, " tempPlayer.ThreeKind=", tempPlayer.FourKind) |
|
|
|
log.Debug(" 桌子号", rr.RId, "UID ", tempPlayer.Uid, " PokerType=", PokerType, " tempPlayer.FourKind=", tempPlayer.FourKind) |
|
|
|
NotifyPokerType.PokerType = PokerType |
|
|
|
for _, poker := range tempPlayer.FourKind { |
|
|
|
NotifyPokerType.BestPoker = append(NotifyPokerType.BestPoker, int32(poker)) |
|
|
|
} |
|
|
|
} else if rr.CurrGameRound == 2 { |
|
|
|
} else if rr.CurrGameRound == 3 { |
|
|
|
PokerType = int32(tempPlayer.BestKind.GetCardType()) |
|
|
|
log.Debug("UID ", tempPlayer.Uid, " PokerType=", PokerType, " tempPlayer.BestKind=", tempPlayer.BestKind) |
|
|
|
log.Debug(" 桌子号", rr.RId, "UID ", tempPlayer.Uid, " PokerType=", PokerType, " tempPlayer.BestKind=", tempPlayer.BestKind) |
|
|
|
NotifyPokerType.PokerType = PokerType |
|
|
|
for _, poker := range tempPlayer.BestKind { |
|
|
|
NotifyPokerType.BestPoker = append(NotifyPokerType.BestPoker, int32(poker)) |
|
|
|
} |
|
|
|
} |
|
|
|
rr.Send(tempPlayer, route.NotifyPokerType, NotifyPokerType) |
|
|
|
log.Debug("UID ", tempPlayer.Uid, " CurrGameRound=", rr.CurrGameRound, " PokerType=", NotifyPokerType.PokerType) |
|
|
|
log.Debug(" 桌子号", rr.RId, "UID ", tempPlayer.Uid, " CurrGameRound=", rr.CurrGameRound, " PokerType=", NotifyPokerType.PokerType) |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
// 1秒后下一个人操作
|
|
|
|
go func() { |
|
|
|
time.Sleep(2000 * time.Millisecond) |
|
|
|
rr.CurrOperationPlayer = rr.CurrBanker // 这需要重置操作玩家 好从小盲注重新开始下一轮
|
|
|
|
rr.NextPLayer() |
|
|
|
}() |
|
|
|
} |
|
|
|
} else { |
|
|
|
// 1秒后下一个人操作
|
|
|
|
go func() { |
|
|
|
rr.CurrentOperationTimer = time.Now().UnixMilli() + 30000 |
|
|
|
time.Sleep(2000 * time.Millisecond) |
|
|
|
rr.NextPLayer() |
|
|
|
}() |
|
|
|