def make_led_mo(newleds, clientVer, clientId): mo = MsgPack() mo.setCmd('led') if clientVer >= 3.6: if ledWithTodoTask: mo.setKey('result', ledWithTodoTask) return mo.pack() return None if newleds['origLeds']: mo.setKey('result', newleds['origLeds']) if newleds['richLeds']: mo.setKey('result', newleds['richLeds']) mo.setKey('richText', newleds['richLeds']) mo.setResult('gameId', gameId) if gameId == 8: if clientVer < 3.0: # 德州老单包有问题,所有格式都转为没有按钮的LED (也就是type='led') newleds['richLeds']['type'] = 'led' elif newleds['richLeds'][ 'type'] == 'vip' and clientVer == 3.37 and 'hall8' in clientId: # 德州大厅3.37版本BUG: 如果消息中有 richText,则收不到消息 mo.rmKey('richText') if popWinInfo and clientId.startswith('Winpc'): mo.setResult('popWin', popWinInfo) return mo.pack()
def doActivityBetguessSetResult(self): ''' @param activityGameId: 6(配置里配置的哪个GameId就填哪个GameId) @param activityId: 活动ID @param issueNumber: '2016-10-31 18:20:00' @param resultState: 0,1,2 ''' try: activityGameId = runhttp.getParamInt('activityGameId') activityId = runhttp.getParamStr('activityId') issueNumber = runhttp.getParamStr('issueNumber') resultState = runhttp.getParamInt('resultState') if activityGameId == None or \ activityId == None or \ issueNumber == None or \ resultState == None: return self.makeErrorResponse('params error').pack() ftlog.debug('BetguessHttpHandler.doActivityBetguessSetResult', 'activityGameId=', activityGameId, 'activityId=', activityId, 'issueNumber=', issueNumber, 'resultState=', resultState) err, issueMap = self.getActivityIssueMapConf(activityId) if err: return err # 验证issueNumber是否存在 if issueNumber not in issueMap: return self.makeErrorResponse('issueNumber not found! issueNumber maybe error').pack() # 给活动设置竞猜结果 if not ActivityModel.updateResult(activityGameId, activityId, issueNumber, resultState): return self.makeErrorResponse('result set failed! resultState maybe error').pack() # 获得最新的活动数据 activityModel = ActivityModel.loadModel(activityGameId, activityId, issueNumber) if activityModel.resultState == activityModel.RESULT_STATE_NONE: return self.makeErrorResponse('activityModel.resultState not set!').pack() # 遍历参与玩家 chipCounter = 0 userIdList = UserRecorder.getUsers(activityGameId, activityId, issueNumber) for userId in userIdList: response = act_betguess_remote.sendRewards(userId, activityModel.countChipLeft, activityModel.countChipRight, activityModel.resultState, activityGameId, activityId, issueNumber) if response.get('err'): return self.makeErrorResponse(response.get('err')).pack() chipCounter += response.get('chip', 0) activityModel = ActivityModel.loadModel(activityGameId, activityId, issueNumber) response = MsgPack() response.setResult("activityModel", activityModel.__dict__) response.setResult('allchip', chipCounter) return response.pack() except: ftlog.error() return self.makeErrorResponse().pack()
def doTreasureChestUnlock(self, userId, rewardId): mo = MsgPack() mo.setCmd('dizhu') mo.setResult('action', 'treasure_chest_unlock') mo.setResult('gameId', DIZHU_GAMEID) mo.setResult('userId', userId) mo.setResult('success', TreasureChestHelper.unlockTreasureChest(userId, rewardId)) return mo.pack()
def doGetTreasureChestList(self, userId): mo = MsgPack() mo.setCmd('dizhu') mo.setResult('action', 'treasure_chest_list') mo.setResult('gameId', DIZHU_GAMEID) mo.setResult('userId', userId) mo.setResult('treasureChestList', TreasureChestHelper.getTreasureChestList(userId)) return mo.pack()
def doActivityBetguessQuery(self): ''' @param activityGameId: 6(配置里配置的哪个GameId就填哪个GameId) @param activityId: 活动ID @param issueNumber: '2016-10-31 18:20:00' ''' try: activityGameId = runhttp.getParamInt('activityGameId') activityId = runhttp.getParamStr('activityId') issueNumber = runhttp.getParamStr('issueNumber') if activityGameId == None or \ activityId == None or \ issueNumber == None: return self.makeErrorResponse('params error').pack() ftlog.debug('BetguessHttpHandler.doActivityBetguessQuery', 'activityGameId=', activityGameId, 'activityId=', activityId, 'issueNumber=', issueNumber) activityModel = ActivityModel.loadModel(activityGameId, activityId, issueNumber) err, issueMap = self.getActivityIssueMapConf(activityId) if err: return err issueCalculator = IssueCalculator(issueMap) issueConf = issueCalculator.getCurrentIssueConf(issueNumber) if (issueNumber not in issueMap) or (not issueConf): return self.makeErrorResponse('issueNumber not found! issueNumber maybe error').pack() bankerPumping = issueConf.get('bankerPumping', 0) # 奖池为抽水金额 totalChip = activityModel.countChipLeft+activityModel.countChipRight # 奖池金额 betPoolChip = int((activityModel.countChipLeft+activityModel.countChipRight)*(1-bankerPumping)) # 左赔率 leftBetOdds = betPoolChip/activityModel.countChipLeft if activityModel.countChipLeft>0 else 0 # 右赔率 rightBetOdds = betPoolChip/activityModel.countChipRight if activityModel.countChipRight>0 else 0 response = MsgPack() response.setResult('totalChip', totalChip) response.setResult('betPoolChip', betPoolChip) response.setResult('leftBetOdds', leftBetOdds) response.setResult('rightBetOdds', rightBetOdds) response.setResult('bankerPumping', bankerPumping) response.setResult('countChipLeft', activityModel.countChipLeft) response.setResult('countChipRight', activityModel.countChipRight) response.setResult('resultState', activityModel.resultState) response.setResult("activityModel", activityModel.__dict__) response.setResult('pastIssueNumberList', issueCalculator.getAlreadyPastIssueNumberList()) return response.pack() except: ftlog.error() return self.makeErrorResponse().pack()
def doTreasureChestOpen(self, userId, rewardId): mo = MsgPack() mo.setCmd('dizhu') mo.setResult('action', 'treasure_chest_open') mo.setResult('gameId', DIZHU_GAMEID) mo.setResult('userId', userId) ret, _ = TreasureChestHelper.openTreasureChest(userId, rewardId) mo.setResult('success', ret) return mo.pack()
def doTreasureChestHelp(self, userId, rewardId, helpUserId): mo = MsgPack() mo.setCmd('dizhu') mo.setResult('action', 'treasure_chest_help') mo.setResult('gameId', DIZHU_GAMEID) mo.setResult('userId', userId) ret, state, leftSeconds = TreasureChestHelper.helpShortenTreasureChest( userId, rewardId, helpUserId) mo.setResult('success', ret) mo.setResult('state', state) mo.setResult('leftSeconds', leftSeconds) return mo.pack()
def convertOldRoomId(roomId, msgstr): if roomId in OLDROOMDI_MAP: rid = OLDROOMDI_MAP[roomId] ftlog.info('convertOldRoomId', roomId, '->', rid) msg = MsgPack() try: msg.unpack(msgstr) except: raise Exception('the json data error 7 !! [' + repr(msgstr) + ']') msg.setParam('roomId', rid) msgstr = msg.pack() return rid, msgstr return roomId, msgstr
def notifyMatchUserRevive(self, player, reviveContent): # 如果是机器人立即直接复活 if self.isRobot(player): self._room.match.currentInstance.doUserRevive(player, True) return afterScore = player.stage.stageConf.rankLine.getMinScoreByRank( reviveContent.get('rank')) afterRank = reviveContent.get('rank') # 判断用户是否需要高倍衰减 if player.championLimitFlag: rate = player.stage.nextStage.stageConf.scoreIntoRateHigh if player.stage.nextStage.stageConf.scoreIntoRateHigh else player.nextStage.stage.stageConf.scoreIntoRate afterScore = afterScore * rate else: afterScore = afterScore * player.stage.nextStage.stageConf.scoreIntoRate msg = MsgPack() msg.setCmd('m_revival') msg.setResult('mixId', player.mixId) msg.setResult('gameId', self._room.gameId) msg.setResult('roomId', self._room.bigRoomId) msg.setResult('userId', player.userId) msg.setResult('rank', player.rank) msg.setResult('afterRank', afterRank) msg.setResult('score', player.score) msg.setResult('afterScore', int(afterScore)) msg.setResult('riseUserCount', player.stage.stageConf.riseUserCount) msg.setResult( 'timeLeft', int(player.reviveExpirationTime - pktimestamp.getCurrentTimestamp())) fee = reviveContent['fee'] itemId = fee['itemId'] userAssets = hallitem.itemSystem.loadUserAssets(player.userId) timestamp = pktimestamp.getCurrentTimestamp() balance = userAssets.balance(HALL_GAMEID, itemId, timestamp) assetKind = hallitem.itemSystem.findAssetKind(itemId) msg.setResult( 'fee', { 'feeCount': fee['count'], 'leftFeeCount': balance, 'pic': fee.get('img') if fee.get('img') else assetKind.pic }) if ftlog.is_debug(): ftlog.debug('MatchPlayerNotifierDizhu.notifyMatchUserRevive', 'instId=', player.matchInst.instId, 'userId=', player.userId, 'signinParams=', player.signinParams, 'stageIndex=', player.stage.index, 'msg=', msg.pack(), 'rank=', player.rank) router.sendToUser(msg, player.userId)
def doTreasureChestAdd(self, userId, rewardType, rewardList, params): success = False if rewardType in [TREASURE_CHEST_TYPE_AS_WINSTREAK]: success = True dizhu_event_remote.publishTreasureChestEvent( DIZHU_GAMEID, userId, rewardType, rewardList, **params) mo = MsgPack() mo.setCmd('dizhu') mo.setResult('action', 'treasure_chest_add') mo.setResult('gameId', DIZHU_GAMEID) mo.setResult('userId', userId) mo.setResult('rewardList', rewardList) mo.setResult('success', success) return mo.pack()
def _sendLogOutMsg(protocol, errorCode, isabort): ''' 发送一个强制logout的消息后, 关闭用户的TCP的链接 ''' if errorCode != ERROR_SYS_LOGOUT_TIME_OUT: ml = MsgPack() ml.setCmd('logout') ml.setError( errorCode, pokerconf.getConnLogoutMsg(errorCode, 'Please try to login again')) protocol.writeEncodeMsg(ml.pack()) protocol.closeConnection(0) ftlog.info('_sendLogOutMsg address=', protocol.clientAddress, 'errorCode=', errorCode)
def sendRewardToUsers(self, userIds, rewardList): for userId, _ in userIds: mo = MsgPack() mo.setCmd('dizhu') mo.setResult('action', 'red_envelope_bomb') mo.setResult('rewardList', rewardList) try: clientId = sessiondata.getClientId(userId) except Exception, e: ftlog.error( 'dizhu_red_envelope_bomb.sendRewardToUsers bad clientId err=', e.message) clientId = None mo.setResult('tipTop', self._getTipTop(userId, clientId)), router.sendToUser(mo, userId) if ftlog.is_debug(): ftlog.debug('dizhu_red_envelope_bomb.sendRewardToUser', 'userId=', userId, 'mo=', mo.pack())
def _remoteCall(markParams, argl, argd): srvtype = markParams['remoteServerType'] syncCall = markParams['remoteSyncCall'] remoteGroupByIndex = markParams['remoteGroupByIndex'] remoteGroupBy = markParams['remoteGroupBy'] cmd = markParams['remoteCmd'] action = markParams['remoteAction'] groupVal = argl[remoteGroupByIndex] msgpack = MsgPack() msgpack.setCmdAction(cmd, action) msgpack.setParam(remoteGroupBy, groupVal) msgpack.setParam('argl', argl[1:]) # 去掉self, cls msgpack.setParam('argd', argd) msgpack.setParam('clientId', configure.CLIENTID_RPC) msgpack = msgpack.pack() jstr = None if srvtype == gdata.SRV_TYPE_UTIL: jstr = _communicateServer(_utilServer, groupVal, groupVal, msgpack, 'RQ', syncCall) elif srvtype == gdata.SRV_TYPE_ROOM: assert (groupVal in gdata.roomIdDefineMap()) jstr = _communicateRoomServer(0, groupVal, msgpack, 'RQ', syncCall) elif srvtype == gdata.SRV_TYPE_TABLE: assert (groupVal in gdata.roomIdDefineMap()) jstr = _communicateTableServer(0, groupVal, msgpack, 'RQ', syncCall) elif srvtype == gdata.SRV_TYPE_CENTER: jstr = _communicateServer(_centerServer, groupVal, groupVal, msgpack, 'RQ', syncCall) else: raise Exception('ERROR RPC cmd route false !!' + cmd + '.' + action) ret = None if syncCall and jstr: mo = MsgPack() try: mo.unpack(jstr) except: raise Exception('the json data error 5 !! [' + repr(jstr) + ']') ret = mo.getKey('result') return ret
def forceUserLogOut(userId, logoutmsg): ''' 管理员发送强制关闭TCP链接的消息, 发送logout消息后,关闭用户的TCP的链接 ''' ftlog.info('forceUserLogOut userId=', userId) if not logoutmsg: logoutmsg = pokerconf.getConnLogoutMsg(ERROR_SYS_LOGOUT_FORCE_LOGOUT, 'Please try to login again') ml = MsgPack() ml.setCmd('logout') ml.setError(ERROR_SYS_LOGOUT_FORCE_LOGOUT, logoutmsg) ml = ml.pack() if userId in _ONLINE_USERS: user = _ONLINE_USERS[userId] ftlog.debug('forceUserLogOut user='******'forceUserLogOut user not in map !!') return 0
def _remoteCall(markParams, argl, argd): srvtype = markParams['remoteServerType'] syncCall = markParams['remoteSyncCall'] remoteGroupByIndex = markParams['remoteGroupByIndex'] remoteGroupBy = markParams['remoteGroupBy'] cmd = markParams['remoteCmd'] action = markParams['remoteAction'] groupVal = argl[remoteGroupByIndex] msgpack = MsgPack() msgpack.setCmdAction(cmd, action) msgpack.setParam(remoteGroupBy, groupVal) msgpack.setParam('argl', argl[1:]) # 去掉self, cls msgpack.setParam('argd', argd) msgpack.setParam('clientId', configure.CLIENTID_RPC) msgpack = msgpack.pack() jstr = None if srvtype == gdata.SRV_TYPE_UTIL: jstr = _communicateServer(_utilServer, groupVal, groupVal, msgpack, 'RQ', syncCall) elif srvtype == gdata.SRV_TYPE_ROOM: assert (groupVal in gdata.roomIdDefineMap()) jstr = _communicateRoomServer(0, groupVal, msgpack, 'RQ', syncCall) elif srvtype == gdata.SRV_TYPE_TABLE: assert (groupVal in gdata.roomIdDefineMap()) jstr = _communicateTableServer(0, groupVal, msgpack, 'RQ', syncCall) elif srvtype == gdata.SRV_TYPE_CENTER: jstr = _communicateServer(_centerServer, groupVal, groupVal, msgpack, 'RQ', syncCall) else: raise Exception('ERROR RPC cmd route false !!' + cmd + '.' + action) ret = None if syncCall and jstr: mo = MsgPack() try: mo.unpack(jstr) except: raise Exception('the json data error 5 !! [' + repr(jstr) + ']') ret = mo.getKey('result') return ret
def _quickStart(cls, msg, userId, gameId, roomId, tableId, playMode, clientId): '''UT server中处理来自客户端的quick_start请求 Args: msg cmd : quick_start if roomId == 0: 表示快速开始,服务器为玩家选择房间,然后将请求转给GR if roomId > 0 and tableId == 0 : 表示玩家选择了房间,将请求转给GR if roomId > 0 and tableId == roomId * 10000 : 表示玩家在队列里断线重连,将请求转给GR if roomId > 0 and tableId > 0: if onlineSeatId > 0: 表示玩家在牌桌里断线重连,将请求转给GT else: 表示玩家选择了桌子,将请求转给GR ''' assert isinstance(userId, int) and userId > 0 assert isinstance(roomId, int) and roomId >= 0 assert isinstance(tableId, int) and tableId >= 0 mixId = msg.getParam('mixId', '') _, version, _ = strutil.parseClientId(clientId) if ftlog.is_debug(): ftlog.debug("DizhuQuickStart._quickStart: clientId=", clientId, "userId=", userId, "roomId=", roomId, "tableId=", tableId, "mixId=", mixId, "version=", version, "type:", type(version), "playMode=", playMode) if playMode == "match": playMode = dizhuconf.PLAYMODE_123 if ftlog.is_debug(): ftlog.debug("DizhuQuickStart << |clientId:", clientId, "mixId:", mixId, "|userId, roomId, tableId:", userId, roomId, tableId, "|gameId, playMode:", gameId, playMode, caller=cls) bigRoomId = gdata.getBigRoomId(roomId) if ftlog.is_debug(): ftlog.debug('DizhuQuickStart bigRoomId:', bigRoomId) if bigRoomId == 0: cls._onEnterRoomFailed(msg, ENTER_ROOM_REASON_ROOM_ID_ERROR, userId, clientId, roomId) return if strutil.getGameIdFromBigRoomId(bigRoomId) != gameId: cls._onEnterRoomFailed(msg, ENTER_ROOM_REASON_ROOM_ID_ERROR, userId, clientId, roomId) return if tableId == 0: # 玩家只选择了房间 if roomId != bigRoomId: ctrlRoomId = gdata.roomIdDefineMap()[roomId].parentId or roomId queryRoomId = roomId else: ctrRoomIds = gdata.bigRoomidsMap()[bigRoomId] ctrlRoomId = ctrRoomIds[userId % len(ctrRoomIds)] queryRoomId = ctrlRoomId buyin = msg.getParam("buyin", 0) # 兼容 pc innerTable = msg.getParam("innerTable", 0) # innerTable 区分不同版本弹窗 if ftlog.is_debug(): ftlog.debug('DizhuQuickStart._quickStart', 'buyin=', buyin, 'innerTable=', innerTable, 'mixId=', mixId) if buyin: innerTable = 1 roomdef = gdata.roomIdDefineMap()[ctrlRoomId] roomConf = roomdef.configure # 免费场重起maxCoin配置 maxCoin = roomConf.get('maxCoin', 0) userChip = userchip.getChip(userId) if maxCoin > 0 and userChip >= maxCoin and innerTable == 0: cls._onEnterRoomFailed(msg, ENTER_ROOM_REASON_GREATER_MAX, userId, clientId, roomId) return # 混房的话从大到小选择一个mixId if roomConf.get('isMix') and not mixId: _, _, mixId = cls._chooseRoom(userId, [ctrlRoomId]) if mixId: msg.setParam('mixId', mixId) else: msg.setParam('mixId', roomConf.get('mixConf')[0].get('mixId')) if innerTable == 0: cls._onEnterRoomFailed(msg, ENTER_ROOM_REASON_LESS_MIN, userId, clientId, roomId) else: mixConf = cls.getMixConf( roomConf, roomConf.get('mixConf')[0].get('mixId')) new_table_remote.processLoseRoundOver( DIZHU_GAMEID, userId, clientId, mixConf.get('roomId'), minCoin=mixConf.get('minCoin')) return reasonType, reason = cls._canQuickEnterRoom(userId, ctrlRoomId, innerTable, mixId) if reason == ENTER_ROOM_REASON_OK: TYRoomMixin.queryRoomQuickStartReq(msg, queryRoomId, 0) # 请求转给GR或GT else: if reasonType == ENTER_ROOM_REASON_TYPE_NORMAL: if reason == ENTER_ROOM_REASON_NOT_OPEN and innerTable == 1: if ftlog.is_debug(): ftlog.debug( 'DizhuQuickStart._quickStart not open userId=', userId, 'roomId=', ctrlRoomId, 'msg=', msg, 'playmode=', playMode) # 直接踢出房间 mp = MsgPack() mp.setCmd('room') mp.setParam('action', 'leave') mp.setParam('reason', TYRoom.LEAVE_ROOM_REASON_ACTIVE) mp.setParam('gameId', gameId) mp.setParam('roomId', roomId) mp.setParam('userId', userId) router.sendRoomServer(mp, roomId) return if reason == ENTER_ROOM_REASON_LESS_MIN or reason == ENTER_ROOM_REASON_GREATER_MAX: if innerTable == 1: ctrRoomIds = gdata.bigRoomidsMap()[bigRoomId] ctrlRoomId = ctrRoomIds[userId % len(ctrRoomIds)] if roomdef.configure.get('isMix', 0): continueLuckyGift = cls.getMixConf( roomdef.configure, mixId).get('continueLuckyGift', 0) continueLuckyVer = cls.getMixConf( roomdef.configure, mixId).get('continueLuckyVer', 0) else: continueLuckyGift = roomdef.configure.get( 'continueLuckyGift', 0) continueLuckyVer = roomdef.configure.get( 'continueLuckyVer', 0) dizhuVersion = SessionDizhuVersion.getVersionNumber( userId) if continueLuckyGift and dizhuVersion >= continueLuckyVer: # 发送转运礼包 if ftlog.is_debug(): ftlog.debug( 'DizhuQuickStart._quickStart _less_min userId=', userId, 'roomId=', ctrlRoomId, 'msg=', msg, 'playmode=', playMode, 'continueLuckyGift=', continueLuckyGift, 'continueLuckyVer=', continueLuckyVer, 'dizhuVersion=', dizhuVersion) if mixId and roomConf.get('isMix'): mixConf = cls.getMixConf(roomConf, mixId) new_table_remote.processLoseRoundOver( DIZHU_GAMEID, userId, clientId, mixConf.get('roomId'), minCoin=mixConf.get('minCoin')) else: new_table_remote.processLoseRoundOver( DIZHU_GAMEID, userId, clientId, roomId) else: roomDef = gdata.roomIdDefineMap()[ctrlRoomId] playMode = roomDef.configure.get('playMode', None) if ftlog.is_debug(): ftlog.debug( 'DizhuQuickStart._quickStart _less_min userId=', userId, 'roomId=', ctrlRoomId, 'msg=', msg, 'playmode=', playMode) msgpack = MsgPack() msgpack.setCmd("quick_start") msgpack.setParam("userId", userId) msgpack.setParam("gameId", gameId) msgpack.setParam("clientId", clientId) msgpack.setParam("innerTable", 1) msgpack.setParam("apiver", msg.getParam("apiver", 3.7)) cls.onCmdQuickStart(msgpack, userId, gameId, 0, 0, playMode, clientId) if ftlog.is_debug(): ftlog.debug( 'DizhuQuickStart._quickStart reenter_less_min userId=', userId, 'roomId=', ctrlRoomId, 'msgpack=', msgpack.pack()) else: cls._onEnterRoomFailed(msg, reason, userId, clientId, roomId) else: cls._onEnterRoomFailed(msg, reason, userId, clientId, roomId) else: cls._sendTodoTaskToUserWithTip(userId, reason) return if tableId == roomId * 10000: # 玩家在队列里断线重连 TYRoomMixin.queryRoomQuickStartReq(msg, roomId, tableId) # 请求转给GR return onlineSeat = onlinedata.getOnlineLocSeatId(userId, roomId, tableId) if onlineSeat: # 牌桌里坐着的玩家断线重连,请求转给GT # TYRoomMixin.querySitReq(userId, roomId, tableId, clientId) # GT人多时会有超时异常 TYRoomMixin.sendSitReq(userId, roomId, tableId, clientId) else: # 玩家选择了桌子, shadowRoomId = tableId / 10000 ctrRoomId = gdata.roomIdDefineMap()[shadowRoomId].parentId TYRoomMixin.queryRoomQuickStartReq(msg, ctrRoomId, tableId, shadowRoomId=shadowRoomId) # 请求转给GR return
def onCmdQuickStart(cls, msg, userId, gameId, roomId, tableId, playMode, clientId): '''UT server中处理来自客户端的quick_start请求 Args: msg cmd : quick_start if roomId == 0: 表示快速开始,服务器为玩家选择房间,然后将请求转给GR if roomId > 0 and tableId == 0 : 表示玩家选择了房间,将请求转给GR if roomId > 0 and tableId == roomId * 10000 : 表示玩家在队列里断线重连,将请求转给GR if roomId > 0 and tableId > 0: if onlineSeatId > 0: 表示玩家在牌桌里断线重连,将请求转给GT else: 表示玩家选择了桌子,将请求转给GR ''' assert isinstance(userId, int) and userId > 0 assert isinstance(roomId, int) and roomId >= 0 assert isinstance(tableId, int) and tableId >= 0 if ftlog.is_debug(): ftlog.debug("<< |clientId:", clientId, "|userId, roomId, tableId:", userId, roomId, tableId, "|gameId, playMode:", gameId, playMode, caller=cls) # 单开, 无论何时quick_start进入都检查loc if not pokerconf.isOpenMoreTable(clientId): loc = onlinedata.checkUserLoc(userId, clientId, gameId) if ftlog.is_debug(): ftlog.debug('old client, checkUserLoc->', loc, caller=cls) if isinstance(loc, basestring): lgameId, lroomId, ltableId, lseatId = loc.split('.') lgameId, lroomId, ltableId, lseatId = strutil.parseInts( lgameId, lroomId, ltableId, lseatId) if lgameId == gameId and lroomId > 0: ftlog.debug('onCmdQuickStart re-connected |userId, loc:', userId, loc, '|roomId, tableId:', roomId, tableId, caller=cls) roomId = lroomId tableId = ltableId msg.setParam('isReConnected', True) if ftlog.is_debug(): ftlog.debug('old client, reset roomId, tableId->', roomId, tableId, caller=cls) if roomId == 0: # 玩家点击快速开始 chosenRoomId, checkResult = cls._chooseRoom( userId, gameId, playMode) ftlog.debug("after choose room", "|userId, chosenRoomId, checkResult:", userId, chosenRoomId, checkResult, caller=cls) if checkResult == TYRoom.ENTER_ROOM_REASON_OK: TYRoomMixin.queryRoomQuickStartReq(msg, chosenRoomId, 0) # 请求转给GR else: candidateRoomIds = cls._getCandidateRoomIds(gameId, playMode) if candidateRoomIds: rid = candidateRoomIds[0] msg.setParam('candidateRoomId', rid) cls._onEnterRoomFailed(msg, checkResult, userId, clientId, roomId) return bigRoomId = gdata.getBigRoomId(roomId) ftlog.debug('bigRoomId:', bigRoomId) if bigRoomId == 0: cls._onEnterRoomFailed(msg, TYRoom.ENTER_ROOM_REASON_ROOM_ID_ERROR, userId, clientId, roomId) return if strutil.getGameIdFromBigRoomId(bigRoomId) != gameId: cls._onEnterRoomFailed(msg, TYRoom.ENTER_ROOM_REASON_ROOM_ID_ERROR, userId, clientId, roomId) return if tableId == 0: # 玩家只选择了房间 if gameId == 6 and roomId != bigRoomId: ctrlRoomId = gdata.roomIdDefineMap()[roomId].parentId or roomId queryRoomId = roomId else: ctrRoomIds = gdata.bigRoomidsMap()[bigRoomId] ctrlRoomId = ctrRoomIds[userId % len(ctrRoomIds)] queryRoomId = ctrlRoomId reason = cls._canQuickEnterRoom(userId, gameId, ctrlRoomId, 1) if reason == TYRoom.ENTER_ROOM_REASON_OK: if gameId == 6: TYRoomMixin.queryRoomQuickStartReq(msg, queryRoomId, 0) # 请求转给GR或GT else: TYRoomMixin.queryRoomQuickStartReq(msg, ctrlRoomId, 0) # 请求转给GR或GT elif reason == TYRoom.ENTER_ROOM_REASON_LESS_MIN or reason == TYRoom.ENTER_ROOM_REASON_GREATER_MAX: if gameId == 6: innerTable = msg.getParam("innerTable", 0) # innerTable 区分不同版本弹窗 if innerTable == 1: roomDef = gdata.roomIdDefineMap()[ctrlRoomId] playMode = roomDef.configure.get('playMode', None) if ftlog.is_debug(): ftlog.debug('enter_less_min userId=', userId, 'roomId=', ctrlRoomId, 'msg=', msg, 'playmode=', playMode) msgpack = MsgPack() msgpack.setCmd("quick_start") msgpack.setParam("userId", userId) msgpack.setParam("gameId", gameId) msgpack.setParam("clientId", clientId) msgpack.setParam("innerTable", 1) msgpack.setParam("apiver", msg.getParam("apiver", 3.7)) # 驱动 cls.onCmdQuickStart(msgpack, userId, gameId, 0, 0, playMode, clientId) if ftlog.is_debug(): ftlog.debug('reenter_less_min userId=', userId, 'roomId=', ctrlRoomId, 'msgpack=', msgpack.pack()) else: cls._onEnterRoomFailed(msg, reason, userId, clientId, roomId) else: cls._onEnterRoomFailed(msg, reason, userId, clientId, roomId) else: cls._onEnterRoomFailed(msg, reason, userId, clientId, roomId) return if tableId == roomId * 10000: # 玩家在队列里断线重连 4400150010001 TYRoomMixin.queryRoomQuickStartReq(msg, roomId, tableId) # 请求转给GR return onlineSeat = onlinedata.getOnlineLocSeatId(userId, roomId, tableId) if onlineSeat: if onlineSeat == gdata.roomIdDefineMap( )[roomId].configure['tableConf']['maxSeatN'] + 1: # 牌桌里旁观的玩家断线重连,请求转给GT TYRoomMixin.sendTableCallObserveReq(userId, roomId, tableId, clientId) else: # 牌桌里坐着的玩家断线重连,请求转给GT # TYRoomMixin.querySitReq(userId, roomId, tableId, clientId) # GT人多时会有超时异常 TYRoomMixin.sendSitReq(userId, roomId, tableId, clientId) else: # 玩家选择了桌子, shadowRoomId = tableId / 10000 ctrRoomId = gdata.roomIdDefineMap()[shadowRoomId].parentId TYRoomMixin.queryRoomQuickStartReq( msg, ctrRoomId, tableId, shadowRoomId=shadowRoomId) # 请求转给GR
def onCmdQuickStart(cls, msg, userId, gameId, roomId, tableId, playMode, clientId): '''UT server中处理来自客户端的quick_start请求 Args: msg cmd : quick_start if roomId == 0: 表示快速开始,服务器为玩家选择房间,然后将请求转给GR if roomId > 0 and tableId == 0 : 表示玩家选择了房间,将请求转给GR if roomId > 0 and tableId == roomId * 10000 : 表示玩家在队列里断线重连,将请求转给GR if roomId > 0 and tableId > 0: if onlineSeatId > 0: 表示玩家在牌桌里断线重连,将请求转给GT else: 表示玩家选择了桌子,将请求转给GR ''' assert isinstance(userId, int) and userId > 0 assert isinstance(roomId, int) and roomId >= 0 assert isinstance(tableId, int) and tableId >= 0 if ftlog.is_debug(): ftlog.debug("<< |clientId:", clientId, "|userId, roomId, tableId:", userId, roomId, tableId, "|gameId, playMode:", gameId, playMode, caller=cls) # 单开, 无论何时quick_start进入都检查loc if not pokerconf.isOpenMoreTable(clientId): loc = onlinedata.checkUserLoc(userId, clientId, gameId) if ftlog.is_debug(): ftlog.debug('old client, checkUserLoc->', loc, caller=cls) if isinstance(loc, basestring): lgameId, lroomId, ltableId, lseatId = loc.split('.') lgameId, lroomId, ltableId, lseatId = strutil.parseInts(lgameId, lroomId, ltableId, lseatId) if lgameId == gameId and lroomId > 0: ftlog.debug('onCmdQuickStart re-connected |userId, loc:', userId, loc, '|roomId, tableId:', roomId, tableId, caller=cls) roomId = lroomId tableId = ltableId msg.setParam('isReConnected', True) if ftlog.is_debug(): ftlog.debug('old client, reset roomId, tableId->', roomId, tableId, caller=cls) if roomId == 0: # 玩家点击快速开始 chosenRoomId, checkResult = cls._chooseRoom(userId, gameId, playMode) ftlog.debug("after choose room", "|userId, chosenRoomId, checkResult:", userId, chosenRoomId, checkResult, caller=cls) if checkResult == TYRoom.ENTER_ROOM_REASON_OK: TYRoomMixin.queryRoomQuickStartReq(msg, chosenRoomId, 0) # 请求转给GR else: candidateRoomIds = cls._getCandidateRoomIds(gameId, playMode) if candidateRoomIds: rid = candidateRoomIds[0] msg.setParam('candidateRoomId', rid) cls._onEnterRoomFailed(msg, checkResult, userId, clientId, roomId) return bigRoomId = gdata.getBigRoomId(roomId) ftlog.debug('bigRoomId:', bigRoomId) if bigRoomId == 0: cls._onEnterRoomFailed(msg, TYRoom.ENTER_ROOM_REASON_ROOM_ID_ERROR, userId, clientId, roomId) return if strutil.getGameIdFromBigRoomId(bigRoomId) != gameId: cls._onEnterRoomFailed(msg, TYRoom.ENTER_ROOM_REASON_ROOM_ID_ERROR, userId, clientId, roomId) return if tableId == 0: # 玩家只选择了房间 if gameId == 6 and roomId != bigRoomId: ctrlRoomId = gdata.roomIdDefineMap()[roomId].parentId queryRoomId = roomId else: ctrRoomIds = gdata.bigRoomidsMap()[bigRoomId] ctrlRoomId = ctrRoomIds[userId % len(ctrRoomIds)] queryRoomId = ctrlRoomId reason = cls._canQuickEnterRoom(userId, gameId, ctrlRoomId, 1) if reason == TYRoom.ENTER_ROOM_REASON_OK: if gameId == 6: TYRoomMixin.queryRoomQuickStartReq(msg, queryRoomId, 0) # 请求转给GR或GT else: TYRoomMixin.queryRoomQuickStartReq(msg, ctrlRoomId, 0) # 请求转给GR或GT elif reason == TYRoom.ENTER_ROOM_REASON_LESS_MIN or reason == TYRoom.ENTER_ROOM_REASON_GREATER_MAX: if gameId == 6: innerTable = msg.getParam("innerTable", 0) # innerTable 区分不同版本弹窗 if innerTable == 1: roomDef = gdata.roomIdDefineMap()[ctrlRoomId] playMode = roomDef.configure.get('playMode', None) if ftlog.is_debug(): ftlog.debug('enter_less_min userId=', userId, 'roomId=', ctrlRoomId, 'msg=', msg, 'playmode=', playMode) msgpack = MsgPack() msgpack.setCmd("quick_start") msgpack.setParam("userId", userId) msgpack.setParam("gameId", gameId) msgpack.setParam("clientId", clientId) msgpack.setParam("innerTable", 1) msgpack.setParam("apiver", msg.getParam("apiver", 3.7)) cls.onCmdQuickStart(msgpack, userId, gameId, 0, 0, playMode, clientId) if ftlog.is_debug(): ftlog.debug('reenter_less_min userId=', userId, 'roomId=', ctrlRoomId, 'msgpack=', msgpack.pack()) else: cls._onEnterRoomFailed(msg, reason, userId, clientId, roomId) else: cls._onEnterRoomFailed(msg, reason, userId, clientId, roomId) else: cls._onEnterRoomFailed(msg, reason, userId, clientId, roomId) return if tableId == roomId * 10000: # 玩家在队列里断线重连 TYRoomMixin.queryRoomQuickStartReq(msg, roomId, tableId) # 请求转给GR return onlineSeat = onlinedata.getOnlineLocSeatId(userId, roomId, tableId) if onlineSeat: if onlineSeat == gdata.roomIdDefineMap()[roomId].configure['tableConf']['maxSeatN'] + 1: # 牌桌里旁观的玩家断线重连,请求转给GT TYRoomMixin.sendTableCallObserveReq(userId, roomId, tableId, clientId) else: # 牌桌里坐着的玩家断线重连,请求转给GT # TYRoomMixin.querySitReq(userId, roomId, tableId, clientId) # GT人多时会有超时异常 TYRoomMixin.sendSitReq(userId, roomId, tableId, clientId) else: # 玩家选择了桌子, shadowRoomId = tableId / 10000 ctrRoomId = gdata.roomIdDefineMap()[shadowRoomId].parentId TYRoomMixin.queryRoomQuickStartReq(msg, ctrRoomId, tableId, shadowRoomId=shadowRoomId) # 请求转给GR