def lockMatchUser(gameId, userId, bigRoomId, instId, ctrlRoomId, tableId, seatId, clientId): if ftlog.is_debug(): ftlog.debug("match_remote.lockMatchUser gameId=", gameId, "userId=", userId, "bigRoomId=", bigRoomId, "instId=", instId, "ctrlRoomId=", ctrlRoomId, "tableId=", tableId, "seatId=", seatId, "clientId=", clientId) userMatchInfo = loadUserMatchInfo(gameId, userId, bigRoomId) if not userMatchInfo: # 此处有异常,正常要有userMatchInfo userMatchInfo = UserMatchInfo(gameId, userId, bigRoomId) userMatchInfo.ctrlRoomId = ctrlRoomId userMatchInfo.instId = instId userMatchInfo.state = UserMatchInfo.ST_SIGNIN userMatchInfo.ctrlRoomId = ctrlRoomId userMatchInfo.state = UserMatchInfo.ST_PLAYING saveUserMatchInfo(userMatchInfo) room = gdata.rooms()[ctrlRoomId] player = room.match.findPlayer(userId) if not player or not player.isQuit: onlinedata.setBigRoomOnlineLoc(userId, ctrlRoomId, tableId, seatId) ftlog.info("match_remote.lockMatchUser ok gameId=", gameId, "userId=", userId, "bigRoomId=", bigRoomId, "instId=", instId, "ctrlRoomId=", ctrlRoomId, "isQuit=", player.isQuit if player else -1, "tableId=", tableId, "seatId=", seatId, "clientId=", clientId) return True
def lockUserForMatch(gameId, userId, bigRoomId, instId, ctrlRoomId, tableId, seatId): if ftlog.is_debug(): ftlog.debug('match_remote.lockUserForMatch gameId=', gameId, 'userId=', userId, 'bigRoomId=', bigRoomId, 'instId=', instId, 'ctrlRoomId=', ctrlRoomId, 'tableId=', tableId, 'seatId=', seatId) userMatchInfo = loadUserMatchInfo(gameId, userId, bigRoomId) if not userMatchInfo: # 此处有异常,正常要有userMatchInfo userMatchInfo = UserMatchInfo(gameId, userId, bigRoomId) userMatchInfo.ctrlRoomId = ctrlRoomId userMatchInfo.instId = instId userMatchInfo.state = UserMatchInfo.ST_SIGNIN userMatchInfo.ctrlRoomId = ctrlRoomId userMatchInfo.state = UserMatchInfo.ST_PLAYING saveUserMatchInfo(userMatchInfo) onlinedata.setBigRoomOnlineLoc(userId, ctrlRoomId, tableId, seatId) ftlog.info('match_remote.lockUserForMatch ok gameId=', gameId, 'userId=', userId, 'bigRoomId=', bigRoomId, 'instId=', instId, 'ctrlRoomId=', ctrlRoomId, 'tableId=', tableId, 'seatId=', seatId) return True
def lockUserForMatch(gameId, userId, bigRoomId, instId, ctrlRoomId, tableId, seatId, clientId): if ftlog.is_debug(): ftlog.debug('match_remote.lockUserForMatch gameId=', gameId, 'userId=', userId, 'bigRoomId=', bigRoomId, 'instId=', instId, 'ctrlRoomId=', ctrlRoomId, 'tableId=', tableId, 'seatId=', seatId, 'clientId=', clientId) if not clientId: clientId = sessiondata.getClientId(userId) locList = dizhuonlinedata.getOnlineLocListByGameId(userId, gameId, clientId) if locList: # 检查loc loc = locList[0] if strutil.getBigRoomIdFromInstanceRoomId(loc[1]) != bigRoomId: ftlog.debug('match_remote.lockUserForMatch Fail gameId=', gameId, 'userId=', userId, 'bigRoomId=', bigRoomId, 'instId=', instId, 'ctrlRoomId=', ctrlRoomId, 'tableId=', tableId, 'seatId=', seatId, 'clientId=', clientId, 'loc=', loc) return False userMatchInfo = loadUserMatchInfo(gameId, userId, bigRoomId) if not userMatchInfo: # 此处有异常,正常要有userMatchInfo userMatchInfo = UserMatchInfo(gameId, userId, bigRoomId) userMatchInfo.ctrlRoomId = ctrlRoomId userMatchInfo.instId = instId userMatchInfo.state = UserMatchInfo.ST_SIGNIN userMatchInfo.ctrlRoomId = ctrlRoomId userMatchInfo.state = UserMatchInfo.ST_PLAYING saveUserMatchInfo(userMatchInfo) room = gdata.rooms()[ctrlRoomId] player = room.match.findPlayer(userId) if not player or not player.isQuit: onlinedata.setBigRoomOnlineLoc(userId, ctrlRoomId, tableId, seatId) ftlog.info('match_remote.lockUserForMatch ok gameId=', gameId, 'userId=', userId, 'bigRoomId=', bigRoomId, 'instId=', instId, 'ctrlRoomId=', ctrlRoomId, 'tableId=', tableId, 'seatId=', seatId, 'isQuit=', player.isQuit if player else -1, 'clientId=', clientId) return True
def lockUserForMatch(gameId, userId, bigRoomId, instId, ctrlRoomId, tableId, seatId, clientId): if ftlog.is_debug(): ftlog.debug("match_remote.lockUserForMatch gameId=", gameId, "userId=", userId, "bigRoomId=", bigRoomId, "instId=", instId, "ctrlRoomId=", ctrlRoomId, "tableId=", tableId, "seatId=", seatId, "clientId=", clientId) if not clientId: clientId = sessiondata.getClientId(userId) loc = None locList = onlinedata.getOnlineLocList(userId) for roomId, tableId, seatId in locList: try: roomGameId = strutil.getGameIdFromInstanceRoomId(roomId) if (roomGameId == gameId and tableId != 0 and seatId != 0): loc = [roomGameId, roomId, tableId, seatId] except: ftlog.error("match_remote.lockUserForMatch userId=", userId, "gameId=", gameId, "clientId=", clientId, "roomId=", roomId) if loc: # 检查loc if strutil.getBigRoomIdFromInstanceRoomId(loc[1]) != bigRoomId: ftlog.debug("match_remote.lockUserForMatch Fail gameId=", gameId, "userId=", userId, "bigRoomId=", bigRoomId, "instId=", instId, "ctrlRoomId=", ctrlRoomId, "tableId=", tableId, "seatId=", seatId, "clientId=", clientId, "loc=", loc) return False userMatchInfo = loadUserMatchInfo(gameId, userId, bigRoomId) if not userMatchInfo: # 此处有异常,正常要有userMatchInfo userMatchInfo = UserMatchInfo(gameId, userId, bigRoomId) userMatchInfo.ctrlRoomId = ctrlRoomId userMatchInfo.instId = instId userMatchInfo.state = UserMatchInfo.ST_SIGNIN userMatchInfo.ctrlRoomId = ctrlRoomId userMatchInfo.state = UserMatchInfo.ST_PLAYING saveUserMatchInfo(userMatchInfo) room = gdata.rooms()[ctrlRoomId] player = room.match.findPlayer(userId) if not player or not player.isQuit: onlinedata.setBigRoomOnlineLoc(userId, ctrlRoomId, tableId, seatId) ftlog.info("match_remote.lockUserForMatch ok gameId=", gameId, "userId=", userId, "bigRoomId=", bigRoomId, "instId=", instId, "ctrlRoomId=", ctrlRoomId, "tableId=", tableId, "seatId=", seatId, "isQuit=", player.isQuit if player else -1, "clientId=", clientId) return True
def lockUser(self, userId, roomId, tableId, seatId, clientId): locList = dizhuonlinedata.getOnlineLocListByGameId( userId, DIZHU_GAMEID, clientId) if locList: for loc in locList: if (strutil.getBigRoomIdFromInstanceRoomId(loc[1]) == strutil.getBigRoomIdFromInstanceRoomId(roomId)): ftlog.warn('UserLockerDizhu.lockUser', 'userId=', userId, 'roomId=', roomId, 'tableId=', tableId, 'seatId=', seatId, 'clientId=', clientId, 'loc=', loc, 'locList=', locList) return False onlinedata.setBigRoomOnlineLoc(userId, roomId, tableId, seatId) return True
def lockUser(self, userId, roomId, tableId, seatId, clientId): locList = dizhuonlinedata.getOnlineLocListByGameId( userId, DIZHU_GAMEID, clientId) if locList: for loc in locList: if (strutil.getBigRoomIdFromInstanceRoomId(loc[1]) != strutil.getBigRoomIdFromInstanceRoomId(roomId)): ftlog.warn('UserLockerDizhu.lockUser', 'userId=', userId, 'roomId=', roomId, 'tableId=', tableId, 'seatId=', seatId, 'clientId=', clientId, 'loc=', loc, 'locList=', locList) return False room = gdata.rooms()[roomId] player = room.match.findPlayer(userId) if not player or not player.isQuit: onlinedata.setBigRoomOnlineLoc(userId, roomId, tableId, seatId) return True
def sitdown(self, table, player, seat, continueBuyin, isReciveVoice=False): ''' 找空闲的座位坐下 @param isNextBuyin: 结算界面,点击继续的带入标记 ''' assert(not seat or seat.table == table) if player.seat: return player.seat if not seat: seat = table.findIdleSeat() if not seat: raise NoIdleSeatException() if seat.player: raise SeatNotIdleException() if table.dealer.buyinPolicy: table.dealer.buyinPolicy.buyin(table, player, seat, continueBuyin) if not player.isQuit: onlinedata.setBigRoomOnlineLoc(player.userId, table.roomId, table.tableId, seat.seatId) # 坐下后自动ready seat._state = DizhuSeat.ST_READY if table.runConf.isSitDownAutoReady else DizhuSeat.ST_WAIT seat.isReciveVoice = isReciveVoice player._seat = seat seat._player = player # 结算界面,点击继续的带入标记 seat.isNextBuyin = continueBuyin if ftlog.is_debug(): ftlog.info('User sitdown', 'tableId=', table.tableId, 'seatId=', seat.seatId, 'userId=', player.userId, 'seatState=', seat.state, 'isNextBuyin=', continueBuyin) table.fire(SitdownEvent(table, seat, player, continueBuyin)) return seat
def _doMatchQuickStart(self): tableInfo = self._match_table_info seatInfos = tableInfo['seats'] userIds = [] userSeatList = [] for x in xrange(len(seatInfos)): this_seat = self.seats[x] userIds.append(seatInfos[x]['userId']) this_seat.userId = seatInfos[x]['userId'] this_seat.state = TYSeat.SEAT_STATE_WAIT this_seat.call123 = -1 userSeatList.append((seatInfos[x]['userId'], x + 1)) # 初始化用户数据 for x in xrange(len(self.players)): self.players[x].initUser(0, 1) # ctrlRoomId = self.room.ctrlRoomId # ctrlRoomTableId = ctrlRoomId * 10000 for userId, seatId in userSeatList: try: onlinedata.setBigRoomOnlineLoc(userId, self.roomId, self.tableId, seatId) # onlinedata.removeOnlineLoc(userId, ctrlRoomId, ctrlRoomTableId) # onlinedata.addOnlineLoc(userId, self.roomId, self.tableId, seatId) if self._logger.isDebug(): self._logger.debug( 'GameTable._doMatchQuickStart setBigRoomOnlineLoc', 'userId=', userId, 'tableId=', self.tableId, 'seatId=', seatId) except: self._logger.error('GameTable._doMatchQuickStart') # 增加从比赛等待界面到下一局开始时的时间间隔 inter = self.__getWaitToNextMatchInter() ftlog.debug("test __getWaitToNextMatchInter inter = ", inter, 'time = ', time.time(), caller=self) if inter > 0: FTTasklet.getCurrentFTTasklet().sleepNb(inter) ftlog.debug("test __getWaitToNextMatchInter inter 2 = ", inter, 'time = ', time.time(), caller=self) for x in xrange(len(self.seats)): this_seat = self.seats[x] if this_seat.userId > 0: mq = MsgPack() mq.setCmd('quick_start') mq.setResult('userId', this_seat.userId) mq.setResult('gameId', self.gameId) mq.setResult('roomId', self.roomId) mq.setResult('tableId', self.tableId) mq.setResult('seatId', x + 1) # 发送用户的quick_start router.sendToUser(mq, this_seat.userId) # 发送table_info self.gamePlay.sender.sendTableInfoResAll() # 延迟1秒进行animation Info相关处理 FTTasklet.getCurrentFTTasklet().sleepNb(1) playAnmi = self._playAnimationIfNeed(tableInfo) if playAnmi['playAnimation'] and playAnmi['delaySeconds'] > 0: FTTasklet.getCurrentFTTasklet().sleepNb(playAnmi['delaySeconds']) for x in xrange(len(self.players)): self.gamePlay.doReady(self.players[x], False) mnotes = self._match_table_info['mnotes'] mtype = mnotes['type'] isFinalStep = mnotes.get('isFinalStep', False) if isFinalStep: mtype = mtype + u',决胜局!' isStartStep = mnotes.get('isStartStep', False) if isStartStep: for userId in userIds: clientVer = sessiondata.getClientId(userId) if clientVer < 3.37: mn = MsgPack() mn.setCmd('m_note') mn.setResult('note', mtype) mn.setResult('mInfos', self._match_table_info['mInfos']) router.sendToUser(mn, userId) else: mn = MsgPack() mn.setCmd('m_note') mn.setResult('note', self._buildNote(userId, tableInfo)) mn.setResult('mInfos', self._match_table_info['mInfos']) router.sendToUser(mn, userId) bscore = mnotes.get('basescore', '') step = mnotes.get('step', '') note = bscore + u',' + step func = functools.partial(self.sendMNoteMsg, userIds, note) FTTimer(3, func) for userId in userIds: self._sendRank(userId)