예제 #1
0
파일: todotask.py 프로젝트: zhaozw/mjserver
def sendFriendInviteTodotask(userId, invite_uid, gameId, play_mode, roomId,
                             tableId, info_str, purl):
    """ 推送牌桌好友邀请的todotask
    * 版本 3.732 之后,改为麻将自己的todotask
    """
    todotask = TodoTaskQuickStart(gameId, roomId, tableId)
    todotask.setParam('play_mode', play_mode)
    client_ver = sessiondata.getClientIdVer(userId)

    if client_ver < 3.732:
        show_info_ = TodoTaskShowInfo(info_str, True)
        show_info_.setSubCmd(todotask)
        msg = TodoTaskHelper.makeTodoTaskMsg(gameId, userId, show_info_)
        router.sendToUser(msg, userId)
    else:
        task = {
            'action': 'pop_wnd_invite',
            'params': {
                'tasks': [todotask.toDict()],
                'invite_uid': invite_uid,
                'purl': purl,
                'info_str': info_str
            }
        }
        mo = MsgPack()
        mo.setCmd('majiang_todotasks')
        mo.setResult('gameId', gameId)
        mo.setResult('userId', userId)
        mo.setResult('tasks', [task])
        router.sendToUser(mo, userId)
예제 #2
0
파일: todotask.py 프로젝트: zhaozw/mjserver
def sendFriendInviteTodotask(userId, invite_uid, gameId, play_mode, roomId, tableId, info_str, purl):
    """ 推送牌桌好友邀请的todotask
    * 版本 3.732 之后,改为麻将自己的todotask
    """
    todotask = TodoTaskQuickStart(gameId, roomId, tableId)
    todotask.setParam('play_mode', play_mode)
    client_ver = sessiondata.getClientIdVer(userId)

    if client_ver < 3.732:
        show_info_ = TodoTaskShowInfo(info_str, True)
        show_info_.setSubCmd(todotask)
        msg = TodoTaskHelper.makeTodoTaskMsg(gameId, userId, show_info_)
        router.sendToUser(msg, userId)
    else:
        task = {
                'action':       'pop_wnd_invite',
                'params':       {
                                 'tasks':       [todotask.toDict()],
                                 'invite_uid':   invite_uid,
                                 'purl':         purl,
                                 'info_str':     info_str
                                 }
                }
        mo = MsgPack()
        mo.setCmd('majiang_todotasks')
        mo.setResult('gameId', gameId)
        mo.setResult('userId', userId)
        mo.setResult('tasks', [task])
        router.sendToUser(mo, userId)
예제 #3
0
파일: todotask.py 프로젝트: zhaozw/mjserver
def sendBuyDiamondTodoTask(userId, gameId, clientId, pay_order):
    """ 幸运大抽奖,钻石购买
    @param         pay_order        挑选商品模板
    """
    if not TYPlayer.isHuman(userId):
        return

    product, _ = hallstore.findProductByPayOrder(gameId, userId, clientId,
                                                 pay_order)
    if not product:
        ftlog.error('userId =', userId, 'clientId =', clientId, 'pay_order =',
                    pay_order, 'can not find suitable product!')
        return
    try:
        product = product.clone()
    except:
        product = strutil.cloneData(product)
    desc = u'您的钻石不够哦~\n现在' + unicode(product.price) + u'元立得' + unicode(
        product.priceDiamond) + u'钻石!'
    product.content.desc = str(product.priceDiamond) + '钻石'
    client_ver = sessiondata.getClientIdVer(userId)
    if client_ver < 3.74:  # 客户端bug,小于3.74的版本转换一下
        product.priceDiamond = product.price
    todotasks = TodoTaskOrderShow.makeByProduct(desc, '', product)
    TodoTaskHelper.sendTodoTask(gameId, userId, todotasks)
예제 #4
0
 def doUpdateMatchTableInfo(self, msg):
     if ftlog.is_debug():
         ftlog.debug('GameTable->doUpdateMatchTableInfo', self.gameId, self.roomId,
                               self.tableId, self.room.bigmatchId, msg)
     table_info = msg.getKey('params')
     if not self._checkMatchTableInfo(table_info):
         return
     if (self._match_table_info
         and self._match_table_info['ccrc'] != table_info['ccrc']):
         ftlog.error('GameTable->doUpdateMatchTableInfo', self.gameId,
                               self.roomId, self.room.bigmatchId, msg,
                               'diff ccrc', self._match_table_info['ccrc'])
         return
     self.__doUpdateTableInfo(table_info)
     for seatInfo in table_info['seats']:
         clientVer = sessiondata.getClientIdVer(seatInfo['userId'])
         mnotes = self._match_table_info.get('mnotes', {})
         if clientVer < 3.37:
             mn = MsgPack()
             mn.setCmd('m_note')
             mn.setResult('note', mnotes.get('incrnote'))
             mn.setResult('basescore', mnotes.get('basescore'))
             mn.setResult('mInfos', self._match_table_info.get('mInfos', {}))
             router.sendToUser(mn, seatInfo['userId'])
         else:
             mn = MsgPack()
             mn.setCmd('m_note')
             mn.setResult('note', self._buildNote(seatInfo['userId'], table_info))
             mn.setResult('basescore', mnotes.get('basescore'))
             mn.setResult('mInfos', table_info.get('mInfos', {}))
             router.sendToUser(mn, seatInfo['userId'])
예제 #5
0
 def __playAnimationIfNeed(self, tableInfo):
     ret = {'playAnimation':False, 'delaySeconds':0}
     
     for x in xrange(len(self.seats)) :
         this_seat = self.seats[x]
         if this_seat.userId > 0:
             clientVer = sessiondata.getClientIdVer(this_seat.userId)
             animationType = self.__getAnimationType(clientVer)
             if animationType != AnimationType.UNKNOWN:
                 msg = MsgPack()
                 msg.setCmd('m_play_animation')
                 msg.setResult('gameId', self.gameId)
                 msg.setResult('roomId', self.roomId)
                 msg.setResult('tableId', self.tableId)
                 msg.setResult('type', animationType)
                 mnotes = self._match_table_info['mnotes']
                 isStartStep = mnotes.get('isStartStep', False)
                 # 添加是否是第一个阶段的标志,是的话前端播放开始比赛的动画
                 msg.setResult('isStartStep', isStartStep)
                 # 组织当前比赛是第几局、共几局的信息
                 msg.setResult('curMatchStep', self._buildMatchStepInfo(this_seat.userId, tableInfo))
                 router.sendToUser(msg, this_seat.userId)
                 # 
                 ret['delaySeconds'] = self.__getAnimationInter(animationType, isStartStep, clientVer)
                 ret['playAnimation'] = True
     return ret
예제 #6
0
 def makeProductDeliveryResponse(cls,
                                 userId,
                                 orderDeliveryResult,
                                 prodId=None):
     mo = MsgPack()
     mo.setCmd('prod_delivery')
     mo.setResult('userId', userId)
     mo.setResult('gameId', orderDeliveryResult.order.gameId)
     if orderDeliveryResult.order.realGameId:
         mo.setResult('realGameId', orderDeliveryResult.order.realGameId)
     mo.setResult('prodId', prodId or orderDeliveryResult.order.productId)
     mo.setResult('orderId', orderDeliveryResult.order.orderId)
     mo.setResult('prodName', orderDeliveryResult.order.product.displayName)
     mo.setResult('pic', orderDeliveryResult.order.product.pic)
     mo.setResult('raffle', 0)
     clientVer = sessiondata.getClientIdVer(userId)
     if clientVer >= 3.37:
         conf = hallstore.storeSystem.deliveryConf
         succ = conf.get('succ', {})
         mo.setResult('info', succ.get('title'))
         mo.setResult('tips', succ.get('tips', u'如有问题请拨打客服电话'))
         mo.setResult(
             'content',
             cls.buildProductDeliveryContent(datetime.now(), succ,
                                             orderDeliveryResult))
     return mo
예제 #7
0
def photoConvert(photo, userId=0, clientVer=0.0):
    """
    转换头像,让新老版本在相遇时能正确显示对方头像。

    userId: 头像接收者的 userId
    clientVer: 头像接收者的 clientVer
    """

    if not photo:
        ftlog.error("error header photo", photo)
        return photo

    if not userId and not clientVer:
        return photo

    if not clientVer:
        clientVer = sessiondata.getClientIdVer(userId)

    if not clientVer:
        return photo

    newClient = clientVer >= 1.9

    old_to_new = {
        'head_01.png': 'head_360_01.png',
        'head_02.png': 'head_du.png',
        'head_03.png': 'head_360_02.png',
        'head_04.png': 'head_360_03.png',
        'head_05.png': 'head_360_04.png',
        'head_06.png': 'head_hanhou.png',
        'head_07.png': 'head_360_05.png',
        'head_08.png': 'head_360_06.png',
        'head_09.png': 'head_360_07.png',
        'head_10.png': 'head_360_07.png',  # 重复使用。
        'head_11.png': 'head_360_08.png',
        'head_12.png': 'head_360_09.png',
        'head_13.png': 'head_360_10.png',
        'head_14.png': 'head_360_11.png',
        'head_15.png': 'head_360_12.png',
    }

    new_to_old = dict(zip(old_to_new.values(), old_to_new.keys()))

    if newClient:
        if photo in new_to_old:
            return photo
        elif photo in old_to_new:
            return old_to_new[photo]
        else:
            return photo
    else:
        if photo in new_to_old:
            return new_to_old[photo]
        elif photo in old_to_new:
            return photo
        else:
            return photo

    return photo
예제 #8
0
파일: util.py 프로젝트: zhaozw/hall37
def photoConvert(photo, userId=0, clientVer=0.0):
    """
    转换头像,让新老版本在相遇时能正确显示对方头像。

    userId: 头像接收者的 userId
    clientVer: 头像接收者的 clientVer
    """

    if not photo:
        ftlog.error("error header photo", photo)
        return photo

    if not userId and not clientVer:
        return photo

    if not clientVer:
        clientVer = sessiondata.getClientIdVer(userId)

    if not clientVer:
        return photo

    newClient = clientVer >= 1.9

    old_to_new = {
        'head_01.png': 'head_360_01.png',
        'head_02.png': 'head_du.png',
        'head_03.png': 'head_360_02.png',
        'head_04.png': 'head_360_03.png',
        'head_05.png': 'head_360_04.png',
        'head_06.png': 'head_hanhou.png',
        'head_07.png': 'head_360_05.png',
        'head_08.png': 'head_360_06.png',
        'head_09.png': 'head_360_07.png',
        'head_10.png': 'head_360_07.png',  # 重复使用。
        'head_11.png': 'head_360_08.png',
        'head_12.png': 'head_360_09.png',
        'head_13.png': 'head_360_10.png',
        'head_14.png': 'head_360_11.png',
        'head_15.png': 'head_360_12.png',
    }

    new_to_old = dict(zip(old_to_new.values(), old_to_new.keys()))

    if newClient:
        if photo in new_to_old:
            return photo
        elif photo in old_to_new:
            return old_to_new[photo]
        else:
            return photo
    else:
        if photo in new_to_old:
            return new_to_old[photo]
        elif photo in old_to_new:
            return photo
        else:
            return photo

    return photo
예제 #9
0
 def sendled():
     newleds = cls._getLedMsgLists(leds, gameId, userId)
     clientVer = sessiondata.getClientIdVer(userId)
     clientId = sessiondata.getClientId(userId)
     if newleds['richLeds'] or newleds['origLeds']:
         key = mo_cache_key(gameId, clientVer, clientId)
         if key not in mo_cache:
             mo_cache[key] = make_led_mo(newleds, clientVer, clientId)
         mo = mo_cache[key]
         if mo:
             protocols.sendCarryMessage(mo, [userId])
예제 #10
0
def _bugFixFilterChatMsgForPNG(userId, chatMsg):
    # 新老版本使用的图片格式不一致
    try:
        clientVer = sessiondata.getClientIdVer(userId)
        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
예제 #11
0
파일: led_util.py 프로젝트: zhaozw/hall37
        def sendled():
            clientVer = sessiondata.getClientIdVer(userId)
            if clientVer < 3.6:
                return

            if sendLedCount[0] <= SEND_COUNT_LIMIT:
                sendLedCount[0] += 1
                if ftlog.is_debug():
                    ftlog.debug("|send led count:", sendLedCount, caller=cls)
                if sendLedCount[0] % 10 == 0:
                    if ftlog.is_debug():
                        ftlog.info("|send led count:",
                                   sendLedCount,
                                   caller=cls)
                onlines.notifyUsers(ledMsg.pack(), [userId])
예제 #12
0
    def _doItemAction(self, gameId, userId, clientId, itemId, params):
        from hall.entity.hallitem import TYItemActionExchange
        from poker.entity.dao import sessiondata
        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')

            if ftlog.is_debug():
                ftlog.debug('ItemTcpHandler._doItemAction', 'gameId=', gameId,
                            'userId=', userId, 'clientId=', clientId,
                            'itemId=', itemId, 'params=', params)

            action = item.itemKind.findActionByName(actionName)
            # 3.9以下不支持京东实物
            if action and isinstance(
                    action,
                    TYItemActionExchange) and action.isJdActualProduct():
                clientIdVer = sessiondata.getClientIdVer(userBag.userId)
                if clientIdVer < 3.90:
                    self._doItemActionUnsupportedExchange(
                        gameId, userId, clientId, itemId, params)
                    return

            actionResult = userBag.doAction(gameId, item, actionName,
                                            timestamp, params)

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

            _, cVer, _ = strutil.parseClientId(clientId)
            if actionResult:
                if actionResult.todotask and cVer >= 3.90:
                    TodoTaskHelper.sendTodoTask(gameId, userId,
                                                actionResult.todotask)
                elif actionResult.message:
                    if isinstance(actionResult.action, TYItemActionExchange
                                  ) and actionResult.action.isWechatRedPack():
                        mytodo = TodoTaskShowInfo(actionResult.message)
                    else:
                        mytodo = TodoTaskPopTip(actionResult.message)
                    TodoTaskHelper.sendTodoTask(gameId, userId, mytodo)

        except TYBizException, e:
            self.handleException(itemId, gameId, userId, clientId, e)
예제 #13
0
 def sendMNoteMsg(self, userIds, note):
     if self._match_table_info:
         for userId in userIds:
             clientVer = sessiondata.getClientIdVer(userId)
             if clientVer < 3.37:
                 mnote = MsgPack()
                 mnote.setCmd('m_note')
                 mnote.setResult('note', note)
                 router.sendToUser(mnote, userId)
             else:
                 mnote = MsgPack()
                 mnote.setCmd('m_note')
                 mnote.setResult(
                     'note', self._buildNote(userId,
                                             self._match_table_info))
                 router.sendToUser(mnote, userId)
예제 #14
0
    def sendMNoteMsg(self, userIds, note):
#         if self._status.state == TABLEDZSTAT_CALLING:
#             userIds2 = []
#             self.makeBroadCastUsers(userIds2)
#             if userIds == userIds2:
                if self._match_table_info:
                    for userId in userIds:
                        clientVer = sessiondata.getClientIdVer(userId)
                        if clientVer < 3.37:
                            mnote = MsgPack()
                            mnote.setCmd('m_note')
                            mnote.setResult('note', note)
                            router.sendToUser(mnote, userId)
                        else:
                            mnote = MsgPack()
                            mnote.setCmd('m_note')
                            mnote.setResult('note', self._buildNote(userId, self._match_table_info))
                            router.sendToUser(mnote, userId)
예제 #15
0
 def makeProductDeliveryResponse(cls, userId, orderDeliveryResult, prodId=None):
     mo = MsgPack()
     mo.setCmd('prod_delivery')
     mo.setResult('userId', userId)
     mo.setResult('gameId', orderDeliveryResult.order.gameId)
     mo.setResult('prodId', prodId or orderDeliveryResult.order.productId)
     mo.setResult('orderId', orderDeliveryResult.order.orderId)
     mo.setResult('prodName', orderDeliveryResult.order.product.displayName)
     mo.setResult('pic', orderDeliveryResult.order.product.pic)
     mo.setResult('raffle', 0)
     clientVer = sessiondata.getClientIdVer(userId)
     if clientVer >= 3.37:
         conf = hallstore.storeSystem.deliveryConf
         succ = conf.get('succ', {})
         mo.setResult('info', succ.get('title'))
         mo.setResult('tips', succ.get('tips', u'如有问题请拨打客服电话'))
         mo.setResult('content', cls.buildProductDeliveryContent(datetime.now(), succ, orderDeliveryResult))
     return mo
예제 #16
0
    def _getLedMsgLists(cls, leds, gameId, userId):
        if not leds:
            return

        newleds = {
            'richLeds': [],  # 带格式的 led 消息
            'origLeds': [],  # 纯文本的 led 消息
        }

        clientVer = sessiondata.getClientIdVer(userId)

        # 过滤 led 消息。过滤器把通过过滤器的消息加入到 richLeds 或者 origLeds 里
        for led in leds:
            if cls._ledMsgFilterRich(gameId, userId, clientVer, led, newleds):
                continue
            if cls._ledMsgFilterOrig(gameId, userId, clientVer, led, newleds):
                continue

        return newleds
예제 #17
0
파일: vip_room.py 프로젝트: zhaozw/hall37
    def doGetVipTableList(self, userId, clientId):
        '''为了效率,贵宾室所有桌子放在一个GT进程里, 在此进程中通过遍历来获取每张桌子的状态
        '''
        msgRes = MsgPack()
        msgRes.setCmd("game")
        msgRes.setResult("action", "vip_table_list")

        clientVer = sessiondata.getClientIdVer(userId)
        if clientVer < 5.0:
            if self.gameId == 8:
                msgRes.setCmd("texas_room_list_response")
            if self.gameId == 30:
                msgRes.setCmd("room")
                msgRes.setResult("action", "vipTableList")

        msg = FTTasklet.getCurrentFTTasklet().pack
        tag = msg.getParam("tag", "")

        msgRes.updateResult(self._getVipTableList(userId, clientId, tag))
        router.sendToUser(msgRes, userId)
예제 #18
0
파일: vip_room.py 프로젝트: zhaozw/hall37
    def doGetVipTableList(self, userId, clientId):
        '''为了效率,贵宾室所有桌子放在一个GT进程里, 在此进程中通过遍历来获取每张桌子的状态
        '''
        msgRes = MsgPack()
        msgRes.setCmd("game")
        msgRes.setResult("action", "vip_table_list")

        clientVer = sessiondata.getClientIdVer(userId)
        if clientVer < 5.0:
            if self.gameId == 8:
                msgRes.setCmd("texas_room_list_response")
            if self.gameId == 30:
                msgRes.setCmd("room")
                msgRes.setResult("action", "vipTableList")

        msg = FTTasklet.getCurrentFTTasklet().pack
        tag = msg.getParam("tag", "")

        msgRes.updateResult(self._getVipTableList(userId, clientId, tag))
        router.sendToUser(msgRes, userId)
예제 #19
0
 def encodeItemAction(cls, gameId, userBag, item, action, timestamp):
     from poker.entity.dao import sessiondata
     from hall.entity.hallitem import TYItemActionExchange
     if isinstance(action,
                   TYItemActionExchange) and action.isJdActualProduct():
         clientIdVer = sessiondata.getClientIdVer(userBag.userId)
         if clientIdVer < 3.90:
             return {
                 'action': action.name,
                 'type': action.TYPE_ID,
                 'name': action.displayName
             }
     ret = {
         'action': action.name,
         'type': action.TYPE_ID,
         'name': action.displayName,
     }
     inputParams = action.getInputParams(gameId, userBag, item, timestamp)
     if inputParams:
         ret['params'] = inputParams
     return ret
예제 #20
0
파일: todotask.py 프로젝트: zhaozw/mjserver
def sendBuyDiamondTodoTask(userId, gameId, clientId, pay_order):
    """ 幸运大抽奖,钻石购买
    @param         pay_order        挑选商品模板
    """
    if not TYPlayer.isHuman(userId):
        return
    
    product, _ = hallstore.findProductByPayOrder(gameId, userId, clientId, pay_order)
    if not product:
        ftlog.error('userId =', userId, 'clientId =', clientId, 'pay_order =', pay_order,
                    'can not find suitable product!')
        return
    try:
        product = product.clone()
    except:
        product = strutil.cloneData(product)
    desc = u'您的钻石不够哦~\n现在' + unicode(product.price) +u'元立得' + unicode(product.priceDiamond) +u'钻石!'
    product.content.desc = str(product.priceDiamond) + '钻石'
    client_ver = sessiondata.getClientIdVer(userId)
    if client_ver < 3.74:   # 客户端bug,小于3.74的版本转换一下
        product.priceDiamond = product.price
    todotasks = TodoTaskOrderShow.makeByProduct(desc, '', product)
    TodoTaskHelper.sendTodoTask(gameId, userId, todotasks)
예제 #21
0
    def sendTableInfoRes(self, userId, clientId, isrobot):
        if self._logger.isDebug():
            self._logger.debug('DizhuGroupMatchSender.sendTableInfoRes',
                               'userId=', userId,
                               'clientId=', clientId,
                               'isrobot=', isrobot)
        tableInfo = self.table._match_table_info
        if not tableInfo:
            self._logger.error('DizhuGroupMatchSender.sendTableInfoRes NoMatchTableInfo',
                               'userId=', userId,
                               'clientId=', clientId,
                               'isrobot=', isrobot)
            return
        
        player = self.table.getPlayer(userId)
        if not player:
            self._logger.error('DizhuGroupMatchSender.sendTableInfoRes NoPlayer',
                               'userId=', userId,
                               'clientId=', clientId,
                               'isrobot=', isrobot)
            return
        
        baseinfo = self.table.buildBasicInfo(False, userId, clientId)
        _, clientVer, _ = strutil.parseClientId(clientId)
        mo = self.createMsgPackRes('table_info')
        playMode = self.table.gamePlay.getPlayMode()
        if clientVer <= 3.7:
            if playMode == dizhuconf.PLAYMODE_HAPPY or playMode == dizhuconf.PLAYMODE_123 :
                playMode = 'normal'  # FIX, 客户端happy和123都是normal, grab=1就是欢乐
        isMatch = self.table.isMatch
        mo.setResult('isrobot', isrobot)
        mo.setResult('playMode', playMode)
        
        roomLevel = gdata.roomIdDefineMap()[self.table.roomId].configure.get('roomLevel', 1)
        mo.setResult('roomLevel', roomLevel)
        roomName = self.table.room.roomConf['name'] if self.table.room else ''
        mo.setResult('roomName', roomName)
        mo.setResult('isMatch', isMatch)
        mo.setResult('info', baseinfo['info'])
        mo.setResult('config', baseinfo['config'])
        mo.setResult('stat', self.buildStatusInfoDict(player))
        mo.setResult('myCardNote', self.buildCardNote(player.seatIndex))
        if self.table.gameRound:
            mo.setResult('roundId', self.table.gameRound.roundId)
            
        if self.table._complain_open:
            clientIdVer = sessiondata.getClientIdVer(userId)
            clientIdLimit = dizhuconf.getAllComplainInfo().get('clientIdLimit', 3.72)
            if clientIdVer >= clientIdLimit:
                mo.setResult('complain', self.table._complain)
        
        if self._logger.isDebug():
            self._logger.debug('DizhuGroupMatchSender.sendTableInfoRes before getMatchTableInfo',
                               'mo=', mo)
        self.getMatchTableInfo(userId, tableInfo, mo)
        if self._logger.isDebug():
            self._logger.debug('DizhuGroupMatchSender.sendTableInfoRes after getMatchTableInfo',
                               'mo=', mo)
        
        for i in xrange(len(self.table.seats)):
            seat = self.table.seats[i]
            oseat = seat.toInfoDict()
            seatuid = seat.userId
            if seatuid :
                seatPlayer = self.table.players[i]
                oseat.update(seatPlayer.datas)
                oseat['cardNote'] = seatPlayer.getCardNoteCount()
                seatPlayer.cleanDataAfterFirstUserInfo()
                self.getMatchUserInfo(seatPlayer.userId, tableInfo, oseat)
            else:
                oseat['uid'] = 0
            mo.setResult('seat' + str(i + 1), oseat)

        tmpobsr = []
        for _, obuser in self.table.observers.items() :
            if obuser :
                tmpobsr.append((obuser.userId, obuser.name))
        mo.setResult('obsr', tmpobsr)
        
        mo.setResult('betpoolClose', 1)

        if player and player.getCardNoteCount() < 1:
            tableConf = self.table.room.roomConf.get('tableConf') if self.table.room else None
            cardNoteChip = tableConf.get('cardNoteChip', 0)
            cardNoteDiamod = tableConf.get('cardNoteDiamond', 0)
            cardNote = dizhuconf.getCardNoteTips(userId, player.datas.get('chip', 0),
                                                 clientId, cardNoteChip, cardNoteDiamod)
            if cardNote:
                mo.setResult('cardNote', cardNote)

        # 发送消息至客户端
        router.sendToUser(mo, userId)
예제 #22
0
 def getClientIdVer(self, uid):
     if uid < 10000:
         clientId = 3.7
     else:
         clientId = sessiondata.getClientIdVer(uid)
     return clientId
예제 #23
0
파일: match.py 프로젝트: luningcowboy/tuyoo
    def getMatchInfo(cls, room, uid, mo):
        match = cls.getMatch(room.roomId)
        if not match:
            mo.setError(1, 'not a match room')
            return

        inst = match.curInst
        conf = inst.matchConf if inst else match.matchConf
        state = cls.convertState(inst.state) if inst else 0
        
        # 为了兼容老客户端m_enter的问题加的
        clientVer = sessiondata.getClientIdVer(uid)
        try:
            match.enter(uid)
        except:
            pass
        info = {}
        info['roomId'] = room.roomId
        info['type'] = conf.start.type
        info['name'] = room.roomConf['name']
        if conf.start.isUserCountType():
            info['minPlayer'] = conf.start.userCount
            info['maxPlayer'] = conf.start.userCount
        else:
            info['minPlayer'] = conf.start.userMinCount
            info['maxPlayer'] = conf.start.userMaxCount
            
        info['state'] = cls.convertState(state)
        info['curTimeLeft'] = cls.getMatchCurTimeLeft(inst) if inst else 0
        mo.setResult('info', info)
        mo.setResult('startTime', inst.startTimeStr if inst else '')

        mo.setResult('desc', conf.rankRewardsDesc)
        matchDuration = int(cls.calcMatchDuration(conf) / 60)
        mo.setResult('rankRewards', cls.buildRankRewards(conf.rankRewardsList))
        mo.setResult('duration', '约%d分钟' % (min(30, matchDuration)))
            
        if clientVer >= 3.37:
            mo.setResult('tips', {'infos':conf.tips.infos,
                                  'interval':conf.tips.interval})
            record = MatchRecord.loadRecord(room.gameId, uid, match.matchConf.recordId)
            if record:
                mo.setResult('mrecord', {'bestRank':record.bestRank,
                                         'bestRankDate':record.bestRankDate,
                                         'isGroup':record.isGroup,
                                         'crownCount':record.crownCount,
                                         'playCount':record.playCount})
        mo.setResult('fees', cls.buildFees(conf.fees))
        # 报名费列表
        mo.setResult('feesList', cls.buildFeesList(uid, conf.fees) if conf.fees else [])
        # 分组赛奖励列表
        groupList = []
        if len(conf.stages) > 0 and conf.stages[0].rankRewardsList and conf.stages[0].groupingUserCount:
            groupList = cls.buildRankRewards(conf.stages[0].rankRewardsList, defaultEnd = conf.stages[0].groupingUserCount)
        mo.setResult('groupRewardList', groupList)
        # 比赛进程 海选赛-》分组赛-》8强赛-》总决赛
        stagesList = cls.buildStages(conf.stages) if conf.stages else []
        mo.setResult('stages', stagesList)
        # 比赛报名的前提条件
        conditionDesc = cls.getMatchConditionDesc(room.roomId, uid)
        if conditionDesc:
            mo.setResult('conditionDesc', conditionDesc)
        # 比赛奖励分割线文字
        mo.setResult('splitWord', cls.getMatchRewardSplitWord(room.roomId))
        # 获得比赛历史数据
        mo.setResult('hisitory', MatchHistoryHandler.getMatchHistory(uid, match.matchConf.recordId))
예제 #24
0
    def sendTableInfoRes(self, userId, clientId, isrobot):
        ftlog.debug('userId',
                    userId,
                    "|clientId",
                    clientId,
                    'isrobot=',
                    isrobot,
                    caller=self)
        player = self.table.getPlayer(userId)
        if not player:
            ftlog.warn('DizhuSender.sendTableInfoRes NotPlayer tableId=',
                       self.table.tableId, 'userId=', userId)
            return
        baseinfo = self.table.buildBasicInfo(False, userId, clientId)
        _, clientVer, _ = strutil.parseClientId(clientId)
        mo = self.createMsgPackRes("table_info")
        playMode = self.table.gamePlay.getPlayMode()
        if clientVer <= 3.7:
            if playMode == dizhuconf.PLAYMODE_HAPPY or playMode == dizhuconf.PLAYMODE_123:
                playMode = 'normal'  # FIX, 客户端happy和123都是normal, grab=1就是欢乐
        isMatch = self.table.isMatch
        mo.setResult('isrobot', isrobot)
        mo.setResult('playMode', playMode)

        roomLevel = gdata.roomIdDefineMap()[self.table.roomId].configure.get(
            'roomLevel', 1)
        mo.setResult('roomLevel', roomLevel)
        roomName = self.table.room.roomConf['name'] if self.table.room else ''
        mo.setResult('roomName', roomName)
        mo.setResult('isMatch', isMatch)
        mo.setResult('info', baseinfo['info'])
        mo.setResult('config', baseinfo['config'])
        mo.setResult('stat', self.buildStatusInfoDict(player))
        mo.setResult('myCardNote', self.buildCardNote(player.seatIndex))
        if self.table.gameRound:
            mo.setResult('roundId', self.table.gameRound.roundId)

        if self.table._complain_open:
            clientIdVer = sessiondata.getClientIdVer(userId)
            clientIdLimit = dizhuconf.getAllComplainInfo().get(
                "clientIdLimit", 3.72)
            if clientIdVer >= clientIdLimit:
                mo.setResult('complain', self.table._complain)

        ftlog.debug("before getMatchTableInfo:", mo)
        if isMatch:
            self.table.room.matchPlugin.getMatchTableInfo(
                self.table.room, self.table, mo)
        ftlog.debug("after getMatchTableInfo:", mo)

        # 当前table的奖券任务奖励 wuyangwei
        bigRoomId = self.table.bigRoomId
        _, itemCount = treasurebox.getTreasureRewardItem(bigRoomId)

        for i in xrange(len(self.table.seats)):
            seat = self.table.seats[i]
            oseat = self.buildSeatInfo(player, seat)
            seatuid = seat.userId
            if seatuid:
                seatPlayer = self.table.players[i]
                oseat.update(seatPlayer.datas)
                oseat['cardNote'] = seatPlayer.getCardNoteCount()
                seatPlayer.cleanDataAfterFirstUserInfo()

                # 当前table的奖券任务奖励 wuyangwei
                oseat['count'] = itemCount

                if isMatch:
                    self.table.room.matchPlugin.getMatchUserInfo(
                        self.table.room, self.table, seatuid, oseat)
            else:
                oseat['uid'] = 0
            mo.setResult('seat' + str(i + 1), oseat)

        tmpobsr = []
        for _, obuser in self.table.observers.items():
            if obuser:
                tmpobsr.append((obuser.userId, obuser.name))
        mo.setResult('obsr', tmpobsr)

        mo.setResult('betpoolClose', 1)

        ftlog.debug("cardNote test come to assemble cardNote info, userId = ",
                    userId)
        if player:
            ftlog.debug("cardNote test player cardNoteCount = ",
                        player.getCardNoteCount())
        else:
            ftlog.debug("cardNote test player is None ")

        if player and player.getCardNoteCount() < 1:
            tableConf = self.table.room.roomConf.get(
                'tableConf') if self.table.room else None
            cardNoteChip = tableConf.get('cardNoteChip', 0)
            cardNoteDiamod = tableConf.get('cardNoteDiamond', 0)
            cardNote = dizhuconf.getCardNoteTips(userId,
                                                 player.datas.get('chip',
                                                                  0), clientId,
                                                 cardNoteChip, cardNoteDiamod)
            if cardNote:
                mo.setResult('cardNote', cardNote)

        if isMatch:
            step = mo.getResult('step')
            if step and self.table._match_table_info:
                # 比赛的当前提示信息
                step['note'] = self.table._buildNote(
                    userId, self.table._match_table_info)
                # 发送消息至客户端
                router.sendToUser(mo, userId)
        else:
            # 桌面充值商品
            player = self.table.getPlayer(userId)
            if not player:
                player = self.table.getObserver(userId)
            if player and player.userId:
                mo.setResult(
                    'products',
                    tablepay.getProducts(userId, self.table.roomId,
                                         player.clientId))
                # 互动表情配置
                mo.setResult('smiliesConf',
                             smilies.getConfDict(self.table.bigRoomId, userId))
                # 发送消息至客户端
                router.sendToUser(mo, userId)
예제 #25
0
파일: util.py 프로젝트: zhaozw/mjserver
 def getClientIdVer(self, uid):
     if uid < 10000:
         clientId = 3.7
     else:
         clientId = sessiondata.getClientIdVer(uid)
     return  clientId
예제 #26
0
    def sendTableInfoRes(self, userId, clientId, isrobot):
        '''
        给牌桌上的人发送tableInfo
        '''
        if TYPlayer.isRobot(userId):
            return

        ftlog.debug('userId',
                    userId,
                    "|clientId",
                    clientId,
                    'isrobot=',
                    isrobot,
                    caller=self)
        tableInfo = self.table._match_table_info
        if not tableInfo:
            ftlog.error('DizhuArenaSender.sendTableInfoRes NoMatchTableInfo',
                        'userId=', userId, 'clientId=', clientId, 'isrobot=',
                        isrobot)
            return

        player = self.table.getPlayer(userId)
        if not player:
            ftlog.error('DizhuArenaSender.sendTableInfoRes NoPlayer',
                        'userId=', userId, 'clientId=', clientId, 'isrobot=',
                        isrobot)
            return

        baseinfo = self.table.buildBasicInfo(False, userId, clientId)
        mo = self.createMsgPackRes("table_info")
        playMode = self.table.gamePlay.getPlayMode()
        isMatch = self.table.isMatch
        mo.setResult('isrobot', isrobot)
        mo.setResult('playMode', playMode)

        roomLevel = gdata.roomIdDefineMap()[self.table.roomId].configure.get(
            'roomLevel', 1)
        mo.setResult('roomLevel', roomLevel)
        roomName = self.table.room.roomConf['name'] if self.table.room else ''
        mo.setResult('roomName', roomName)
        mo.setResult('isMatch', isMatch)
        mo.setResult('notShowRank', 1)
        mo.setResult('info', baseinfo['info'])
        mo.setResult('config', baseinfo['config'])
        mo.setResult('stat', self.buildStatusInfoDict(player))
        mo.setResult('myCardNote', self.buildCardNote(player.seatIndex))
        if self.table.gameRound:
            mo.setResult('roundId', self.table.gameRound.roundId)

        if self.table._complain_open:
            clientIdVer = sessiondata.getClientIdVer(userId)
            clientIdLimit = dizhuconf.getAllComplainInfo().get(
                "clientIdLimit", 3.72)
            if clientIdVer >= clientIdLimit:
                mo.setResult('complain', self.table._complain)

        for i in xrange(len(self.table.seats)):
            seat = self.table.seats[i]
            oseat = self.buildSeatInfo(player, seat)
            seatuid = seat.userId
            if seatuid:
                seatPlayer = self.table.players[i]
                oseat.update(seatPlayer.datas)
                oseat['cardNote'] = seatPlayer.getCardNoteCount()
                seatPlayer.cleanDataAfterFirstUserInfo()
            else:
                oseat['uid'] = 0
            mo.setResult('seat' + str(i + 1), oseat)

        tmpobsr = []
        for _, obuser in self.table.observers.items():
            if obuser:
                tmpobsr.append((obuser.userId, obuser.name))

        mo.setResult('obsr', tmpobsr)
        mo.setResult('betpoolClose', 1)

        if player and player.getCardNoteCount() < 1:
            tableConf = self.table.room.roomConf.get(
                'tableConf') if self.table.room else None
            cardNoteChip = tableConf.get('cardNoteChip', 0)
            cardNoteDiamod = tableConf.get('cardNoteDiamond', 0)
            cardNote = dizhuconf.getCardNoteTips(userId,
                                                 player.datas.get('chip',
                                                                  0), clientId,
                                                 cardNoteChip, cardNoteDiamod)
            if cardNote:
                mo.setResult('cardNote', cardNote)

        # 发送消息至客户端
        router.sendToUser(mo, userId)
예제 #27
0
 def getClientVersionWithUserId(cls, userId):
     '''
     通过userId获取客户端的版本号
     '''
     ver = sessiondata.getClientIdVer(userId)
     return ver
예제 #28
0
 def getMatchInfo(self, userId, mp):
     inst = self.match.curInst
     conf = inst.matchConf if inst else self.match.matchConf
     state = self.convertState(inst.state) if inst else 0
     
     # 为了兼容老客户端m_enter的问题加的
     clientVer = sessiondata.getClientIdVer(userId)
     try:
         self.match.enter(userId)
     except:
         pass
     info = {}
     info['roomId'] = self.roomId
     info['type'] = conf.start.type
     try:
         clientId = sessiondata.getClientId(userId)
         info['name'] = dizhuhallinfo.getMatchSessionName(DIZHU_GAMEID, clientId, self.bigRoomId)
     except:
         info['name'] = self.roomConf['name']
     if conf.start.isUserCountType():
         info['minPlayer'] = conf.start.userCount
         info['maxPlayer'] = conf.start.userCount
     else:
         info['minPlayer'] = conf.start.userMinCount
         info['maxPlayer'] = conf.start.userMaxCount
         
     info['state'] = self.convertState(state)
     info['curTimeLeft'] = self.getMatchCurTimeLeft(inst) if inst else 0
     mp.setResult('info', info)
     mp.setResult('startTime', inst.startTimeStr if inst else '')
     matchDuration = int(self.calcMatchDuration(conf) / 60)
     mp.setResult('rankRewards', self.buildRankRewards(self.match.matchRankRewardsSelector.getRewardsList(userId, conf.rankRewardsList)))
     mp.setResult('duration', '约%d分钟' % (min(30, matchDuration)))
         
     if clientVer >= 3.37:
         mp.setResult('tips', {
                               'infos':conf.tips.infos,
                               'interval':conf.tips.interval
                               })
         record = MatchRecord.loadRecord(self.gameId, userId, self.match.matchConf.recordId)
         if record:
             mp.setResult('mrecord', {'bestRank':record.bestRank,
                                      'bestRankDate':record.bestRankDate,
                                      'isGroup':record.isGroup,
                                     'crownCount':record.crownCount,
                                     'playCount':record.playCount})
     mp.setResult('fees', matchutil.buildFees(conf.fees))
     # 报名费列表
     mp.setResult('feesList', matchutil.buildFeesList(userId, conf.fees) if conf.fees else [])
     # 分组赛奖励列表
     groupList = []
     if len(conf.stages) > 0 and conf.stages[0].rankRewardsList and conf.stages[0].groupingUserCount:
         groupList = self.buildRankRewards(conf.stages[0].rankRewardsList, defaultEnd = conf.stages[0].groupingUserCount)
     mp.setResult('groupRewardList', groupList)
     # 比赛进程 海选赛-》分组赛-》8强赛-》总决赛
     stagesList = self.buildStages(conf.stages) if conf.stages else []
     mp.setResult('stages', stagesList)
     # 比赛报名的前提条件
     conditionDesc = self.getMatchConditionDesc(self.roomId, userId)
     if conditionDesc:
         mp.setResult('conditionDesc', conditionDesc)
     # 比赛奖励分割线文字
     mp.setResult('splitWord', self.getMatchRewardSplitWord())
     # 获得比赛历史数据
     mp.setResult('hisitory', MatchHistoryHandler.getMatchHistory(userId, self.match.matchConf.recordId))