Esempio n. 1
0
def getCanGivestartChip(userId, gameId, clientId):
    global newuser_startchip
    _, clientVer, _ = strutil.parseClientId(clientId)
    if clientVer < client_ver_judge.client_ver_397:
        return 3000
    else:
        return newuser_startchip
Esempio n. 2
0
    def _doUpdate(cls, gameId, userId, clientId, timestamp=None):
        mo = MsgPack()
        mo.setCmd('hall_rp_main')
        mo.setResult('action', 'update')
        mo.setResult('userId', userId)
        timestamp = timestamp or pktimestamp.getCurrentTimestamp()
        mo.setResult('curTime', timestamp)
        conf = hall_red_packet_main.getConf()

        if not conf:
            mo.setResult('startTime', 0)
            mo.setResult('stopTime', 0)
        else:
            startTime = pktimestamp.datetime2Timestamp(
                conf.startDT) if conf.startDT else 0
            stopTime = pktimestamp.datetime2Timestamp(
                conf.stopDT) if conf.stopDT else 0
            mo.setResult('startTime', startTime)
            mo.setResult('stopTime', stopTime)
            _, clientVer, _ = strutil.parseClientId(clientId)
            if clientVer >= 4.58:
                if conf.inviteTodotaskFac:
                    todotask = conf.inviteTodotaskFac.newTodoTask(
                        HALL_GAMEID, userId, clientId)
                    if todotask:
                        mo.setResult('todotask', todotask.toDict())
            else:
                if conf.oldInviteTodotaskFac:
                    todotask = conf.oldInviteTodotaskFac.newTodoTask(
                        HALL_GAMEID, userId, clientId)
                    if todotask:
                        mo.setResult('todotask', todotask.toDict())
        return mo
Esempio n. 3
0
def checkClientVer(userId, gameId, clientId):
    _, clientVer, _ = strutil.parseClientId(clientId)
    if clientId in localServiceConfig.SPECIAL_CLIENTIDS:
        return True
    if clientVer < localServiceConfig.CLIENT_VER:
        return False
    return True
Esempio n. 4
0
def makeTodoTaskZhuanyun_(gameId, userId, clientId, benefitsSend, userBenefits,
                          roomId):
    from hall.entity import hallproductselector
    if ftlog.is_debug():
        ftlog.debug('hallpopwnd.makeTodoTaskZhuanyun gameId=', gameId,
                    'userId=', userId, 'clientId=', clientId, 'benefitsSend=',
                    benefitsSend, 'userBenefits=', userBenefits.__dict__,
                    'roomId=', roomId)
    clientOs, _clientVer, _ = strutil.parseClientId(clientId)
    clientOs = clientOs.lower()

    if clientOs != 'winpc':
        return TodoTaskHelper.makeZhuanyunTodoTaskNew(gameId, userId, clientId,
                                                      benefitsSend,
                                                      userBenefits, roomId)

    product, _ = hallproductselector.selectLessbuyProduct(
        gameId, userId, clientId, roomId)
    if not product:
        return None

    user_diamond = pkuserdata.getAttr(userId, 'diamond')
    if user_diamond >= int(product.priceDiamond):
        chip = product.getMinFixedAssetCount(hallitem.ASSET_CHIP_KIND_ID)
        show_str = u'运气不好,来个转运礼包!%s元得%s万金币。' % (product.price, chip)
        buy_type = 'consume'
        btn_txt = u'兑换'
    else:
        show_str = u'运气不好~,买点金币战个痛快吧!'
        buy_type = 'charge'
        btn_txt = u'去充值'
    orderShow = TodoTaskOrderShow.makeByProduct(show_str, '', product,
                                                buy_type)
    orderShow.setParam('sub_action_btn_text', btn_txt)
    return orderShow
Esempio n. 5
0
 def getMatchStatesByPlayer(cls, match, room, player, mo):
     mo.setResult('roomId', room.bigRoomId)
     mo.setResult('state', 20)
     mo.setResult('inst', player.instId)
     mo.setResult('curPlayer', player.group.playerCount)
     mo.setResult('curTimeLeft', 0)
     mo.setResult('startTime', '')
     
     tcount = player.group.calcTotalUncompleteTableCount()
     if (tcount > 1
         and player.group.stageConf.type == StageType.DIEOUT
         and player.cardCount < player.group.stageConf.cardCount):
         # 定局需要减掉本桌
         tcount -= 1
         if ftlog.is_debug():
             ftlog.debug('GroupMatch.getMatchStatesByPlayer roomId=', room.bigRoomId,
                         'instId=', player.instId,
                         'userId=', player.userId,
                         'tcount=', tcount)
         
     progress = cls.getMatchProgress(player)
     allcount = player.group.playerCount
     _, clientVer, _ = strutil.parseClientId(player.clientId)
     waitInfo = {
         'uncompleted':tcount, # 还有几桌未完成
         'tableRunk':'%d/3' % player.tableRank, # 本桌排名
         'runk':'%d/%d' % (player.rank, allcount), # 总排名
         'chip':player.score # 当前积分
     }
     if clientVer >= 3.37:
         waitInfo['info'] = cls._buildWaitInfoMsg(room, player)
     mo.setResult('waitInfo', waitInfo)
     mo.setResult('progress', progress)
Esempio n. 6
0
def doSendLedToUser(userId):
    gameIdList = onlinedata.getGameEnterIds(userId)
    if not gameIdList:
        return

    clientId = sessiondata.getClientId(userId)
    _, clientVer, _ = strutil.parseClientId(clientId)
    for gameId in gameIdList:
        try:
            leds = getLedMsgList(gameId)
            if ftlog.is_debug():
                ftlog.debug('hallled.doSendLedToUser gameId=', gameId,
                            'gameId=', gameId, 'userId=', userId, 'clientId=',
                            clientId, 'leds=', leds)
            if leds:
                msgDict = leds[0][2]
                if clientVer >= 3.6:
                    mo = MsgPack()
                    mo.setCmd('led')
                    for k, v in msgDict.iteritems():
                        mo.setResult(k, v)
                else:
                    mo = MsgPack()
                    mo.setCmd('led')
                    if gameId in (1, 8):
                        msgDictV2 = translateToMsgDictV2(msgDict)
                        if msgDictV2:
                            mo.setKey('richText', msgDictV2.get('richText'))
                    msgV1 = translateToMsgDictV1(msgDict)
                    if msgV1:
                        gameId = msgDict.get('gameId', leds[0][1])
                        mo.setKey('result', [[leds[0][0], gameId, msgV1]])
                router.sendToUser(mo, userId)
        except:
            ftlog.error()
Esempio n. 7
0
def makeTodoTaskZhuanyun_(gameId, userId, clientId, benefitsSend, userBenefits, roomId):
    from hall.entity import hallproductselector
    if ftlog.is_debug():
        ftlog.debug('hallpopwnd.makeTodoTaskZhuanyun gameId=', gameId,
                    'userId=', userId,
                    'clientId=', clientId,
                    'benefitsSend=', benefitsSend,
                    'userBenefits=', userBenefits.__dict__,
                    'roomId=', roomId)
    clientOs, _clientVer, _ = strutil.parseClientId(clientId)
    clientOs = clientOs.lower()

    if clientOs != 'winpc':
        return TodoTaskHelper.makeZhuanyunTodoTaskNew(gameId, userId, clientId,
                                                      benefitsSend, userBenefits, roomId)

    product, _ = hallproductselector.selectLessbuyProduct(gameId, userId, clientId, roomId)
    if not product:
        return None

    user_diamond = pkuserdata.getAttr(userId, 'diamond')
    if user_diamond >= int(product.priceDiamond):
        chip = product.getMinFixedAssetCount(hallitem.ASSET_CHIP_KIND_ID)
        show_str = u'运气不好,来个转运礼包!%s元得%s万金币。' % (product.price, chip)
        buy_type = 'consume'
        btn_txt = u'兑换'
    else:
        show_str = u'运气不好~,买点金币战个痛快吧!'
        buy_type = 'charge'
        btn_txt = u'去充值'
    orderShow = TodoTaskOrderShow.makeByProduct(show_str, '', product, buy_type)
    orderShow.setParam('sub_action_btn_text', btn_txt)
    return orderShow
Esempio n. 8
0
def sendShareForWXRedEnvelope(userId, record, item):
    try:
        action = item.itemKind.findActionByName('exchange')
        from hall.entity.hallitem import TYItemActionExchange
        if isinstance(
                action,
                TYItemActionExchange) and action.isWechatRedPack():  # 微信红包
            from poker.util import strutil
            from poker.entity.dao import sessiondata
            clientId = sessiondata.getClientId(userId)
            _, cVer, _ = strutil.parseClientId(clientId)
            if cVer >= 3.90:
                from hall.entity import hallshare
                gameId = strutil.getGameIdFromHallClientId(clientId)
                shareId = hallshare.getShareId('wxRedEnvelope', userId, gameId)
                share = hallshare.findShare(shareId)
                if share:
                    todotask = share.buildTodotask(HALL_GAMEID, userId,
                                                   'wxRedEnvelope')
                    if todotask:
                        from hall.entity.todotask import TodoTaskHelper
                        TodoTaskHelper.sendTodoTask(gameId, userId, todotask)
    except:
        ftlog.error('sendShareForWXRedEnvelope', 'userId=', userId,
                    'exchangeId=', record.exchangeId, 'itemId=', item.itemId,
                    'itemKindId=', item.kindId)
Esempio n. 9
0
def checkin(userId, gameId, clientId, nowDate=None):
    '''
    用户签到
    @param userId: 用户ID
    @param nowDate: 当前日期
    @return: MonthCheckinStatus
    '''
    from hall.game import TGHall

    nowDate = nowDate or datetime.now().date()
    status = loadStatus(userId, nowDate)

    if not status.addCheckinDate(nowDate):
        raise AlreadyCheckinException()
    if isScriptDoGetReward(userId):
        raise AlreadyCheckinException('亲,签到奖励准备中,请玩几把再来领取吧!')
    _saveStatus(status)
    userToGetGift(userId, gameId, 0)

    # 领取累计奖励
    _, clientVer, _ = strutil.parseClientId(clientId)
    if clientVer <= 3.76:
        # 自动领奖
        days = status.allCheckinCount
        getDaysReward(userId, days, gameId, nowDate)

    TGHall.getEventBus().publishEvent(MonthCheckinOkEvent(userId, gameId, status, nowDate))

    ftlog.debug('checkin userId =', userId
                , 'gameId =', gameId
                , 'clientId =', clientId)
    return status
Esempio n. 10
0
def checkin(userId, gameId, clientId, nowDate=None):
    '''
    用户签到
    @param userId: 用户ID
    @param nowDate: 当前日期
    @return: MonthCheckinStatus
    '''
    from hall.game import TGHall

    nowDate = nowDate or datetime.now().date()
    status = loadStatus(userId, nowDate)

    if not status.addCheckinDate(nowDate):
        raise AlreadyCheckinException()
    if isScriptDoGetReward(userId):
        raise AlreadyCheckinException('亲,签到奖励准备中,请玩几把再来领取吧!')
    _saveStatus(status)
    userToGetGift(userId, gameId, 0)

    # 领取累计奖励
    _, clientVer, _ = strutil.parseClientId(clientId)
    if clientVer <= 3.76:
        # 自动领奖
        days = status.allCheckinCount
        getDaysReward(userId, days, gameId, nowDate)

    TGHall.getEventBus().publishEvent(
        MonthCheckinOkEvent(userId, gameId, status, nowDate))

    ftlog.debug('checkin userId =', userId, 'gameId =', gameId, 'clientId =',
                clientId)
    return status
Esempio n. 11
0
    def _handleSigninFeeNotEnoughException(cls, room, ex, uid, mo):
        payOrder = ex.fee.getParam('payOrder')

        clientId = sessiondata.getClientId(uid)
        clientOs, _clientVer, _ = strutil.parseClientId(clientId)
        msg = runcmd.getMsgPack()
        ddzver = msg.getParam('ddzver', 0) if msg else 0

        ftlog.debug("groupmatch._handleSigninFeeNotEnoughException", "userId", uid, "_clientVer=", _clientVer)
        if ddzver >= 3.772:
            cls._handleSigninFeeNotEnoughException_V3_772(room, ex, uid, mo)
            return

        if payOrder:
            clientOs = clientOs.lower()
            product, _shelves = hallstore.findProductByPayOrder(room.gameId, uid, clientId, payOrder)
            if product:
                buyType = ''
                btnTxt = ''
                if ex.fee.assetKindId == hallitem.ASSET_CHIP_KIND_ID and clientOs == 'winpc':
                    user_diamond = userdata.getAttrInt(uid, 'diamond')
                    if user_diamond >= int(product.priceDiamond):
                        buyType = 'consume'
                        btnTxt = '兑换'
                    else:
                        buyType = 'charge'
                        btnTxt = '去充值'
                orderShow = TodoTaskOrderShow.makeByProduct(ex.fee.failure, '', product, buyType)
                orderShow.setParam('sub_action_btn_text', btnTxt)
                mo = TodoTaskHelper.makeTodoTaskMsg(room.gameId, uid, orderShow)
                router.sendToUser(mo, uid)
                return True
        mo = TodoTaskHelper.makeTodoTaskMsg(room.gameId, uid, TodoTaskShowInfo(ex.fee.failure))
        router.sendToUser(mo, uid)
Esempio n. 12
0
    def _buildMatchStatasByPlayer(self, player, mp):
        mp.setResult('roomId', self.bigRoomId)
        mp.setResult('state', 20)
        mp.setResult('inst', player.instId)
        mp.setResult('curPlayer', player.group.playerCount)
        mp.setResult('curTimeLeft', 0)
        mp.setResult('startTime', '')

        tcount = player.group.calcTotalUncompleteTableCount(player)
        if ftlog.is_debug():
            ftlog.debug('DizhuErdayiMatchCtrlRoom._buildMatchStatasByPlayer',
                        'roomId=', self.bigRoomId, 'instId=', player.instId,
                        'userId=', player.userId, 'tcount=', tcount)

        progress = self._getMatchProgress(player)
        allcount = player.group.playerCount

        _, clientVer, _ = strutil.parseClientId(player.clientId)
        waitInfo = {
            'uncompleted': tcount,  # 还有几桌未完成
            'tableRunk': '%d/3' % player.tableRank,  # 本桌排名
            'runk': '%d/%d' % (player.rank, allcount),  # 总排名
            'chip': float(self._fmtScore(player.score))  # 当前积分
        }
        if clientVer >= 3.37:
            waitInfo['info'] = self._buildWaitInfoMsg(player)
        mp.setResult('waitInfo', waitInfo)
        mp.setResult('progress', progress)
        return mp
Esempio n. 13
0
def getVcTemplate(moduleKey, clientId, gameId=None):
    """
    http://192.168.10.93:8090/pages/viewpage.action?pageId=1868148
    """
    if isinstance(clientId, int):
        strClientId = numberToClientId(clientId)
        numClientId = clientIdToNumber(strClientId)
    else:
        numClientId = clientIdToNumber(clientId)
        strClientId = numberToClientId(numClientId)

    assert (numClientId > 0), 'the clientId int value error, input=' + str(clientId) + ' convert=' + str(
        numClientId) + ' ' + str(strClientId)
    assert (strClientId != ''), 'the clientId str value error, input=' + str(clientId) + ' convert=' + str(
        numClientId) + ' ' + str(strClientId)

    if not gameId:
        gameId = strutil.getGameIdFromHallClientId(strClientId)
        assert (gameId > 0), 'the gameId error, input=' + str(strClientId) + ' convert=' + str(gameId) + ' ' + str(
            numClientId) + ' ' + str(strClientId)

    xkey = 'game:' + str(gameId) + ':' + moduleKey + ':' + CLIENT_ID_MATCHER
    datas = _get(xkey, {})
    if not '_cache' in datas:
        strutil.replaceObjRefValue(datas)
        datas['_cache'] = {}

    _cache = datas['_cache']
    tname = _cache.get(numClientId, None)
    if tname == None:
        # 先判定1:1真实映射
        actual = datas.get('actual', {})
        tname = actual.get(strClientId, None)
        if tname == None:
            tname = actual.get(str(numClientId), None)

        # 第二优先级判定主次渠道,主次渠道可覆盖大部分的批量配置需求,比正则表达式配置难度低
        if tname == None:
            channel = strutil.getChannelFromHallClientId(clientId)
            tname = actual.get(channel, None)

        # 再判定正则表达式映射
        if tname == None:
            for vm in datas.get('virtual', []):
                if strutil.regMatch(vm[0], strClientId):
                    tname = vm[1]
                    break
        # 最后取缺省值
        if tname == None:
            clientSys, _, _ = strutil.parseClientId(strClientId)
            tname = datas.get('default_' + str(clientSys).lower(), None)
        # 最后取缺省值
        if tname == None:
            tname = datas.get('default', None)
        if tname == None:
            ftlog.warn('the clientId can not find template name ' + str(moduleKey) + ' ' + str(
                numClientId) + ' ' + strClientId)
        _cache[numClientId] = tname
    return tname
Esempio n. 14
0
def getClientIdInfo(userId):
    '''
    取得用户的当前的客户端ID的分解信息
    返回: 客户端的OS, 客户端的版本, 客户端的渠道, 客户端ID
    '''
    clientId = getClientId(userId)
    clientOs, clientVer, clientChannel = strutil.parseClientId(clientId)
    return clientOs, clientVer, clientChannel, clientId
Esempio n. 15
0
def getClientIdInfo(userId):
    '''
    取得用户的当前的客户端ID的分解信息
    返回: 客户端的OS, 客户端的版本, 客户端的渠道, 客户端ID
    '''
    clientId = getClientId(userId)
    clientOs, clientVer, clientChannel = strutil.parseClientId(clientId)
    return clientOs, clientVer, clientChannel, clientId
Esempio n. 16
0
def supplementCheckin(userId, gameId, clientId, supplementDate=None, nowDate=None):
    '''
    用户补签
    @param userId: 用户ID
    @param supDate: 补签日期,如果为None则表示补签最近一天
    @param nowDate: 当前日期
    @return: MonthCheckinStatus
    '''
    from hall.game import TGHall

    nowDate = nowDate or datetime.now().date()
    status = loadStatus(userId, nowDate)
    if isScriptDoGetReward(userId):
        raise AlreadyCheckinException('亲,签到奖励准备中,请玩几把再来领取吧!')
    # 检查最大补签数
    if status.supplementCheckinCount >= getConf().get("maxSupplementCheckinCount"):
        raise SupplementOverException()

    if supplementDate:
        if not pktimestamp.isSameMonth(supplementDate, status.curDate):
            raise InvalidSupplementDateException()
    else:
        holeDateList = status._getHoleDateList()
        if not holeDateList:
            raise AlreadyCheckinException()
        supplementDate = holeDateList[0]

    if not status.addSupplementCheckinDate(supplementDate):
        raise AlreadyCheckinException()

    # 减少抽奖卡,消耗成功之后,发放奖励。
    userAssets = hallitem.itemSystem.loadUserAssets(userId)
    timestamp = pktimestamp.getCurrentTimestamp()

    _, consumeCount, _final = userAssets.consumeAsset(gameId, 'item:4168', 1,
                                                      timestamp, 'HALL_CHECKIN', 0)
    if consumeCount < 1:
        result = {}
        result["lessCard"] = "您的补签卡不足"
        return 1, result
    datachangenotify.sendDataChangeNotify(gameId, userId, 'item')
    _saveStatus(status)

    userToGetGift(userId, gameId, state=0)
    # 领取累计奖励
    _, clientVer, _ = strutil.parseClientId(clientId)
    if clientVer <= 3.76:
        # 自动领奖
        days = status.allCheckinCount
        getDaysReward(userId, days, gameId, nowDate)

    TGHall.getEventBus().publishEvent(MonthSupCheckinOkEvent(userId, gameId, status, nowDate))

    ftlog.debug('supplementCheckin userId =', userId
                , 'gameId =', gameId
                , 'clientId =', clientId
                , 'noeDate =', nowDate)
    return 0, status
Esempio n. 17
0
def supplementCheckin(userId,
                      gameId,
                      clientId,
                      supplementDate=None,
                      nowDate=None):
    '''
    用户补签
    @param userId: 用户ID
    @param supDate: 补签日期,如果为None则表示补签最近一天
    @param nowDate: 当前日期
    @return: MonthCheckinStatus
    '''
    nowDate = nowDate or datetime.now().date()
    status = monthcheckin.loadStatus(userId, nowDate)
    if monthcheckin.isScriptDoGetReward(userId):
        raise monthcheckin.AlreadyCheckinException('非法签到')
    # 检查最大补签数
    if status.supplementCheckinCount >= monthcheckin._monthCheckinConf.get(
            "maxSupplementCheckinCount"):
        raise monthcheckin.SupplementOverException()

    if supplementDate:
        if not pktimestamp.isSameMonth(supplementDate, status.curDate):
            raise monthcheckin.InvalidSupplementDateException()
    else:
        supplementDate = status._getHoleDateList()
        if not supplementDate:
            raise monthcheckin.AlreadyCheckinException()

    if not status.addSupplementCheckinDate(supplementDate[0]):
        raise monthcheckin.AlreadyCheckinException()

    # TODO 发放补签奖励
    # TODO publish event
    #减少抽奖卡,消耗成功之后,发放奖励。
    userAssets = hallitem.itemSystem.loadUserAssets(userId)
    timestamp = pktimestamp.getCurrentTimestamp()

    _, consumeCount, _final = userAssets.consumeAsset(gameId, 'item:4168', 1,
                                                      timestamp,
                                                      'HALL_CHECKIN', 0)
    if consumeCount < 1:
        result = {}
        result["lessCard"] = "您的补签卡不足"
        return 1, result
    datachangenotify.sendDataChangeNotify(gameId, userId, 'item')
    monthcheckin._saveStatus(status)
    monthcheckin.userToGetGift(userId, gameId, state=0)
    #领取累计奖励
    _, clientVer, _ = strutil.parseClientId(clientId)
    if clientVer <= 3.76:
        #自动领奖
        days = status.allCheckinCount
        monthcheckin.getDaysReward(userId, days, gameId)
    ftlog.info('supplementCheckin userId =', userId, 'gameId =', gameId,
               'clientId =', clientId, 'noeDate =', nowDate)
    return 0, status
Esempio n. 18
0
def parseClientIdForDL(clientId):
    cid = configure.clientIdToNumber(clientId)
    if cid == 0:
        return False, '', 0, '', '', ''
    clientOs, _, info = strutil.parseClientId(clientId)
    parts = info.split('.')
    if len(parts) < 5:
        return False, '', 0, '', '', ''
    return True, clientOs.lower(), cid, parts[2], parts[3], parts[4]
Esempio n. 19
0
    def onCmdQuickStart(cls, msg, userId, gameId, roomId, tableId, playMode,
                        clientId):
        '''
        拦截父类处理的选择房间逻辑,先于父类处理,若选择成功,则不进行父类的选择房间处理逻辑,否则正常走父类的处理逻辑
        '''

        if not pokerconf.isOpenMoreTable(clientId):
            loc = onlinedata.checkUserLoc(userId, clientId, gameId)
            ftlog.debug(
                'DizhuQuickStartV4_0.onCmdQuickStart: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:
                    roomId = lroomId
                    tableId = ltableId
                    ftlog.debug(
                        'DizhuQuickStartV4_0.onCmdQuickStartold client, reset roomId, tableId->',
                        roomId,
                        tableId,
                        caller=cls)

        _, version, _ = strutil.parseClientId(clientId)
        ftlog.debug("DizhuQuickStartV4_0.onCmdQuickStart: clientId=", clientId,
                    "userId=", userId, "roomId=", roomId,
                    "tableId=", tableId, "version=", version, "type:",
                    type(version), "playMode=", playMode)

        # 地主会优先去匹配比赛的房间,客户端是3.76及更高版本才支持
        if (playMode == None or playMode == "match" or playMode
                == "straightMatch") and roomId == 0 and gameId == 6 and (
                    version >= 3.76 or
                    (version >= 3.73
                     and not (clientId in _DIZHU_QMATCH_V3_73_IGNORE))):
            chose_roomid, ok = cls._chooseDizhuMatchRoom(
                userId, gameId, playMode)
            ftlog.debug(
                "DizhuQuickStartV4_0._chooseDizhuMatchRoom:chosen|room_id=",
                chose_roomid, "userId=", userId, "ok=", ok)
            if ok:
                bigroomid = gdata.getBigRoomId(chose_roomid)
                ftlog.debug(
                    "DizhuQuickStartV4_0._chooseDizhuMatchRoom: userId=",
                    userId, "roomId=", chose_roomid)
                cls.notifyQuickGotoDizhuMatch(gameId, userId, bigroomid)
                return

        if playMode == "match":
            playMode = dizhuconf.PLAYMODE_123

        super(DizhuQuickStartV4_0,
              cls).onCmdQuickStart(msg, userId, gameId, roomId, tableId,
                                   playMode, clientId)
        return
Esempio n. 20
0
 def isSendModuleTip(self, gameId, userId, clientId):
     if clientId and gameId and userId:
         _, clientVer, _ = strutil.parseClientId(clientId)
         if clientVer >= 3.9:
             listConfig = self._dao.getActivitiesForClient(clientId)
             gId = strutil.getGameIdFromHallClientId(clientId)
             if listConfig:
                 for actName in listConfig:
                     self.getActState(userId, gId, actName)
Esempio n. 21
0
    def sendRewards(self, userId, gameId, clientId):
        bSend = True

        for cond in self.conditions:
            if not cond.check(gameId, userId, clientId,
                              pktimestamp.getCurrentTimestamp()):
                bSend = False

        if bSend:
            from hall.entity import hallitem
            userAssets = hallitem.itemSystem.loadUserAssets(userId)
            assetList = userAssets.sendContent(
                gameId, self.items, 1, True, pktimestamp.getCurrentTimestamp(),
                'LOGIN_REWARD', 0)

            if assetList:
                if ftlog.is_debug():
                    ftlog.debug('hall_login_reward.sendReward gameId=', gameId,
                                'userId=', userId, 'rewards=',
                                [(atup[0].kindId, atup[1])
                                 for atup in assetList])
                # 记录登录奖励获取时间
                gamedata.setGameAttr(userId, HALL_GAMEID, 'login_reward',
                                     pktimestamp.getCurrentTimestamp())
                # 通知更新
                changedDataNames = TYAssetUtils.getChangeDataNames(assetList)
                datachangenotify.sendDataChangeNotify(gameId, userId,
                                                      changedDataNames)
                pkmessage.send(gameId, pkmessage.MESSAGE_TYPE_SYSTEM, userId,
                               self.mail)
                from poker.util import strutil
                _, cVer, _ = strutil.parseClientId(clientId)
                if cVer < 3.90:
                    TodoTaskHelper.sendTodoTask(
                        gameId, userId, TodoTaskShowInfo(self.mail, True))
                else:
                    rewardsList = []
                    for assetItemTuple in assetList:
                        '''
                        0 - assetItem
                        1 - count
                        2 - final
                        '''
                        assetItem = assetItemTuple[0]
                        reward = {}
                        reward['name'] = assetItem.displayName
                        reward['pic'] = assetItem.pic
                        reward['count'] = assetItemTuple[1]
                        rewardsList.append(reward)

                    if ftlog.is_debug():
                        ftlog.debug(
                            'hall_login_reward.TodoTaskShowRewards rewardsList: ',
                            rewardsList)

                    TodoTaskHelper.sendTodoTask(
                        gameId, userId, TodoTaskShowRewards(rewardsList))
Esempio n. 22
0
 def isSendModuleTip(self, gameId, userId, clientId):
     if clientId and gameId and userId:
         _, clientVer, _ = strutil.parseClientId(clientId)
         if clientVer >= 3.9:
             listConfig = self._dao.getActivitiesForClient(clientId)
             gId = strutil.getGameIdFromHallClientId(clientId)
             if listConfig:
                 for actName in listConfig:
                     self.getActState(userId, gId, actName)
Esempio n. 23
0
    def onCmdQuickStart1(cls, msg, userId, gameId, roomId, tableId, playMode,
                         clientId):
        '''
        拦截父类处理的选择房间逻辑,先于父类处理,若选择成功,则不进行父类的选择房间处理逻辑,否则正常走父类的处理逻辑
        '''

        if not pokerconf.isOpenMoreTable(clientId):
            ok, loc = cls.checkUserLoc(userId, gameId, roomId, tableId,
                                       clientId)
            if not ok:
                # 弹框
                tipsPlaying = dizhuconf.getPublicConf('tips.playing',
                                                      '您正在其它房间对局,是否回去?')
                showInfo = TodoTaskShowInfo(tipsPlaying)
                showInfo.setSubCmd(
                    TodoTaskQuickStart(loc[0], loc[1], loc[2], loc[3]))
                TodoTaskHelper.sendTodoTask(gameId, userId, showInfo)
                ftlog.debug('DizhuQuickStartV4_0.onCmdQuickStart Fail userId=',
                            userId, 'roomId=', roomId, 'tableId=', tableId,
                            'clientId=', clientId, 'loc=', loc)
                return
            if loc:
                tableId = loc[2]

        _, version, _ = strutil.parseClientId(clientId)
        ftlog.debug("DizhuQuickStartV4_0.onCmdQuickStart: clientId=", clientId,
                    "userId=", userId, "roomId=", roomId,
                    "tableId=", tableId, "version=", version, "type:",
                    type(version), "playMode=", playMode)

        # 地主会优先去匹配比赛的房间,客户端是3.76及更高版本才支持
        if (playMode == None or playMode == "match" or playMode
                == "straightMatch") and roomId == 0 and gameId == 6 and (
                    version >= 3.76 or
                    (version >= 3.73
                     and not (clientId in _DIZHU_QMATCH_V3_73_IGNORE))):
            chose_roomid, ok = cls._chooseDizhuMatchRoom(
                userId, gameId, playMode)
            ftlog.debug(
                "DizhuQuickStartV4_0._chooseDizhuMatchRoom:chosen|room_id=",
                chose_roomid, "userId=", userId, "ok=", ok)
            if ok:
                bigroomid = gdata.getBigRoomId(chose_roomid)
                ftlog.debug(
                    "DizhuQuickStartV4_0._chooseDizhuMatchRoom: userId=",
                    userId, "roomId=", chose_roomid)
                cls.notifyQuickGotoDizhuMatch(gameId, userId, bigroomid)
                return

        if playMode == "match":
            playMode = dizhuconf.PLAYMODE_123

        super(DizhuQuickStartV4_0,
              cls).onCmdQuickStart(msg, userId, gameId, roomId, tableId,
                                   playMode, clientId)
        return
Esempio n. 24
0
def _isOutOfBeijingIp(userId, clientId):
    conf = configure.getGameJson(HALL_GAMEID, 'gamelistipfilter', {},
                                 configure.DEFAULT_CLIENT_ID)
    if not conf.get('enableIpCheck', 0):
        return 1


#     intClientId = pokerconf.clientIdToNumber(clientId)
#     if intClientId not in conf.get('filterClientIds', []):
#         return 1

    passHall = conf.get('passHall', [])
    if passHall:
        for ph in passHall:
            if clientId.find(ph) > 0:
                if _DEBUG:
                    ftlog.debug('gamelistipfilter', userId, clientId, ph,
                                'passHall !')
                return 1

    passClientVer = conf.get('passClientVer', 0)
    if passClientVer > 0:
        _, cver, _ = strutil.parseClientId(clientId)
        if cver < passClientVer:
            if _DEBUG:
                ftlog.debug('gamelistipfilter', userId, clientId,
                            passClientVer, 'passClientVer !')
            return 1

    ipstr = sessiondata.getClientIp(userId)
    if not iploc.isBeijingIp(ipstr):
        if _DEBUG:
            ftlog.debug('gamelistipfilter', userId, ipstr, 'enableIpCheck !')
        return 1

    passTotalPlayTime = conf.get('passTotalPlayTime', 0)
    if passTotalPlayTime > 0:
        totalTime = gamelistipfilter._getPlayTimes(userId)
        if totalTime >= passTotalPlayTime:
            if _DEBUG:
                ftlog.debug('gamelistipfilter', userId, totalTime,
                            passTotalPlayTime, 'passTotalPlayTime !')
            return 1

    passVipLevel = conf.get('passVipLevel', 0)
    if passVipLevel > 0:
        vipLevel = gamelistipfilter._getVIpLevel(userId)
        if vipLevel >= passVipLevel:
            if _DEBUG:
                ftlog.debug('gamelistipfilter', userId, vipLevel, passVipLevel,
                            'passVipLevel !')
            return 1

    if _DEBUG:
        ftlog.debug('filtergamelist go filter !', userId, ipstr)
    return 0
Esempio n. 25
0
def doSendLedToUser(userId):
    global _ledClosesConf

    gameIdList = onlinedata.getGameEnterIds(userId)
    lastGameId = onlinedata.getLastGameId(userId)
    if not HALL_GAMEID in gameIdList:
        gameIdList.append(HALL_GAMEID)
    if not lastGameId in gameIdList:
        gameIdList.append(lastGameId)

    clientId = sessiondata.getClientId(userId)

    gameIdInClientId = strutil.getGameIdFromHallClientId(clientId)
    if not gameIdInClientId in gameIdList:
        gameIdList.append(gameIdInClientId)

    if ftlog.is_debug():
        ftlog.debug('hallled.doSendLedToUser userId=', userId, 'gameIdList=',
                    gameIdList, 'clientId=', clientId, 'gameIdInClientId=',
                    gameIdInClientId, 'lastGameId=', lastGameId)

    _, clientVer, _ = strutil.parseClientId(clientId)
    for gameId in gameIdList:
        try:
            leds = getLedMsgList(gameId)
            if ftlog.is_debug():
                ftlog.debug('hallled.doSendLedToUser gameId=', gameId,
                            'userId=', userId, 'clientId=', clientId, 'leds=',
                            leds)
            if leds:
                for led in leds:
                    if canSendToUser(userId, clientId, led):
                        msgDict = led[2]
                        if clientVer >= 3.6:
                            mo = MsgPack()
                            mo.setCmd('led')
                            for k, v in msgDict.iteritems():
                                mo.setResult(k, v)
                            mo.setResult('scope', led[3])
                        else:
                            mo = MsgPack()
                            mo.setCmd('led')
                            if gameId in (1, 8):
                                msgDictV2 = translateToMsgDictV2(msgDict)
                                if msgDictV2:
                                    mo.setKey('richText',
                                              msgDictV2.get('richText'))
                            msgV1 = translateToMsgDictV1(msgDict)
                            if msgV1:
                                gameId = msgDict.get('gameId', led[1])
                                mo.setKey('result', [[led[0], gameId, msgV1]])

                        router.sendToUser(mo, userId)
        except:
            ftlog.error("error leds:", leds)
Esempio n. 26
0
 def shelvesToProductIdList(cls, gameId, userId, clientId, shelves):
     productInfos = cls.buildProductInfos(shelves.productList, userId) if shelves else []
     # 拼十老包需要特殊处理一下,price替换为price_diamond
     if gameId == 10:
         _, clientVer, _ = strutil.parseClientId(clientId)
         if clientVer <= 3.31:
             for productInfo in productInfos:
                 if 'price_diamond' in productInfo:
                     productInfo['price'] = productInfo['price_diamond']
                 productInfo['name'] = ''
     return productInfos
Esempio n. 27
0
def doUserStandUp(userId, roomId, tableId, clientId, reason):
    _, clientVer, _ = strutil.parseClientId(clientId)
    ftlog.debug('table_remote.doUserStandUp userId=', userId, 'roomId=',
                roomId, 'tableId=', tableId, 'clientId=', clientId, 'reason=',
                reason, 'clientVer=', clientVer)
    if reason not in (TableStandUpEvent.REASON_GAME_OVER, ):
        return 0

    chipCount = userchip.getChip(userId)
    roomConf = gdata.getRoomConfigure(roomId) or {'minCoin': 0, 'maxCoin': -1}
    if chipCount < roomConf['minCoin']:
        reason = TableStandUpEvent.REASON_CHIP_NOT_ENOUGHT
        if clientVer >= 3.77:  # 新版救济金弹气泡支持
            processLoseOutRoomV3_77(DIZHU_GAMEID,
                                    userId,
                                    clientId,
                                    roomId,
                                    showMemberTry=False)
        elif clientVer >= 3.7:
            hallpopwnd.processLoseOutRoomV3_7(DIZHU_GAMEID,
                                              userId,
                                              clientId,
                                              roomId,
                                              showMemberTry=False)
        elif clientVer == 3.502:
            processLoseOutRoom(DIZHU_GAMEID, userId, clientId, roomId)
        elif clientVer >= 3.0:
            timestamp = pktimestamp.getCurrentTimestamp()
            benefitsSend, userBenefits = hallbenefits.benefitsSystem.sendBenefits(
                DIZHU_GAMEID, userId, timestamp)
            ftlog.debug('benefitsSend, userBenefits =', benefitsSend,
                        userBenefits)
            zhuanyun = hallpopwnd.makeTodoTaskZhuanyun(DIZHU_GAMEID, userId,
                                                       clientId, benefitsSend,
                                                       userBenefits, roomId)
            if zhuanyun:
                TodoTaskHelper.sendTodoTask(DIZHU_GAMEID, userId, zhuanyun)
            else:
                ttask = TodoTaskHelper.makeBenefitsTodoTask(
                    DIZHU_GAMEID, userId, clientId, benefitsSend, userBenefits)
                if ttask:
                    TodoTaskHelper.sendTodoTask(DIZHU_GAMEID, userId, ttask)
            datachangenotify.sendDataChangeNotify(DIZHU_GAMEID, userId, 'chip')
        else:
            benefitsSend, userBenefits = hallbenefits.benefitsSystem.sendBenefits(
                DIZHU_GAMEID, userId, pktimestamp.getCurrentTimestamp())
            ftlog.debug('benefitsSend, userBenefits =', benefitsSend,
                        userBenefits)
    elif (roomConf['maxCoin'] != -1 and chipCount > roomConf['maxCoin']):
        pass
        # reason = TableStandUpEvent.REASON_CHIP_TOO_MUCH
        # from dizhu.gametable.quick_start import DizhuQuickStartV4_0
        # DizhuQuickStartV4_0._sendTodoTaskJumpHighRoom(userId, roomConf['playMode'], clientId)
    return 1
Esempio n. 28
0
    def doUserHeartBeat(self, userId, gameId, clientId, isMust):
        hallled.doSendLedToUser(userId)
        clientIdVer = strutil.parseClientId(clientId)[1]
        if clientIdVer < 3.0:  # c++老版本斗地主才需要在heart_beat时下发m_signs 
            self._sendMatchSignsToUser(userId, gameId, clientId)
        self._sendOnLineInfoToUser(userId, gameId, clientId)

        if ftlog.is_debug():
            ftlog.debug("user|heart_beat", userId, gameId, clientId)
        from hall.entity import hallnewnotify
        hallnewnotify.pushNotify(userId, gameId, clientId)
Esempio n. 29
0
    def parseClientId(cls, clientId):
        #os_version_login.pay.special.main.sub
        cid = configure.clientIdToNumber(clientId)
        if cid == 0:
            return False, 0, '', ''

        _, _, info = strutil.parseClientId(clientId)
        parts = info.split('.')
        if len(parts) < 5:
            return False, 0, '', ''

        return True, cid, parts[3], parts[4]
Esempio n. 30
0
 def parseClientId(cls, clientId):
     cid = configure.clientIdToNumber(clientId)
     if cid == 0:
         return None
 
     clientOS, clientVer, info = strutil.parseClientId(clientId)
     parts = info.split('.')
     if len(parts) < 5:
         return None
     
     return ParsedClientId(clientId, cid, clientOS.lower(), clientVer,
                           parts[0], parts[1], parts[2], parts[3], parts[4])
Esempio n. 31
0
def getNeiTuiGuangConf(clientId):
    templates = configure.getGameJson(HALL_GAMEID, 'neituiguang', {}, configure.DEFAULT_CLIENT_ID).get('templates', {})
    intClientId = pokerconf.clientIdToNumber(clientId)
    templateName = configure.getGameJson(HALL_GAMEID, 'neituiguang', {}, intClientId).get('template', '')
    if templateName:
        return templates.get(templateName, {})
    else:
        _, clientVer, _ = strutil.parseClientId(clientId)
        if clientVer >= 3.372:
            return templates.get('default_neituiguang_new', {})
        else:
            return templates.get('default_neituiguang_3_37', {})
Esempio n. 32
0
    def _doChangeNameTry(self, userId, clientId, newName):
#         renameConf = hallconf.getClientRenameConf(clientId)
#         if (renameConf
#             and not renameConf.get('containsSensitive', 1)
#             and keywords.isContains(newName)):
#             info = TodoTaskShowInfo(hallrename.stringRenameContainsSensitive)
#             return TodoTaskHelper.sendTodoTask(HALL_GAMEID, userId, info)
        code, info = hallrename.tryRename(HALL_GAMEID, userId, newName)
        if ftlog.is_debug():
            ftlog.debug('hallrename._doChangeNameTry->', code, info)

        CLIENT_VER = 4.57
        _, clientVer, _ = strutil.parseClientId(clientId)

        if ftlog.is_debug():
            ftlog.debug("_doChangeNameTry clientVer", userId, clientId, newName, code, info, clientVer)

        reInfo = ""
        if code == -3 :
            reInfo = "昵称没有变化"
        elif code == -2 :
            # 没有改名卡
            info = TodoTaskShowInfo(hallrename.stringRenameCardRequired, True)
            if hallrename.payOrder:
                product, _ = hallstore.findProductByPayOrder(HALL_GAMEID, userId, clientId, hallrename.payOrder)
                if product:
                    info.setSubCmd(TodoTaskPayOrder(product))
            return TodoTaskHelper.sendTodoTask(HALL_GAMEID, userId, info)
        elif code == 0 :
            reInfo = "昵称修改成功"
            # 改名成功
            if clientVer < CLIENT_VER:
                if ftlog.is_debug():
                    ftlog.debug("_doChangeNameTry ok", userId, clientId, newName, code, info, clientVer)
                return TodoTaskHelper.sendTodoTask(HALL_GAMEID, userId, TodoTaskPopTip(hallrename.stringRenameSuccessed))
        else:
            #reInfo = "修改昵称失败,请重试"
            reInfo = info
            # SDK改名失败
            if clientVer < CLIENT_VER:
                if ftlog.is_debug():
                    ftlog.debug("_doChangeNameTry fail", userId, clientId, newName, code, info, clientVer)
                return TodoTaskHelper.sendTodoTask(HALL_GAMEID, userId, TodoTaskPopTip(info))
                    
        mo = MsgPack()
        mo.setCmd('change_name')
        mo.setResult('action', 'try')
        mo.setResult('userId', userId)
        mo.setResult('code', code)
        mo.setResult('reInfo', reInfo)
        router.sendToUser(mo, userId)
        if ftlog.is_debug():
            ftlog.debug("_doChangeNameTry result",userId, clientId, newName, code, reInfo)
Esempio n. 33
0
def isSupportBuyin(clientId):
    buyinconf = getBuyInConf()
    _, ver, _ = strutil.parseClientId(clientId)
    start_version = buyinconf.get('start_version', 3.502)
    closed = buyinconf.get('closed', [])
    if ver in closed:
        return False
    else:
        if ver >= start_version:
            return True
        else:
            return False
Esempio n. 34
0
 def shelvesToProductIdList(cls, gameId, userId, clientId, shelves):
     productInfos = cls.buildProductInfos(shelves.productList,
                                          userId) if shelves else []
     # 拼十老包需要特殊处理一下,price替换为price_diamond
     if gameId == 10:
         _, clientVer, _ = strutil.parseClientId(clientId)
         if clientVer <= 3.31:
             for productInfo in productInfos:
                 if 'price_diamond' in productInfo:
                     productInfo['price'] = productInfo['price_diamond']
                 productInfo['name'] = ''
     return productInfos
    def _getAnimationDelay(self, animationType, isStartStep, clientId):
        _, clientVer, _ = strutil.parseClientId(clientId)
        if str(clientVer) < 3.77:
            return self.MSTART_SLEEP

        delayConf = dizhuconf.getPublic().get('matchAnimationDelay')
        if not delayConf:
            return 3
        valKey = 'startStep'
        if not isStartStep:
            valKey = 'type' + str(animationType)
        return delayConf.get(valKey, 3)
Esempio n. 36
0
    def buildTableBasicConfig(self, player, zeroSumFlag=0):
        '''
        原table.buildBasicInfo中的config数据
        '''
        if not player.mixId:
            raise Exception('')

        tableConf = player.mixConf.get('tableConf', {})

        # 宝箱信息
        tbbox, couponrule = treasurebox.getTreasureTableTip(
            self.gameId, player.mixConf.get('roomId'))

        # 配置信息
        config = {}
        config['tbbox'] = tbbox
        config['couponrule'] = couponrule

        config['maxseat'] = tableConf.get('maxSeatN')
        config['rangpaiMultiType'] = tableConf.get('rangpaiMultiType')
        config['autoChange'] = tableConf.get('autochange')
        config['base'] = tableConf.get('basebet')
        config['basemulti'] = tableConf.get('basemulti')
        config['gslam'] = tableConf.get('gslam')
        config['grab'] = tableConf.get('grab')
        config['chat'] = tableConf.get('canchat')
        config['cardNote'] = self.table.runConf.cardNote
        config['optime'] = tableConf.get('optimeOutCard')
        config['coin2chip'] = tableConf.get('coin2chip')
        config['lucky'] = tableConf.get('lucky')
        config['untiCheat'] = tableConf.get('unticheat')
        config['passtime'] = tableConf.get('passtime')
        config['mixShowChip'] = tableConf.get('mixShowChip')

        config['isMingPai'] = self.table.runConf.showCard
        config['roommulti'] = player.mixConf.get('roomMutil')
        config['maxcoin'] = player.mixConf.get('maxCoin')
        config['mincoin'] = player.mixConf.get('minCoin')
        config['sfee'] = player.mixConf.get('roomFee')
        config['optime'] = tableConf.get('optime')
        config['matchInfo'] = ''  # 老版本数据结构兼容
        config['autoPlay'] = self.table.runConf.autoPlay
        config['canQuit'] = self.table.runConf.canQuit
        config['winCoinLimit'] = tableConf.get('winCoinLimit', 0)

        # 小于3.7版本是否能够聊天、防作弊统一使用的是untiCheat字段
        # 对于小于3.7版本的在不防作弊但是不能聊天时处理为防作弊
        _, clientVer, _ = strutil.parseClientId(player.clientId)
        if clientVer and clientVer < 3.7:
            if not config['chat'] and not config['untiCheat']:
                config['untiCheat'] = 1
        return config
Esempio n. 37
0
def _bugFixFilterChatMsgForPNG(clientId, chatMsg):
    # 新老版本使用的图片格式不一致
    try:
        _, clientVer, _ = strutil.parseClientId(clientId)
        if clientVer >= 2.6 and chatMsg.endswith('.gif'):
            chatMsg = chatMsg[0:-4] + '.png'
        elif clientVer < 2.6 and chatMsg.endswith('.png'):
            chatMsg = chatMsg[0:-4] + '.gif'
            if chatMsg not in OLD_FACES:
                chatMsg = ''
    except:
        ftlog.error()
    return chatMsg
Esempio n. 38
0
 def onUserLogin(self, event):
     if not self._mailWhenCanExchange:
         return
     _, clientVer, _ = strutil.parseClientId(event.clientId)
     if clientVer < 3.0:
         return
     if not event.dayFirst or event.gameId != HALL_GAMEID:
         return
     couponItem = self.findMinCouponItem([CouponItem.TYPE_PHONE_CARD])
     if not couponItem:
         return
     userCouponCount = pkuserchip.getCoupon(event.userId)
     if userCouponCount >= couponItem.couponCount:
         pkmessage.send(HALL_GAMEID, pkmessage.MESSAGE_TYPE_SYSTEM, event.userId, self._mailWhenCanExchange)
         datachangenotify.sendDataChangeNotify(self.gameId, event.userId, 'message')
Esempio n. 39
0
    def getTodoTasksAfterLogin(self, userId, gameId, clientId, isdayfirst):
        '''
        获取登录后的todotasks列表
        '''
        from hall.entity import hallitem, hallstartchip, hallpopwnd
        # 每日登录奖励,以前在各个游戏,现在移到大厅
        ret = []
        # 3.7以前9999没有todotask
        _, clientVer, _ = strutil.parseClientId(clientId)
        if clientVer < 3.7:
            return ret

        if hallstartchip.needSendStartChip(userId, gameId):
            # 需要弹启动资金领取弹框
            assetKind = hallitem.itemSystem.findAssetKind(hallitem.ASSET_ITEM_NEWER_GIFT_KIND_ID)
            pic = assetKind.pic if assetKind else ''
            if ftlog.is_debug():
                ftlog.debug('TGHall.getTodoTasksAfterLogin userId=', userId,
                            'gameId=', gameId,
                            'clientId=', clientId,
                            'isDayFirst=', isdayfirst,
                            'assetKind=', assetKind)
            ret.append(TodoTaskIssueStartChip(hallstartchip.newuser_startchip, 0, pic, ''))

        timestamp = pktimestamp.getCurrentTimestamp()
        remainDays, memberBonus = hallitem.getMemberInfo(userId, timestamp)

        nsloginTodotaskList = hallpopwnd.makeTodoTaskNsloginReward(gameId, userId, clientId, remainDays, memberBonus,
                                                                   isdayfirst)

        if ftlog.is_debug():
            ftlog.debug('TGHall.getTodoTasksAfterLogin gameId=', gameId,
                        'userId=', userId,
                        'clientId=', clientId,
                        'nsloginTodotaskList=', nsloginTodotaskList)

        if nsloginTodotaskList:
            ret.extend(nsloginTodotaskList)

        # ios 提示更新
        iosUpgrade = hallpopwnd.makeTodoTaskByTemplate(gameId, userId, clientId, 'iosUpgrade')
        if iosUpgrade:
            ret.append(iosUpgrade)

        return ret
Esempio n. 40
0
def getClientIdVer(msg):
    '''
    获取当前命令的clientId的大版本号,
    如果消息中没有clientId,那么取用户的登录时的clientId
    '''
    client_ver = 0
    clientId = getClientId(msg)
    if clientId:
        try:
            clientId = float(clientId)  # BUGFIX 老版本的传递有时候是个数字
            return clientId
        except:
            pass
        _, client_ver, _ = strutil.parseClientId(clientId)
        if client_ver > 0:
            return client_ver
    ftlog.warn('WARRING !! the tcp msg clientId is error !!', msg)
    return 0
Esempio n. 41
0
def getGaoFangIp(clientId, ip, port):
    try:
        _, cver, _ = strutil.parseClientId(clientId)
        gaofangConfs = configure.getJson('poker:map.gaofangip', None)
        if gaofangConfs:
            policy = gaofangConfs['policy']
            if policy == 'tuyou':
                ip = gaofangConfs[policy].get(ip, ip)

            elif policy == 'aligaofang':
                original = gaofangConfs['original']
                group = original[ip + ':' + str(port)]
                groupIps = gaofangConfs[policy][group]
                if groupIps:
                    ip = random.choice(groupIps)
            if cver >= 3.78:
                ip = gaofangConfs['namespace'][ip]
    except:
        ftlog.error()
    ftlog.info('getGaoFangIp->', ip, port, clientId)
    return ip, port
Esempio n. 42
0
    def doItemAction(self, gameId, userId, clientId, itemId, params):
        try:
            timestamp = pktimestamp.getCurrentTimestamp()
            userBag = hallitem.itemSystem.loadUserAssets(userId).getUserBag()
            item = userBag.findItem(itemId)
            if not item:
                raise TYItemNotFoundException(itemId)
            actionName = runcmd.getMsgPack().getParam('action')
            actionResult = userBag.doAction(gameId, item, actionName, timestamp, params)

            mo = ItemHelper.makeItemListResponseV3_7(gameId, userId)
            router.sendToUser(mo, userId)

            from poker.util import strutil
            _, cVer, _ = strutil.parseClientId(clientId)
            if actionResult:
                if actionResult.todotask and cVer >= 3.90:
                    TodoTaskHelper.sendTodoTask(gameId, userId, actionResult.todotask)
                elif actionResult.message:
                    TodoTaskHelper.sendTodoTask(gameId, userId, TodoTaskPopTip(actionResult.message))

        except TYBizException, e:
            self.handleException(itemId, gameId, userId, clientId, e)
Esempio n. 43
0
def getClientModuleDefaultConf(clientId, moduleName):
    '''
    @return: 默认配置 如果没有 返回None
    '''

    # 提取版本号 提取游戏ID
    clientOS, ver, info = strutil.parseClientId(clientId)
    ftlog.debug('getClientModuleDefaultConf clientOS:', clientOS, ' ver:', ver, ' info:', info)
    gameId = strutil.getGameIdFromHallClientId(clientId)
    tName = 'hall' + str(gameId) + '_' + str("%.2f" % ver)
    ftlog.debug('getClientModuleDefaultConf tName:', tName)

    if tName in _defaultTemplateMap:
        tConf = _defaultTemplateMap[tName]
        if moduleName in tConf:
            # 格式化返回数据
            conf = {}
            conf['template'] = tConf[moduleName]
            return conf
        else:
            ftlog.debug('No default module, module:', moduleName)
    else:
        ftlog.debug('No default module config, clientId:', clientId)
    return None
Esempio n. 44
0
def _parseClientId(clientId):
    clientOS, ver, info = strutil.parseClientId(clientId)
    channelName = info.split('.', 2)[-1]
    return ver, clientOS.lower() + '.' + channelName
Esempio n. 45
0
def doSendLedToUser(userId):
    global _ledClosesConf

    gameIdList = onlinedata.getGameEnterIds(userId)
    lastGameId = onlinedata.getLastGameId(userId)
    if not HALL_GAMEID in gameIdList:
        gameIdList.append(HALL_GAMEID)
    if not lastGameId in gameIdList:
        gameIdList.append(lastGameId)

    clientId = sessiondata.getClientId(userId)
    if clientId in _ledClosesConf:
        if ftlog.is_debug():
            ftlog.debug('hallled.doSendLedToUser clientId:', clientId, ' is in closes list:', _ledClosesConf, ' return')
        return

    gameIdInClientId = strutil.getGameIdFromHallClientId(clientId)
    if not gameIdInClientId in gameIdList:
        gameIdList.append(gameIdInClientId)

    if ftlog.is_debug():
        ftlog.debug('hallled.doSendLedToUser userId=', userId,
                    'gameIdList=', gameIdList,
                    'clientId=', clientId,
                    'gameIdInClientId=', gameIdInClientId,
                    'lastGameId=', lastGameId)

    _, clientVer, _ = strutil.parseClientId(clientId)
    for gameId in gameIdList:
        try:
            leds = getLedMsgList(gameId)
            if ftlog.is_debug():
                ftlog.debug('hallled.doSendLedToUser gameId=', gameId,
                            'userId=', userId,
                            'clientId=', clientId,
                            'leds=', leds)
            if leds:
                for led in leds:
                    msgDict = led[2]
                    if clientVer >= 3.6:
                        mo = MsgPack()
                        mo.setCmd('led')
                        for k, v in msgDict.iteritems():
                            mo.setResult(k, v)
                        mo.setResult('scope', led[3])
                    else:
                        mo = MsgPack()
                        mo.setCmd('led')
                        if gameId in (1, 8):
                            msgDictV2 = translateToMsgDictV2(msgDict)
                            if msgDictV2:
                                mo.setKey('richText', msgDictV2.get('richText'))
                        msgV1 = translateToMsgDictV1(msgDict)
                        if msgV1:
                            gameId = msgDict.get('gameId', led[1])
                            mo.setKey('result', [[led[0], gameId, msgV1]])

                    # 过滤LED
                    clientIdFilter = led[4]
                    if len(clientIdFilter) == 0 or clientId in clientIdFilter:
                        if ftlog.is_debug():
                            ftlog.debug('sendLed to user='******'msg=', mo)
                        router.sendToUser(mo, userId)
        except:
            ftlog.error("error leds:", leds)
Esempio n. 46
0
 def doUserHeartBeat(self, userId, gameId, clientId, isMust):
     hallled.doSendLedToUser(userId)
     clientIdVer = strutil.parseClientId(clientId)[1]
     if clientIdVer < 3.0:  # c++老版本斗地主才需要在heart_beat时下发m_signs 
         self._sendMatchSignsToUser(userId, gameId, clientId)
     self._sendOnLineInfoToUser(userId, gameId, clientId)