Пример #1
0
def _sendMatchDataResponse(userId, gameId, intClientId, apiVersion):
    """
    仅发送match_data命令, USER的我的比赛数据至客户端
    """
    mo = MsgPack()
    mo.setCmd('match_data5')
    mo.setResult('action', 'list')
    mo.setKey('apiVersion', apiVersion)
    mo.setResult('intClientId', intClientId)
    mo.setResult('gameId', gameId)
    mo.setResult('userId', userId)
    match_history_list = _dao.loadHistoryRecord(userId)
    match_sigin_list = _dao.loadSiginRecord(userId)
    if _DEBUG:
        if len(match_history_list) == 0:
            match_history_list = [{
                "gameId": 6,
                "roomList": [6666, 6888]
            }, {
                "gameId": 701,
                "roomList": [701230, 701250]
            }]
        debug('_sendMatchDataResponse OUT match_history_list=',
              match_history_list, 'match_sigin_list=', match_sigin_list)
    mock_match_list = {
        "historyList": match_history_list,
        "signinList": match_sigin_list
    }
    mo.setResult('matchData', mock_match_list)
    if _DEBUG:
        debug('_sendMatchDataResponse OUT userId=', userId, 'Msg=', mo)

    tyrpcconn.sendToUser(userId, mo)
Пример #2
0
    def doAction(self, gameId, clientId, userAssets, item, timestamp, params):
        assert (isinstance(item, TYExchangeItem))
        if item.isDied(timestamp):
            if item.itemKind.units.isTiming():
                return items.TYItemActionResult(None, None, -30, '道具已经过期',
                                                None)
            else:
                return items.TYItemActionResult(None, None, -31, '道具数量不足',
                                                None)

        if item.state != TYExchangeItem.STATE_NORMAL:
            return items.TYItemActionResult(None, None, -32, '道具审核中', None)

        wechat_red_pack = self.isWechatRedPack()  # 微信红包,无需手机号、地址
        msg = MsgPack()
        msg.setKey('apiVersion', 5.0)
        msg.setCmdAction('exchange5', 'exchange')
        msg.updateParam(self.auditParams)
        msg.setParam(
            'phone',
            str(
                params.get('phoneNumber'
                           ) if not wechat_red_pack else '11111111111'))
        msg.setParam('uName', params.get('uName', ''))
        msg.setParam('bindPhone', params.get('bindPhone', ''))
        msg.setParam('phoneNumber', params.get('phoneNumber', ''))
        msg.setParam('uAddres', params.get('uAddres', ''))
        msg.setParam('gameId', gameId)
        msg.setParam('itemId', item.itemId)
        msg.setParam('userId', userAssets.userId)
        msg.setParam('extabName', '_item_')
        msg.setParam('clientId', clientId)
        msg.setParam('wxappid',
                     hallconf.getWeiXinAppId(userAssets.userId, clientId))
        msg.setParam('proviceId', params.get('proviceId', ''))
        msg.setParam('cityId', params.get('cityId', ''))
        msg.setParam('countyId', params.get('countyId', ''))
        msg.setParam('townId', params.get('townId', ''))
        msg.setParam('proviceName', params.get('proviceName', ''))
        msg.setParam('cityName', params.get('cityName', ''))
        msg.setParam('countyName', params.get('countyName', ''))
        msg.setParam('townName', params.get('townName', ''))

        ftlog.info('TYItemActionExchange->doAction', msg)
        exchangeId, errMsg = pluginCross.hallexchange.doExchangeRequest(
            userAssets.userId, msg)
        if not exchangeId or errMsg:
            return items.TYItemActionResult(None, None, -33, errMsg, None)

        # 兑换开始,成功,转换道具状态
        item.state = TYExchangeItem.STATE_AUDIT
        item.original = 0
        userAssets.getUserBag().updateItem(item, timestamp)

        replaceParams = {'item': item.itemKind.displayName}
        _mail, message, _changed = _action._handleMailAndMessageAndChanged(
            gameId, userAssets, self, None, replaceParams)
        # TGHall.getEventBus().publishEventent(TYItemExchangeEvent(gameId, userAssets.userId, item))
        return TYItemActionExchangeResult(self, item, message, exchangeId)
Пример #3
0
def _sendUserGotoTable(userId, gameId, intClientId, apiVersion, locInfoList):
    mo = MsgPack()
    mo.setCmd('goto_table5')
    mo.setKey('apiVersion', apiVersion)
    mo.setResult('intClientId', intClientId)
    mo.setResult('gameId', gameId)
    mo.setResult('userId', userId)
    mo.setResult('locs', locInfoList)
    tyrpcconn.sendToUser(userId, mo)
Пример #4
0
 def doHttpUserItemAddAll(self, request):
     mo = MsgPack()
     mi = self.checkHttpUser.check(request)
     if mi.error:
         mo.setError(1, mi.error)
     else:
         result = hallRpcOne.hallitem.addAllItem(mi.userId, HALL_GAMEID,
                                                 "GM_ADJUST").getResult()
         mo.setKey('result', result)
     return mo
Пример #5
0
def _sendUserQueryCardInfo(userId, gameId, intClientId, apiVersion, is_verify,
                           ret_msg):
    mo = MsgPack()
    mo.setCmd('user_cardInfo')
    mo.setKey('apiVersion', apiVersion)
    mo.setResult('intClientId', intClientId)
    mo.setResult('gameId', gameId)
    mo.setResult('userId', userId)
    mo.setResult('is_verify', is_verify)
    mo.setResult('ret_msg', ret_msg)
    tyrpcconn.sendToUser(userId, mo)
Пример #6
0
def sendHallUiGameList(userId, intClientId, apiVersion):
    nowdate = fttime.formatTimeSecond()
    mo = MsgPack()
    mo.setCmd('hall_ui5')
    mo.setKey('apiVersion', apiVersion)
    mo.setResult('gameId', HALL_GAMEID)
    mo.setResult('intClientId', intClientId)
    mo.setResult('userId', userId)
    mo.setResult('gamelist',
                 _hallgamelist.getUiInfo(userId, intClientId, nowdate))
    tyrpcconn.sendToUser(userId, mo)
Пример #7
0
def getHallGameManager(userId, intClientId, apiVersion):
    ipstr = sessiondata.getClientIp(userId)
    location = getIpLocation(ipstr)
    mo = MsgPack()
    mo.setCmd('hall_gamelist5')
    mo.setKey('apiVersion', apiVersion)
    mo.setResult('action', "get")
    mo.setResult('gameId', HALL_GAMEID)
    mo.setResult('intClientId', intClientId)
    mo.setResult('userId', userId)
    mo.setResult('gamelist', _getListGames(userId, intClientId, location))
    tyrpcconn.sendToUser(userId, mo)
Пример #8
0
 def doHttpUserItemAction(self, request):
     mo = MsgPack()
     mi = self.checkHttpDoAction.check(request)
     if mi.error:
         mo.setError(1, mi.error)
     else:
         params = request.getDict()
         result = hallRpcOne.hallitem.doActionByItemId(
             mi.userId, mi.gameId, mi.itemId, mi.action,
             fttime.getCurrentTimestamp(), params).getResult()
         mo.setKey('result', result)
     return mo
Пример #9
0
def _sendUserInfoResponse(userId, gameId, intClientId, apiVersion):
    '''
    仅发送user_info命令, USER的主账户信息和游戏账户信息至客户端
    '''
    udatas = pluginCross.halldata.getUserDataDict(userId, USERATTS)
    mo = MsgPack()
    mo.setCmd('user_info5')
    mo.setKey('apiVersion', apiVersion)
    mo.setResult('intClientId', intClientId)
    mo.setResult('gameId', gameId)
    mo.setResult('userId', userId)
    mo.setResult('udata', udatas)
    tyrpcconn.sendToUser(userId, mo)
Пример #10
0
def _sendSetUserInfoResponse(userId, gameId, intClientId, apiVersion, retCode):
    mo = MsgPack()
    mo.setCmd('user5')
    mo.setKey('apiVersion', apiVersion)
    mo.setResult('action', 'setinfo')
    if retCode == 0:
        mo.setResult('ok', 1)
    else:
        mo.setError(1, '设置失败')

    tyrpcconn.sendToUser(userId, mo)

    if retCode == 0:
        _sendUserInfoResponse(userId, gameId, intClientId, apiVersion)
Пример #11
0
def delHallGameManager(userId, intClientId, apiVersion, gameIds):
    mo = MsgPack()
    mo.setCmd('hall_gamelist5')
    mo.setKey('apiVersion', apiVersion)
    mo.setResult('action', "del")
    mo.setResult('gameId', HALL_GAMEID)
    mo.setResult('intClientId', intClientId)
    mo.setResult('userId', userId)
    code = _delGames(userId, gameIds)
    if code != 1:
        mo.setResult('ok', 0)
        mo.setError(code, "")
    else:
        mo.setResult('ok', 1)
    tyrpcconn.sendToUser(userId, mo)
Пример #12
0
def _sendGameDataResponse(userId, gameId, intClientId, apiVersion):
    '''
    仅发送game_data命令, USER的大厅游戏数据至客户端
    '''
    gdatas = pluginCross.halldata.getUserDataDict(userId, GAMEATTS)
    gdatas['vipInfo'] = pluginCross.hallvip.getVipInfo(userId)
    mo = MsgPack()
    mo.setCmd('game_data5')
    mo.setKey('apiVersion', apiVersion)
    mo.setResult('intClientId', intClientId)
    mo.setResult('gameId', gameId)
    mo.setResult('userId', userId)
    mo.setResult('gdata', gdatas)
    tyrpcconn.sendToUser(userId, mo)
    return gdatas[UserKeys.ATT_CHIP], gdatas[UserKeys.ATT_COUPON]
Пример #13
0
def addHallGameManager(userId, intClientId, apiVersion, gameIds):
    ipstr = sessiondata.getClientIp(userId)
    location = getIpLocation(ipstr)
    mo = MsgPack()
    mo.setCmd('hall_gamelist5')
    mo.setKey('apiVersion', apiVersion)
    mo.setResult('action', "add")
    mo.setResult('gameId', HALL_GAMEID)
    mo.setResult('intClientId', intClientId)
    mo.setResult('userId', userId)
    mo.setResult('gameIds', gameIds)
    code = _safeAddGames(userId, intClientId, gameIds, location)
    if code != 1:
        mo.setResult('ok', 0)
        mo.setError(code, "")
    else:
        mo.setResult('ok', 1)
    tyrpcconn.sendToUser(userId, mo)
Пример #14
0
 def doExchangeExchange(self, request):
     mo = MsgPack()
     mi = self.checkExchange.check(request)
     if mi.error:
         mo.setError(1, mi.error)
     else:
         clientId = tysessiondata.getClientId(mi.userId)
         msg = MsgPack()
         msg.setKey('apiVersion', 5.0)
         msg.setCmdAction('exchange5', 'exchange')
         msg.setParam('phone', request.getParamStr('phone'))
         msg.setParam('uName', request.getParamStr('uName'))
         msg.setParam('uAddres', request.getParamStr('uAddres'))
         msg.setParam('gameId', tyglobal.gameId())
         msg.setParam('itemId', mi.itemId)
         msg.setParam('userId', mi.userId)
         msg.setParam('extabName', request.getParamStr('extabName'))
         msg.setParam('clientId', clientId)
         msg.setParam('wxappid',
                      hallconf.getWeiXinAppId(mi.userId, clientId))
         msg.setParam('proviceId', request.getParamStr('proviceId'))
         msg.setParam('cityId', request.getParamStr('cityId'))
         msg.setParam('countyId', request.getParamStr('countyId'))
         msg.setParam('townId', request.getParamStr('townId'))
         msg.setParam('proviceName', request.getParamStr('proviceName'))
         msg.setParam('cityName', request.getParamStr('cityName'))
         msg.setParam('countyName', request.getParamStr('countyName'))
         msg.setParam('townName', request.getParamStr('townName'))
         msg = msg.getDict()
         try:
             ret = hallRpcOne.hallexchange.doExchangeRequest(mi.userId, msg)
             datas = ret.getResult()
             if datas:
                 exchangeId, errMsg = datas[0], datas[1]
                 if exchangeId:
                     mo.setResult('exchangeId', exchangeId)
                     mo.setResult('info', errMsg)
                 else:
                     mo.setError(1, errMsg)
             else:
                 mo.setError(1, 'doExchangeRequest return is None')
         except Exception, e:
             mo.setError(1, str(e))
Пример #15
0
    def updateMsg(cls, msg=None, cmd=None, params=None, result=None, **other):
        if not msg:
            msg = MsgPack()
        if cmd:
            msg.setCmd(cmd)
        if params is not None:
            msg.setKey('params', params)
        if result is not None:
            msg.setKey('result', result)

        for k, v in other.items():
            msg.setKey(k, v)

        return msg