|
|
@ -37,7 +37,7 @@ type RobotManager struct { |
|
|
|
NextEnterTimer int64 //下个机器人进入时间
|
|
|
|
FlushCountTimer int64 //下次刷新机器人数量的时间
|
|
|
|
MaxCount int //机器人数量
|
|
|
|
playerMaps map[int32]*Player //当前有的机器人
|
|
|
|
PlayerMaps map[int32]*Player //当前有的机器人
|
|
|
|
playerBetCtrl map[int32]*RobotBetCtrlInfo //当前有的机器人
|
|
|
|
playerStat map[int32]int32 //机器人的状态
|
|
|
|
RobotTimer map[int32]int64 //机器人的操作时间
|
|
|
@ -46,7 +46,7 @@ type RobotManager struct { |
|
|
|
func NewRobotManager() *RobotManager { |
|
|
|
rm := &RobotManager{ |
|
|
|
Lock: sync.RWMutex{}, |
|
|
|
playerMaps: make(map[int32]*Player), |
|
|
|
PlayerMaps: make(map[int32]*Player), |
|
|
|
playerStat: make(map[int32]int32), |
|
|
|
playerBetCtrl: make(map[int32]*RobotBetCtrlInfo), |
|
|
|
RobotTimer: make(map[int32]int64), |
|
|
@ -119,10 +119,22 @@ func (r *RobotManager) RobotsEnterGameRoom() { |
|
|
|
return |
|
|
|
} |
|
|
|
|
|
|
|
// 通知大厅有机器人坐下
|
|
|
|
NotifySitDown := &protocol.NotifyDTSitDown{ |
|
|
|
Uid: pPlayer.Uid, |
|
|
|
RoomID: r.GameRoom.RoomID, |
|
|
|
TableID: r.GameRoom.RId, |
|
|
|
ChairID: pPlayer.ChairId, |
|
|
|
Avatar: pPlayer.Avatar, |
|
|
|
State: r.GameRoom.CurrentGameState, |
|
|
|
CurrentCount: r.GameRoom.GetRoomPlayerCount(), |
|
|
|
} |
|
|
|
r.GameRoom.NotifyFunc(route.NotifyDTSitDown, NotifySitDown) |
|
|
|
|
|
|
|
r.Lock.Lock() |
|
|
|
defer r.Lock.Unlock() |
|
|
|
|
|
|
|
r.playerMaps[pPlayer.ChairId] = pPlayer |
|
|
|
r.PlayerMaps[pPlayer.ChairId] = pPlayer |
|
|
|
r.playerStat[pPlayer.ChairId] = 1 |
|
|
|
r.playerBetCtrl[pPlayer.ChairId] = &RobotBetCtrlInfo{} |
|
|
|
//随机一个下次判断行为时间
|
|
|
@ -136,7 +148,7 @@ func (r *RobotManager) CopyRobotsEnterGameRoom(pPlayer *Player) { // 复制的 |
|
|
|
r.Lock.Lock() |
|
|
|
defer r.Lock.Unlock() |
|
|
|
|
|
|
|
r.playerMaps[pPlayer.ChairId] = pPlayer |
|
|
|
r.PlayerMaps[pPlayer.ChairId] = pPlayer |
|
|
|
r.playerStat[pPlayer.ChairId] = 1 |
|
|
|
r.playerBetCtrl[pPlayer.ChairId] = &RobotBetCtrlInfo{} |
|
|
|
//随机一个下次判断行为时间
|
|
|
@ -150,12 +162,12 @@ func (r *RobotManager) AddLeaveRobot(chairId int32) { // 机器人离开 |
|
|
|
r.Lock.Lock() |
|
|
|
defer r.Lock.Unlock() |
|
|
|
|
|
|
|
robot := r.playerMaps[chairId] |
|
|
|
robot := r.PlayerMaps[chairId] |
|
|
|
if robot == nil { |
|
|
|
return |
|
|
|
} |
|
|
|
|
|
|
|
delete(r.playerMaps, chairId) |
|
|
|
delete(r.PlayerMaps, chairId) |
|
|
|
delete(r.RobotTimer, chairId) |
|
|
|
delete(r.playerStat, chairId) |
|
|
|
delete(r.playerBetCtrl, chairId) |
|
|
@ -331,6 +343,18 @@ func (r *RobotManager) OnRobotMessage(msgId int32, player *Player, msg interface |
|
|
|
} |
|
|
|
|
|
|
|
if r.GameRoom.GetInRoomRobotCount() > int32(LeastMin) && rand.Intn(10000) < LeavePro { |
|
|
|
// 通知大厅有人离开
|
|
|
|
NotifySitDown := &protocol.NotifyDTSitDown{ |
|
|
|
Uid: player.Uid, |
|
|
|
RoomID: r.GameRoom.RoomID, |
|
|
|
TableID: r.GameRoom.RId, |
|
|
|
ChairID: player.ChairId, |
|
|
|
Avatar: player.Avatar, |
|
|
|
State: r.GameRoom.CurrentGameState, |
|
|
|
CurrentCount: r.GameRoom.GetRoomPlayerCount() - 1, |
|
|
|
} |
|
|
|
r.GameRoom.NotifyFunc(route.NotifyDTStandUp, NotifySitDown) |
|
|
|
|
|
|
|
r.GameRoom.OnGetOutRoom(player.Uid, 0) |
|
|
|
log.Debug(r.GameRoom.RId, " 机器人 ", player.Uid, " 需要离开 当前机器人个数", r.GameRoom.GetInRoomRobotCount()) |
|
|
|
} |
|
|
|