Пример #1
0
 def getDashiFenLevel(cls, userId):
     '''
     获取用户的大师分等级
     '''
     from dizhu.game import TGDizhu
     info = TGDizhu.getDaShiFen(userId, None)
     if info:
         return info.get('level', 0)
     return 0
Пример #2
0
    def _canQuickEnterRoom(cls, userId, gameId, roomId, isOnly):
        ret = cls._canQuickEnterRoomBase(userId, gameId, roomId, isOnly)
        if ret != TYRoom.ENTER_ROOM_REASON_OK:
            return ret

        roomConfig = gdata.roomIdDefineMap()[roomId].configure

        # 检测准入情况,配置中若没有准入时间(openTimeList),则默认准许全天进入
        if not cls._checkOpenTime(roomConfig, datetime.now().time()):
            return TYRoom.ENTER_ROOM_REASON_NOT_OPEN

        if roomConfig.get('typeName') in ('dizhuFT', 'dizhu_friend'):
            return TYRoom.ENTER_ROOM_REASON_NOT_OPEN

        clientId = sessiondata.getClientId(userId)
        if not dizhuhallinfo.canDisplayRoom(gameId, userId, clientId, roomId,
                                            roomConfig):
            if ftlog.is_debug():
                ftlog.debug(
                    'DizhuQuickStartV4_0._canQuickEnterMatchRoom NotCanDisplayRoom',
                    'gameId=', gameId, 'userId=', userId, 'clientId=',
                    clientId, 'roomId=', roomId)
            return TYRoom.ENTER_ROOM_REASON_NOT_OPEN

        # 大师分和vip准入筛选
        # 两个条件是`或者`的关系
        dashifenLevel = roomConfig.get('dashifenLevel', 0)
        vipLevel = roomConfig.get('vipLevel', 0)
        ftlog.debug('_canQuickEnterRoom->', userId, gameId, roomId,
                    'dashifenLevel=', dashifenLevel, 'vipLevel=', vipLevel)
        if dashifenLevel <= 0 and vipLevel <= 0:
            return TYRoom.ENTER_ROOM_REASON_OK

        # 若大师分不满足情况,则再检测VIP,不能直接返回大师分不满足的错误
        if dashifenLevel > 0:
            dashifen = 0
            from dizhu.game import TGDizhu
            info = TGDizhu.getDaShiFen(userId, None)
            ftlog.debug('_canQuickEnterRoom->', userId, gameId, roomId,
                        'dashifenInfo=', info)
            if info:
                dashifen = info.get('level', 0)
            if dashifen >= dashifenLevel:
                return TYRoom.ENTER_ROOM_REASON_OK

        if vipLevel > 0:
            vip = 0
            vipInfo = hallvip.userVipSystem.getUserVip(userId)
            ftlog.debug('_canQuickEnterRoom->', userId, gameId, roomId,
                        'vipInfo=', vipInfo)
            if vipInfo:
                vip = vipInfo.vipLevel.level
            if vip >= vipLevel:
                return TYRoom.ENTER_ROOM_REASON_OK

        return TYRoom.ENTER_ROOM_REASON_DASHIFEI_LEVEL