Exemple #1
0
 def _fetchAllRoomInfos(self, uid, gid, playMode):
     ftlog.debug("|gameId, roomIds:", gid, [room.roomId for room in gdata.roomIdDefineMap().values() if room.gameId == gid])
     ftlog.debug("|gameId, bigRoomIds:", gid, list(gdata.gameIdBigRoomidsMap()[gid]))
     ctlRoomIds = [bigRoomId * 10000 + 1000 for bigRoomId in gdata.gameIdBigRoomidsMap()[gid]]
     ctlRoomIds.sort()
     ftlog.debug("|gameId, ctrRoomIds:", gid, ctlRoomIds)
     roomInfos = []
     ucount_infos = bireport.getRoomOnLineUserCount(gid, True)
     ftlog.debug("_fetchAllRoomInfosxxxxxxxx", ucount_infos)
     if playMode :
         for ctlRoomId in ctlRoomIds :
             roomDef = gdata.roomIdDefineMap()[ctlRoomId]
             ftlog.debug('_generateRoomList ', 'roomDef=', roomDef)
             roomConfig = roomDef.configure
             if roomConfig.get('playMode', None) == playMode \
                 and (not roomConfig.get('ismatch', 0)) \
                 and (not roomConfig.get(MFTDefine.IS_CREATE, 0)):
                 # 有playMode 非比赛 非自建桌
                 roomDesc = {}
                 roomDesc["play_mode"] = roomConfig["playMode"]
                 roomDesc["min_coin"] = roomConfig["minCoin"]
                 roomDesc["max_coin"] = roomConfig["maxCoin"]
                 roomDesc["base_chip"] = roomConfig["tableConf"]["base_chip"]
                 roomDesc["service_fee"] = roomConfig["tableConf"]["service_fee"]
                 playerCount = ucount_infos[1].get(str(roomDef.bigRoomId), 0)
                 ftlog.debug("_fetchAllRoomInfosxxxxxxxx", ucount_infos[1], roomDef.bigRoomId, ctlRoomId, playerCount)
                 roomInfos.append([
                                     ctlRoomId,
                                     playerCount,
                                     "",
                                     "",
                                     "",
                                     roomDesc                                      
                                   ])
     return roomInfos
Exemple #2
0
    def _do_http_gm_room_list(self, gameId, httpRequest, httpArgs, httpResult):
        '''获取房间列表'''

        roomOnlineInfos = daobase._executeBiCmd('HGETALL', daoconst.BI_KEY_ROOM_ONLINES % (gameId))
        roomOnlineInfos = dict(utils.pairwise(roomOnlineInfos))
        bigRoomOnlineInfos = {}
        for roomId, onlineInfo in roomOnlineInfos.items():
            bigRoomId = gdata.getBigRoomId(roomId)
            tcs = map(int, onlineInfo.split('|'))
            ucount, tcount = tcs[0], tcs[-1]
            if bigRoomId not in bigRoomOnlineInfos:
                bigRoomOnlineInfos[bigRoomId] = [0, 0]
            bigRoomOnlineInfos[bigRoomId][0] += ucount
            bigRoomOnlineInfos[bigRoomId][1] += tcount

        roomList = []

        for bigRoomId in gdata.gameIdBigRoomidsMap()[gameId]:
            ctrlRoomId = gdata.bigRoomidsMap()[bigRoomId][0]
            roomDefine = gdata.roomIdDefineMap()[ctrlRoomId]
            ucount, tcount = bigRoomOnlineInfos.get(roomDefine.bigRoomId, [0, 0])
            roomInfo = {
                'bigRoomId': bigRoomId,
                'tableCount': roomDefine.configure['gameServerCount'] * roomDefine.configure['gameTableCount'],
                'name': roomDefine.configure['tableConf'].get('tname', ''),
                'playingPlayers': ucount,
                'playingTables': tcount,
            }
            roomList.append(roomInfo)
        httpResult['roomList'] = roomList
    def _initCandidateRoomIdsByGameId(cls, gameId):
        """通过游戏gameId初始化推荐房间Ids"""
        roomids = {'': []}
        ctlRoomIds = [
            bigRoomId * 10000 + 1000
            for bigRoomId in gdata.gameIdBigRoomidsMap().get(gameId, [])
        ]
        for ctlRoomId in ctlRoomIds:
            roomDef = gdata.roomIdDefineMap()[ctlRoomId]
            playMode = roomDef.configure.get('playMode', '')
            ismatch = roomDef.configure.get('ismatch', 0)
            if ismatch == 0:
                sortVal = roomDef.configure.get('quickIndex', 0)
                if not playMode in roomids:
                    roomids[playMode] = []
                roomids[playMode].append([ctlRoomId, sortVal])

        croomids = {}
        allids = []
        for k, v in roomids.items():
            v.sort(key=lambda x: x[1])
            rids = [x[0] for x in v]
            croomids[k] = rids
            allids.extend(rids)
            ftlog.debug('_initCandidateRoomIds->', gameId, k, '=', croomids[k])

        allids.sort()
        croomids['_all_'] = allids
        ftlog.debug('_initCandidateRoomIds->', gameId, '_all_', '=',
                    croomids['_all_'])
        return croomids
Exemple #4
0
    def _initCandidateRoomIdsByGameId(cls, gameId):

        roomids = {'': []}
        ctlRoomIds = [bigRoomId * 10000 + 1000 for bigRoomId in gdata.gameIdBigRoomidsMap().get(gameId, [])]
        for ctlRoomId in ctlRoomIds:
            roomDef = gdata.roomIdDefineMap()[ctlRoomId]
            playMode = roomDef.configure.get('playMode', '')
            ismatch = roomDef.configure.get('ismatch', 0)
            if ismatch == 0:
                sortVal = roomDef.configure.get('quickIndex', 0)
                if not playMode in roomids:
                    roomids[playMode] = []
                roomids[playMode].append([ctlRoomId, sortVal])

        croomids = {}
        allids = []
        for k, v in roomids.items():
            v.sort(key=lambda x: x[1])
            rids = [x[0] for x in v]
            croomids[k] = rids
            allids.extend(rids)
            ftlog.debug('_initCandidateRoomIds->', gameId, k, '=', croomids[k])

        allids.sort()
        croomids['_all_'] = allids
        ftlog.debug('_initCandidateRoomIds->', gameId, '_all_', '=', croomids['_all_'])

        return croomids
Exemple #5
0
    def _getDizhuMatchCandidateRoomIds(cls):
        '''
        初始化地主比赛的待选房间列表
        '''
        # 若存在初始化好的地主比赛房间列表,则直接返回
        global _DIZHU_QMATCH_CANDIDATE_ROOM_IDS
        if _DIZHU_QMATCH_CANDIDATE_ROOM_IDS:
            return _DIZHU_QMATCH_CANDIDATE_ROOM_IDS

        gameId = 6
        # ctrlroomid_list = [
        #    [ ctrlroomid, quickindex],
        #    ...
        # ]
        ctrlroomid_quickindex_list = []
        # 生成的控制房间的房间id列表,ctrlroomid = bigRoomId * 10000 + 1000
        ctrlroomid_list = [
            bigRoomId * 10000 + 1000
            for bigRoomId in gdata.gameIdBigRoomidsMap().get(gameId, [])
        ]
        for ctrlroomid in ctrlroomid_list:
            roomdef = gdata.roomIdDefineMap()[ctrlroomid]
            ismatch = roomdef.configure.get('ismatch', 0)
            # 只选择比赛场,ismatch!=0为比赛场
            if ismatch != 0:
                quickindex = roomdef.configure.get('quickIndex', 0)
                ctrlroomid_quickindex_list.append([ctrlroomid, quickindex])

        # 默认是升序
        ctrlroomid_quickindex_list.sort(key=lambda x: x[1])

        _DIZHU_QMATCH_CANDIDATE_ROOM_IDS = [
            x[0] for x in ctrlroomid_quickindex_list
        ]
        return _DIZHU_QMATCH_CANDIDATE_ROOM_IDS
Exemple #6
0
def collectCtrlRoomIdsByFTPlayMode(ftPlayMode):
    bigRoomIds = gdata.gameIdBigRoomidsMap().get(DIZHU_GAMEID)
    ctrlRoomIds = []
    for bigRoomId in bigRoomIds:
        roomConf = gdata.getRoomConfigure(bigRoomId)
        if ((roomConf.get('typeName') in ('dizhuFT', 'dizhu_friend')) 
            and ftPlayMode == roomConf.get('ftPlayMode')):
            ctrlRoomIds.extend(gdata.bigRoomidsMap().get(bigRoomId, []))
    ctrlRoomIds.sort()
    return ctrlRoomIds
Exemple #7
0
 def _fetchAllRoomInfos(self, uid, gid, playMode):
     ftlog.debug("|gameId, roomIds:", gid, [
         room.roomId
         for room in gdata.roomIdDefineMap().values() if room.gameId == gid
     ])
     ftlog.debug("|gameId, bigRoomIds:", gid,
                 list(gdata.gameIdBigRoomidsMap()[gid]))
     ctlRoomIds = [
         bigRoomId * 10000 + 1000
         for bigRoomId in gdata.gameIdBigRoomidsMap()[gid]
     ]
     ctlRoomIds.sort()
     ftlog.debug("|gameId, ctrRoomIds:", gid, ctlRoomIds)
     roomInfos = []
     ucount_infos = bireport.getRoomOnLineUserCount(gid, True)
     ftlog.debug("_fetchAllRoomInfosxxxxxxxx", ucount_infos)
     if playMode:
         for ctlRoomId in ctlRoomIds:
             roomDef = gdata.roomIdDefineMap()[ctlRoomId]
             ftlog.debug('_generateRoomList ', 'roomDef=', roomDef)
             roomConfig = roomDef.configure
             if roomConfig.get('playMode', None) == playMode \
                     and (not roomConfig.get('ismatch', 0)) \
                     and (not roomConfig.get(MFTDefine.IS_CREATE, 0)):
                 # 有playMode 非比赛 非自建桌
                 roomDesc = {}
                 roomDesc["play_mode"] = roomConfig["playMode"]
                 roomDesc["min_coin"] = roomConfig["minCoin"]
                 roomDesc["max_coin"] = roomConfig["maxCoin"]
                 roomDesc["base_chip"] = roomConfig["tableConf"][
                     "base_chip"]
                 roomDesc["service_fee"] = roomConfig["tableConf"][
                     "service_fee"]
                 playerCount = ucount_infos[1].get(str(roomDef.bigRoomId),
                                                   0)
                 ftlog.debug("_fetchAllRoomInfosxxxxxxxx", ucount_infos[1],
                             roomDef.bigRoomId, ctlRoomId, playerCount)
                 roomInfos.append(
                     [ctlRoomId, playerCount, "", "", "", roomDesc])
     return roomInfos
Exemple #8
0
 def signinNextMatch(self, gameId, userId):
     """报名下一场比赛
     """
     msg = runcmd.getMsgPack()
     roomId = msg.getParam('room_id', 0)
     ctlRoomIds = [bigRoomId * 10000 + 1000 for bigRoomId in gdata.gameIdBigRoomidsMap()[gameId]]
     if roomId in ctlRoomIds:
         room = gdata.rooms()[roomId]
         if room:
             signinParams = gamedata.getGameAttrJson(userId, room.gameId, 'test.signinParams')
             room.doSignin(userId, signinParams)
         else:
             ftlog.info('=======signinNextMatch==Trace==', roomId, userId)
Exemple #9
0
    def onGameCreateCustomTable(self, gameId, msg):
        '''创建自建桌的请求入口, 具体逻辑转发给GR执行
        '''
        if ftlog.is_debug():
            ftlog.debug("<< |msg", msg, caller=self)

        userId = msg.getParam("userId")
        clientId = msg.getParam("clientId")

        if DiFangQuickStart.checkReConnect(userId, clientId, gameId):
            # self.sendGameCreateCustomTableRes(0, userId)
            return

        # 转发给GR处理具体逻辑
        roomId = msg.getParam("roomId", 0)
        if not roomId:
            roomId = gdata.gameIdBigRoomidsMap()[gameId][0]
            msg.setParam("roomId", roomId)
        msg.setCmdAction("room", "create_custom_table")

        # 需要用query模式等待GR回复再return,return前UT会锁住userId,从而避免客户端同时发多个请求时出现混乱
        router.queryRoomServer(msg, roomId)
Exemple #10
0
    def _fetchAllRoomInfos(self, userId, gameId):
        """
        获取所有房间信息
        """
        lang = util.getLanguage(userId)
        testMode = util.getNewbieABCTestMode(userId)
        recommendRoomId, reason = FishQuickStart._chooseRoom(userId, gameId)
        if reason != FishQuickStart.ENTER_ROOM_REASON_OK:
            recommendRoomId = 0
        re_roomConf = None
        if recommendRoomId != 0:
            re_roomConf = gdata.roomIdDefineMap()[recommendRoomId]
            if re_roomConf:
                re_roomConf = re_roomConf.configure

        ctrlRoomIds = [bigRoomId * 10000 + 1000 for bigRoomId in gdata.gameIdBigRoomidsMap()[gameId]]
        ctrlRoomIds.sort()
        ftlog.debug("_fetchAllRoomInfos", userId, gameId, ctrlRoomIds, recommendRoomId, re_roomConf)
        normalRoomInfos = []
        friendRoomInfos = []
        matchRoomInfos = []
        pointMatchRoomInfos = []
        robberyRoomInfos = []
        grandPrixRoomInfos = []
        poseidonRoomInfos = []

        isLimitedVer = util.isVersionLimit(userId)
        newbieRoomListMode = gamedata.getGameAttr(userId, FISH_GAMEID, ABTestData.newbieRoomListMode)   # 新手房间列表模式
        isFinishAllRedTask = util.isFinishAllRedTask(userId)
        clientVersion = gamedata.getGameAttr(userId, FISH_GAMEID, GameData.clientVersion)
        fpMultipleTestMode = config.getPublic("fpMultipleTestMode") or gamedata.getGameAttr(userId, FISH_GAMEID,
                                                                                            ABTestData.fpMultipleTestMode)  # 渔场倍率AB测试
        for ctlRoomId in ctrlRoomIds:
            pass


        return normalRoomInfos, friendRoomInfos, matchRoomInfos, robberyRoomInfos, \
               pointMatchRoomInfos, grandPrixRoomInfos, poseidonRoomInfos
Exemple #11
0
 def getDdzBigRoomIdList(cls):
     '''
     获得地主的所有房间ID的列表
     :return 返回的房间ID列表是配置中的ID,如:[6015, 6016]
     '''
     return gdata.gameIdBigRoomidsMap()[6]
Exemple #12
0
def _updateRoomDefine(keylist, sleepTime):
    import json
    from poker.entity.game import quick_start
    isall = 1 if len(keylist) == 1 and keylist[0] == 'all' else 0
    if _DEBUG:
        debug('_syncConfigure._updateRoomDefine-> in', keylist)
    _sleepnb(sleepTime)
    keylist = set(keylist)
    changedGameIds = []
    changedBigRoomIds = []
    for gid, bigRoomIds in gdata.gameIdBigRoomidsMap().items():
        rkey = 'game:' + str(gid) + ':room:0'
        if isall or rkey in keylist:
            changedGameIds.append([rkey, gid])
        for bigRoomId in bigRoomIds:
            rkey = 'game:' + str(gid) + ':room:' + str(bigRoomId)
            if isall or rkey in keylist:
                changedBigRoomIds.append([rkey, bigRoomId])

    changeRoomIds = set([])
    for changed in changedGameIds:
        rkey = changed[0]
        gid = changed[1]
        if _DEBUG:
            debug('_syncConfigure._updateRoomDefine-> reload roomdef', rkey)
        roomdict = ftcon.getConfNoCache('GET', rkey)
        if roomdict:
            roomdict = json.loads(roomdict)
        if not isinstance(roomdict, dict):
            continue
        for roomIdStr, configure in roomdict.items():
            bigRoomId = int(roomIdStr)
            # 所有BIGROOMID下的configure是同一个对象,update第一个即可
            roomid0 = gdata.bigRoomidsMap()[bigRoomId][0]
            room0 = gdata.roomIdDefineMap()[roomid0]
            room0.configure.update(configure)
            changeRoomIds.add(bigRoomId)
            if _DEBUG:
                debug(
                    '_syncConfigure._updateRoomDefine-> reload roomdef by 0.json',
                    bigRoomId)
            _sleepnb(sleepTime)

    for changed in changedBigRoomIds:
        rkey = changed[0]
        bigRoomId = changed[1]
        if _DEBUG:
            debug('_syncConfigure._updateRoomDefine-> reload roomdef', rkey)
        extdict = ftcon.getConfNoCache('GET', rkey)
        if extdict:
            extdict = json.loads(extdict)
        if not isinstance(extdict, dict):
            continue
            # 所有BIGROOMID下的configure是同一个对象,update第一个即可
        roomid0 = gdata.bigRoomidsMap()[bigRoomId][0]
        room0 = gdata.roomIdDefineMap()[roomid0]
        room0.configure.update(extdict)
        changeRoomIds.add(bigRoomId)
        if _DEBUG:
            debug(
                '_syncConfigure._updateRoomDefine-> reload roomdef by ' +
                str(bigRoomId) + '.json', bigRoomId)
        _sleepnb(sleepTime)

    if changeRoomIds:
        for _, roomIns in gdata.rooms().items():
            if roomIns.bigRoomId in changeRoomIds:
                if _DEBUG:
                    debug('_syncConfigure._updateRoomDefine-> reload roomins',
                          roomIns.roomId)
                rdef = gdata.roomIdDefineMap().get(roomIns.roomId)
                roomIns.doReloadConf(rdef)
                _sleepnb(sleepTime)

        quick_start._CANDIDATE_ROOM_IDS = {}

    _sleepnb(sleepTime)
    if _DEBUG:
        debug('_syncConfigure._updateRoomDefine-> out')
Exemple #13
0
                        return [startRooms[-1] * 10000 + 1000]
                except Exception, e:
                    ftlog.error('DizhuQuickStart._getQuickStartRoomList',
                                'userId=', userId, 'playMode=', playMode,
                                'kwargs=', kwargs, 'startRooms=', startRooms,
                                'err=', e.message)
                return [bigRoomId * 10000 + 1000 for bigRoomId in startRooms]

    ctrlroomid_quickstartchip_list = []

    global _DIZHU_CTRL_ROOM_IDS_LIST
    if not _DIZHU_CTRL_ROOM_IDS_LIST:
        # 生成的控制房间的房间id列表,ctrlroomid = bigRoomId * 10000 + 1000
        _DIZHU_CTRL_ROOM_IDS_LIST = [
            bigRoomId * 10000 + 1000
            for bigRoomId in gdata.gameIdBigRoomidsMap().get(DIZHU_GAMEID, [])
        ]

    rankId = kwargs.get('rankId', '-1')
    for ctrlroomid in _DIZHU_CTRL_ROOM_IDS_LIST:
        roomdef = gdata.roomIdDefineMap()[ctrlroomid]
        ismatch = roomdef.configure.get('ismatch', 0)

        if ismatch != isMatch:
            continue

        # 过滤玩法
        playmode = roomdef.configure.get('playMode', '')
        if not ismatch and playmode != playMode:
            if playMode == dizhuconf.PLAYMODE_LAIZI and playmode == dizhuconf.PLAYMODE_QUICKLAIZI:
                pass
Exemple #14
0
def _updateRoomDefine(keylist, sleepTime):
    import json
    from poker.entity.game import quick_start
    isall = 1 if len(keylist) == 1 and keylist[0] == 'all' else 0
    if _DEBUG:
        debug('_syncConfigure._updateRoomDefine-> in', keylist)
    _sleepnb(sleepTime)
    keylist = set(keylist)
    changedGameIds = []
    changedBigRoomIds = []
    for gid, bigRoomIds in gdata.gameIdBigRoomidsMap().items():
        rkey = 'game:' + str(gid) + ':room:0'
        if isall or rkey in keylist:
            changedGameIds.append([rkey, gid])
        for bigRoomId in bigRoomIds:
            rkey = 'game:' + str(gid) + ':room:' + str(bigRoomId)
            if isall or rkey in keylist:
                changedBigRoomIds.append([rkey, bigRoomId])

    changeRoomIds = set([])
    for changed in changedGameIds:
        rkey = changed[0]
        gid = changed[1]
        if _DEBUG:
            debug('_syncConfigure._updateRoomDefine-> reload roomdef', rkey)
        roomdict = ftcon.getConfNoCache('GET', rkey)
        if roomdict:
            roomdict = json.loads(roomdict)
        if not isinstance(roomdict, dict):
            continue
        for roomIdStr, configure in roomdict.items():
            bigRoomId = int(roomIdStr)
            # 所有BIGROOMID下的configure是同一个对象,update第一个即可
            roomid0 = gdata.bigRoomidsMap()[bigRoomId][0]
            room0 = gdata.roomIdDefineMap()[roomid0]
            room0.configure.update(configure)
            changeRoomIds.add(bigRoomId)
            if _DEBUG:
                debug('_syncConfigure._updateRoomDefine-> reload roomdef by 0.json', bigRoomId)
            _sleepnb(sleepTime)

    for changed in changedBigRoomIds:
        rkey = changed[0]
        bigRoomId = changed[1]
        if _DEBUG:
            debug('_syncConfigure._updateRoomDefine-> reload roomdef', rkey)
        extdict = ftcon.getConfNoCache('GET', rkey)
        if extdict:
            extdict = json.loads(extdict)
        if not isinstance(extdict, dict):
            continue
            # 所有BIGROOMID下的configure是同一个对象,update第一个即可
        roomid0 = gdata.bigRoomidsMap()[bigRoomId][0]
        room0 = gdata.roomIdDefineMap()[roomid0]
        room0.configure.update(extdict)
        changeRoomIds.add(bigRoomId)
        if _DEBUG:
            debug('_syncConfigure._updateRoomDefine-> reload roomdef by ' + str(bigRoomId) + '.json', bigRoomId)
        _sleepnb(sleepTime)

    if changeRoomIds:
        for _, roomIns in gdata.rooms().items():
            if roomIns.bigRoomId in changeRoomIds:
                if _DEBUG:
                    debug('_syncConfigure._updateRoomDefine-> reload roomins', roomIns.roomId)
                rdef = gdata.roomIdDefineMap().get(roomIns.roomId)
                roomIns.doReloadConf(rdef)
                _sleepnb(sleepTime)

        quick_start._CANDIDATE_ROOM_IDS = {}

    _sleepnb(sleepTime)
    if _DEBUG:
        debug('_syncConfigure._updateRoomDefine-> out')
                            return [startRooms[-1] * 10000 + 1000], 1
                    except Exception, e:
                        ftlog.error('DizhuQuickStart._getQuickStartRoomList',
                                    'userId=', userId,
                                    'playMode=', playMode,
                                    'kwargs=', kwargs,
                                    'startRooms=', startRooms,
                                    'err=', e.message)
                    return [bigRoomId * 10000 + 1000 for bigRoomId in startRooms], 1

        ctrlroomid_quickstartchip_list = []

        global _DIZHU_CTRL_ROOM_IDS_LIST
        if not _DIZHU_CTRL_ROOM_IDS_LIST:
            # 生成的控制房间的房间id列表,ctrlroomid = bigRoomId * 10000 + 1000
            _DIZHU_CTRL_ROOM_IDS_LIST = [bigRoomId * 10000 + 1000 for bigRoomId in gdata.gameIdBigRoomidsMap().get(DIZHU_GAMEID, [])]

        rankId = kwargs.get('rankId', '-1')
        for ctrlroomid in _DIZHU_CTRL_ROOM_IDS_LIST:
            roomdef = gdata.roomIdDefineMap()[ctrlroomid]
            ismatch = roomdef.configure.get('ismatch', 0)

            if roomdef.configure.get('segment') == 1:
                continue

            if ismatch != isMatch:
                continue

            # 过滤玩法
            playmode = roomdef.configure.get('playMode', '')
            if not ismatch and playmode != playMode: