Esempio n. 1
0
def itemUpdate(gameId, userId, kindId, detalCount, finalCount, eventId, intEventParam, *arglist, **argdict):
    '''
    道具变化的标准本地日志文件汇报
    '''
    _, clientIdInt = sessiondata.getClientIdNum(userId)
    reportBiChip(userId, detalCount, detalCount, finalCount, eventId, clientIdInt, gameId, gameId, intEventParam,
                 CHIP_TYPE_ITEM, kindId, arglist=arglist, argdict=argdict, logtag='item_update')
Esempio n. 2
0
def getGaoFangIp2(userId, clientId):
    ip, port, wsport = '', 0, 0
    try:
        gaofangConfs = configure.getJson('poker:map.gaofangip.2', {})
        policy = gaofangConfs.get('policy')
        if policy == 'defence2':
            intClientId = sessiondata.getClientIdNum(userId, clientId)
            clientIds = gaofangConfs['clientIds']
            areaId = clientIds.get(intClientId)
            if not areaId:
                areaId = clientIds.get(str(intClientId))
                if not areaId:
                    areaId = clientIds.get('default')
                    if not areaId:
                        areaId = gaofangConfs['areas'].keys()[0]
                    ftlog.warn('ERROR, getGaoFangIp2 not found area id of ',
                               intClientId, clientId, 'use default !')
                clientIds[intClientId] = areaId
            entrys = gaofangConfs['areas'][areaId]
            ipPorts = entrys[userId % len(entrys)] # 切换不同的端口接入
            ipPort = ipPorts[userId % len(ipPorts)] # 使用相对固定的IP地址接入
            ip, port = ipPort[0], ipPort[1]
            if len(ipPort) > 2 :
                wsport = ipPort[2]
    except:
        ftlog.error()
    ftlog.info('getGaoFangIp2->', ip, port, wsport, userId, clientId)
    return ip, port, wsport
Esempio n. 3
0
def getGaoFangIp2(userId, clientId):
    ip, port = '', 0
    try:
        gaofangConfs = configure.getJson('poker:map.gaofangip.2', {})
        policy = gaofangConfs.get('policy')
        if policy == 'defence2':
            intClientId = sessiondata.getClientIdNum(userId, clientId)
            clientIds = gaofangConfs['clientIds']
            areaId = clientIds.get(intClientId)
            if not areaId:
                areaId = clientIds.get(str(intClientId))
                if not areaId:
                    areaId = clientIds.get('default')
                    if not areaId:
                        areaId = gaofangConfs['areas'].keys()[0]
                    ftlog.warn('ERROR, getGaoFangIp2 not found area id of ',
                               intClientId, clientId, 'use default !')
                clientIds[intClientId] = areaId
            entrys = gaofangConfs['areas'][areaId]
            ipPorts = random.choice(entrys)  # 切换不同的端口接入
            ipPort = ipPorts[userId % len(ipPorts)]  # 使用相对固定的IP地址接入
            ip, port = ipPort[0], ipPort[1]
    except:
        ftlog.error()
    ftlog.info('getGaoFangIp2->', ip, port, userId, clientId)
    return ip, port
Esempio n. 4
0
 def isValidUser(cls, userId):
     ''' 对外接口是不是执行宝箱逻辑的用户 '''
     if _treasureChestTotalConf.switch == 0:
         return False
     _, intClientId = sessiondata.getClientIdNum(userId)
     if intClientId in _treasureChestTotalConf.clientIds:
         return True
     return False
    def processEnterGame(cls, evt):
        # # 检查当前已结束赛季并发放赛季奖励, 只发放上一期的
        if ftlog.is_debug():
            ftlog.debug('============= processEnterGame userId=', evt.userId)
        _, intClientId = sessiondata.getClientIdNum(evt.userId)
        if intClientId == 24105:
            latestTwoIssues = SegmentMatchHelper.getIssueStateList()[-2:]
            for issuestate in reversed(latestTwoIssues):
                if issuestate['state'] == 0:
                    continue

                # 判断用户有没有结算此赛季
                userData = SegmentMatchHelper.getUserSegmentDataIssue(
                    evt.userId, issuestate['issue']) or UserSegmentDataIssue()
                if userData and userData.segmentRewardsState == UserSegmentDataIssue.IDEAL:
                    # 结算 发奖
                    settlementRanking(evt.userId, issuestate['issue'])

        segmentConf = getSegmentConf()
        if segmentConf.closed:
            return

        if evt.dayFirst:
            # 检查用户是否已经发送
            if not gamedata.getGameAttrInt(evt.userId, DIZHU_GAMEID,
                                           'wxNotice'):
                # 保存消息记录
                gamedata.setGameAttr(evt.userId, DIZHU_GAMEID, 'wxNotice', 1)

                # 新用户发送一条额外消息
                mailstr = '游戏公告#如有任何意见建议,欢迎加客服微信:Tuyoo_taozi,进入官方群反馈'
                message.send(DIZHU_GAMEID, message.MESSAGE_TYPE_SYSTEM,
                             evt.userId, mailstr)

        # 同步钻石为用户道具
        if not segmentdata.getSegmentAttr(evt.userId, DIZHU_GAMEID,
                                          'diamondConvert'):
            segmentdata.setSegmentAttr(evt.userId, DIZHU_GAMEID,
                                       'diamondConvert', 1)
            userDiamond = userdata.getAttr(evt.userId, 'diamond')
            if userDiamond:
                # count
                user_remote.consumeAssets(DIZHU_GAMEID, evt.userId,
                                          [{
                                              'itemId': 'user:diamond',
                                              'count': userDiamond
                                          }], 'DIZHU_SEGMENT_DIAMOND_CONVERT',
                                          0)
                contentItems = TYContentItem.decodeList([{
                    'itemId': 'item:1311',
                    'count': userDiamond
                }])
                from dizhu.entity import dizhu_util
                dizhu_util.sendRewardItems(evt.userId, contentItems, None,
                                           'DIZHU_SEGMENT_DIAMOND_CONVERT', 0)
                ftlog.info('DizhuSegmentRewardsHelper diamondConvert userId=',
                           evt.userId, 'userDiamond=', userDiamond)
Esempio n. 6
0
def reportCardEvent(eventId, user_id, gameId, roomId, tableId, roundId, detalChip, state1, state2, cardlist, clientId,
                    finalTableChip=0, finalUserChip=0,
                    arglist=[], argdict={}, logtag='card_event'):
    '''
    游戏出牌事件的HTTP远程BI汇报
    '''
    # fmt = "I I H I Q Q I q q q B B 20B"
    #        | | | | | | | | | | | | |
    #        | | | | | | | | | | | | └- cardlist 当前事件操作的牌, 数字(0~54), 0xFF为无效
    #        | | | | | | | | | | | └- state2 当前事件操作的状态2(例如:托管,超时)
    #        | | | | | | | | | | └- state1 当前事件操作的状态1(例如:托管,超时)
    #        | | | | | | | | | └- finalUserChip 当前事件用户的最终所有金币数量
    #        | | | | | | | | └- finalTableChip 当前事件用户的最终桌子金币数量
    #        | | | | | | | └- detalChip 当前事件操作涉及的金币数量
    #        | | | | | | └- roundId 当前事件的游戏局ID(如果为比赛事件,即为比赛的ID, 如果为普通牌桌,即为牌局ID或时间戳)
    #        | | | | | └- tableId 游戏事件发生的房间桌子ID
    #        | | | | └- roomId 游戏事件发生的房间
    #        | | | └- clientId 客户端的clientId
    #        | | └- gameId 后端服务操作时使用的gameId
    #        | └- userId 事件产生的用户
    #        └- eventId 事件ID
    eventId = pokerconf.biEventIdToNumber(eventId)
    user_id = int(user_id)
    gameId = int(gameId)
    _, clientId = sessiondata.getClientIdNum(user_id, clientId)
    assert (isinstance(eventId, (int, long)))
    assert (isinstance(user_id, (int, long)))
    assert (isinstance(gameId, (int, long)))
    assert (isinstance(roomId, (int, long)))
    assert (isinstance(tableId, (int, long)))
    assert (isinstance(roundId, (int, long)))
    assert (isinstance(detalChip, (int, long)))
    assert (isinstance(state1, (int, long)))
    assert (isinstance(state2, (int, long)))
    assert (isinstance(clientId, (int, long)))
    assert (isinstance(finalUserChip, (int, long)))
    assert (isinstance(finalTableChip, (int, long)))
    cards = [0xFF, 0xFF, 0xFF, 0xFF, 0xFF,
             0xFF, 0xFF, 0xFF, 0xFF, 0xFF,
             0xFF, 0xFF, 0xFF, 0xFF, 0xFF,
             0xFF, 0xFF, 0xFF, 0xFF, 0xFF]
    if cardlist:
        for x in xrange(min(20, len(cardlist))):
            cards[x] = int(cardlist[x])
    # 本地日志
    alist = [logtag, eventId, user_id, gameId, roomId, tableId, roundId, detalChip, state1, state2, cardlist, clientId,
             finalTableChip, finalUserChip]
    alist.extend(arglist)
    _report(alist, argdict)
    if _ENABLE_BIFILE:
        return 1
Esempio n. 7
0
def _onUnExpectedUserLogin(event):
    userId = event.userId
    behaviourConf = dizhuconf.getUserBehaviourReward()
    if not _checkExpectedUser(userId, behaviourConf):
        if ftlog.is_debug():
            ftlog.debug('_onUnExpectedUserLogin check failed userId=', userId)
        return

    _, intClientId = sessiondata.getClientIdNum(userId)
    expectedClientIds = behaviourConf.get('expectedClientIds', [])

    try:
        # 只处理配置中的clientId包的表外用户
        if expectedClientIds and intClientId in expectedClientIds:
            todayDate = int(dizhu_util.calcTodayIssueNum())
            olderInfo = daobase.executeUserCmd(
                event.userId, 'HGET', 'userBehaviour:6:' + str(userId), 'info')
            if olderInfo:
                olderInfo = strutil.loads(olderInfo)
                olderType = olderInfo.get('type', 0)
                olderDate = olderInfo.get('date', 0)
                if olderType in [
                        BEHAVIOUR_TYPE_REWARDED, BEHAVIOUR_TYPE_NOUSEED
                ]:
                    # 已处理过的不再处理
                    return
                if olderDate - todayDate > 1:
                    # 过期记录重新分组
                    behaviourInfo = {
                        'type': random.randrange(1, 4, 2),
                        'date': todayDate
                    }
                    daobase.executeUserCmd(userId, 'HSET',
                                           'userBehaviour:6:' + str(userId),
                                           'info',
                                           strutil.dumps(behaviourInfo))
                    ftlog.info('_onUnExpectedUserLogin userId=', userId,
                               'info=', behaviourInfo, 'olderInfo=', olderInfo)
            else:
                # 未记录过的表外用户平均分到1、3组
                behaviourInfo = {
                    'type': random.randrange(1, 4, 2),
                    'date': todayDate
                }
                daobase.executeUserCmd(userId, 'HSET',
                                       'userBehaviour:6:' + str(userId),
                                       'info', strutil.dumps(behaviourInfo))
    except Exception, e:
        ftlog.warn('_onUnExpectedUserLogin userId=', userId, 'error=', e)
Esempio n. 8
0
def _incrUserDatasLimit(userId, field, value, lowLimit, highLimit, chipNotEnoughOpMode, dataKey=None):
    from poker.entity.dao import sessiondata
    _, numberClientId = sessiondata.getClientIdNum(userId, None)
    appId = sessiondata.getGameId(userId)

    if dataKey == None:
        dataKey = UserDataSchema.mkey(userId)
    trueDetal, finalCount, fixCount = daobase.executeUserLua(userId, user_scripts.MAIN_INCR_CHIP_LUA_SCRIPT,
                                                             6, value, lowLimit, highLimit, chipNotEnoughOpMode,
                                                             dataKey, field)

    if dataKey == UserDataSchema.mkey(userId):
        if _CACHE_USER_ENABLE:
            _cacheUser.replace_group_dict_data(userId, dataKey, field, finalCount)
    return trueDetal, finalCount, fixCount, appId, numberClientId
Esempio n. 9
0
def _setTableChipToRange(userId, gameid, _min, _max, eventId, intEventParam,
                         clientId, tableId, rhashkey, rfield):
    from poker.entity.dao import sessiondata
    _, numberClientId = sessiondata.getClientIdNum(userId, None)
    appId = sessiondata.getGameId(userId)

    tdelta, tfinal, tfixed, delta, final, fixed = daobase.executeUserLua(
        userId, user_scripts.MAIN_MOVE_CHIP_TO_TABLE_LUA_SCRIPT, 6, userId,
        gameid, _min, _max, rhashkey, rfield)
    # TODO 替换GAME DATA中的金币数据值

    ftlog.debug('dbuser->_setTableChipToRange', userId, gameid, _min, _max,
                eventId, intEventParam, clientId, tableId, rhashkey,
                'result->', tdelta, tfinal, tfixed, delta, final, fixed)
    return tdelta, tfinal, tfixed, delta, final, fixed, appId, numberClientId
Esempio n. 10
0
def _checkExpectedUser(userId, behaviourConf):
    if not behaviourConf or behaviourConf.get('open', 0) != 1:
        return False

    # 过滤clientId
    _, intClientId = sessiondata.getClientIdNum(userId)
    intClientIds = behaviourConf.get('intClientIds', [])
    if intClientId in intClientIds:
        return False

    # 过滤注册时间在7天以内的用户
    timestamp = pktimestamp.getCurrentTimestamp()
    if UserInfo.getRegisterDays(userId, timestamp) <= 7:
        return False
    return True
Esempio n. 11
0
def _setTableChipToRange(userId, gameid, _min, _max, eventId, intEventParam, clientId, tableId, rhashkey, rfield):
    from poker.entity.dao import sessiondata
    _, numberClientId = sessiondata.getClientIdNum(userId, None)
    appId = sessiondata.getGameId(userId)

    tdelta, tfinal, tfixed, delta, final, fixed = daobase.executeUserLua(userId,
                                                                         user_scripts.MAIN_MOVE_CHIP_TO_TABLE_LUA_SCRIPT,
                                                                         6, userId, gameid, _min, _max, rhashkey,
                                                                         rfield)
    if _CACHE_USER_ENABLE:
        _cacheUser.replace_group_dict_data(userId, UserDataSchema.mkey(userId), UserDataSchema.CHIP, final)
    # TODO 替换GAME DATA中的金币数据值

    ftlog.debug('dbuser->_setTableChipToRange', userId, gameid, _min, _max,
                eventId, intEventParam, clientId, tableId, rhashkey,
                'result->', tdelta, tfinal, tfixed, delta, final, fixed)
    return tdelta, tfinal, tfixed, delta, final, fixed, appId, numberClientId
Esempio n. 12
0
    def getUserCollectList(self, userId):
        userAssets = hallitem.itemSystem.loadUserAssets(userId)
        ret = []
        for socks in self._collectItemList:
            itemConf = self._collectItemList[socks]
            itemId = itemConf.get('itemId')
            itemCount = itemConf.get('count')
            balance = userAssets.balance(HALL_GAMEID, itemId, pktimestamp.getCurrentTimestamp())
            todotask = itemConf.get('todotask')
            todotaskDict = None
            if todotask.get('shareId'):
                # 分享的todotask
                clientIdList = [20232, 20293, 20329, 20338, 20340, 20354, 20689, 20729, 21306, 21317, 21360, 21368,
                    21377, 21736, 20195, 20259, 20294, 20331, 20685, 20698, 21330, 21355, 21361, 21419, 20264, 20265,
                    20267, 20268, 20272, 20287, 20288, 20289, 20348, 20349, 20350, 20351, 20488, 20489, 20490, 20699,
                    20701, 20702, 20788, 20790, 20791, 21040, 21328, 21331, 21333, 21334, 21350, 21352, 21353, 21791,
                    21792, 21793, 21794, 22043]
                from poker.entity.dao import sessiondata
                _, intClientId = sessiondata.getClientIdNum(userId)
                if intClientId in clientIdList:
                    # 无法分享的包,弹出提示todotask
                    msg = u"今日登录已获得友谊之袜×1 明天再来吧~"
                    dialog_task = TodoTaskShowInfo(msg, True)
                    # TodoTaskHelper.sendTodoTask(DIZHU_GAMEID, userId, [dialog_task])
                    todotaskDict = dialog_task.toDict() if dialog_task else None
                else:
                    shareId = todotask.get('shareId')
                    share = hallshare.findShare(shareId)
                    todotask = share.buildTodotask(DIZHU_GAMEID, userId, 'diploma_share')
                    todotaskDict = todotask.toDict() if todotask else None
                if not todotaskDict:
                    ftlog.warn('christmas sharePointId not Found. userId=', userId)
                if ftlog.is_debug():
                    ftlog.debug('christmas.shareTodotask. userId=', userId, 'todotaskDict=', todotaskDict)

            elif todotask.get('sessionIndex'):
                # 生成快开的todotask
                jumpTodoTask = TodoTaskEnterGame("enter_game", "")
                enterParam = dict()
                enterParam["type"] = "quickstart"
                enterParam["pluginParams"] = {}
                enterParam["pluginParams"]["gameType"] = 1
                enterParam["pluginParams"]["sessionIndex"] = int(todotask.get('sessionIndex'))    #0-经典 1-欢乐 2-癞子 3-二人
                jumpTodoTask.setParam('gameId', DIZHU_GAMEID)
                jumpTodoTask.setParam('type', "quickstart")
                jumpTodoTask.setParam('enter_param', enterParam)
                if not jumpTodoTask:
                    ftlog.warn('christmas TodoTaskQuickStart not Found. userId=', userId)
                else:
                    todotaskDict = jumpTodoTask.toDict()

            elif todotask.get('matchIndex'):
                # 跳转比赛列表的todotask
                jumpTodoTask = TodoTaskEnterGame("enter_game", "")
                enterParam = dict()
                enterParam["type"] = "roomlist"
                enterParam["pluginParams"] = {}
                enterParam["pluginParams"]["gameType"] = 3
                enterParam["pluginParams"]["matchIndex"] = int(todotask.get('matchIndex'))    #0-比赛第一页 1-比赛第二页 2-比赛第三页
                jumpTodoTask.setParam('gameId', DIZHU_GAMEID)
                jumpTodoTask.setParam('type', "roomlist")
                jumpTodoTask.setParam('enter_param', enterParam)
                if not jumpTodoTask:
                    ftlog.warn('christmas TodoTaskEnterGame not Found. userId=', userId)
                else:
                    todotaskDict = jumpTodoTask.toDict()
            ret.append([itemId, balance, itemCount, todotaskDict])

        if ftlog.is_debug():
            ftlog.debug('christmas.getUserCollectList userId=', userId,
                        'collectList=', ret)
        return ret