def enterFriendTable(self, userId, gameId, clientId, ftId): """进入自建桌,插件实现具体功能""" if ftlog.is_debug(): ftlog.debug('MAJIANG enterFriendTable userId:', userId, ' gameId:', gameId, ' clientId:', clientId, ' ftId:', ftId) tableId0, roomId0 = CreateTableData.getTableIdByCreateTableNo(ftId) if ftlog.is_debug(): ftlog.debug('MAJIANG enterFriendTable ftId:', ftId, ' roomId:', roomId0, ' tableId:', tableId0) if not tableId0 or not roomId0: from majiang2.entity.util import sendPopTipMsg sendPopTipMsg(userId, '您要进入的朋友场房间不存在,请核对房间号') return config = { "type": "game", "pluginParams": { "gameType": 11, "ftId": ftId } } todotask = TodoTaskEnterGameNew(GAMEID, config) mo = MsgPack() mo.setCmd('todo_tasks') mo.setResult('gameId', gameId) mo.setResult('pluginId', GAMEID) mo.setResult('userId', userId) mo.setResult('tasks', TodoTaskHelper.encodeTodoTasks(todotask)) router.sendToUser(mo, userId)
def enterFriendTable(self, userId, gameId, clientId, ftId): """进入自建桌,插件实现具体功能""" if ftlog.is_debug(): ftlog.debug('MAJIANG enterFriendTable userId:', userId , ' gameId:', gameId , ' clientId:', clientId , ' ftId:', ftId) tableId0, roomId0 = CreateTableData.getTableIdByCreateTableNo(ftId) if ftlog.is_debug(): ftlog.debug('MAJIANG enterFriendTable ftId:', ftId , ' roomId:', roomId0 , ' tableId:', tableId0) if not tableId0 or not roomId0: from majiang2.entity.util import sendPopTipMsg sendPopTipMsg(userId, '您要进入的朋友场房间不存在,请核对房间号') return config = { "type":"game", "pluginParams": { "gameType": 11, "ftId": ftId } } todotask = TodoTaskEnterGameNew(GAMEID, config) mo = MsgPack() mo.setCmd('todo_tasks') mo.setResult('gameId', gameId) mo.setResult('pluginId', GAMEID) mo.setResult('userId', userId) mo.setResult('tasks', TodoTaskHelper.encodeTodoTasks(todotask)) router.sendToUser(mo, userId)
def _calcShareFangka(self, itemParams, gameId, playMode, fangka_count, userId): ''' 计算分享房卡数目 ''' shareFangkaId = itemParams.get('shareFangka', 0) shareFangkaConfig = majiang_conf.getCreateTableConfig( gameId, playMode, 'shareFangka', shareFangkaId) ftlog.debug('share Fangkaconfig:', shareFangkaConfig) if shareFangkaConfig: shareFangka = shareFangkaConfig.get('share_fangka', 0) ftlog.debug('share Fangka:', shareFangka) if shareFangka: playerTypeId = itemParams.get(MFTDefine.PLAYER_TYPE, 1) playerTypeConfig = majiang_conf.getCreateTableConfig( gameId, playMode, MFTDefine.PLAYER_TYPE, playerTypeId) ftlog.debug('playerTypeConfig:', playerTypeConfig) if not playerTypeConfig: sendPopTipMsg(userId, '人数配置有误,请稍后重试') return False playerCount = playerTypeConfig.get('count', 4) fangka_count = fangka_count / playerCount ftlog.debug('share Fangka :', fangka_count) return fangka_count
def doJoinCreateTable(self, userId, gameId, clientId, roomId0, tableId0, playMode): """用户加入自建牌桌 """ loc = onlinedata.checkUserLoc(userId, clientId, gameId) lgameId, lroomId, ltableId, lseatId = loc.split('.') lgameId, lroomId, ltableId, lseatId = strutil.parseInts( lgameId, lroomId, ltableId, lseatId) if lgameId > 0 and lroomId > 0 and ltableId > 0 and lseatId >= 0: ftlog.warn('create_table error, user in table') sendPopTipMsg(userId, "请稍候,正在进桌...") config = { "type": "quickstart", "pluginParams": { "roomId": lroomId, "tableId": ltableId, "seatId": lseatId } } todotask = TodoTaskEnterGameNew(lgameId, config) mo = MsgPack() mo.setCmd('todo_tasks') mo.setResult('gameId', gameId) mo.setResult('pluginId', lgameId) mo.setResult('userId', userId) mo.setResult('tasks', TodoTaskHelper.encodeTodoTasks(todotask)) router.sendToUser(mo, userId) else: msg = runcmd.getMsgPack() createTableNo = msg.getParam('createTableNo', 0) if not createTableNo: return tableId0, roomId0 = CreateTableData.getTableIdByCreateTableNo( createTableNo) if not tableId0 or not roomId0: sendPopTipMsg(userId, "找不到您输入的房间号") return msg = runcmd.getMsgPack() msg.setParam("shadowRoomId", roomId0) msg.setParam("roomId", roomId0) msg.setParam("tableId", tableId0) msg.setCmdAction("room", "join_create_table") router.sendRoomServer(msg, roomId0) if router.isQuery(): mo = runcmd.newOkMsgPack(1) router.responseQurery(mo, '', str(userId))
def doJoinCreateTable(self, userId, gameId, clientId, roomId0, tableId0, playMode): """用户加入自建牌桌 """ loc = onlinedata.checkUserLoc(userId, clientId, gameId) lgameId, lroomId, ltableId, lseatId = loc.split('.') lgameId, lroomId, ltableId, lseatId = strutil.parseInts(lgameId, lroomId, ltableId, lseatId) if lgameId > 0 and lroomId > 0 and ltableId > 0 and lseatId >=0: ftlog.warn('create_table error, user in table') sendPopTipMsg(userId, "请稍候,正在进桌...") config = { "type":"quickstart", "pluginParams": { "roomId": lroomId, "tableId": ltableId, "seatId": lseatId } } todotask = TodoTaskEnterGameNew(lgameId, config) mo = MsgPack() mo.setCmd('todo_tasks') mo.setResult('gameId', gameId) mo.setResult('pluginId', lgameId) mo.setResult('userId', userId) mo.setResult('tasks', TodoTaskHelper.encodeTodoTasks(todotask)) router.sendToUser(mo, userId) else: msg = runcmd.getMsgPack() createTableNo = msg.getParam('createTableNo', 0) if not createTableNo: return tableId0, roomId0 = CreateTableData.getTableIdByCreateTableNo(createTableNo) if not tableId0 or not roomId0: sendPopTipMsg(userId, "找不到您输入的房间号") return msg = runcmd.getMsgPack() msg.setParam("shadowRoomId", roomId0) msg.setParam("roomId", roomId0) msg.setParam("tableId", tableId0) msg.setCmdAction("room", "join_create_table") router.sendRoomServer(msg, roomId0) if router.isQuery() : mo = runcmd.newOkMsgPack(1) router.responseQurery(mo, '', str(userId))
def _calcShareFangka(self, itemParams, gameId, playMode, fangka_count, userId): shareFangkaId= itemParams.get('shareFangka', 0) shareFangkaConfig = majiang_conf.getCreateTableConfig(gameId, playMode, 'shareFangka', shareFangkaId) ftlog.debug('share Fangkaconfig:',shareFangkaConfig) if shareFangkaConfig: shareFangka = shareFangkaConfig.get('share_fangka', 0) ftlog.debug('share Fangka:',shareFangka) if shareFangka: playerTypeId = itemParams.get(MFTDefine.PLAYER_TYPE, 1) playerTypeConfig = majiang_conf.getCreateTableConfig(gameId, playMode, MFTDefine.PLAYER_TYPE, playerTypeId) ftlog.debug('playerTypeConfig:',playerTypeConfig) if not playerTypeConfig: sendPopTipMsg(userId, '人数配置有误,请稍后重试') return False playerCount = playerTypeConfig.get('count', 4) fangka_count = fangka_count/playerCount ftlog.debug('share Fangka :',fangka_count) return fangka_count
def doCreateTable(self, userId, gameId, clientId, roomId0, tableId0, playMode, hasRobot=0): #临时硬编码,解决91晃晃提审问题 if gameId == 791 and playMode == "queshou-lianjiang" and clientId == "IOS_3.901_weixin.appStore,weixinPay.0-hall791.queshou.iostsljmj": hasRobot = 1 if gameId == 790 and playMode == 'luosihu-luosihuts' and clientId == "IOS_3.901_weixin.appStore,weixinPay.0-hall790.laodao.iostsxjmj": hasRobot = 1 """房主创建牌桌""" if not playMode: ftlog.error( 'game_handler, cat not create table without playMode...') loc = onlinedata.checkUserLoc(userId, clientId, gameId) lgameId, lroomId, ltableId, lseatId = loc.split('.') lgameId, lroomId, ltableId, lseatId = strutil.parseInts( lgameId, lroomId, ltableId, lseatId) if lgameId > 0 and lroomId > 0 and ltableId > 0 and lseatId >= 0: ftlog.warn('create_table error, user in table', lgameId, lroomId, ltableId, lseatId) sendPopTipMsg(userId, "请稍候,正在进桌...") config = { "type": "quickstart", "pluginParams": { "roomId": lroomId, "tableId": ltableId, "seatId": lseatId } } todotask = TodoTaskEnterGameNew(lgameId, config) mo = MsgPack() mo.setCmd('todo_tasks') mo.setResult('gameId', gameId) mo.setResult('pluginId', lgameId) mo.setResult('userId', userId) mo.setResult('tasks', TodoTaskHelper.encodeTodoTasks(todotask)) router.sendToUser(mo, userId) elif self._canEnterGame(userId, gameId): # 保存建桌时间戳 gamedata.setGameAttr(userId, gameId, 'createTableTime', pktimestamp.getCurrentTimestamp()) msg = runcmd.getMsgPack() itemParams = msg.getParam("itemParams") playerCount = 4 playerTypeId = itemParams.get(MFTDefine.PLAYER_TYPE, 1) playerTypeConfig = majiang_conf.getCreateTableConfig( gameId, playMode, MFTDefine.PLAYER_TYPE, playerTypeId) if not playerTypeConfig: sendPopTipMsg(userId, '人数配置有误,请稍后重试') return playerCount = playerTypeConfig.get('count', 4) ftlog.debug('MajiangCreateTable.create_table playerCount:', playerCount) cardCountKey = playerTypeConfig.get(MFTDefine.CARD_COUNT, MFTDefine.CARD_COUNT) cardCountId = itemParams.get(cardCountKey, 0) cardCountConfig = majiang_conf.getCreateTableConfig( gameId, playMode, cardCountKey, cardCountId) if not cardCountConfig: sendPopTipMsg(userId, '房卡配置有误,请稍后重试') return if hasRobot == 1 and 'hasRobot' in cardCountConfig: cardCountConfig = cardCountConfig.get('hasRobot', {}) ftlog.debug('MajiangCreateTable.create_table hasRobot == 1:') fangka_count = cardCountConfig.get('fangka_count', 1) ftlog.debug('MajiangCreateTable.create_table fangka_count:', fangka_count, ' cardCountConfig:', cardCountConfig) msg.setParam('isCreateTable', 1) #标记创建的桌子是 自建桌 from poker.entity.game.rooms.room import TYRoom ''' 根据五个因素筛选合适的房间 1)gameId 游戏ID 2)playMode 游戏玩法 3)playerCount 玩家个数 4)hasRobot 是否有机器人 5)itemId 房卡道具 ''' itemId = hall_fangka.queryFangKaItem(gameId, userId, clientId) if itemId: ftlog.debug( 'MajiangCreateTable._chooseCreateRoom fangKa itemId:', itemId) roomId, checkResult = MajiangCreateTable._chooseCreateRoom( userId, gameId, playMode, playerCount, hasRobot, itemId) ftlog.debug('MajiangCreateTable._chooseCreateRoom roomId:', roomId, ' checkResult:', checkResult) if checkResult == TYRoom.ENTER_ROOM_REASON_OK: msg = runcmd.getMsgPack() msg.setCmdAction("room", "create_table") msg.setParam("roomId", roomId) msg.setParam("itemParams", itemParams) msg.setParam('needFangka', fangka_count) ftlog.debug( 'MajiangCreateTable._chooseCreateRoom send message to room:', msg) router.sendRoomServer(msg, roomId) else: sendPopTipMsg(userId, "暂时无法创建请稍后重试") if router.isQuery(): mo = runcmd.newOkMsgPack(1) router.responseQurery(mo, '', str(userId)) else: ftlog.info('majiang2 game_handler, ignore enter game request...')
def _doCreateTable(self, room, msg, gameId): """选择合适的table,然后sit """ assert room.roomId == msg.getParam("roomId") userId = msg.getParam("userId") clientId = msg.getParam("clientId") ftlog.info("<< _doCreateTable |userId, clientId, roomId, msg:", userId, clientId, room.roomId, msg) fangka_count = msg.getParam("needFangka") itemId = room.roomConf.get('create_item', None) if not itemId: sendPopTipMsg(userId, "未知房卡") itemParams = msg.getParam("itemParams") playMode = msg.getParam('play_mode') ftlog.debug('itemParams', itemParams) fangka_count = self._calcShareFangka(itemParams, gameId, playMode, fangka_count, itemId) ftlog.debug('fangka share:', fangka_count) if fangka_count == False and type(fangka_count) == bool: sendPopTipMsg(userId, "房卡配置错误") return isFangKaEnough = True if room.roomConf.get('late_consume_fangka', 0): # 后扣房卡(江西安徽) userFangKaCount = user_remote.getItemCount(userId, itemId) if userFangKaCount < fangka_count: isFangKaEnough = False else: consumeResult = user_remote.consumeItem(userId, gameId, itemId, fangka_count, room.roomId, room.bigRoomId) if not consumeResult: isFangKaEnough = False if not isFangKaEnough: sendPopTipMsg(userId, "房卡不足,请购买") return # 扣卡成功,产生自建桌号,分配table shadowRoomId = choice(room.roomDefine.shadowRoomIds) tableId = room.getBestTableId(userId, shadowRoomId) if not tableId: # 拿不到桌子 sendPopTipMsg(userId, "哎呀呀,没有空桌子了……我们稍候会优先为您安排新桌,请稍等片刻~") ftlog.error("getFreeTableId timeout", "|userId, roomId, tableId:", userId, room.roomId, tableId) if not room.roomConf.get('late_consume_fangka', 0): user_remote.resumeItemFromRoom(userId, gameId, itemId, fangka_count, room.roomId, room.bigRoomId) return # 扣卡成功,产生自建桌号 for _ in range(10): ftId = hall_friend_table.createFriendTable(gameId) if ftId: ftlog.info("room._doCreateTable create_table ok, userId:", userId, " shadowRoomId:", shadowRoomId, " roomId:", room.roomId, " tableId:", tableId, " ftId:", ftId, " fangka_count:", fangka_count, room.roomConf) extParams = msg.getKey('params') extParams['ftId'] = ftId room.querySitReq(userId, shadowRoomId, tableId, clientId, extParams) return ftlog.error( 'room._doCreateTable request ftId error, return fangka item...') if not room.roomConf.get('late_consume_fangka', 0): user_remote.resumeItemFromRoom(userId, gameId, itemId, fangka_count, room.roomId, room.bigRoomId)
def _doCreateTable(self, room, msg, gameId): """选择合适的table,然后sit """ assert room.roomId == msg.getParam("roomId") userId = msg.getParam("userId") clientId = msg.getParam("clientId") ftlog.info("<< _doCreateTable |userId, clientId, roomId, msg:", userId, clientId, room.roomId, msg) fangka_count = msg.getParam("needFangka") itemId = room.roomConf.get('create_item', None) if not itemId: sendPopTipMsg(userId, "未知房卡") itemParams = msg.getParam("itemParams") playMode = msg.getParam('play_mode') ftlog.debug('itemParams',itemParams) fangka_count = self._calcShareFangka(itemParams, gameId, playMode, fangka_count, itemId) ftlog.debug('fangka share:', fangka_count) if fangka_count == False and type(fangka_count) == bool: sendPopTipMsg(userId, "房卡配置错误") return isFangKaEnough = True if room.roomConf.get('late_consume_fangka', 0): # 后扣房卡(江西安徽) userFangKaCount = user_remote.getItemCount(userId, itemId) if userFangKaCount < fangka_count: isFangKaEnough = False else: consumeResult = user_remote.consumeItem(userId, gameId, itemId, fangka_count, room.roomId, room.bigRoomId) if not consumeResult: isFangKaEnough = False if not isFangKaEnough: sendPopTipMsg(userId, "房卡不足,请购买") return # 扣卡成功,产生自建桌号,分配table shadowRoomId = choice(room.roomDefine.shadowRoomIds) tableId = room.getBestTableId(userId, shadowRoomId) if not tableId: # 拿不到桌子 sendPopTipMsg(userId, "哎呀呀,没有空桌子了……我们稍候会优先为您安排新桌,请稍等片刻~") ftlog.error("getFreeTableId timeout", "|userId, roomId, tableId:", userId, room.roomId, tableId) if not room.roomConf.get('late_consume_fangka', 0): user_remote.resumeItemFromRoom(userId, gameId, itemId, fangka_count, room.roomId, room.bigRoomId) return # 扣卡成功,产生自建桌号 for _ in range(10): ftId = hall_friend_table.createFriendTable(gameId) if ftId: ftlog.info("room._doCreateTable create_table ok, userId:", userId , " shadowRoomId:", shadowRoomId , " roomId:", room.roomId , " tableId:", tableId , " ftId:", ftId , " fangka_count:", fangka_count , room.roomConf) extParams = msg.getKey('params') extParams['ftId'] = ftId room.querySitReq(userId, shadowRoomId, tableId, clientId, extParams) return ftlog.error('room._doCreateTable request ftId error, return fangka item...') if not room.roomConf.get('late_consume_fangka', 0): user_remote.resumeItemFromRoom(userId, gameId, itemId, fangka_count, room.roomId, room.bigRoomId)
def doCreateTable(userId, gameId, clientId, roomId0, tableId0, playMode, hasRobot=0, msg=None): """房主创建牌桌""" if not playMode: ftlog.error('game_handler, cat not create table without playMode...') loc = onlinedata.checkUserLoc(userId, clientId, gameId) lgameId, lroomId, ltableId, lseatId = loc.split('.') lgameId, lroomId, ltableId, lseatId = ftstr.parseInts( lgameId, lroomId, ltableId, lseatId) if lgameId > 0 and lroomId > 0 and ltableId > 0 and lseatId >= 0: ftlog.warn('create_table error, user in table', lgameId, lroomId, ltableId, lseatId) sendPopTipMsg(userId, "请稍候,正在进桌...") config = { "type": "quickstart", "pluginParams": { "roomId": lroomId, "tableId": ltableId, "seatId": lseatId } } todotask = TodoTaskEnterGameNew(lgameId, config) mo = MsgPack() mo.setCmd('todo_tasks') mo.setResult('gameId', gameId) mo.setResult('pluginId', lgameId) mo.setResult('userId', userId) mo.setResult('tasks', TodoTaskHelper.encodeTodoTasks(todotask)) router.sendToUser(mo, userId) elif _canEnterGame(userId, gameId): # 保存建桌时间戳 gamedata.setGameAttr(userId, gameId, 'createTableTime', fttime.getCurrentTimestamp()) itemParams = msg.getParam("itemParams") playerCount = 4 playerTypeId = itemParams.get(MFTDefine.PLAYER_TYPE, 1) playerTypeConfig = majiang_conf.getCreateTableConfig( gameId, playMode, MFTDefine.PLAYER_TYPE, playerTypeId) if not playerTypeConfig: ftlog.info('MajiangCreateTable.doCreateTable playerTypeId:', playerTypeId, ' playerTypeConfig:', playerTypeConfig) sendPopTipMsg(userId, '人数配置有误,请稍后重试') return playerCount = playerTypeConfig.get('count', 4) ftlog.debug('MajiangCreateTable.create_table playerCount:', playerCount) cardCountKey = playerTypeConfig.get(MFTDefine.CARD_COUNT, MFTDefine.CARD_COUNT) cardCountId = itemParams.get(cardCountKey, 0) cardCountConfig = majiang_conf.getCreateTableConfig( gameId, playMode, cardCountKey, cardCountId) if not cardCountConfig: sendPopTipMsg(userId, '房卡配置有误,请稍后重试') return if hasRobot == 1 and 'hasRobot' in cardCountConfig: cardCountConfig = cardCountConfig.get('hasRobot', {}) ftlog.debug('MajiangCreateTable.create_table hasRobot == 1:') fangka_count = cardCountConfig.get('fangka_count', 1) ftlog.debug('MajiangCreateTable.create_table fangka_count:', fangka_count, ' cardCountConfig:', cardCountConfig) msg.setParam('isCreateTable', 1) # 标记创建的桌子是 自建桌 ''' 根据五个因素筛选合适的房间 1)gameId 游戏ID 2)playMode 游戏玩法 3)playerCount 玩家个数 4)hasRobot 是否有机器人 5)itemId 房卡道具 ''' itemId = hall_fangka.queryFangKaItem(gameId, userId, clientId) if itemId: ftlog.debug('MajiangCreateTable._chooseCreateRoom fangKa itemId:', itemId) roomId, checkResult = MajiangCreateTable._chooseCreateRoom( userId, gameId, playMode, playerCount, hasRobot, itemId) ftlog.debug('MajiangCreateTable._chooseCreateRoom roomId:', roomId, ' checkResult:', checkResult) if checkResult == TYRoom.ENTER_ROOM_REASON_OK: msg1 = MsgPack() msg1.setCmdAction("room", "create_table") msg1.setParam("roomId", roomId) msg1.setParam("itemParams", itemParams) msg1.setParam('needFangka', fangka_count) ftlog.debug( 'MajiangCreateTable._chooseCreateRoom send message to room:', msg1) router.sendRoomServer(msg1, roomId) else: sendPopTipMsg(userId, "暂时无法创建请稍后重试") else: ftlog.info('majiang2 game_handler, ignore enter game request...')
def sendScheduleTips(self, uids, gameId): if self.isOver(): for uid in uids: util.sendPopTipMsg(uid, '本局结束后,将进行结算并解散房间')
def doCreateTable(self, userId, gameId, clientId, roomId0, tableId0, playMode, hasRobot = 0): #临时硬编码,解决91晃晃提审问题 if gameId==791 and playMode=="queshou-lianjiang" and clientId=="IOS_3.901_weixin.appStore,weixinPay.0-hall791.queshou.iostsljmj": hasRobot=1 if gameId == 790 and playMode == 'luosihu-luosihuts' and clientId=="IOS_3.901_weixin.appStore,weixinPay.0-hall790.laodao.iostsxjmj": hasRobot=1 """房主创建牌桌""" if not playMode: ftlog.error('game_handler, cat not create table without playMode...') loc = onlinedata.checkUserLoc(userId, clientId, gameId) lgameId, lroomId, ltableId, lseatId = loc.split('.') lgameId, lroomId, ltableId, lseatId = strutil.parseInts(lgameId, lroomId, ltableId, lseatId) if lgameId > 0 and lroomId > 0 and ltableId > 0 and lseatId >=0: ftlog.warn('create_table error, user in table',lgameId, lroomId, ltableId, lseatId) sendPopTipMsg(userId, "请稍候,正在进桌...") config = { "type":"quickstart", "pluginParams": { "roomId": lroomId, "tableId": ltableId, "seatId": lseatId } } todotask = TodoTaskEnterGameNew(lgameId, config) mo = MsgPack() mo.setCmd('todo_tasks') mo.setResult('gameId', gameId) mo.setResult('pluginId', lgameId) mo.setResult('userId', userId) mo.setResult('tasks', TodoTaskHelper.encodeTodoTasks(todotask)) router.sendToUser(mo, userId) elif self._canEnterGame(userId, gameId): # 保存建桌时间戳 gamedata.setGameAttr(userId, gameId, 'createTableTime', pktimestamp.getCurrentTimestamp()) msg = runcmd.getMsgPack() itemParams = msg.getParam("itemParams") playerCount = 4 playerTypeId = itemParams.get(MFTDefine.PLAYER_TYPE, 1) playerTypeConfig = majiang_conf.getCreateTableConfig(gameId, playMode, MFTDefine.PLAYER_TYPE, playerTypeId) if not playerTypeConfig: sendPopTipMsg(userId, '人数配置有误,请稍后重试') return playerCount = playerTypeConfig.get('count', 4) ftlog.debug('MajiangCreateTable.create_table playerCount:', playerCount) cardCountKey = playerTypeConfig.get(MFTDefine.CARD_COUNT, MFTDefine.CARD_COUNT) cardCountId = itemParams.get(cardCountKey, 0) cardCountConfig = majiang_conf.getCreateTableConfig(gameId, playMode, cardCountKey, cardCountId) if not cardCountConfig: sendPopTipMsg(userId, '房卡配置有误,请稍后重试') return if hasRobot == 1 and 'hasRobot' in cardCountConfig: cardCountConfig = cardCountConfig.get('hasRobot', {}) ftlog.debug('MajiangCreateTable.create_table hasRobot == 1:') fangka_count = cardCountConfig.get('fangka_count', 1) ftlog.debug('MajiangCreateTable.create_table fangka_count:', fangka_count , ' cardCountConfig:', cardCountConfig) msg.setParam('isCreateTable', 1) #标记创建的桌子是 自建桌 from poker.entity.game.rooms.room import TYRoom ''' 根据五个因素筛选合适的房间 1)gameId 游戏ID 2)playMode 游戏玩法 3)playerCount 玩家个数 4)hasRobot 是否有机器人 5)itemId 房卡道具 ''' itemId = hall_fangka.queryFangKaItem(gameId, userId, clientId) if itemId: ftlog.debug('MajiangCreateTable._chooseCreateRoom fangKa itemId:', itemId) roomId, checkResult = MajiangCreateTable._chooseCreateRoom(userId, gameId, playMode, playerCount, hasRobot, itemId) ftlog.debug('MajiangCreateTable._chooseCreateRoom roomId:', roomId, ' checkResult:', checkResult) if checkResult==TYRoom.ENTER_ROOM_REASON_OK: msg = runcmd.getMsgPack() msg.setCmdAction("room", "create_table") msg.setParam("roomId", roomId) msg.setParam("itemParams", itemParams) msg.setParam('needFangka', fangka_count) ftlog.debug('MajiangCreateTable._chooseCreateRoom send message to room:', msg) router.sendRoomServer(msg, roomId) else: sendPopTipMsg(userId, "暂时无法创建请稍后重试") if router.isQuery() : mo = runcmd.newOkMsgPack(1) router.responseQurery(mo, '', str(userId)) else: ftlog.info('majiang2 game_handler, ignore enter game request...')