Browse Source

1 修改开始游戏不能退出

2 修改记录在后台的记录
3 修改机器人下注档位变成按概率
dev
MoQingYu 4 months ago
parent
commit
691ed92636
  1. 1
      game-server/game/21Game/app/config/config.go
  2. 18
      game-server/game/21Game/app/core/game/game_logic.go
  3. 18
      game-server/game/21Game/app/core/game/game_over.go
  4. 2
      game-server/game/21Game/app/core/game/game_player.go
  5. 15
      game-server/game/21Game/app/core/game/game_robot.go
  6. 1
      game-server/game/21Game/app/core/protocol/protocol_msg.go
  7. 1
      game-server/game/21Game/app/core/room/base.go
  8. 26
      game-server/game/21Game/app/gamemanage/gamemanage.go
  9. 12
      game-server/game/21Game/config/blood.json
  10. 18
      game-server/game/AndarBahar/app/core/game/game_logic.go
  11. 22
      game-server/game/AndarBahar/app/core/game/game_over.go
  12. 2
      game-server/game/AndarBahar/app/core/game/game_player.go
  13. 7
      game-server/game/AndarBahar/app/core/protocol/protocol_msg.go
  14. 1
      game-server/game/AndarBahar/app/core/protocol/protocol_struct.go
  15. 1
      game-server/game/AndarBahar/app/core/room/base.go
  16. 29
      game-server/game/AndarBahar/app/gamemanage/gamemanage.go
  17. 83
      game-server/game/DZ/app/core/game/game_table_take.go
  18. 17
      game-server/game/SixAndarBahar/app/config/config.go
  19. 43
      game-server/game/SixAndarBahar/app/core/game/game_logic.go
  20. 24
      game-server/game/SixAndarBahar/app/core/game/game_over.go
  21. 2
      game-server/game/SixAndarBahar/app/core/game/game_player.go
  22. 36
      game-server/game/SixAndarBahar/app/core/game/game_robot.go
  23. 7
      game-server/game/SixAndarBahar/app/core/protocol/protocol_msg.go
  24. 1
      game-server/game/SixAndarBahar/app/core/room/base.go
  25. 22
      game-server/game/SixAndarBahar/app/gamemanage/gamemanage.go
  26. 12
      game-server/game/SixAndarBahar/config/blood.json
  27. 18
      game-server/game/rummy/app/core/game/game_logic.go
  28. 55
      game-server/game/rummy/app/core/game/game_over.go
  29. 2
      game-server/game/rummy/app/core/game/game_player.go
  30. 18
      game-server/game/rummy/app/core/protocol/protocol_msg.go
  31. 1
      game-server/game/rummy/app/core/room/base.go
  32. 19
      game-server/game/rummy/app/gamemanage/gamemanage.go
  33. 12
      game-server/game/rummy/config/blood.json
  34. 1
      game-server/internal/code/code.go

1
game-server/game/21Game/app/config/config.go

@ -29,6 +29,7 @@ type BloodCtrl struct {
GearConfig []struct {
BoomPro [][]int `json:"BoomPro"`
GearID int `json:"GearID"`
ChipPro []int `json:"ChipPro"`
BlackJK int `json:"BlackJK"`
BankerPro int `json:"BankerPro"`
MustBankerPro int `json:"MustBankerPro"`

18
game-server/game/21Game/app/core/game/game_logic.go

@ -33,6 +33,19 @@ func (rr *Room) UpdateCtx(uid int64, ctx *node.Context) {
}
}
func (rr *Room) UpdateUserOut(uid int64) { // 更新用户退出状态
rr.roomRWLock.Lock()
defer rr.roomRWLock.Unlock()
for Index, p := range rr.PlayerMap {
if p.Uid == uid {
rr.PlayerMap[Index].UserNeedOut = true
break
}
}
}
func (rr *Room) run() {
milliseconds := time.Now().UnixMilli()
@ -283,6 +296,11 @@ func (rr *Room) run() {
log.Debug(" 桌子号", rr.RId, " 用户 ", player.Nickname, " 不在线 ")
rr.OnGetOutRoom(player.Uid)
}
if player.UserNeedOut {
log.Debug(" 桌子号", rr.RId, " 用户 ", player.Nickname, " 需要退出 ")
rr.OnGetOutRoom(player.Uid)
}
}
for _, player := range rr.PlayerWatchMap {
if player.IsRobot {

18
game-server/game/21Game/app/core/game/game_over.go

@ -263,13 +263,17 @@ func (rr *Room) OnEventGameSingeConclude(SingleChairID int32) { // 结束-单独
sArea = ""
var RecordInfo protocol.RecordInfo
for _, player := range rr.PlayerMap {
if !player.CanBet {
if !player.CanBet && player.ChairId != rr.CurrBanker {
continue
}
var RecordInfoPlayer protocol.RecordInfoPlayer
RecordInfoPlayer.ChairID = player.ChairId
RecordInfoPlayer.UserNo = player.UserNo
RecordInfoPlayer.IsBanker = false
if player.ChairId == rr.CurrBanker {
RecordInfoPlayer.IsBanker = true
}
for _, poker := range player.HandPoker {
RecordInfoPlayer.HandPoker = append(RecordInfoPlayer.HandPoker, int32(poker))
}
@ -459,13 +463,17 @@ func (rr *Room) OnEventGameConclude() { // 结束-结算
sArea = ""
var RecordInfo protocol.RecordInfo
for _, player := range rr.PlayerMap {
if !player.CanBet {
if !player.CanBet && player.ChairId != rr.CurrBanker {
continue
}
var RecordInfoPlayer protocol.RecordInfoPlayer
RecordInfoPlayer.ChairID = player.ChairId
RecordInfoPlayer.UserNo = player.UserNo
RecordInfoPlayer.IsBanker = false
if player.ChairId == rr.CurrBanker {
RecordInfoPlayer.IsBanker = true
}
for _, poker := range player.HandPoker {
RecordInfoPlayer.HandPoker = append(RecordInfoPlayer.HandPoker, int32(poker))
}
@ -664,13 +672,17 @@ func (rr *Room) OnEventGameConcludeBX() { // 结束-保险结算
sArea = ""
var RecordInfo protocol.RecordInfo
for _, player := range rr.PlayerMap {
if !player.CanBet {
if !player.CanBet && player.ChairId != rr.CurrBanker {
continue
}
var RecordInfoPlayer protocol.RecordInfoPlayer
RecordInfoPlayer.ChairID = player.ChairId
RecordInfoPlayer.UserNo = player.UserNo
RecordInfoPlayer.IsBanker = false
if player.ChairId == rr.CurrBanker {
RecordInfoPlayer.IsBanker = true
}
for _, poker := range player.HandPoker {
RecordInfoPlayer.HandPoker = append(RecordInfoPlayer.HandPoker, int32(poker))
}

2
game-server/game/21Game/app/core/game/game_player.go

@ -41,4 +41,6 @@ type Player struct {
CanBet bool // 玩家是否需要等待下一局开始
GameState int32 // 1 玩家已投降 2 玩家杰克 3 玩家五小龙 4 玩家已爆牌
HandPoker types.PokerSlice // 玩家手牌
UserNeedOut bool //退出状态
}

15
game-server/game/21Game/app/core/game/game_robot.go

@ -321,8 +321,21 @@ func (r *RobotManager) OnRobotMessage(msgId int32, player *Player, msg interface
go func() {
SelectTime := rand.Int63n(2000) + 5000
time.Sleep(time.Duration(SelectTime) * time.Millisecond)
// 判断下注的档位
tempChipPro := rand.Intn(10000)
tempIndex := 0
for index, pro := range CurrentGearConfig.ChipPro {
if tempChipPro <= pro {
tempIndex = index
break
} else {
tempChipPro -= pro
}
}
r.GameRoom.OnUserBet(player.Uid, &protocol.BetReq{
BetAmount: r.GameRoom.Opt.BetAssetOptions[0],
BetAmount: r.GameRoom.Opt.BetAssetOptions[tempIndex],
})
}()
}

1
game-server/game/21Game/app/core/protocol/protocol_msg.go

@ -247,6 +247,7 @@ type Options struct {
type RecordInfoPlayer struct { // 存储的结构显示
ChairID int32 `json:"chairId"` //座位ID
IsBanker bool `json:"isBanker"` //是否是庄
UserNo string `json:"userNo"` //用户ID
HandPoker []int32 `json:"handPoker,omitempty"` // 用户当前手牌
Point []int32 `json:"point,omitempty"` // 当前点数和

1
game-server/game/21Game/app/core/room/base.go

@ -29,6 +29,7 @@ type HomeBase interface {
GetRoomCreator() int64 // 获取房主
IsCanDissolution() bool // 是否能解散房间
UpdateCtx(uid int64, ctx *node.Context) // 无奈加的,更新node.Context
UpdateUserOut(uid int64) // 更新用户退出状态
OnUserOperate(uid int64, msg interface{}) // 用户操作
OnUserGetBanker(uid int64, msg interface{}) // 用户抢庄
OnUserWatchToDown(uid int64, msg interface{}) // 用户观战转坐下

26
game-server/game/21Game/app/gamemanage/gamemanage.go

@ -9,6 +9,7 @@ import (
"xgame/game/21Game/app/core/protocol"
"xgame/game/21Game/app/core/room"
"xgame/game/21Game/app/route"
"xgame/internal/code"
accountservice "xgame/internal/service/account"
accountpb "xgame/internal/service/account/pb"
assetservice "xgame/internal/service/asset"
@ -383,19 +384,34 @@ func LogoutTable(ctx *node.Context) { // 用户退出游戏请求
}
if RoomInfo != nil && RoomInfo.CurrentGameState > protocol.STATE_GET_BANKER {
if TempPlayer.ChairId != -1 && TempPlayer.CanBet && RoomInfo.CurrentGameState == protocol.STATE_ROUND_POKER {
log.Debug("LogoutTable 发牌期间不能离开房间 ", " Request", ctx.Request)
if TempPlayer.ChairId != -1 && TempPlayer.CanBet {
log.Debug("LogoutTable 开始游戏后不能退出游戏 ", " Request", ctx.Request)
LeaveTableRes := &protocol.LeaveTableRes{
Code: protocol.ErrorLeaveTableRoundPoker,
CodeMsg: "发牌期间不能离开房间",
Code: code.ErrorWaitGameEndOut.Code(),
CodeMsg: "开始游戏后不能退出游戏",
}
Ctx.Request.Message.Route = route.LogoutTableRes
if err := Ctx.Response(LeaveTableRes); err != nil {
log.Debugf("发牌期间不能离开房间 出错了: %v", err)
log.Debugf("开始游戏后不能退出游戏 出错了: %v", err)
}
RoomInfo.UpdateUserOut(Ctx.Request.UID)
return
}
//if TempPlayer.ChairId != -1 && TempPlayer.CanBet && RoomInfo.CurrentGameState == protocol.STATE_ROUND_POKER {
// log.Debug("LogoutTable 发牌期间不能离开房间 ", " Request", ctx.Request)
// LeaveTableRes := &protocol.LeaveTableRes{
// Code: protocol.ErrorLeaveTableRoundPoker,
// CodeMsg: "发牌期间不能离开房间",
// }
//
// Ctx.Request.Message.Route = route.LogoutTableRes
// if err := Ctx.Response(LeaveTableRes); err != nil {
// log.Debugf("发牌期间不能离开房间 出错了: %v", err)
// }
// return
//}
if TempPlayer != nil && TempPlayer.ChairId == RoomInfo.CurrBanker && RoomInfo.CurrentGameState > protocol.STATE_GET_BANKER {
log.Debug("LogoutTable 庄家不能离开房间 ", " Request", ctx.Request)

12
game-server/game/21Game/config/blood.json

@ -13,6 +13,8 @@
"BoomPro": [[12,3300],[13,4170],[14,5000],[15,5830],[16,6670],[17,7500],[18,8330],[19,9170],[20,9950],[21,10000]],
"GearIDComment": "GearID 【输 3000档】",
"GearID": 3000,
"CommentChipPro": "机器人下注的概率",
"ChipPro": [4000,2000,2000,1000,1000],
"BlackJKComment": "(机器人是庄)BlackJK、Twenty 手牌黑杰克和20点抽中概率",
"BlackJK": 4000,
"Twenty": 5000,
@ -31,6 +33,8 @@
"BoomPro": [[12,3300],[13,4170],[14,5000],[15,5830],[16,6670],[17,7500],[18,8330],[19,9170],[20,9950],[21,10000]],
"GearIDComment": "GearID 【输 2000档】",
"GearID": 2000,
"CommentChipPro": "机器人下注的概率",
"ChipPro": [4000,2000,2000,1000,1000],
"BlackJKComment": "(机器人是庄)BlackJK、Twenty 手牌黑杰克和20点抽中概率",
"BlackJK": 3000,
"Twenty": 4000,
@ -49,6 +53,8 @@
"BoomPro": [[12,3300],[13,4170],[14,5000],[15,5830],[16,6670],[17,7500],[18,8330],[19,9170],[20,9950],[21,10000]],
"GearIDComment": "GearID 【输 1000档】",
"GearID": 1000,
"CommentChipPro": "机器人下注的概率",
"ChipPro": [4000,2000,2000,1000,1000],
"BlackJKComment": "(机器人是庄)BlackJK、Twenty 手牌黑杰克和20点抽中概率",
"BlackJK": 2000,
"Twenty": 3000,
@ -67,6 +73,8 @@
"BoomPro": [[12,3300],[13,4170],[14,5000],[15,5830],[16,6670],[17,7500],[18,8330],[19,9170],[20,9950],[21,10000]],
"GearIDComment": "GearID 【赢 -1000档】",
"GearID": -1000,
"CommentChipPro": "机器人下注的概率",
"ChipPro": [4000,2000,2000,1000,1000],
"BlackJKComment": "(机器人是庄)BlackJK、Twenty 手牌黑杰克和20点抽中概率",
"BlackJK": 3000,
"Twenty": 4000,
@ -85,6 +93,8 @@
"BoomPro": [[12,3300],[13,4170],[14,5000],[15,5830],[16,6670],[17,7500],[18,8330],[19,9170],[20,9950],[21,10000]],
"GearIDComment": "GearID 【赢 -2000档】",
"GearID": -2000,
"CommentChipPro": "机器人下注的概率",
"ChipPro": [4000,2000,2000,1000,1000],
"BlackJKComment": "(机器人是庄)BlackJK、Twenty 手牌黑杰克和20点抽中概率",
"BlackJK": 2000,
"Twenty": 3000,
@ -103,6 +113,8 @@
"BoomPro": [[12,3300],[13,4170],[14,5000],[15,5830],[16,6670],[17,7500],[18,8330],[19,9170],[20,9950],[21,10000]],
"GearIDComment": "GearID 【赢 -3000档】",
"GearID": -3000,
"CommentChipPro": "机器人下注的概率",
"ChipPro": [4000,2000,2000,1000,1000],
"BlackJKComment": "(机器人是庄)BlackJK、Twenty 手牌黑杰克和20点抽中概率",
"BlackJK": 1000,
"Twenty": 2000,

18
game-server/game/AndarBahar/app/core/game/game_logic.go

@ -24,6 +24,19 @@ func (rr *Room) UpdateCtx(uid int64, ctx *node.Context) {
}
}
func (rr *Room) UpdateUserOut(uid int64) { // 更新用户退出状态
rr.roomRWLock.Lock()
defer rr.roomRWLock.Unlock()
for Index, p := range rr.playerMap {
if p.Uid == uid {
rr.playerMap[Index].UserNeedOut = true
break
}
}
}
func (rr *Room) run() {
milliseconds := time.Now().UnixMilli()
@ -152,6 +165,11 @@ func (rr *Room) run() {
rr.OnGetOutRoom(player.Uid, protocol.ErrorLongTimeKickUser)
}
if player.UserNeedOut {
log.Debug(" 桌子号", rr.RId, " 用户 ", player.Nickname, " 需要退出 ")
rr.OnGetOutRoom(player.Uid, 0)
}
if player.IsCheat && rr.CreatorId != player.Uid {
log.Debug("用户 ", player.Nickname, " 被点控 换房间 ", rr.RId)
rr.Send(player, route.NotifyReEnter, protocol.LeaveTableRes{})

22
game-server/game/AndarBahar/app/core/game/game_over.go

@ -1,6 +1,7 @@
package game
import (
"base/encoding/json"
"base/log"
"fmt"
"github.com/shopspring/decimal"
@ -713,15 +714,22 @@ func (rr *Room) OnEventGameConclude2() { // 结束-结算
//输赢
TempUserWinScore := int64(0)
player.WinBetScore = 0
sArea = ""
var RecordInfo []protocol.RecordInfo
for _, BetWinArea := range player.BetWin {
if !player.IsRobot {
if BetWinArea.BetAmount > 0 {
if len(sArea) == 0 {
sArea = "{" + strconv.Itoa(int(BetWinArea.BetArea)) + ":" + strconv.Itoa(int(BetWinArea.BetAmount))
} else {
sArea = sArea + "," + strconv.Itoa(int(BetWinArea.BetArea)) + ":" + strconv.Itoa(int(BetWinArea.BetAmount))
recordInfo := protocol.RecordInfo{}
recordInfo.Area = BetWinArea.BetArea
recordInfo.BetAmount = BetWinArea.BetAmount
recordInfo.AreaPro = rr.BloodCtrl.AreaConfig[BetWinArea.BetArea-1].AreaPro
recordInfo.IsWin = false
if BetWinArea.BetArea == WinABArea || BetWinArea.BetArea == WinCountArea {
recordInfo.IsWin = true
}
RecordInfo = append(RecordInfo, recordInfo)
}
}
@ -732,9 +740,11 @@ func (rr *Room) OnEventGameConclude2() { // 结束-结算
}
}
if len(sArea) != 0 {
sArea = sArea + "}"
options, err := json.Marshal(RecordInfo)
if err != nil {
log.Debug("RecordInfo 序列化失败")
}
sArea = string(options)
//记录输赢并写分
UserRealBet := int64(0) // 计算打码量

2
game-server/game/AndarBahar/app/core/game/game_player.go

@ -40,4 +40,6 @@ type Player struct {
WinScore int64 // 结算时的总输赢
WinBetScore int64 // 赢的区域的总下注
BetWin []protocol.BetAreaInfo //分区下注
UserNeedOut bool //退出状态
}

7
game-server/game/AndarBahar/app/core/protocol/protocol_msg.go

@ -160,3 +160,10 @@ type Options struct {
DefaultBet int64 `json:"defaultBet"` // 默认下注
RoundTime int64 `json:"roundTime"` // 每轮回合的轮次时间
}
type RecordInfo struct { // 通知最新一条记录
Area int32 `json:"area"`
BetAmount int64 `json:"betAmount"`
AreaPro float64 `json:"areaPro"`
IsWin bool `json:"isWin"`
}

1
game-server/game/AndarBahar/app/core/protocol/protocol_struct.go

@ -7,6 +7,7 @@ const (
ErrorCodeNoBetState = 20005004 //非下注阶段
ErrorCodeBetError = 20005005 //下注失败
ErrorLongTimeKickUser = 20005006 //长时间未下注踢人 连续5局未下注
ErrorNeedLeaveKickUser = 20005007 //标记了离开 结束正常离开
)
type RoomPlayer struct { //房间的用户信息

1
game-server/game/AndarBahar/app/core/room/base.go

@ -29,6 +29,7 @@ type HomeBase interface {
GetRoomCreator() int64 // 获取房主
IsCanDissolution() bool // 是否能解散房间
UpdateCtx(uid int64, ctx *node.Context) // 无奈加的,更新node.Context
UpdateUserOut(uid int64) // 更新用户退出状态
OnUserBet(uid int64, msg interface{}) // 用户下注
OnResumeGameData(uid int64) //
OnDestroy(uid int64) // 销毁房间

29
game-server/game/AndarBahar/app/gamemanage/gamemanage.go

@ -8,7 +8,9 @@ import (
"xgame/game/AndarBahar/app/core/game"
"xgame/game/AndarBahar/app/core/protocol"
"xgame/game/AndarBahar/app/core/room"
"xgame/game/AndarBahar/app/route"
"xgame/game/service/rpc_client"
"xgame/internal/code"
accountservice "xgame/internal/service/account"
accountpb "xgame/internal/service/account/pb"
assetservice "xgame/internal/service/asset"
@ -274,6 +276,33 @@ func LogoutTable(ctx *node.Context) { // 退出游戏
return
}
RoomID := room.Gh.GetRoomIdByUid(Ctx.Request.UID)
RoomInfo := room.Gh.GetGameRoomByRoomId(RoomID)
var TempPlayer *game.Player
TempPlayer = RoomInfo.GetRoomPlayerByUid(Ctx.Request.UID)
if TempPlayer != nil {
log.Debug("LogoutTable 没有获取到用户 ", Ctx.Request.UID)
}
if RoomInfo != nil {
if TempPlayer.ChairId != -1 && TempPlayer.CurrentRoundBet {
log.Debug("LogoutTable 开始游戏后不能退出游戏 ", " Request", ctx.Request)
LeaveTableRes := &protocol.LeaveTableRes{
Code: code.ErrorWaitGameEndOut.Code(),
CodeMsg: "开始游戏后不能退出游戏",
}
Ctx.Request.Message.Route = route.LogoutTableRes
if err := Ctx.Response(LeaveTableRes); err != nil {
log.Debugf("开始游戏后不能退出游戏 出错了: %v", err)
}
RoomInfo.UpdateUserOut(Ctx.Request.UID)
return
}
}
log.Debug("UpdateCtx LogoutTable ", Ctx.Request.UID, " UserId", ctx.Request.UserId, " UID", ctx.Request.UID, " Request", ctx.Request)
r.UpdateCtx(Ctx.Request.UID, Ctx)

83
game-server/game/DZ/app/core/game/game_table_take.go

@ -0,0 +1,83 @@
package game
import (
"base/log"
"strconv"
"time"
"xgame/game/DZ/app/core/protocol"
"xgame/game/DZ/app/route"
)
func (rr *Room) OnUserTableTake(uid int64, msg interface{}) { // 带入金币
message := msg.(*protocol.TableTakeReq)
TableTakeRes := &protocol.TableTakeRes{}
ChairId := int32(-1)
for _, player := range rr.PlayerMap {
if player.Uid == uid {
ChairId = player.ChairId
break
}
}
if ChairId == -1 {
log.Debug(" 桌子号", rr.RId, " ChairId == -1")
return
}
player := rr.PlayerMap[ChairId]
//判断用户带入的钱是否超过自身持有
if !player.IsRobot && message.Score > player.Gold.IntPart() {
log.Debug(" 桌子号", rr.RId, " 玩家", ChairId, "带入金额超过自身持有 想带入", message.Score, " 实际持有", player.Gold.IntPart())
TableTakeRes.Code = protocol.ErrorTableTakeNotEnoughScore
TableTakeRes.CodeMsg = "带入金额超过自身持有 你只有 " + strconv.Itoa(int(player.Gold.IntPart()))
rr.Send(rr.PlayerMap[ChairId], route.TableTakeRes, TableTakeRes)
return
}
//判断用户带入的钱是否符合规则
if message.Score+player.TableScore > rr.Opt.MaxTableTake || message.Score+player.TableScore < rr.Opt.MinTableTake {
log.Debug(" 桌子号", rr.RId, " 玩家", ChairId, "带入金额不符合带入限制 想带入", message.Score, " 实际最小限制", rr.Opt.MinTableTake, " 最大限制", rr.Opt.MaxTableTake)
TableTakeRes.Code = protocol.ErrorTableTakeNotLimitScore
TableTakeRes.CodeMsg = "带入金额不符合带入限制"
rr.Send(rr.PlayerMap[ChairId], route.TableTakeRes, TableTakeRes)
return
}
player.TableScore += message.Score
delete(rr.NeedOutPlayer, player.ChairId)
rr.Send(player, route.TableTakeRes, TableTakeRes)
// 通知其它人谁入金了
for _, player2 := range rr.PlayerMap {
if player2.IsRobot {
continue
}
NotifyTableTake := &protocol.NotifyTableTake{
ChairID: player.ChairId,
Score: player.TableScore,
}
rr.Send(player2, route.NotifyWhoTableTake, NotifyTableTake)
}
//判断开场
if rr.State < EN_TABLE_STATE_PLAYING && rr.GetRoomCanPlayPlayerCount() > 2 {
rr.State = EN_TABLE_STATE_PLAYING
milliseconds := time.Now().UnixMilli()
rr.CurrentGameState = protocol.STATE_GET_BANKER
rr.CurrentOperationTimer = milliseconds + rr.TimeOutGetBanker
rr.RepeatRoomUser()
log.Debug(" 桌子号", rr.RId, " 开始游戏 抢庄倒计时 ", rr.TimeOutGetBanker)
rr.SendAllMessage(route.NotifyStateTime, &protocol.NotifyStateTime{
NextState: protocol.STATE_GET_BANKER,
NextTimestamp: rr.CurrentOperationTimer,
})
// 抢庄做了加一秒的容错判断
rr.CurrentOperationTimer += 1000
}
}

17
game-server/game/SixAndarBahar/app/config/config.go

@ -28,14 +28,15 @@ type BloodCtrl struct {
AreaLimit int64 `json:"AreaLimit"`
} `json:"AreaConfig"`
GearConfig []struct {
GearID int `json:"GearID"`
WinPro int `json:"WinPro"`
BankerPro int `json:"BankerPro"`
MustBankerPro int `json:"MustBankerPro"`
Round1Pro int `json:"Round1Pro"`
Round1AreaPro int `json:"Round1AreaPro"`
Round2Pro int `json:"Round2Pro"`
Round2AreaPro int `json:"Round2AreaPro"`
GearID int `json:"GearID"`
ChipPro []int `json:"ChipPro"`
WinPro int `json:"WinPro"`
BankerPro int `json:"BankerPro"`
MustBankerPro int `json:"MustBankerPro"`
Round1Pro int `json:"Round1Pro"`
Round1AreaPro int `json:"Round1AreaPro"`
Round2Pro int `json:"Round2Pro"`
Round2AreaPro int `json:"Round2AreaPro"`
} `json:"GearConfig"`
AndroidOprateConfig struct {
MustBanker int `json:"MustBanker"`

43
game-server/game/SixAndarBahar/app/core/game/game_logic.go

@ -33,6 +33,19 @@ func (rr *Room) UpdateCtx(uid int64, ctx *node.Context) {
}
}
func (rr *Room) UpdateUserOut(uid int64) { // 更新用户退出状态
rr.roomRWLock.Lock()
defer rr.roomRWLock.Unlock()
for Index, p := range rr.PlayerMap {
if p.Uid == uid {
rr.PlayerMap[Index].UserNeedOut = true
break
}
}
}
func (rr *Room) run() {
milliseconds := time.Now().UnixMilli()
@ -249,6 +262,11 @@ func (rr *Room) run() {
log.Debug("用户 ", player.Nickname, " 连续五局没下注 ", rr.RId)
rr.OnGetOutRoom(player.Uid)
}
if player.UserNeedOut {
log.Debug(" 桌子号", rr.RId, " 用户 ", player.Nickname, " 需要退出 ")
rr.OnGetOutRoom(player.Uid)
}
//else if player.IsCheat && rr.CreatorId != player.Uid {
// log.Debug("用户 ", player.Nickname, " 被点控 换房间 ", rr.RId)
// rr.Send(player, route.NotifyReEnter, protocol.LeaveTableRes{})
@ -348,12 +366,25 @@ func (rr *Room) run() {
rr.RepeatRoom()
rr.RepeatRoomUser()
rr.SendAllMessage(route.NotifyStateTime, &protocol.NotifyStateTime{
NextState: protocol.STATE_GET_BANKER,
NextTimestamp: rr.CurrentOperationTimer,
})
// 抢庄做了加一秒的容错判断
rr.CurrentOperationTimer += 1000
//人数不足了 重新等待开场
if rr.GetRoomPlayerCount() <= 1 {
rr.State = EN_TABLE_STATE_READY_TO_START
rr.CurrentGameState = protocol.STATE_WAIT
rr.CurrentOperationTimer = milliseconds + rr.TimeoutDestroy
rr.SendAllMessage(route.NotifyStateTime, &protocol.NotifyStateTime{
NextState: protocol.STATE_WAIT,
NextTimestamp: rr.CurrentOperationTimer,
})
break
} else {
rr.SendAllMessage(route.NotifyStateTime, &protocol.NotifyStateTime{
NextState: protocol.STATE_GET_BANKER,
NextTimestamp: rr.CurrentOperationTimer,
})
// 抢庄做了加一秒的容错判断
rr.CurrentOperationTimer += 1000
}
}
}
}

24
game-server/game/SixAndarBahar/app/core/game/game_over.go

@ -1,6 +1,7 @@
package game
import (
"base/encoding/json"
"base/log"
"fmt"
"github.com/shopspring/decimal"
@ -306,14 +307,23 @@ func (rr *Room) OnEventGameConclude(EndState int) { // 结束-结算
TempUserWinScore := int64(0)
player.WinBetScore = 0
sArea = ""
var RecordInfo []protocol.RecordInfo
for _, BetWinArea := range player.BetWin {
if !player.IsRobot {
if BetWinArea.BetAmount > 0 {
if len(sArea) == 0 {
sArea = "{" + strconv.Itoa(int(BetWinArea.BetArea)) + ":" + strconv.Itoa(int(BetWinArea.BetAmount))
} else {
sArea = sArea + "," + strconv.Itoa(int(BetWinArea.BetArea)) + ":" + strconv.Itoa(int(BetWinArea.BetAmount))
recordInfo := protocol.RecordInfo{}
recordInfo.Area = BetWinArea.BetArea
recordInfo.BetAmount = BetWinArea.BetAmount
if EndState == 1 {
recordInfo.AreaPro = rr.BloodCtrl.AreaConfig[BetWinArea.BetArea-1].AreaPro1
} else if EndState == 2 {
recordInfo.AreaPro = rr.BloodCtrl.AreaConfig[BetWinArea.BetArea-1].AreaPro2
}
recordInfo.IsWin = false
if BetWinArea.BetArea == WinABArea {
recordInfo.IsWin = true
}
RecordInfo = append(RecordInfo, recordInfo)
}
}
@ -332,9 +342,11 @@ func (rr *Room) OnEventGameConclude(EndState int) { // 结束-结算
}
}
if len(sArea) != 0 {
sArea = sArea + "}"
options, err := json.Marshal(RecordInfo)
if err != nil {
log.Debug("RecordInfo 序列化失败")
}
sArea = string(options)
//记录输赢并写分
UserRealBet := int64(0) // 计算打码量

2
game-server/game/SixAndarBahar/app/core/game/game_player.go

@ -43,4 +43,6 @@ type Player struct {
WinScore int64 // 结算时的总输赢
WinBetScore int64 // 赢的区域的总下注
BetWin []protocol.BetAreaInfo //分区下注
UserNeedOut bool //退出状态
}

36
game-server/game/SixAndarBahar/app/core/game/game_robot.go

@ -279,6 +279,18 @@ func (r *RobotManager) OnRobotMessage(msgId int32, player *Player, msg interface
}
}
// 判断下注的档位
tempChipPro := rand.Intn(10000)
tempIndex := 0
for index, pro := range CurrentGearConfig.ChipPro {
if tempChipPro <= pro {
tempIndex = index
break
} else {
tempChipPro -= pro
}
}
milliseconds := time.Now().UnixMilli()
if message.NextState == protocol.STATE_FIRST_BET || message.NextState == protocol.STATE_OTHER_BET {
@ -296,11 +308,13 @@ func (r *RobotManager) OnRobotMessage(msgId int32, player *Player, msg interface
// 随机下注金额
if len(r.GameRoom.Opt.BetAssetOptions) >= 2 {
if rand.Intn(100) < 50 {
r.playerBetCtrl[player.ChairId].BetAmount = r.GameRoom.Opt.BetAssetOptions[0]
} else {
r.playerBetCtrl[player.ChairId].BetAmount = r.GameRoom.Opt.BetAssetOptions[1]
}
//if rand.Intn(100) < 50 {
// r.playerBetCtrl[player.ChairId].BetAmount = r.GameRoom.Opt.BetAssetOptions[0]
//} else {
// r.playerBetCtrl[player.ChairId].BetAmount = r.GameRoom.Opt.BetAssetOptions[1]
//}
r.playerBetCtrl[player.ChairId].BetAmount = r.GameRoom.Opt.BetAssetOptions[tempIndex]
} else {
r.playerBetCtrl[player.ChairId].BetAmount = r.GameRoom.BloodCtrl.ChipList[0]
}
@ -319,11 +333,13 @@ func (r *RobotManager) OnRobotMessage(msgId int32, player *Player, msg interface
// 随机下注金额
if len(r.GameRoom.Opt.BetAssetOptions) >= 2 {
if rand.Intn(100) < 50 {
r.playerBetCtrl[player.ChairId].BetAmount = r.GameRoom.Opt.BetAssetOptions[0]
} else {
r.playerBetCtrl[player.ChairId].BetAmount = r.GameRoom.Opt.BetAssetOptions[1]
}
//if rand.Intn(100) < 50 {
// r.playerBetCtrl[player.ChairId].BetAmount = r.GameRoom.Opt.BetAssetOptions[0]
//} else {
// r.playerBetCtrl[player.ChairId].BetAmount = r.GameRoom.Opt.BetAssetOptions[1]
//}
r.playerBetCtrl[player.ChairId].BetAmount = r.GameRoom.Opt.BetAssetOptions[tempIndex]
} else {
r.playerBetCtrl[player.ChairId].BetAmount = r.GameRoom.BloodCtrl.ChipList[0]
}

7
game-server/game/SixAndarBahar/app/core/protocol/protocol_msg.go

@ -211,3 +211,10 @@ type Options struct {
DefaultBet int64 `json:"defaultBet"` // 默认下注
RoundTime int64 `json:"roundTime"` // 每轮回合的轮次时间
}
type RecordInfo struct { // 通知最新一条记录
Area int32 `json:"area"`
BetAmount int64 `json:"betAmount"`
AreaPro float64 `json:"areaPro"`
IsWin bool `json:"isWin"`
}

1
game-server/game/SixAndarBahar/app/core/room/base.go

@ -29,6 +29,7 @@ type HomeBase interface {
GetRoomCreator() int64 // 获取房主
IsCanDissolution() bool // 是否能解散房间
UpdateCtx(uid int64, ctx *node.Context) // 无奈加的,更新node.Context
UpdateUserOut(uid int64) // 更新用户退出状态
OnUserBet(uid int64, msg interface{}, Auto bool) // 用户下注
OnUserGetBanker(uid int64, msg interface{}) // 用户抢庄
OnUserWatchToDown(uid int64, msg interface{}) // 用户观战转坐下

22
game-server/game/SixAndarBahar/app/gamemanage/gamemanage.go

@ -9,6 +9,7 @@ import (
"xgame/game/SixAndarBahar/app/core/protocol"
"xgame/game/SixAndarBahar/app/core/room"
"xgame/game/SixAndarBahar/app/route"
"xgame/internal/code"
accountservice "xgame/internal/service/account"
accountpb "xgame/internal/service/account/pb"
assetservice "xgame/internal/service/asset"
@ -367,7 +368,26 @@ func LogoutTable(ctx *node.Context) { // 用户退出游戏请求
if TempPlayer != nil {
log.Debug("LogoutTable 没有获取到用户 ", Ctx.Request.UID)
}
if TempPlayer != nil && TempPlayer.ChairId == RoomInfo.CurrBanker && RoomInfo.CurrentGameState > protocol.STATE_GET_BANKER {
if RoomInfo != nil && RoomInfo.CurrentGameState > protocol.STATE_GET_BANKER && RoomInfo.CurrentGameState != protocol.STATE_OTHER_RESULT {
if TempPlayer.ChairId != -1 && (TempPlayer.ChairId == RoomInfo.CurrBanker || TempPlayer.CanBet) {
log.Debug("LogoutTable 开始游戏后不能退出游戏 ", " Request", ctx.Request)
LeaveTableRes := &protocol.LeaveTableRes{
Code: code.ErrorWaitGameEndOut.Code(),
CodeMsg: "开始游戏后不能退出游戏",
}
Ctx.Request.Message.Route = route.LogoutTableRes
if err := Ctx.Response(LeaveTableRes); err != nil {
log.Debugf("开始游戏后不能退出游戏 出错了: %v", err)
}
RoomInfo.UpdateUserOut(Ctx.Request.UID)
return
}
}
if TempPlayer != nil && TempPlayer.ChairId == RoomInfo.CurrBanker && RoomInfo.CurrentGameState > protocol.STATE_GET_BANKER && RoomInfo.CurrentGameState != protocol.STATE_OTHER_RESULT {
log.Debug("LogoutTable 庄家不能离开房间 ", " Request", ctx.Request)
LeaveTableRes := &protocol.LeaveTableRes{
Code: protocol.ErrorLeaveTableBanker,

12
game-server/game/SixAndarBahar/config/blood.json

@ -31,6 +31,8 @@
"GearConfig": [
{
"GearID": 3000,
"CommentChipPro": "机器人下注的概率",
"ChipPro": [4000,2000,2000,1000,1000],
"WinPro": 6000,
"BankerPro": 2000,
"MustBankerPro": 2000,
@ -40,6 +42,8 @@
"Round2AreaPro": 5000
},{
"GearID": 2000,
"CommentChipPro": "机器人下注的概率",
"ChipPro": [4000,2000,2000,1000,1000],
"WinPro": 3000,
"BankerPro": 2000,
"MustBankerPro": 2000,
@ -49,6 +53,8 @@
"Round2AreaPro": 5000
},{
"GearID": 1000,
"CommentChipPro": "机器人下注的概率",
"ChipPro": [4000,2000,2000,1000,1000],
"WinPro": 500,
"BankerPro": 2000,
"MustBankerPro": 2000,
@ -58,6 +64,8 @@
"Round2AreaPro": 5000
},{
"GearID": -1000,
"CommentChipPro": "机器人下注的概率",
"ChipPro": [4000,2000,2000,1000,1000],
"WinPro": 0,
"BankerPro": 2000,
"MustBankerPro": 2000,
@ -67,6 +75,8 @@
"Round2AreaPro": 5000
},{
"GearID": -2000,
"CommentChipPro": "机器人下注的概率",
"ChipPro": [4000,2000,2000,1000,1000],
"WinPro": 1500,
"BankerPro": 2000,
"MustBankerPro": 2000,
@ -76,6 +86,8 @@
"Round2AreaPro": 5000
},{
"GearID": -3000,
"CommentChipPro": "机器人下注的概率",
"ChipPro": [4000,2000,2000,1000,1000],
"WinPro": 3000,
"BankerPro": 2000,
"MustBankerPro": 2000,

18
game-server/game/rummy/app/core/game/game_logic.go

@ -32,6 +32,19 @@ func (rr *Room) UpdateCtx(uid int64, ctx *node.Context) {
}
}
func (rr *Room) UpdateUserOut(uid int64) { // 更新用户退出状态
rr.roomRWLock.Lock()
defer rr.roomRWLock.Unlock()
for Index, p := range rr.PlayerMap {
if p.Uid == uid {
rr.PlayerMap[Index].UserNeedOut = true
break
}
}
}
func (rr *Room) run() {
nowUnixNano := time.Now().UnixNano()
@ -249,6 +262,11 @@ func (rr *Room) run() {
log.Debug("用户 ", player.Nickname, " 连续观战了3局 ", rr.RId)
rr.OnGetOutRoom(player.Uid, protocol.LEAVE_REASON_2)
}
if player.UserNeedOut {
log.Debug(" 桌子号", rr.RId, " 用户 ", player.Nickname, " 需要退出 ")
rr.OnGetOutRoom(player.Uid, protocol.LEAVE_REASON_4)
}
}
//for _, player := range rr.PlayerWatchMap {

55
game-server/game/rummy/app/core/game/game_over.go

@ -1,6 +1,7 @@
package game
import (
"base/encoding/json"
"base/log"
"fmt"
"github.com/shopspring/decimal"
@ -64,6 +65,44 @@ func (rr *Room) OnEventGameConclude(chairID int32, reason int32) {
rr.CurrentOperationTimer = milliseconds + END_SHOW_OUT
rr.CurrentGameState = TIME_ID_END_SHOW
var sArea string
sArea = ""
var RecordInfo protocol.RecordInfo
for _, player := range rr.PlayerMap {
var RecordInfoPlayer protocol.RecordInfoPlayer
RecordInfoPlayer.ChairID = player.ChairId
RecordInfoPlayer.UserNo = player.UserNo
for _, cards := range player.HandsCard {
TempHandCardsInfo := protocol.RecordInfoPlayerHandCards{
CardType: cards.CardType,
AllCoin: cards.AllCoin,
}
for _, poker := range cards.Pokers {
TempHandCardsInfo.Pokers = append(TempHandCardsInfo.Pokers, int32(poker))
}
RecordInfoPlayer.HandPoker = append(RecordInfoPlayer.HandPoker, TempHandCardsInfo)
}
RecordInfoPlayer.Score = player.GetTotalCount(player.HandsCard)
RecordInfo.Player = append(RecordInfo.Player, RecordInfoPlayer)
}
options, err := json.Marshal(RecordInfo)
if err != nil {
log.Debug("RecordInfo 序列化失败")
}
sArea = string(options)
var sPlayers string
for _, player := range rr.PlayerMap {
if !player.IsRobot {
if len(sPlayers) == 0 {
sPlayers = sPlayers + player.UserNo
} else {
sPlayers = sPlayers + "," + player.UserNo
}
}
}
switch reason {
case NORMAL_END: //常规结束
{
@ -121,7 +160,7 @@ func (rr *Room) OnEventGameConclude(chairID int32, reason int32) {
//rr.UserScore[i] = rr.UserScore[i].Sub(AddScore)
if !TempPlayer.IsRobot && (TempPlayer.Ctx != nil) {
AfterGold, BloodPool, StockNum := rr.WriteUserScore(TempPlayer, -AddScore.CoefficientInt64(), rr.ReasonString, AddScore.CoefficientInt64())
AfterGold, BloodPool, StockNum := rr.WriteUserScore(TempPlayer, -AddScore.CoefficientInt64(), rr.ReasonString, AddScore.CoefficientInt64(), sArea, sPlayers)
log.Debug("WriteUserScore 后 AfterGold=", AfterGold, " BloodPool=", BloodPool, " StockNum=", StockNum)
//rpc_client.DecrAsset(TempPlayer.Ctx, AddScore.CoefficientInt64(), rr.GameID*10+rr.RoomID)
rr.UserScore[i] = decimal.NewFromInt(AfterGold)
@ -157,7 +196,7 @@ func (rr *Room) OnEventGameConclude(chairID int32, reason int32) {
}
if !WinPlayer.IsRobot && (WinPlayer.Ctx != nil) {
AfterGold, BloodPool, StockNum := rr.WriteUserScore(WinPlayer, WinPlayerScore, rr.ReasonString, UserRealBet)
AfterGold, BloodPool, StockNum := rr.WriteUserScore(WinPlayer, WinPlayerScore, rr.ReasonString, UserRealBet, sArea, sPlayers)
log.Debug("WriteUserScore 后 AfterGold=", AfterGold, " BloodPool=", BloodPool, " StockNum=", StockNum)
//rpc_client.IncrAsset(WinPlayer.Ctx, WinPlayerScore, rr.ReasonString)
WinPlayer.Gold = decimal.NewFromInt(AfterGold)
@ -282,7 +321,7 @@ func (rr *Room) OnEventGameConclude(chairID int32, reason int32) {
rr.UserScore[i] = rr.UserScore[i].Add(AddScore)
if !p.IsRobot && (p.Ctx != nil) {
AfterGold, BloodPool, StockNum := rr.WriteUserScore(p, AddScore.CoefficientInt64(), rr.ReasonString, rr.Opt.MinBetAsset)
AfterGold, BloodPool, StockNum := rr.WriteUserScore(p, AddScore.CoefficientInt64(), rr.ReasonString, rr.Opt.MinBetAsset, sArea, sPlayers)
log.Debug("WriteUserScore 后 AfterGold=", AfterGold, " BloodPool=", BloodPool, " StockNum=", StockNum)
//rpc_client.IncrAsset(p.Ctx, AddScore.CoefficientInt64(), rr.ReasonString)
rr.PlayerMap[i].Gold = decimal.NewFromInt(AfterGold)
@ -311,7 +350,7 @@ func (rr *Room) OnEventGameConclude(chairID int32, reason int32) {
rr.UserScore[i] = rr.UserScore[i].Sub(AddScore)
if !p.IsRobot && (p.Ctx != nil) {
AfterGold, BloodPool, StockNum := rr.WriteUserScore(p, -AddScore.CoefficientInt64(), rr.ReasonString, AddScore.CoefficientInt64())
AfterGold, BloodPool, StockNum := rr.WriteUserScore(p, -AddScore.CoefficientInt64(), rr.ReasonString, AddScore.CoefficientInt64(), sArea, sPlayers)
log.Debug("WriteUserScore 后 AfterGold=", AfterGold, " BloodPool=", BloodPool, " StockNum=", StockNum)
//rpc_client.DecrAsset(p.Ctx, AddScore.CoefficientInt64(), rr.ReasonString)
p.Gold = decimal.NewFromInt(AfterGold)
@ -378,7 +417,7 @@ func (rr *Room) OnEventGameConclude(chairID int32, reason int32) {
rr.UserScore[i] = rr.UserScore[i].Add(AddScore)
if !p.IsRobot && (p.Ctx != nil) {
AfterGold, BloodPool, StockNum := rr.WriteUserScore(p, AddScore.CoefficientInt64(), rr.ReasonString, rr.Opt.MinBetAsset)
AfterGold, BloodPool, StockNum := rr.WriteUserScore(p, AddScore.CoefficientInt64(), rr.ReasonString, rr.Opt.MinBetAsset, sArea, sPlayers)
log.Debug("WriteUserScore 后 AfterGold=", AfterGold, " BloodPool=", BloodPool, " StockNum=", StockNum)
//rpc_client.IncrAsset(p.Ctx, AddScore.CoefficientInt64(), rr.ReasonString)
rr.PlayerMap[i].Gold = decimal.NewFromInt(AfterGold)
@ -404,7 +443,7 @@ func (rr *Room) OnEventGameConclude(chairID int32, reason int32) {
rr.UserScore[i] = rr.UserScore[i].Sub(AddScore)
if !p.IsRobot && (p.Ctx != nil) {
AfterGold, BloodPool, StockNum := rr.WriteUserScore(p, -AddScore.CoefficientInt64(), rr.ReasonString, AddScore.CoefficientInt64())
AfterGold, BloodPool, StockNum := rr.WriteUserScore(p, -AddScore.CoefficientInt64(), rr.ReasonString, AddScore.CoefficientInt64(), sArea, sPlayers)
log.Debug("WriteUserScore 后 AfterGold=", AfterGold, " BloodPool=", BloodPool, " StockNum=", StockNum)
//rpc_client.DecrAsset(p.Ctx, AddScore.CoefficientInt64(), rr.ReasonString)
p.Gold = decimal.NewFromInt(AfterGold)
@ -433,7 +472,7 @@ func (rr *Room) OnEventGameConclude(chairID int32, reason int32) {
log.Debug(END_SHOW_OUT/1000, ":秒后开始判断是否开启下一局")
}
func (rr *Room) WriteUserScore(User *Player, count int64, reason string, UserRealBet int64) (int64, float64, int64) {
func (rr *Room) WriteUserScore(User *Player, count int64, reason string, UserRealBet int64, Area string, Players string) (int64, float64, int64) {
currentDate := time.Now().Format("20060102")
roundNo := fmt.Sprintf(fmt.Sprintf("%s%s%s", currentDate, strconv.Itoa(int(rr.RoomID)), rpc_client.GenerateRoundNo()))
Req := writeUserScorepb.WriteUserScoreArgs{
@ -465,6 +504,8 @@ func (rr *Room) WriteUserScore(User *Player, count int64, reason string, UserRea
CheatValueBefore: User.CheatValueBefore,
CheatValueAfter: 0,
UserAmount: count / rr.Opt.MinBetAsset,
Area: Area,
Players: Players,
UserRealBet: UserRealBet,
}
log.Debug("用户", User.Uid, "名字", User.Nickname, "写分 ", Req)

2
game-server/game/rummy/app/core/game/game_player.go

@ -46,6 +46,8 @@ type Player struct {
PlayCount int //在桌子上呆了几局
PlayWatchCount int //在桌子连续观战了几局
CanBet bool // 玩家是否需要等待下一局开始
UserNeedOut bool //退出状态
}
func (p *Player) GetTotalCount(CurrentHandCards []types.HandCards) int32 {

18
game-server/game/rummy/app/core/protocol/protocol_msg.go

@ -227,3 +227,21 @@ type Options struct {
DefaultBet int64 `json:"defaultBet"` // 默认下注
RoundTime int64 `json:"roundTime"` // 每轮回合的轮次时间
}
// HandCards 手牌
type RecordInfoPlayerHandCards struct {
Pokers []int32 `json:"pokers"` // 牌组
CardType byte `json:"card_type"` // 牌型
AllCoin int `json:"all_coin"` // 牌分值
}
type RecordInfoPlayer struct { // 存储的结构显示
ChairID int32 `json:"chairId"` //座位ID
UserNo string `json:"userNo"` //用户ID
HandPoker []RecordInfoPlayerHandCards `json:"handPoker,omitempty"` //用户当前手牌
Score int32 `json:"score"` //总分数
}
type RecordInfo struct { // 存储的结构显示
Player []RecordInfoPlayer `json:"player,omitempty"` // 单独用户信息
}

1
game-server/game/rummy/app/core/room/base.go

@ -32,6 +32,7 @@ type HomeBase interface {
GetRoomCreator() int64 // 获取房主
IsCanDissolution() bool // 是否能解散房间
UpdateCtx(uid int64, ctx *node.Context) // 无奈加的,更新node.Context
UpdateUserOut(uid int64) // 更新用户退出状态
OnUserWatchToDown(uid int64, msg interface{}) // 用户观战转坐下
OnNoticeGameConclude(seat int32, reason int32) // 通知有人胡牌 理牌操作
OnReqGroupCard(uid int64, msg interface{}) //

19
game-server/game/rummy/app/gamemanage/gamemanage.go

@ -9,6 +9,7 @@ import (
"xgame/game/rummy/app/core/protocol"
"xgame/game/rummy/app/core/room"
"xgame/game/rummy/app/route"
"xgame/internal/code"
accountservice "xgame/internal/service/account"
accountpb "xgame/internal/service/account/pb"
assetservice "xgame/internal/service/asset"
@ -474,6 +475,24 @@ func LogoutTable(ctx *node.Context) { // 用户退出游戏请求
return
}
if RoomInfo != nil && (RoomInfo.State == game.EN_TABLE_STATE_PLAYING || RoomInfo.State == game.EN_TABLE_STATE_LIANG_PAI) {
if TempPlayer.ChairId != -1 {
log.Debug("LogoutTable 开始游戏后不能退出游戏 ", " Request", ctx.Request)
LeaveTableRes := &protocol.LeaveTableRes{
Code: code.ErrorWaitGameEndOut.Code(),
CodeMsg: "开始游戏后不能退出游戏",
}
Ctx.Request.Message.Route = route.LogoutTableRes
if err := Ctx.Response(LeaveTableRes); err != nil {
log.Debugf("开始游戏后不能退出游戏 出错了: %v", err)
}
RoomInfo.UpdateUserOut(Ctx.Request.UID)
return
}
}
log.Debug("UpdateCtx LogoutTable ", Ctx.Request.UID, " UserId", ctx.Request.UserId, " UID", ctx.Request.UID, " Request", ctx.Request)
r.UpdateCtx(Ctx.Request.UID, Ctx)

12
game-server/game/rummy/config/blood.json

@ -10,36 +10,48 @@
{
"GearIDComment": "GearID 【输 3000档】",
"GearID": 3000,
"CommentChipPro": "机器人下注的概率",
"ChipPro": [4000,2000,2000,1000,1000],
"RoundRate": [[0,0],[1,1046],[2,1700 ],[3,2720 ],[5,4534 ]],
"RobotScorePro": [[80,100],[60,1000],[40,3000],[20,5000]]
},
{
"GearIDComment": "GearID 【输 2000档】",
"GearID": 2000,
"CommentChipPro": "机器人下注的概率",
"ChipPro": [4000,2000,2000,1000,1000],
"RoundRate": [[0,0],[1,953 ],[3,1540 ],[5,2502 ],[8,5005 ]],
"RobotScorePro": [[80,100],[60,1000],[40,3000],[20,5000]]
},
{
"GearIDComment": "GearID 【输 1000档】",
"GearID": 1000,
"CommentChipPro": "机器人下注的概率",
"ChipPro": [4000,2000,2000,1000,1000],
"RoundRate": [[0,0],[2,991 ],[5,1604 ],[8,2592 ],[13,4813 ]],
"RobotScorePro": [[80,100],[60,1000],[40,3000],[20,5000]]
},
{
"GearIDComment": "GearID 【赢 -1000档】",
"GearID": -1000,
"CommentChipPro": "机器人下注的概率",
"ChipPro": [4000,2000,2000,1000,1000],
"RoundRate": [[0,0],[3,978 ],[8,1580 ],[13,2558 ],[21,4884 ]],
"RobotScorePro": [[80,100],[60,1000],[40,3000],[20,5000]]
},
{
"GearIDComment": "GearID 【赢 -2000档】",
"GearID": -2000,
"CommentChipPro": "机器人下注的概率",
"ChipPro": [4000,2000,2000,1000,1000],
"RoundRate": [[0,0],[5,1071 ],[13,1467 ],[21,2166 ],[34,5296 ]],
"RobotScorePro": [[80,100],[60,1000],[40,3000],[20,5000]]
},
{
"GearIDComment": "GearID 【赢 -3000档】",
"GearID": -3000,
"CommentChipPro": "机器人下注的概率",
"ChipPro": [4000,2000,2000,1000,1000],
"RoundRate": [[0,0],[8,981 ],[21,1586 ],[34,2566 ],[55,4867 ]],
"RobotScorePro": [[80,100],[60,1000],[40,3000],[20,5000]]
}

1
game-server/internal/code/code.go

@ -116,4 +116,5 @@ var (
UserAgentRateLimitDown = codes.NewCode(504, "user agent rate limit up") // 该代理级别的分成必须大于下级分成的百分之五(零除外)
UserAgentHaveNextLevel = codes.NewCode(505, "user agent have next level") // 该代理有下级代理不能删除,不能操作
ErrorWaitGameEndOut = codes.NewCode(80000001, "you will out wait game over") //将在本局结束后自动退出
)

Loading…
Cancel
Save