def unlockMatchUser(gameId, userId, bigRoomId, instId, ctrlRoomId, tableId, seatId): if ftlog.is_debug(): ftlog.debug('match_remote.unlockMatchUser gameId=', gameId, 'userId=', userId, 'bigRoomId=', bigRoomId, 'instId=', instId, 'ctrlRoomId=', ctrlRoomId, 'tableId=', tableId, 'seatId=', seatId) if _removeMatchUser(gameId, userId, bigRoomId, instId, ctrlRoomId): try: onlinedata.removeOnlineLoc(userId, ctrlRoomId, tableId) except: ftlog.error('match_remote.unlockMatchUser gameId=', gameId, 'userId=', userId, 'bigRoomId=', bigRoomId, 'instId=', instId, 'ctrlRoomId=', ctrlRoomId, 'tableId=', tableId, 'seatId=', seatId) ftlog.info('match_remote.unlockMatchUser ok gameId=', gameId, 'userId=', userId, 'bigRoomId=', bigRoomId, 'instId=', instId, 'ctrlRoomId=', ctrlRoomId, 'tableId=', tableId, 'seatId=', seatId)
def unlockMatchUser(gameId, userId, bigRoomId, instId, ctrlRoomId, tableId, seatId): if ftlog.is_debug(): ftlog.debug('match_remote.unlockMatchUser gameId=', gameId, 'userId=', userId, 'bigRoomId=', bigRoomId, 'instId=', instId, 'ctrlRoomId=', ctrlRoomId, 'tableId=', tableId, 'seatId=', seatId) if _removeMatchUser(gameId, userId, bigRoomId, instId, ctrlRoomId): try: onlinedata.removeOnlineLoc(userId, ctrlRoomId, tableId) except: ftlog.error('match_remote.unlockMatchUser gameId=', gameId, 'userId=', userId, 'bigRoomId=', bigRoomId, 'instId=', instId, 'ctrlRoomId=', ctrlRoomId, 'tableId=', tableId, 'seatId=', seatId) ftlog.info('match_remote.unlockMatchUser ok gameId=', gameId, 'userId=', userId, 'bigRoomId=', bigRoomId, 'instId=', instId, 'ctrlRoomId=', ctrlRoomId, 'tableId=', tableId, 'seatId=', seatId)
def doQuickStart(self, msg): assert self.roomId == msg.getParam("roomId") userId = msg.getParam("userId") shadowRoomId = msg.getParam("shadowRoomId") tableId = msg.getParam("tableId") clientId = msg.getParam("clientId") ftlog.info(getMethodName(), "<<", "|userId, clientId, roomId, shadowRoomId, tableId:", userId, clientId, self.roomId, shadowRoomId, tableId) if tableId == self.roomId * 10000: isOk = True # 玩家在队列里时断线重连 player = self.match.findPlayer(userId) if player is None or not player.group: # if player is None or not player.group: ftlog.warn(getMethodName(), '|room=', self.roomId, 'userId=', userId, 'not found player') onlinedata.removeOnlineLoc(userId, self.roomId, tableId) isOk = False else: isOk = False if isOk: reason = self.ENTER_ROOM_REASON_OK self.sendQuickStartRes(self.gameId, userId, reason, self.bigRoomId, self.match.tableId) # 如果用户已经被分组则发送等待信息 if player.group: self.match.playerNotifier.notifyMatchWait(player, player.group) else: reason = self.ENTER_ROOM_REASON_INNER_ERROR info = u'在线状态错误或其他系统内部错误' self.sendQuickStartRes(self.gameId, userId, reason, self.bigRoomId, 0, info)
def onSitOk(self, userId, idleSeatId, result): '''坐下条件成功后的处理 ''' if ftlog.is_debug(): ftlog.debug('onSitOk << |userId, tableId, seatId:', userId, self.tableId, idleSeatId, "|observers:", self.observers, caller=self) # 设置玩家坐在座位上 seat = self.table.seats[idleSeatId - 1] seat.userId = userId seat.setWaitingState() if ftlog.is_debug(): ftlog.debug("|seats:", self.table.seats, caller=self) if userId in self.table.observers: del self.table.observers[userId] onlinedata.removeOnlineLoc(userId, self.roomId, self.tableId) # 设置玩家的在线状态 if ftlog.is_debug(): ftlog.debug("before addOnlineLoc. |tableId, onlineSeatId:", self.tableId, onlinedata.getOnlineLocSeatId(userId, self.roomId, self.tableId), caller=self) onlinedata.addOnlineLoc(userId, self.roomId, self.tableId, idleSeatId) if ftlog.is_debug(): ftlog.debug("after addOnlineLoc. |tableId, onlineSeatId:", self.tableId, onlinedata.getOnlineLocSeatId(userId, self.roomId, self.tableId), caller=self) result["seatId"] = idleSeatId result["reason"] = TYRoom.ENTER_ROOM_REASON_OK ftlog.hinfo('onSitOk >> |userId, tableId, seatId:', userId, self.tableId, idleSeatId, "|observers:", self.observers, caller=self)
def doQuickStart(self, msg): assert self.roomId == msg.getParam("roomId") userId = msg.getParam("userId") shadowRoomId = msg.getParam("shadowRoomId") tableId = msg.getParam("tableId") clientId = msg.getParam("clientId") ftlog.info(getMethodName(), "<<", "|userId, clientId, roomId, shadowRoomId, tableId:", userId, clientId, self.roomId, shadowRoomId, tableId) if tableId == self.roomId * 10000: isOk = True # 玩家在队列里时断线重连 player = self.match.findPlayer(userId) if player is None or not player.group: # if player is None or not player.group: ftlog.warn(getMethodName(), '|room=', self.roomId, 'userId=', userId, 'not found player') onlinedata.removeOnlineLoc(userId, self.roomId, tableId) isOk = False else: isOk = False if isOk: reason = self.ENTER_ROOM_REASON_OK self.sendQuickStartRes(self.gameId, userId, reason, self.bigRoomId, self.match.tableId) # 如果用户已经被分组则发送等待信息 if player.group: self.match.playerNotifier.notifyMatchWait(player, player.group) else: reason = self.ENTER_ROOM_REASON_INNER_ERROR info = u'在线状态错误或其他系统内部错误' self.sendQuickStartRes(self.gameId, userId, reason, self.bigRoomId, 0, info)
def _doMatchQuickStart(self): tableInfo = self._match_table_info userInfos = tableInfo['userInfos'] userIds = [] userSeatList = [] for i, userInfo in enumerate(userInfos): this_seat = self.seats[i] userIds.append(userInfo['userId']) this_seat.userId = userInfo['userId'] this_seat.state = TYSeat.SEAT_STATE_WAIT this_seat.call123 = -1 userSeatList.append((userInfo['userId'], i + 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: onlinedata.removeOnlineLoc(userId, ctrlRoomId, ctrlRoomTableId) onlinedata.addOnlineLoc(userId, self.roomId, self.tableId, seatId) if ftlog.is_debug(): ftlog.debug("|locList:", onlinedata.getOnlineLocList(userId), caller=self) # 做一个延迟 delayConf = dizhuconf.getPublic().get('matchAnimationDelay', '') inter = delayConf.get('waitToNextMatch', 3) FTTasklet.getCurrentFTTasklet().sleepNb(inter) 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() delay = self._playAnimation(userInfos) if delay > 0: FTTasklet.getCurrentFTTasklet().sleepNb(delay) for x in xrange(len(self.players)): self.gamePlay.doReady(self.players[x], False) self._sendRanks(userInfos)
def _remoteTableLeave(self, userId, reason=LEAVE_ROOM_REASON_ACTIVE, locList=None): if not locList: locList = onlinedata.getOnlineLocList(userId) if ftlog.is_debug(): ftlog.debug("<< |roomId, userId: ", self.roomId, userId, "|locList:", locList, caller=self) for loc in locList: onlineRoomId, onlineTableId = loc[0], loc[1] if not onlineRoomId in gdata.roomIdDefineMap(): onlinedata.removeOnlineLoc(userId, onlineRoomId, onlineTableId) continue ctrlRoomId = gdata.roomIdDefineMap()[onlineRoomId].parentId if ctrlRoomId == self.roomId: ftlog.hinfo( "table leave |userId, onlineRoomId, onlineTableId:", userId, onlineRoomId, onlineTableId, caller=self) clientId = sessiondata.getClientId(userId) tableLeaveResultStr = self.queryTableManageTableLeaveReq( userId, onlineRoomId, onlineTableId, clientId, {"reason": reason}) if not tableLeaveResultStr: ftlog.warn( "table leave timeout, |userId, onlineRoomId, onlineTableId, reason:", userId, onlineRoomId, onlineTableId, reason, caller=self) # 玩家离开牌桌只返回成功 # tableLeaveResult = json.loads(tableLeaveResultStr) # ftlog.debug("|tableLeaveResult:", tableLeaveResult) # if tableLeaveResult.get("error"): # return False # if not tableLeaveResult["result"]["isOK"]: # return False if ftlog.is_debug(): locList = onlinedata.getOnlineLocList(userId) ftlog.debug(">> |roomId, userId: ", self.roomId, userId, "|locList:", locList, caller=self) # return True return True
def _doSitDown(self, msg, userId, seatId, clientId): """ 比赛牌桌只有玩家断线重连时才会触发坐下操作,既重新坐回牌桌 """ if seatId != 0: if self.seats[seatId - 1].userId == 0: onlinedata.removeOnlineLoc(userId, self.roomId, self.tableId) ftlog.warn("reconnect user is cleaned from table", "seats =", self.seats) return False elif userId != self.seats[seatId - 1].userId: onlinedata.removeOnlineLoc(userId, self.roomId, self.tableId) ftlog.warn("reconnect user id is not matched", "seats =", self.seats) return False else: ftlog.info("user reconect, userId:", userId) onlinedata.addOnlineLoc(userId, self.roomId, self.tableId, seatId) self.players[seatId - 1].offline = 1 self.players[seatId - 1].clientId = clientId self.players[seatId - 1].lang = util.getLanguage( userId, clientId) self.players[seatId - 1].refreshGunSkin() self._sendTableInfo(userId, seatId) self._updateMatchInfo(userId) self._updateMatchRank(userId) self._updateMatchTask(userId) self.players[seatId - 1].dealEnterTable() self.players[seatId - 1].enterTime = int(time.time()) self.players[seatId - 1].offline = 0 from newfish.game import TGFish event = EnterTableEvent(userId, FISH_GAMEID, self.roomId, self.tableId, seatId, 1) TGFish.getEventBus().publishEvent(event) return True else: for i in range(len(self.seats)): if self.seats[i].userId == userId: ftlog.info("lost user reconect, userId:", userId, "i =", i) onlinedata.addOnlineLoc(userId, self.roomId, self.tableId, i + 1) self.players[i].offline = 1 self.players[i].clientId = clientId self.players[i].lang = util.getLanguage(userId, clientId) self.players[i].refreshGunSkin() self._sendTableInfo(userId, i + 1) self._updateMatchInfo(userId) self._updateMatchRank(userId) self._updateMatchTask(userId) self.players[i].dealEnterTable() self.players[i].enterTime = int(time.time()) self.players[i].offline = 0 from newfish.game import TGFish event = EnterTableEvent(userId, FISH_GAMEID, self.roomId, self.tableId, seatId, 1) TGFish.getEventBus().publishEvent(event) return True
def leave(self, userId): '''玩家离开队列''' # 只有玩家在队列里时才锁队列并删除他 if userId in self.users: del self.users[userId] onlinedata.removeOnlineLoc(userId, self.room.roomId, self.room.roomId * 10000) if ftlog.is_debug(): ftlog.debug(">>", self.baseLogStr(None, userId), "|locList:", onlinedata.getOnlineLocList(userId), caller=self) return True
def doQuickStart(self, msg): assert self.roomId == msg.getParam("roomId") userId = msg.getParam("userId") shadowRoomId = msg.getParam("shadowRoomId") tableId = msg.getParam("tableId") clientId = msg.getParam("clientId") ftlog.hinfo("doQuickStart <<", "|userId, clientId, roomId, shadowRoomId, tableId:", userId, clientId, self.roomId, shadowRoomId, tableId) # msg = TYPluginCenter.event(TYPluginUtils.updateMsg(cmd='EV_QUICK_START', params=TYPluginUtils.mkdict( # userId=userId, roomId=self.roomId), result={}), self.gameId) # # if msg.getResult("reason") != None: # info = u'玩家需要验证' # self.sendQuickStartRes(self.gameId, userId, msg.getResult("reason"), self.bigRoomId, 0, info) # return if tableId == 0: isOk, reason = self.doEnter(userId) elif tableId == self.roomId * 10000: if userId in self._roomUsers: isOk = True # 玩家在队列里时断线重连 reason = TYRoom.ENTER_ROOM_REASON_OK else: # 服务器重启造成玩家已经不在房间对象里了 onlinedata.removeOnlineLoc(userId, self.roomId, tableId) isOk = False reason = TYRoom.ENTER_ROOM_REASON_CONFLICT else: # 防御性代码,处理快速开始online错乱 onlineSeat = onlinedata.getOnlineLocSeatId(userId, shadowRoomId, tableId) if onlineSeat == 0: # 断线重连过程中玩家因为超时、金币不足或比赛淘汰等原因已被踢出房间 isOk = False reason = TYRoom.ENTER_ROOM_REASON_CONFLICT ftlog.warn("doQuickStart conflict!", "|userId, onlineLocList:", userId, onlinedata.getOnlineLocList(userId), "|shadowRoomId, tableId:", shadowRoomId, tableId) else: ftlog.error("doQuickStart conflict!", "|onlineSeat:", onlineSeat) if onlineSeat == gdata.roomIdDefineMap()[shadowRoomId].configure['tableConf']['maxSeatN'] + 1: # 牌桌里旁观的玩家断线重连,请求转给GT self.sendTableCallObserveReq(userId, shadowRoomId, tableId, clientId) elif onlineSeat > 0: # 牌桌里坐着的玩家断线重连,请求转给GT self.querySitReq(userId, shadowRoomId, tableId, clientId) return if isOk: self._onQuickStartOk(userId) elif reason == TYRoom.ENTER_ROOM_REASON_CONFLICT: info = u'玩家已经在游戏中,状态冲突' self.sendQuickStartRes(self.gameId, userId, reason, self.bigRoomId, 0, info) else: self.sendQuickStartRes(self.gameId, userId, reason, self.bigRoomId, 0, '')
def ensureNotInSeat(self, userId): ''' 确认该用户没有在其它桌子上打牌 ''' locList = onlinedata.getOnlineLocList(userId) for loc in locList: onlineRoomId, onlineTableId, onlineSeatId = loc[0], loc[1], loc[2] if not onlineRoomId in gdata.roomIdDefineMap(): onlinedata.removeOnlineLoc(userId, onlineRoomId, onlineTableId) continue gameId = strutil.getGameIdFromBigRoomId(onlineRoomId) if gameId == DIZHU_GAMEID and onlineSeatId: raise InSeatException()
def onStandUpOk(self, userId, seatId): '''坐下条件成功后的处理 note: 站起后没有自动进入旁观列表 ''' if ftlog.is_debug(): ftlog.debug('<< |userId, tableId, seatId:', userId, self.tableId, seatId, caller=self) # 清理在线信息 onlinedata.removeOnlineLoc(userId, self.roomId, self.tableId) seat = self.table.seats[seatId - 1] seat.userId = 0 ftlog.hinfo('onStandUpOk >> |userId, tableId, seatId:', userId, self.tableId, seatId, "|observers:", self.observers, caller=self)
def kickOffUser(self, userId, seatId, sendLeave): """让一个玩家leave""" ftlog.debug('MajiangQuickTable.kickOffUser userId:', userId, ' seatId:', seatId) onlinedata.removeOnlineLoc(userId, self.roomId, self.tableId) # uids = self.logic_table.getBroadCastUIDs() # 临时注释掉 待整体确认 taoxc # self.logic_table.msgProcessor.table_leave(userId, seatId, uids) # 游戏开始之后的退出,客户端不需要再收到退出消息 客户端的退出由其自身控制 sendLeave = False # 游戏未开始时房主解散了房间才需要向客户端发消息 sendLeave = True if sendLeave: uids = self.logic_table.getBroadCastUIDs() self.logic_table.msgProcessor.create_table_dissolve(userId, seatId, 'dissolve', uids) self.logic_table.removePlayer(seatId) self.seats[seatId] = TYSeat(self) self.players[seatId] = None
def _doLeave(self, msg, userId, clientId): ''' 玩家操作, 尝试离开当前的桌子 实例桌子可以覆盖 _doLeave 方法来进行自己的业务逻辑处理 ''' ftlog.hinfo(self._baseLogStr("_doLeave <<", userId), "|msg, observers:", msg, self.observers, caller=self) gameId = msg.getParam("gameId", 0) if gameId and gameId != self.gameId: ftlog.warn("_doLeave gameId != self.gameId", userId, gameId, clientId) return {"isOK": False, "reason": TYRoom.LEAVE_ROOM_REASON_SYSTEM} reason = msg.getParam("reason", TYRoom.LEAVE_ROOM_REASON_ACTIVE) # if reason == TYRoom.LEAVE_ROOM_REASON_LOST_CONNECTION: # self.sendPlayerDataToAll(userId, managed=True) # return {"isOK": False, "reason": reason} if ftlog.is_debug(): ftlog.debug(self._baseLogStr("<<", userId), "|locList:", onlinedata.getOnlineLocList(userId), caller=self) result = {"isOK": True, "userId": userId, "gameId": self.gameId, "roomId": self.roomId, "tableId": self.tableId} player = self.getPlayer(userId) if player: self._doStandUp(msg, userId, player.seatId, reason, clientId) if userId in self.observers: del self.observers[userId] onlinedata.removeOnlineLoc(userId, self.roomId, self.tableId) if ftlog.is_debug(): ftlog.debug(self._baseLogStr(">>", userId), "|locList:", onlinedata.getOnlineLocList(userId), "|observers:", self.observers, caller=self) mpRes = self.createMsgPackRes("table_leave") mpRes.setResult("reason", reason) mpRes.setResult("userId", userId) router.sendToUser(mpRes, userId) if ftlog.is_debug(): ftlog.info(self._baseLogStr("_doLeave >>", userId), "|reason, observers:", reason, self.observers, caller=self) TYPluginCenter.evmsg(self.gameId, PluginEvents.EV_LEAVE_TABLE, { 'table': self, 'userId': userId, 'reason': reason }) return result
def leave(self, userId): '''玩家离开队列''' # 只有玩家在队列里时才锁队列并删除他 if userId in self.users: del self.users[userId] onlinedata.removeOnlineLoc(userId, self.room.roomId, self.room.roomId * 10000) if ftlog.is_debug(): ftlog.debug(">>", self.baseLogStr(None, userId), "|locList:", onlinedata.getOnlineLocList(userId), caller=self) return True
def unlockUserForMatch(gameId, userId, bigRoomId, instId, ctrlRoomId, tableId, seatId, contentItem): if ftlog.is_debug(): ftlog.debug("match_remote.unlockUserForMatch gameId=", gameId, "userId=", userId, "bigRoomId=", bigRoomId, "instId=", instId, "ctrlRoomId=", ctrlRoomId, "tableId=", tableId, "seatId=", seatId, "contentItem=", contentItem) userMatchInfo = loadUserMatchInfo(gameId, userId, bigRoomId) if userMatchInfo: # 此处有异常,正常要有userMatchInfo removeUserMatchInfo(userMatchInfo) if contentItem: try: contentItemObj = TYContentItem.decodeFromDict(contentItem) userAssets = hallitem.itemSystem.loadUserAssets(userId) assetList = userAssets.sendContentItemList( gameId, [contentItemObj], 1, True, pktimestamp.getCurrentTimestamp(), "MATCH_RETURN_FEE", bigRoomId) datachangenotify.sendDataChangeNotify( gameId, userId, TYAssetUtils.getChangeDataNames(assetList)) ftlog.info( "match_remote.unlockUserForMatch returnFees ok gameId=", gameId, "userId=", userId, "bigRoomId=", bigRoomId, "instId=", instId, "ctrlRoomId=", ctrlRoomId, "tableId=", tableId, "seatId=", seatId, "contentItem=", contentItem) except: ftlog.error("match_remote.unlockUserForMatch gameId=", gameId, "userId=", userId, "bigRoomId=", bigRoomId, "instId=", instId, "ctrlRoomId=", ctrlRoomId, "tableId=", tableId, "seatId=", seatId, "contentItem=", contentItem) try: onlinedata.removeOnlineLoc(userId, ctrlRoomId, tableId) except: ftlog.error("match_remote.unlockUserForMatch gameId=", gameId, "userId=", userId, "bigRoomId=", bigRoomId, "instId=", instId, "ctrlRoomId=", ctrlRoomId, "tableId=", tableId, "seatId=", seatId, "contentItem=", contentItem) ftlog.info("match_remote.unlockUserForMatch ok gameId=", gameId, "userId=", userId, "bigRoomId=", bigRoomId, "instId=", instId, "ctrlRoomId=", ctrlRoomId, "tableId=", tableId, "seatId=", seatId, "contentItem=", contentItem)
def _do_room__quick_start(self, msg): assert(self.roomId == msg.getParam('roomId')) player = None userId = msg.getParam('userId') shadowRoomId = msg.getParam('shadowRoomId') tableId = msg.getParam('tableId') clientId = msg.getParam('clientId') ftlog.info('DizhuCtrlRoomArenaMatch._do_room__quick_start', 'roomId=', self.roomId, 'userId=', userId, 'clientId=', clientId, 'shadowRoomId=', shadowRoomId, 'tableId=', tableId) if tableId == self.roomId * 10000: isOk = True # 玩家在队列里时断线重连 player = self.match.findPlayer(userId) if ftlog.is_debug(): ftlog.debug('DizhuCtrlRoomArenaMatch._do_room__quick_start reconnect userId=', userId, 'tableId=', tableId, 'player=', player.__dict__ if player else None) if player is None: ftlog.warn('DizhuCtrlRoomArenaMatch._do_room__quick_start NotFoundPlayer', 'roomId=', self.roomId, 'userId=', userId) onlinedata.removeOnlineLoc(userId, self.roomId, tableId) isOk = False else: isOk = False if isOk: reason = TYRoom.ENTER_ROOM_REASON_OK self.sendQuickStartRes(self.gameId, userId, reason, self.bigRoomId, self.match.tableId, mixId=player.mixId if player else None) # 如果用户已经被分组则发送等待信息 if player.stage and player.state in (MatchPlayer.STATE_WAIT, MatchPlayer.STATE_RISE): self.match.playerNotifier.notifyMatchWait(player) # 如果用户处在处在则发送等待消息 if pktimestamp.getCurrentTimestamp() <= player.reviveExpirationTime: self.match.playerNotifier.notifyMatchUserRevive(player, player.stage.stageConf.reviveCondition) else: reason = TYRoom.ENTER_ROOM_REASON_INNER_ERROR info = '在线状态错误或其他系统内部错误' self.sendQuickStartRes(self.gameId, userId, reason, self.bigRoomId, 0, info, mixId=player.mixId if player else None)
def _do_room__quick_start(self, msg): assert(self.roomId == msg.getParam('roomId')) userId = msg.getParam('userId') tableId = msg.getParam('tableId') shadowRoomId = msg.getParam('shadowRoomId') clientId = msg.getParam('clientId') ftlog.info('DizhuCtrlRoomGroupMatch._do_room__quick_start', 'userId=', userId, 'tableId=', tableId, 'shadowRoomId=', shadowRoomId, 'clientId=', clientId) if tableId == self.roomId * 10000: isOk = True # 玩家在队列里时断线重连 player = self.match.findPlayer(userId) if player is None: ftlog.warn('DizhuCtrlRoomGroupMatch._do_room__quick_start', 'userId=', userId, 'tableId=', tableId, 'shadowRoomId=', shadowRoomId, 'clientId=', clientId, 'err=', 'NotFoundPlayer') try: onlinedata.removeOnlineLoc(userId, self.roomId, tableId) except: ftlog.error('DizhuCtrlRoomGroupMatch._do_room__quick_start', 'userId=', userId, 'tableId=', tableId, 'shadowRoomId=', shadowRoomId, 'clientId=', clientId) isOk = False else : isOk = False if isOk: reason = TYRoom.ENTER_ROOM_REASON_OK self.sendQuickStartRes(self.gameId, userId, reason, self.bigRoomId, self.match.tableId) # 如果用户已经被分组则发送等待信息 if player.group: self.match.playerNotifier.notifyMatchWait(player, 1) else: reason = TYRoom.ENTER_ROOM_REASON_INNER_ERROR info = u'在线状态错误或其他系统内部错误' self.sendQuickStartRes(self.gameId, userId, reason, self.bigRoomId, 0, info)
def doQuickStart(self, msg): userId = msg.getParam('userId') tableId = msg.getParam('tableId') shadowRoomId = msg.getParam('shadowRoomId') clientId = msg.getParam('clientId') self._logger.info('TYGroupMatchRoom.doQuickStart', 'userId=', userId, 'tableId=', tableId, 'shadowRoomId=', shadowRoomId, 'clientId=', clientId) if tableId == self.roomId * 10000: isOk = True # 玩家在队列里时断线重连 player = self.match.findPlayer(userId) if player is None: self._logger.warn('TYGroupMatchRoom.doQuickStart', 'userId=', userId, 'tableId=', tableId, 'shadowRoomId=', shadowRoomId, 'clientId=', clientId, 'err=', 'NotFoundPlayer') try: onlinedata.removeOnlineLoc(userId, self.roomId, tableId) except: self._logger.error('TYGroupMatchRoom.doQuickStart', 'userId=', userId, 'tableId=', tableId, 'shadowRoomId=', shadowRoomId, 'clientId=', clientId) isOk = False else: isOk = False if isOk: reason = self.ENTER_ROOM_REASON_OK self.sendQuickStartRes(self.gameId, userId, reason, self.bigRoomId, self.match.tableId) # 如果用户已经被分组则发送等待信息 if player.group: self.match.playerNotifier.notifyMatchWait(player, player.group) else: reason = self.ENTER_ROOM_REASON_INNER_ERROR info = u'在线状态错误或其他系统内部错误' self.sendQuickStartRes(self.gameId, userId, reason, self.bigRoomId, 0, info)
def onStandUpOk(self, userId, seatId): '''坐下条件成功后的处理 note: 站起后没有自动进入旁观列表 ''' if ftlog.is_debug(): ftlog.debug('<< |userId, tableId, seatId:', userId, self.tableId, seatId, caller=self) # 清理在线信息 onlinedata.removeOnlineLoc(userId, self.roomId, self.tableId) # 清理当前座位的userId self.recordSeatUserId(seatId, 0) seat = self.table.seats[seatId - 1] seat.userId = 0 # 更新当前桌子的快速开始积分, 如果此时桌子正在分配玩家,刷新将失败 # self.room.updateTableScore(self.getTableScore(), self.tableId) ftlog.hinfo('onStandUpOk >> |userId, tableId, seatId:', userId, self.tableId, seatId, "|observers:", self.observers, caller=self)
def doQuickStart(self, msg): assert (self.roomId == msg.getParam("roomId")) userId = msg.getParam("userId") shadowRoomId = msg.getParam("shadowRoomId") tableId = msg.getParam("tableId") clientId = msg.getParam("clientId") ftlog.info(getMethodName(), "<<", "|userId, clientId, roomId, shadowRoomId, tableId:", userId, clientId, self.roomId, shadowRoomId, tableId) if tableId == self.roomId * 10000: isOk = True # 玩家在队列里时断线重连 player = self.match.findPlayer(userId) if ftlog.is_debug(): ftlog.debug('TYArenaMatchRoom.doQuickStart reconnect userId=', userId, 'tableId=', tableId, 'player=', player.__dict__ if player else None) if player is None: ftlog.warn(getMethodName(), '|room=', self.roomId, 'userId=', userId, 'not found player') onlinedata.removeOnlineLoc(userId, self.roomId, tableId) isOk = False else: isOk = False if isOk: reason = self.ENTER_ROOM_REASON_OK self.sendQuickStartRes(self.gameId, userId, reason, self.bigRoomId, self.match.tableId) # 如果用户已经被分组则发送等待信息 if player.stage and player.state in (MatchPlayer.STATE_WAIT, MatchPlayer.STATE_RISE): self.match.playerNotifier.notifyMatchWait(player) else: reason = self.ENTER_ROOM_REASON_INNER_ERROR info = u'在线状态错误或其他系统内部错误' self.sendQuickStartRes(self.gameId, userId, reason, self.bigRoomId, 0, info)
def doQuickStart(self, msg): userId = msg.getParam('userId') tableId = msg.getParam('tableId') shadowRoomId = msg.getParam('shadowRoomId') clientId = msg.getParam('clientId') self._logger.info('TYErdayiMatchRoom.doQuickStart', 'userId=', userId, 'tableId=', tableId, 'shadowRoomId=', shadowRoomId, 'clientId=', clientId) if tableId == self.roomId * 10000: isOk = True # 玩家在队列里时断线重连 player = self.match.findPlayer(userId) if player is None: self._logger.warn('TYErdayiMatchRoom.doQuickStart', 'userId=', userId, 'tableId=', tableId, 'shadowRoomId=', shadowRoomId, 'clientId=', clientId, 'err=', 'NotFoundPlayer') try: onlinedata.removeOnlineLoc(userId, self.roomId, tableId) except: self._logger.error('TYErdayiMatchRoom.doQuickStart', 'userId=', userId, 'tableId=', tableId, 'shadowRoomId=', shadowRoomId, 'clientId=', clientId) isOk = False else: isOk = False if isOk: reason = self.ENTER_ROOM_REASON_OK self.sendQuickStartRes(self.gameId, userId, reason, self.bigRoomId, self.match.tableId) # 如果用户已经被分组则发送等待信息 if player.group: self.match.playerNotifier.notifyMatchWait(player, player.group) else: reason = self.ENTER_ROOM_REASON_INNER_ERROR info = u'在线状态错误或其他系统内部错误' self.sendQuickStartRes(self.gameId, userId, reason, self.bigRoomId, 0, info)
def doQuickStart(self, msg): userId = msg.getParam("userId") tableId = msg.getParam("tableId") shadowRoomId = msg.getParam("shadowRoomId") clientId = msg.getParam("clientId") self._logger.info("doQuickStart", "userId=", userId, "tableId=", tableId, "shadowRoomId=", shadowRoomId, "clientId=", clientId) player = self.match.findPlayer(userId) if player is None: self._logger.warn("doQuickStart", "userId=", userId, "tableId=", tableId, "shadowRoomId=", shadowRoomId, "clientId=", clientId, "err=", "NotFoundPlayer") try: onlinedata.removeOnlineLoc(userId, self.roomId, tableId) except: self._logger.warn("doQuickStart", "userId=", userId, "tableId=", tableId, "shadowRoomId=", shadowRoomId, "clientId=", clientId) isOk = False else: isOk = True # if not isOk: # FishQuickStart.onQuickStartFailed(FishQuickStart.ENTER_ROOM_REASON_STATE_ERROR, # userId, clientId, shadowRoomId) """
def unlockMatchUser(gameId, userId, bigRoomId, instId, ctrlRoomId, tableId, seatId): if ftlog.is_debug(): ftlog.debug("match_remote.unlockMatchUser gameId=", gameId, "userId=", userId, "bigRoomId=", bigRoomId, "instId=", instId, "ctrlRoomId=", ctrlRoomId, "tableId=", tableId, "seatId=", seatId) if _removeMatchUser(gameId, userId, bigRoomId, instId, ctrlRoomId): try: onlinedata.removeOnlineLoc(userId, ctrlRoomId, tableId) except: ftlog.error("match_remote.unlockMatchUser gameId=", gameId, "userId=", userId, "bigRoomId=", bigRoomId, "instId=", instId, "ctrlRoomId=", ctrlRoomId, "tableId=", tableId, "seatId=", seatId) ftlog.info("match_remote.unlockMatchUser ok gameId=", gameId, "userId=", userId, "bigRoomId=", bigRoomId, "instId=", instId, "ctrlRoomId=", ctrlRoomId, "tableId=", tableId, "seatId=", seatId)
def quit(self, table, seat): assert (seat.table == table) ftlog.info('PlayMode.quit', 'roomId=', table.roomId, 'tableId=', table.tableId, 'seatId=', seat.seatId, 'userId=', seat.userId) # 将用户位置信息存到redis, 清空大厅的位置信息 if seat._status: seat._status.giveup = True if seat.player: seat.player.isQuit = 1 timestamp = pktimestamp.getCurrentTimestamp() try: if seat.userId: onlinedata.removeOnlineLoc(seat.userId, table.roomId, table.tableId) except Exception, e: ftlog.warn('DizhuTableRoomNormalBase.leaveRoom removeOnlineLoc', 'roomId=', table.roomId, 'userId=', seat.userId, 'ex=', str(e))
def doQuickStart(self, msg): assert (self.roomId == msg.getParam("roomId")) userId = msg.getParam("userId") shadowRoomId = msg.getParam("shadowRoomId") tableId = msg.getParam("tableId") clientId = msg.getParam("clientId") ftlog.info(getMethodName(), "<<", "|userId, clientId, roomId, shadowRoomId, tableId:", userId, clientId, self.roomId, shadowRoomId, tableId) if tableId == self.roomId * 10000: isOk = True # 玩家在队列里时断线重连 player = self.match.findPlayer(userId) if ftlog.is_debug(): ftlog.debug('TYArenaMatchRoom.doQuickStart reconnect userId=', userId, 'tableId=', tableId, 'player=', player.__dict__ if player else None) if player is None: ftlog.warn(getMethodName(), '|room=', self.roomId, 'userId=', userId, 'not found player') onlinedata.removeOnlineLoc(userId, self.roomId, tableId) isOk = False else: isOk = False if isOk: reason = self.ENTER_ROOM_REASON_OK self.sendQuickStartRes(self.gameId, userId, reason, self.bigRoomId, self.match.tableId) # 如果用户已经被分组则发送等待信息 if player.stage and player.state in (MatchPlayer.STATE_WAIT, MatchPlayer.STATE_RISE): self.match.playerNotifier.notifyMatchWait(player) else: reason = self.ENTER_ROOM_REASON_INNER_ERROR info = u'在线状态错误或其他系统内部错误' self.sendQuickStartRes(self.gameId, userId, reason, self.bigRoomId, 0, info)
def onSitOk(self, userId, idleSeatId, result): '''坐下条件成功后的处理 Return: player:新空座位上的player ''' ftlog.hinfo('onSitOk << |userId, tableId, seatId:', userId, self.tableId, idleSeatId, "|observers:", self.observers, caller=self) # 设置玩家坐在座位上, 为了支持并发坐下,此设置需要在异步操作前完成!!! seat = self.table.seats[idleSeatId - 1] seat.userId = userId seat.setWaitingState() if ftlog.is_debug(): ftlog.debug("|seats:", self.table.seats, caller=self) if userId in self.table.observers: del self.table.observers[userId] onlinedata.removeOnlineLoc(userId, self.roomId, self.tableId) # 设置玩家的在线状态 if ftlog.is_debug(): ftlog.debug("before addOnlineLoc. |tableId, onlineSeatId:", self.tableId, onlinedata.getOnlineLocSeatId(userId, self.roomId, self.tableId), caller=self) onlinedata.addOnlineLoc(userId, self.roomId, self.tableId, idleSeatId) if ftlog.is_debug(): ftlog.debug("after addOnlineLoc. |tableId, onlineSeatId:", self.tableId, onlinedata.getOnlineLocSeatId(userId, self.roomId, self.tableId), caller=self) # 记录当前座位的userId, 以便对玩家的金币做恢复处理 self.table.recordSeatUserId(idleSeatId, userId) result["seatId"] = idleSeatId result["reason"] = TYRoom.ENTER_ROOM_REASON_OK ftlog.hinfo('onSitOk >> |userId, tableId, seatId:', userId, self.tableId, idleSeatId, "|observers:", self.observers, caller=self)
def doSitDown(self, userId, seatId, msg, clientId): """ 用户坐到某个桌子上,逻辑处理:如果是非重连用户,将用户坐下的消息广播给 其它已经坐下的用户,然后将当前的桌子信息发送给新来用户 继承自table类 这是的seatId为游戏的座位号 返回值: 1)是否做下 2)是否断线重连 """ ftlog.debug('>>MajiangQuickTable.doSitDown seatId =', seatId, ', userId = ', userId, ' tableId:', self.tableId) if (seatId != -1) and (userId != self.seats[seatId][TYSeat.INDEX_SEATE_USERID]): onlinedata.removeOnlineLoc(userId, self.roomId, self.tableId) ftlog.warn('reconnecting user id is not matched', 'seats =', self.seats, ' tableId:', self.tableId) return False frameSeatId = self.findIdleSeat(userId) ftlog.debug('MajiangQuickTable.doSitDown userId:', userId, ' findSeatId:', frameSeatId) sitRe = True if 0 == frameSeatId: ftlog.debug('MajiangQuickTable.doSitDown now seats:', self.seats) sendPopTipMsg(userId, '对不起,该房间已满员') self.logic_table.msgProcessor.quick_start_err(userId) sitRe = False elif 0 > frameSeatId: # 补发tableInfo seatId = self.getSeatIdByUserId(userId) if seatId < 0: onlinedata.removeOnlineLoc(userId, self.roomId, self.tableId) else: self.sendMsgTableInfo(msg, userId, seatId, True) elif frameSeatId > 0: isReady = self.getTableConfig(MTDefine.READY_AFTER_SIT, 0) gameSeatId = self.changeFrameSeatToMJSeatId(frameSeatId) # 设置座位的状态 self.seats[gameSeatId][TYSeat.INDEX_SEATE_USERID] = userId # 快速桌用户坐下就是准备状态 self.seats[gameSeatId][ TYSeat.INDEX_SEATE_STATE] = TYSeat.SEAT_STATE_READY if isReady else TYSeat.SEAT_STATE_WAIT # 添加玩家 tPlayer = TYPlayer(self, gameSeatId) self.players[gameSeatId] = tPlayer ftlog.debug('MajiangQuickTable.doSitDown user:'******' seat in:', gameSeatId , ' now seats:', self.seats , ' now playersNum:', self.playersNum) # 向牌桌添加用户:联网/机器人 if TYPlayer.isHuman(userId): locResult = onlinedata.addOnlineLoc(userId, self.roomId, self.tableId, frameSeatId) ftlog.info('MajiangQuickTable.doSitDown, add online loc userId:', userId , ' roomId:', self.roomId , ' tableId:', self.tableId , ' frameSeatId:', frameSeatId , ' locResult:', locResult) _name, _purl, _sex, _coin = userdata.getAttrs(userId, ['name', 'purl', 'sex', 'coin']) player = MPlayer(_name, _sex, userId, 0, _purl, _coin, clientId) # 快速桌 默认坐下就是准备状态 默认非托管状态 self.logic_table.addPlayer(player, gameSeatId, isReady, False) # 发送location消息 self.logic_table.msgProcessor.send_location_message(gameSeatId, userId) else: from difang.majiang2.resource import resource robot = resource.getRobotByUserId(userId) if robot: player = MPlayer(robot['name'], robot['sex'], userId, 0, robot['purl'], robot['coin']) # 机器人默认准备 默认托管状态 self.logic_table.addPlayer(player, gameSeatId, True, True) # 座位号调整,框架返回时进行了加1的操作,调整还原 self.room.updateTableScore(self.getTableScore(), self.tableId) self.sendMsgTableInfo(msg, userId, self.getSeatIdByUserId(userId), False) if self.playersNum != self.maxSeatN: # 一次召唤一个机器人 self.setTimerOfDispatchRobot() uids = self.logic_table.getBroadCastUIDs() self.logic_table.msgProcessor.sendTableEvent(self.playersNum, userId, gameSeatId, uids) else: # 人满了,启动定时器 self.setTimerHandleAutoDecideAction() return sitRe
assert(table.gameRound is None) player = seat._player if table.dealer.buyinPolicy: try: table.dealer.buyinPolicy.cashin(table, player, seat) except Exception, e: ftlog.warn('PlayMode.standup cashin', 'tableId=', table.tableId, 'seatId=', seat.seatId, 'userId=', player.userId, 'ex=', str(e)) try: onlinedata.removeOnlineLoc(player.userId, table.roomId, table.tableId) except Exception, e: ftlog.warn('PlayMode.standup removeOnlineLoc', 'tableId=', table.tableId, 'seatId=', seat.seatId, 'userId=', player.userId, 'ex=', str(e)) seat._player = None seat._state = DizhuSeat.ST_IDLE seat.isNextBuyin = False player._seat = None if ftlog.is_debug(): ftlog.info('Seat standup', 'tableId=', table.tableId,
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 : # ftlog.debug("|userId, ctrlRoomId, ctrlRoomTableId:", userId, ctrlRoomId, ctrlRoomTableId, caller=self) onlinedata.removeOnlineLoc(userId, ctrlRoomId, ctrlRoomTableId) # ftlog.debug("|userId, roomId, tableId, seatId:", userId, self.roomId, self.tableId, seatId, caller=self) # ftlog.debug("|locList:", onlinedata.getOnlineLocList(userId), caller=self) onlinedata.addOnlineLoc(userId, self.roomId, self.tableId, seatId) if ftlog.is_debug() : ftlog.debug("|locList:", onlinedata.getOnlineLocList(userId), caller=self) # 增加从比赛等待界面到下一局开始时的时间间隔 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() 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 # clmn = MsgPack() # clmn.setCmd('table_call') # clmn.setParam('action', 'CL_MNOTE_SEND') # clmn.setParam('gameId', self.gameId) # clmn.setParam('roomId', self.roomId) # clmn.setParam('tableId', self.tableId) # clmn.setParam('userIds', userIds) # clmn.setParam('note', note) func = functools.partial(self.sendMNoteMsg, userIds, note) FTTimer(3, func) # self._mnoteTimer.setupTimer(0, 3, clmn, tasklet.gdata) for userId in userIds: self.__sendRank(userId)
def unlockUserForMatch(gameId, userId, bigRoomId, instId, ctrlRoomId, tableId, seatId, contentItem): if ftlog.is_debug(): ftlog.debug('match_remote.unlockUserForMatch gameId=', gameId, 'userId=', userId, 'bigRoomId=', bigRoomId, 'instId=', instId, 'ctrlRoomId=', ctrlRoomId, 'tableId=', tableId, 'seatId=', seatId, 'contentItem=', contentItem) userMatchInfo = loadUserMatchInfo(gameId, userId, bigRoomId) if userMatchInfo: # 此处有异常,正常要有userMatchInfo removeUserMatchInfo(userMatchInfo) if contentItem: try: contentItemObj = TYContentItem.decodeFromDict(contentItem) userAssets = hallitem.itemSystem.loadUserAssets(userId) assetList = userAssets.sendContentItemList(gameId, [contentItemObj], 1, True, pktimestamp.getCurrentTimestamp(), 'MATCH_RETURN_FEE', bigRoomId) datachangenotify.sendDataChangeNotify(gameId, userId, TYAssetUtils.getChangeDataNames(assetList)) ftlog.info('match_remote.unlockUserForMatch returnFees ok gameId=', gameId, 'userId=', userId, 'bigRoomId=', bigRoomId, 'instId=', instId, 'ctrlRoomId=', ctrlRoomId, 'tableId=', tableId, 'seatId=', seatId, 'contentItem=', contentItem) except: ftlog.error('match_remote.unlockUserForMatch gameId=', gameId, 'userId=', userId, 'bigRoomId=', bigRoomId, 'instId=', instId, 'ctrlRoomId=', ctrlRoomId, 'tableId=', tableId, 'seatId=', seatId, 'contentItem=', contentItem) try: onlinedata.removeOnlineLoc(userId, ctrlRoomId, tableId) except: ftlog.error('match_remote.unlockUserForMatch gameId=', gameId, 'userId=', userId, 'bigRoomId=', bigRoomId, 'instId=', instId, 'ctrlRoomId=', ctrlRoomId, 'tableId=', tableId, 'seatId=', seatId, 'contentItem=', contentItem) ftlog.info('match_remote.unlockUserForMatch ok gameId=', gameId, 'userId=', userId, 'bigRoomId=', bigRoomId, 'instId=', instId, 'ctrlRoomId=', ctrlRoomId, 'tableId=', tableId, 'seatId=', seatId, 'contentItem=', contentItem)
def doQuickStart(self, msg): assert self.roomId == msg.getParam("roomId") userId = msg.getParam("userId") shadowRoomId = msg.getParam("shadowRoomId") tableId = msg.getParam("tableId") clientId = msg.getParam("clientId") ftlog.hinfo("doQuickStart <<", "|userId, clientId, roomId, shadowRoomId, tableId:", userId, clientId, self.roomId, shadowRoomId, tableId) msg = TYPluginCenter.event( TYPluginUtils.updateMsg(cmd='EV_QUICK_START', params=TYPluginUtils.mkdict( userId=userId, roomId=self.roomId), result={}), self.gameId) if msg.getResult("reason") != None: info = u'玩家需要验证' self.sendQuickStartRes(self.gameId, userId, msg.getResult("reason"), self.bigRoomId, 0, info) return if tableId == 0: isOk, reason = self.doEnter(userId) elif tableId == self.roomId * 10000: if userId in self._roomUsers: isOk = True # 玩家在队列里时断线重连 reason = TYRoom.ENTER_ROOM_REASON_OK else: # 服务器重启造成玩家已经不在房间对象里了 onlinedata.removeOnlineLoc(userId, self.roomId, tableId) isOk = False reason = TYRoom.ENTER_ROOM_REASON_CONFLICT else: # 防御性代码,处理快速开始online错乱 onlineSeat = onlinedata.getOnlineLocSeatId(userId, shadowRoomId, tableId) if onlineSeat == 0: # 断线重连过程中玩家因为超时、金币不足或比赛淘汰等原因已被踢出房间 isOk = False reason = TYRoom.ENTER_ROOM_REASON_CONFLICT ftlog.warn("doQuickStart conflict!", "|userId, onlineLocList:", userId, onlinedata.getOnlineLocList(userId), "|shadowRoomId, tableId:", shadowRoomId, tableId) else: ftlog.error("doQuickStart conflict!", "|onlineSeat:", onlineSeat) if onlineSeat == gdata.roomIdDefineMap( )[shadowRoomId].configure['tableConf']['maxSeatN'] + 1: # 牌桌里旁观的玩家断线重连,请求转给GT self.sendTableCallObserveReq(userId, shadowRoomId, tableId, clientId) elif onlineSeat > 0: # 牌桌里坐着的玩家断线重连,请求转给GT self.querySitReq(userId, shadowRoomId, tableId, clientId) return if isOk: self._onQuickStartOk(userId) elif reason == TYRoom.ENTER_ROOM_REASON_CONFLICT: info = u'玩家已经在游戏中,状态冲突' self.sendQuickStartRes(self.gameId, userId, reason, self.bigRoomId, 0, info) else: self.sendQuickStartRes(self.gameId, userId, reason, self.bigRoomId, 0, '')
def unlockUser(self, userId, roomId, tableId, clientId): onlinedata.removeOnlineLoc(userId, roomId, tableId)
def unlockUserForMatch(gameId, userId, bigRoomId, instId, ctrlRoomId, tableId, seatId, contentItem): if ftlog.is_debug(): ftlog.debug('match_remote.unlockUserForMatch gameId=', gameId, 'userId=', userId, 'bigRoomId=', bigRoomId, 'instId=', instId, 'ctrlRoomId=', ctrlRoomId, 'tableId=', tableId, 'seatId=', seatId, 'contentItem=', contentItem) userMatchInfo = loadUserMatchInfo(gameId, userId, bigRoomId) if userMatchInfo and userMatchInfo.instId == instId: # 此处有异常,正常要有userMatchInfo removeUserMatchInfo(userMatchInfo) if contentItem: try: userAssets = hallitem.itemSystem.loadUserAssets(userId) # 过滤贵族月卡退费 if contentItem['itemId'] not in matchutil.getMatchSigninFeeWithoutCollect(): # 折扣价格 contentItem = match_signin_discount.changeItemToDiscount(userId, bigRoomId, contentItem) contentItemObj = TYContentItem.decodeFromDict(contentItem) assetList = userAssets.sendContentItemList(gameId, [contentItemObj], 1, True, pktimestamp.getCurrentTimestamp(), 'MATCH_RETURN_FEE', bigRoomId) datachangenotify.sendDataChangeNotify(gameId, userId, TYAssetUtils.getChangeDataNames(assetList)) ftlog.info('match_remote.unlockUserForMatch dizhu.returnFees ok gameId=', gameId, 'userId=', userId, 'bigRoomId=', bigRoomId, 'instId=', instId, 'ctrlRoomId=', ctrlRoomId, 'tableId=', tableId, 'seatId=', seatId, 'contentItem=', contentItem) except: ftlog.error('match_remote.unlockUserForMatch gameId=', gameId, 'userId=', userId, 'bigRoomId=', bigRoomId, 'instId=', instId, 'ctrlRoomId=', ctrlRoomId, 'tableId=', tableId, 'seatId=', seatId, 'contentItem=', contentItem) try: onlinedata.removeOnlineLoc(userId, ctrlRoomId, tableId) except: ftlog.error('match_remote.unlockUserForMatch gameId=', gameId, 'userId=', userId, 'bigRoomId=', bigRoomId, 'instId=', instId, 'ctrlRoomId=', ctrlRoomId, 'tableId=', tableId, 'seatId=', seatId, 'contentItem=', contentItem) ftlog.info('match_remote.unlockUserForMatch ok gameId=', gameId, 'userId=', userId, 'bigRoomId=', bigRoomId, 'instId=', instId, 'ctrlRoomId=', ctrlRoomId, 'tableId=', tableId, 'seatId=', seatId, 'contentItem=', contentItem)