Browse Source

1 新增首次进入机器人

2 新增获取真人开的房间的机器人进入配置
3 新增游戏记录增加桌子id和机器人数量
dev
MoQingYu 4 months ago
parent
commit
35ab75c0fe
  1. 6
      game-server/game/21Game/app/core/game/game_init.go
  2. 2
      game-server/game/21Game/app/core/game/game_over.go
  3. 45
      game-server/game/21Game/app/core/game/game_robot.go
  4. 10
      game-server/game/21Game/app/core/game/game_robot_timer.go
  5. 2
      game-server/game/21Game/app/core/room/roommgr.go
  6. 2
      game-server/game/AndarBahar/app/core/game/game_over.go
  7. 4
      game-server/game/AndarBahar/app/gamemanage/gamemanage.go
  8. 2
      game-server/game/SixAndarBahar/app/core/game/game_over.go
  9. 45
      game-server/game/SixAndarBahar/app/core/game/game_robot.go
  10. 10
      game-server/game/SixAndarBahar/app/core/game/game_robot_timer.go
  11. 2
      game-server/game/SixAndarBahar/app/core/room/roommgr.go
  12. 6
      game-server/game/rummy/app/core/game/game_init.go
  13. 7
      game-server/game/rummy/app/core/game/game_over.go
  14. 45
      game-server/game/rummy/app/core/game/game_robot.go
  15. 10
      game-server/game/rummy/app/core/game/game_robot_timer.go
  16. 4
      game-server/game/rummy/app/core/protocol/protocol_msg.go
  17. 2
      game-server/game/rummy/app/core/room/roommgr.go

6
game-server/game/21Game/app/core/game/game_init.go

@ -59,7 +59,11 @@ func (rr *Room) OnInit() bool {
rr.InitBloodControl()
var gameTableConfig *gamepb.FetchGameTableTotalsReply
gameTableConfig = rpc_client.GetTableCtrlConfig(rr.RoomProxy, int64(rr.GameID), strconv.Itoa(int(rr.RoomID)))
TableType := int64(1) //1 系统 2玩家
if rr.CreatorId != 0 {
TableType = 2
}
gameTableConfig = rpc_client.GetTableCtrlConfig(rr.RoomProxy, int64(rr.GameID), strconv.Itoa(int(rr.RoomID)), TableType)
if len(gameTableConfig.List) == 0 {
log.Error(" 21点后台获取桌子配置 无配置 房间等级 ", rr.RoomID)
} else {

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

@ -860,6 +860,8 @@ func (rr *Room) WriteUserScore(User *Player, BetType int32, BetGold int64, WinBe
Area: Area,
Players: Players,
UserRealBet: UserRealBet,
TableId: rr.RId,
RobotCount: int64(rr.GetRoomPlayerCount() - rr.GetRoomRealPlayerCount()),
}
if BetType == 3 {
Req.UserAmount = 0

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

@ -29,6 +29,7 @@ type RobotManager struct {
GronTimer *gron.Cron
Lock sync.RWMutex
GameRoom *Room
FirstEnterTimer int64 //首个机器人进入时间
NextEnterTimer int64 //下个机器人进入时间
FlushCountTimer int64 //下次刷新机器人数量的时间
MaxCount int //机器人数量
@ -81,12 +82,44 @@ func (r *RobotManager) OnInit(conf string, GameRoom *Room) {
nowUnixNano := time.Now().UnixNano()
nowMilliSeconds := nowUnixNano / 1e6
// 这里现在修改立马进入一个机器人
r.NextEnterTimer = nowMilliSeconds + 100
//MinInterTime := GameRoom.BloodCtrl.AndroidOprateConfig.JoinHZ[0] * 1000
//MaxInterTime := GameRoom.BloodCtrl.AndroidOprateConfig.JoinHZ[1] * 1000
//rTime := int64(rand.Intn(MaxInterTime-MinInterTime) + MinInterTime)
//r.NextEnterTimer = nowMilliSeconds + rTime
// 第一个进入的机器人 只判断一次
r.FirstEnterTimer = 0
if r.GameRoom.CreatorId != 0 {
FirstMinTime := r.GameRoom.TableConfig.FirstRobotCheckMinFrequency
FirstMaxTime := r.GameRoom.TableConfig.FirstRobotCheckMaxFrequency
if FirstMaxTime <= FirstMinTime {
r.FirstEnterTimer = nowMilliSeconds + FirstMaxTime
} else {
r.FirstEnterTimer = nowMilliSeconds + rand.Int63n(FirstMaxTime-FirstMinTime) + FirstMinTime
}
}
// 间隔多少时间正常进个机器人
MinInterTime := 0
MaxInterTime := 0
if r.GameRoom.TableConfig != nil {
MinInterTime = int(r.GameRoom.TableConfig.RobotCheckMinFrequency) * 1000
MaxInterTime = int(r.GameRoom.TableConfig.RobotCheckMaxFrequency) * 1000
log.Debug(" 后台配置 机器人进入频率 最小 ", MinInterTime, " 最大 ", MaxInterTime)
} else {
MinInterTime = r.GameRoom.BloodCtrl.AndroidOprateConfig.JoinHZ[0] * 1000
MaxInterTime = r.GameRoom.BloodCtrl.AndroidOprateConfig.JoinHZ[1] * 1000
}
rTime := int64(0)
if MaxInterTime <= MinInterTime {
rTime = int64(MinInterTime)
} else {
rTime = int64(rand.Intn(MaxInterTime-MinInterTime) + MinInterTime)
}
//处理个意外
if rTime == 0 {
rTime = 2000
log.Error(" 出现0了 是不行的 ", r.GameRoom.RoomID)
}
r.NextEnterTimer = nowMilliSeconds + rTime
if GameRoom.TableConfig != nil {
r.MaxCount = 0

10
game-server/game/21Game/app/core/game/game_robot_timer.go

@ -16,8 +16,16 @@ func (r *RobotManager) KickRobotTimer() {
func (r *RobotManager) run() {
milliseconds := time.Now().UnixMilli()
if r.FirstEnterTimer != 0 && milliseconds >= r.FirstEnterTimer {
r.FirstEnterTimer = 0
if r.GameRoom.GetInRoomRobotCount() < int32(r.MaxCount) {
//r.Lock.Lock()
r.RobotsEnterGameRoom()
}
}
if milliseconds >= r.NextEnterTimer {
if r.GameRoom.CreatorId == 0 && r.GameRoom.GetInRoomRobotCount() < int32(r.MaxCount) {
if r.GameRoom.GetInRoomRobotCount() < int32(r.MaxCount) {
//r.Lock.Lock()
r.RobotsEnterGameRoom()

2
game-server/game/21Game/app/core/room/roommgr.go

@ -90,7 +90,7 @@ func (h *Home) InitBloodControl() {
func (h *Home) InitBloodControlByBackend() {
// 按等级从后台获取到配置
var replyOpt *gamepb.FetchGameTableTotalsReply
replyOpt = rpc_client.GetTableCtrlConfig(h.GameProxy, game.GAME_ID, "")
replyOpt = rpc_client.GetTableCtrlConfig(h.GameProxy, game.GAME_ID, "", 1)
h.TableConfig = replyOpt.List
if len(h.TableConfig) == 0 {
log.Error(game.GAME_ID, " 21点后台获取桌子配置 无配置")

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

@ -858,6 +858,8 @@ func (rr *Room) WriteUserScore(User *Player, BetType int32, BetGold int64, WinBe
Area: Area,
Players: Players,
UserRealBet: UserRealBet,
TableId: rr.RId,
RobotCount: int64(rr.GetRoomPlayerCount() - rr.GetRoomRealPlayerCount()),
}
log.Debug("用户", User.Uid, "名字", User.Nickname, "写分 ", Req)
Res := rpc_client.WriteUserScore(rr.RoomProxy, Req)

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

@ -121,6 +121,10 @@ func EnterGame(ctx *node.Context) {
if playerControl.CheatType != 0 {
log.Debug("EnterGame user:", user.Nickname, "在房间中 但还是单分一个房间出来")
roomObj = room.Gh.CopyRoom(Ctx.Request.UID, GameProxy)
log.Debug("UpdateCtx EnterGame ", Ctx.Request.UID, " UserId", Ctx.Request.UserId, " UID", Ctx.Request.UID, " Request", Ctx.Request)
roomObj.OnGetRoomInfo(Ctx.Request.UID, Ctx)
return
} else {
log.Debug("玩家", Ctx.Request.UID, " name:", user.Nickname, "====>在房间中 发送最新的房间信息")

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

@ -496,6 +496,8 @@ func (rr *Room) WriteUserScore(User *Player, BetType int32, BetGold int64, WinBe
Area: Area,
Players: Players,
UserRealBet: UserRealBet,
TableId: rr.RId,
RobotCount: int64(rr.GetRoomPlayerCount() - rr.GetRoomRealPlayerCount()),
}
if BetType == 3 {
Req.UserAmount = 0

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

@ -36,6 +36,7 @@ type RobotManager struct {
GronTimer *gron.Cron
Lock sync.RWMutex
GameRoom *Room
FirstEnterTimer int64 //首个机器人进入时间
NextEnterTimer int64 //下个机器人进入时间
FlushCountTimer int64 //下次刷新机器人数量的时间
MaxCount int //机器人数量
@ -73,12 +74,44 @@ func (r *RobotManager) OnInit(conf string, GameRoom *Room) {
nowUnixNano := time.Now().UnixNano()
nowMilliSeconds := nowUnixNano / 1e6
// 这里现在修改立马进入一个机器人
r.NextEnterTimer = nowMilliSeconds + 100
//MinInterTime := GameRoom.BloodCtrl.AndroidOprateConfig.JoinHZ[0] * 1000
//MaxInterTime := GameRoom.BloodCtrl.AndroidOprateConfig.JoinHZ[1] * 1000
//rTime := int64(rand.Intn(MaxInterTime-MinInterTime) + MinInterTime)
//r.NextEnterTimer = nowMilliSeconds + rTime
// 第一个进入的机器人 只判断一次
r.FirstEnterTimer = 0
if r.GameRoom.CreatorId != 0 {
FirstMinTime := r.GameRoom.TableConfig.FirstRobotCheckMinFrequency
FirstMaxTime := r.GameRoom.TableConfig.FirstRobotCheckMaxFrequency
if FirstMaxTime <= FirstMinTime {
r.FirstEnterTimer = nowMilliSeconds + FirstMaxTime
} else {
r.FirstEnterTimer = nowMilliSeconds + rand.Int63n(FirstMaxTime-FirstMinTime) + FirstMinTime
}
}
// 间隔多少时间正常进个机器人
MinInterTime := 0
MaxInterTime := 0
if r.GameRoom.TableConfig != nil {
MinInterTime = int(r.GameRoom.TableConfig.RobotCheckMinFrequency) * 1000
MaxInterTime = int(r.GameRoom.TableConfig.RobotCheckMaxFrequency) * 1000
log.Debug(" 后台配置 机器人进入频率 最小 ", MinInterTime, " 最大 ", MaxInterTime)
} else {
MinInterTime = r.GameRoom.BloodCtrl.AndroidOprateConfig.JoinHZ[0] * 1000
MaxInterTime = r.GameRoom.BloodCtrl.AndroidOprateConfig.JoinHZ[1] * 1000
}
rTime := int64(0)
if MaxInterTime <= MinInterTime {
rTime = int64(MinInterTime)
} else {
rTime = int64(rand.Intn(MaxInterTime-MinInterTime) + MinInterTime)
}
//处理个意外
if rTime == 0 {
rTime = 2000
log.Error(" 出现0了 是不行的 ", r.GameRoom.RoomID)
}
r.NextEnterTimer = nowMilliSeconds + rTime
if GameRoom.TableConfig != nil {
r.MaxCount = 0

10
game-server/game/SixAndarBahar/app/core/game/game_robot_timer.go

@ -15,8 +15,16 @@ func (r *RobotManager) KickRobotTimer() {
func (r *RobotManager) run() {
milliseconds := time.Now().UnixMilli()
if r.FirstEnterTimer != 0 && milliseconds >= r.FirstEnterTimer {
r.FirstEnterTimer = 0
if r.GameRoom.GetInRoomRobotCount() < int32(r.MaxCount) {
//r.Lock.Lock()
r.RobotsEnterGameRoom()
}
}
if milliseconds >= r.NextEnterTimer {
if r.GameRoom.CreatorId == 0 && r.GameRoom.GetInRoomRobotCount() < int32(r.MaxCount) {
if r.GameRoom.GetInRoomRobotCount() < int32(r.MaxCount) {
//r.Lock.Lock()
r.RobotsEnterGameRoom()

2
game-server/game/SixAndarBahar/app/core/room/roommgr.go

@ -88,7 +88,7 @@ func (h *Home) InitBloodControl() {
func (h *Home) InitBloodControlByBackend() {
// 按等级从后台获取到配置
var replyOpt *gamepb.FetchGameTableTotalsReply
replyOpt = rpc_client.GetTableCtrlConfig(h.GameProxy, game.GAME_ID, "")
replyOpt = rpc_client.GetTableCtrlConfig(h.GameProxy, game.GAME_ID, "", 1)
h.TableConfig = replyOpt.List
if len(h.TableConfig) == 0 {
log.Error(game.GAME_ID, " 21点后台获取桌子配置 无配置")

6
game-server/game/rummy/app/core/game/game_init.go

@ -58,7 +58,11 @@ func (rr *Room) OnInit() bool {
rr.InitBloodControl()
var gameTableConfig *gamepb.FetchGameTableTotalsReply
gameTableConfig = rpc_client.GetTableCtrlConfig(rr.RoomProxy, int64(rr.GameID), strconv.Itoa(int(rr.RoomID)))
TableType := int64(1) //1 系统 2玩家
if rr.CreatorId != 0 {
TableType = 2
}
gameTableConfig = rpc_client.GetTableCtrlConfig(rr.RoomProxy, int64(rr.GameID), strconv.Itoa(int(rr.RoomID)), TableType)
if len(gameTableConfig.List) == 0 {
log.Error(" 21点后台获取桌子配置 无配置 房间等级 ", rr.RoomID)
} else {

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

@ -68,6 +68,7 @@ func (rr *Room) OnEventGameConclude(chairID int32, reason int32) {
var sArea string
sArea = ""
var RecordInfo protocol.RecordInfo
RecordInfo.WildJokerCard = int32(rr.WildJokerCard)
for _, player := range rr.PlayerMap {
var RecordInfoPlayer protocol.RecordInfoPlayer
RecordInfoPlayer.ChairID = player.ChairId
@ -83,6 +84,10 @@ func (rr *Room) OnEventGameConclude(chairID int32, reason int32) {
RecordInfoPlayer.HandPoker = append(RecordInfoPlayer.HandPoker, TempHandCardsInfo)
}
RecordInfoPlayer.Score = player.GetTotalCount(player.HandsCard)
RecordInfoPlayer.IsWin = false
if chairID == player.ChairId {
RecordInfoPlayer.IsWin = true
}
RecordInfo.Player = append(RecordInfo.Player, RecordInfoPlayer)
}
options, err := json.Marshal(RecordInfo)
@ -507,6 +512,8 @@ func (rr *Room) WriteUserScore(User *Player, count int64, reason string, UserRea
Area: Area,
Players: Players,
UserRealBet: UserRealBet,
TableId: rr.RId,
RobotCount: int64(rr.GetRoomPlayerCount() - rr.GetRoomRealPlayerCount()),
}
log.Debug("用户", User.Uid, "名字", User.Nickname, "写分 ", Req)
Res := rpc_client.WriteUserScore(rr.RoomProxy, Req)

45
game-server/game/rummy/app/core/game/game_robot.go

@ -33,6 +33,7 @@ type RobotManager struct {
GronTimer *gron.Cron
Lock sync.RWMutex
GameRoom *Room
FirstEnterTimer int64 //首个机器人进入时间
NextEnterTimer int64 //下个机器人进入时间
FlushCountTimer int64 //下次刷新机器人数量的时间
MaxCount int //机器人数量
@ -82,12 +83,44 @@ func (r *RobotManager) OnInit(conf string, GameRoom *Room) {
nowUnixNano := time.Now().UnixNano()
nowMilliSeconds := nowUnixNano / 1e6
// 这里现在修改立马进入一个机器人
r.NextEnterTimer = nowMilliSeconds + 100
//MinInterTime := GameRoom.BloodCtrl.AndroidOprateConfig.JoinHZ[0] * 1000
//MaxInterTime := GameRoom.BloodCtrl.AndroidOprateConfig.JoinHZ[1] * 1000
//rTime := int64(rand.Intn(MaxInterTime-MinInterTime) + MinInterTime)
//r.NextEnterTimer = nowMilliSeconds + rTime
// 第一个进入的机器人 只判断一次
r.FirstEnterTimer = 0
if r.GameRoom.CreatorId != 0 {
FirstMinTime := r.GameRoom.TableConfig.FirstRobotCheckMinFrequency
FirstMaxTime := r.GameRoom.TableConfig.FirstRobotCheckMaxFrequency
if FirstMaxTime <= FirstMinTime {
r.FirstEnterTimer = nowMilliSeconds + FirstMaxTime
} else {
r.FirstEnterTimer = nowMilliSeconds + rand.Int63n(FirstMaxTime-FirstMinTime) + FirstMinTime
}
}
// 间隔多少时间正常进个机器人
MinInterTime := 0
MaxInterTime := 0
if r.GameRoom.TableConfig != nil {
MinInterTime = int(r.GameRoom.TableConfig.RobotCheckMinFrequency) * 1000
MaxInterTime = int(r.GameRoom.TableConfig.RobotCheckMaxFrequency) * 1000
log.Debug(" 后台配置 机器人进入频率 最小 ", MinInterTime, " 最大 ", MaxInterTime)
} else {
MinInterTime = r.GameRoom.BloodCtrl.AndroidOprateConfig.JoinHZ[0] * 1000
MaxInterTime = r.GameRoom.BloodCtrl.AndroidOprateConfig.JoinHZ[1] * 1000
}
rTime := int64(0)
if MaxInterTime <= MinInterTime {
rTime = int64(MinInterTime)
} else {
rTime = int64(rand.Intn(MaxInterTime-MinInterTime) + MinInterTime)
}
//处理个意外
if rTime == 0 {
rTime = 2000
log.Error(" 出现0了 是不行的 ", r.GameRoom.RoomID)
}
r.NextEnterTimer = nowMilliSeconds + rTime
if GameRoom.TableConfig != nil {
r.MaxCount = 0

10
game-server/game/rummy/app/core/game/game_robot_timer.go

@ -17,8 +17,16 @@ func (r *RobotManager) KickRobotTimer() {
func (r *RobotManager) run() {
milliseconds := time.Now().UnixMilli()
if r.FirstEnterTimer != 0 && milliseconds >= r.FirstEnterTimer {
r.FirstEnterTimer = 0
if r.GameRoom.GetInRoomRobotCount() < int32(r.MaxCount) {
//r.Lock.Lock()
r.RobotsEnterGameRoom()
}
}
if milliseconds >= r.NextEnterTimer {
if r.GameRoom.CreatorId == 0 && r.GameRoom.GetInRoomRobotCount() < int32(r.MaxCount) {
if r.GameRoom.GetInRoomRobotCount() < int32(r.MaxCount) {
//r.Lock.Lock()
r.RobotsEnterGameRoom()

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

@ -240,8 +240,10 @@ type RecordInfoPlayer struct { // 存储的结构显示
UserNo string `json:"userNo"` //用户ID
HandPoker []RecordInfoPlayerHandCards `json:"handPoker,omitempty"` //用户当前手牌
Score int32 `json:"score"` //总分数
IsWin bool `json:"isWin"`
}
type RecordInfo struct { // 存储的结构显示
Player []RecordInfoPlayer `json:"player,omitempty"` // 单独用户信息
WildJokerCard int32 `json:"wildJokerCard"` // 鬼牌
Player []RecordInfoPlayer `json:"player,omitempty"` // 单独用户信息
}

2
game-server/game/rummy/app/core/room/roommgr.go

@ -88,7 +88,7 @@ func (h *Home) InitBloodControl() {
func (h *Home) InitBloodControlByBackend() {
// 按等级从后台获取到配置
var replyOpt *gamepb.FetchGameTableTotalsReply
replyOpt = rpc_client.GetTableCtrlConfig(h.GameProxy, game.GAME_ID, "")
replyOpt = rpc_client.GetTableCtrlConfig(h.GameProxy, game.GAME_ID, "", 1)
h.TableConfig = replyOpt.List
if len(h.TableConfig) == 0 {
log.Error(game.GAME_ID, " 21点后台获取桌子配置 无配置")

Loading…
Cancel
Save