Пример #1
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)
Пример #2
0
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
 def _sendTodoTaskJumpHighRoom(cls, userId, playMode, clientId):
     # todo fix the pop wnd to ddz's
     if not playMode in dizhuconf.PLAYMODE_ALLSET:
         playMode = dizhuconf.PLAYMODE_DEFAULT
     chosenRoomId, _ = cls._chooseRoom(userId, DIZHU_GAMEID, playMode)
     if chosenRoomId:
         quick_start_ = TodoTaskQuickStart(DIZHU_GAMEID, chosenRoomId)
         info_str_ = dizhuconf.getQuickStartErrorMsg(
             TYRoom.ENTER_ROOM_REASON_GREATER_MAX)
         show_info_ = TodoTaskShowInfo(info_str_, True)
         show_info_.setSubCmd(quick_start_)
         try:
             if cls._useSelfPopWnd(userId):
                 todoTaskObj = TodoTaskHelper.encodeTodoTasks(quick_start_)
                 Alert.sendNormalAlert2Button(DIZHU_GAMEID, userId, '提示',
                                              info_str_, todoTaskObj[0],
                                              '确定', None, '取消')
                 return
         except:
             ftlog.error('_sendTodoTaskJumpHighRoom error userId = ',
                         userId, ' clientId = ', clientId, 'playMode = ',
                         playMode)
         msg = TodoTaskHelper.makeTodoTaskMsg(DIZHU_GAMEID, userId,
                                              show_info_)
         router.sendToUser(msg, userId)
     else:
         cls._sendTodoTaskToUser(userId,
                                 TYRoom.ENTER_ROOM_REASON_GREATER_ALL)
Пример #4
0
    def _handleSigninFeeNotEnoughException_V3_772(cls, room, ex, uid, mo):
        payOrder = ex.fee.getParam('payOrder')
        clientId = sessiondata.getClientId(uid)
        ftlog.debug("groupmatch._handleSigninFeeNotEnoughException_V3_772", "userId", uid, "fee.itemId=", ex.fee.assetKindId, "fee.params=", ex.fee.params)
        ftlog.debug("groupmatch._handleSigninFeeNotEnoughException_V3_772, userId=", uid, "payOrder=", payOrder)

        if payOrder:
            product, _shelves = hallstore.findProductByPayOrder(room.gameId, uid, clientId, payOrder)
            if not product:
                cls.sendDizhuFailureMsg(room.gameId, uid, '报名失败', ex.fee.failure, None)
                return

            buyType = ''
            btnTxt = ''
            if ex.fee.assetKindId == hallitem.ASSET_CHIP_KIND_ID: # 金币是报名费
                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

        ## 其他报名费/gotoshop
        todotask = ex.fee.getParam('todotask')
        todotask_str = None
        button_title = None
        ftlog.debug("groupmatch._handleSigninFeeNotEnoughException_V3_772, userId=", uid, "todotask=", todotask)
        if todotask:
            button_title = "去商城"
            todotask_str = hallpopwnd.decodeTodotaskFactoryByDict(todotask).newTodoTask(room.gameId, uid, clientId).toDict()
        cls.sendDizhuFailureMsg(room.gameId, uid, '报名失败', ex.fee.failure, todotask_str, button_title)
Пример #5
0
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)
Пример #6
0
def sendTableInviteShareTodoTask(userId, gameId, tableNo, playMode, cardCount,
                                 contentStr):
    '''牌桌上邀请处理
    '''
    shareId = hallshare.getShareId('mj_invite_play_share', userId, gameId)
    if shareId:
        share = hallshare.findShare(shareId)
        if not share:
            return

        retDesc = ''
        play_mode_dict = majiang_conf.get_room_other_config(gameId).get(
            'playmode_desc_map', {})
        retDesc += play_mode_dict.get(playMode, '') if playMode else ''
        retDesc += contentStr
        ftlog.debug('sendTableInviteShareTodoTask last retDesc:', retDesc)
        share.setDesc(retDesc)

        title = share.title.getValue(userId, gameId)
        title = '房间号:' + tableNo + ',' + title
        share.setTitle(title)

        todotask = share.buildTodotask(gameId, userId, 'mj_invite_play_share')
        mo = TodoTaskHelper.makeTodoTaskMsg(gameId, userId, todotask)
        router.sendToUser(mo, userId)
Пример #7
0
    def doPutMessage(self, gameId, fromUid, toUid, mtype, msg, ismgr, scope,
                     clientIds):
        button = runhttp.getParamStr('button', None)
        button = strutil.loads(button, ignoreException=True)
        data = None
        mo = MsgPack()

        if mtype == 0 and len(msg) > 0 and toUid > 0 and gameId >= 0:
            # 发送私人消息
            # 必须参数
            # 1)msg - 消息
            # 2)toUid - 接收消息的userId
            # 3)gameId
            data = pkmessage.sendPrivate(gameId, toUid, fromUid, msg, button)
        elif mtype == 1 and len(msg) > 0 and gameId >= 0:
            # 发送站内消息到全体用户
            # 必选参数
            # msg - 消息
            # gameId
            data = pkmessage.sendGlobal(gameId, msg, button)
        elif mtype == 2 and gameId > 0 and len(msg) > 0:
            # 发送LED
            # TODO 当前Game服务为4,5,6号 , 每个服务都发送
            mo.setCmd('send_led')
            mo.setParam('msg', msg)
            mo.setParam('gameId', gameId)
            mo.setParam('ismgr', 1)
            router.sendToAll(mo, gdata.SRV_TYPE_UTIL)
            data = True
        elif mtype == 3 and gameId > 0 and toUid > 0 and len(msg) > 0:
            # 封装popwnd
            # 必选参数
            # gameId
            # toUid 接收弹窗的userId
            # msg 弹窗消息内容
            task = TodoTaskShowInfo(msg, True)
            mo = TodoTaskHelper.makeTodoTaskMsg(gameId, toUid, task)
            # 将消息发送给此人
            router.sendToUser(mo, toUid)
            data = True
        elif mtype == 4 and gameId > 0 and len(msg) > 0 and len(scope) > 0:
            mo.setCmd('send_led')
            mo.setParam('msg', msg)
            ftlog.info('send_led new msg=', msg)
            mo.setParam('gameId', gameId)
            ftlog.info('send_led new gameId=', gameId)
            mo.setParam('ismgr', ismgr)
            ftlog.info('send_led new ismgr=', ismgr)
            mo.setParam('scope', scope)
            ftlog.info('send_led new scope=', scope)
            mo.setParam('clientIds', clientIds)
            ftlog.info('send_led new clientIds=', clientIds)
            router.sendToAll(mo, gdata.SRV_TYPE_UTIL)
            data = True

        if data == None:
            mo.setError(1, 'params error')
        else:
            mo.setResult('ok', 'true')
        return mo
Пример #8
0
 def sendTodoTaskShowInfo(cls, gameId, userId, info):
     '''
     弹窗提示TodoTask
     '''
     task = TodoTaskShowInfo(info, True)
     mo = TodoTaskHelper.makeTodoTaskMsg(gameId, userId, task)
     router.sendToUser(mo, userId)
Пример #9
0
    def doPutMessage(self, gameId, fromUid, toUid, mtype, msg, ismgr, scope, clientIds):
        button = runhttp.getParamStr('button', None)
        button = strutil.loads(button, ignoreException=True)
        data = None
        mo = MsgPack()

        if mtype == 0 and len(msg) > 0 and toUid > 0 and gameId >= 0:
            # 发送私人消息
            # 必须参数 
            # 1)msg - 消息
            # 2)toUid - 接收消息的userId
            # 3)gameId
            data = pkmessage.sendPrivate(gameId, toUid, fromUid, msg, button)
        elif mtype == 1 and len(msg) > 0 and gameId >= 0:
            # 发送站内消息到全体用户
            # 必选参数
            # msg - 消息
            # gameId
            data = pkmessage.sendGlobal(gameId, msg, button)
        elif mtype == 2 and gameId > 0 and len(msg) > 0:
            # 发送LED
            # TODO 当前Game服务为4,5,6号 , 每个服务都发送
            mo.setCmd('send_led')
            mo.setParam('msg', msg)
            mo.setParam('gameId', gameId)
            mo.setParam('ismgr', 1)
            router.sendToAll(mo, gdata.SRV_TYPE_UTIL)
            data = True
        elif mtype == 3 and gameId > 0 and toUid > 0 and len(msg) > 0:
            # 封装popwnd
            # 必选参数
            # gameId
            # toUid 接收弹窗的userId
            # msg 弹窗消息内容
            task = TodoTaskShowInfo(msg, True)
            mo = TodoTaskHelper.makeTodoTaskMsg(gameId, toUid, task)
            # 将消息发送给此人
            router.sendToUser(mo, toUid)
            data = True
        elif mtype == 4 and gameId > 0 and len(msg) > 0 and len(scope) > 0:
            mo.setCmd('send_led')
            mo.setParam('msg', msg)
            ftlog.info('send_led new msg=', msg)
            mo.setParam('gameId', gameId)
            ftlog.info('send_led new gameId=', gameId)
            mo.setParam('ismgr', ismgr)
            ftlog.info('send_led new ismgr=', ismgr)
            mo.setParam('scope', scope)
            ftlog.info('send_led new scope=', scope)
            mo.setParam('clientIds', clientIds)
            ftlog.info('send_led new clientIds=', clientIds)
            router.sendToAll(mo, gdata.SRV_TYPE_UTIL)
            data = True

        if data == None:
            mo.setError(1, 'params error')
        else:
            mo.setResult('ok', 'true')
        return mo
Пример #10
0
 def _handleSigninException(self, ex, userId, mp):
     msg = runcmd.getMsgPack()
     ddzver = msg.getParam('ddzver', 0) if msg else 0
     if ddzver < 3.772:
         infoTodotask = TodoTaskShowInfo(ex.message)
         mp = TodoTaskHelper.makeTodoTaskMsg(self.gameId, userId, infoTodotask)
         router.sendToUser(mp, userId)
     else:
         self.sendDizhuFailureMsg(self.gameId, userId, '报名失败', ex.message, None)
Пример #11
0
 def _handleSigninException(cls, room, ex, uid, mo):
     msg = runcmd.getMsgPack()
     ddzver = msg.getParam('ddzver', 0) if msg else 0
     if ddzver < 3.772:
         infoTodotask = TodoTaskShowInfo(ex.message)
         mo = TodoTaskHelper.makeTodoTaskMsg(room.gameId, uid, infoTodotask)
         router.sendToUser(mo, uid)
     else:
         cls.sendDizhuFailureMsg(room.gameId, uid, '报名失败', ex.message, None)
Пример #12
0
    def _handleSigninFeeNotEnoughException(self, ex, userId, mo):
        payOrder = ex.fee.getParam('payOrder')
        clientId = sessiondata.getClientId(userId)
        clientOs, _clientVer, _ = strutil.parseClientId(clientId)
        msg = runcmd.getMsgPack()
        ddzver = msg.getParam('ddzver', 0) if msg else 0

        if ftlog.is_debug():
            ftlog.debug(
                'DizhuErdayiMatchCtrlRoom._handleSigninFeeNotEnoughException',
                'roomId=', self.roomId, 'userId=', userId, 'feeItem=',
                ex.fee.assetKindId, 'feeParams=', ex.fee.params)

        if ddzver >= 3.772:
            self._handleSigninFeeNotEnoughException_V3_772(ex, userId, mo)
            return

        if payOrder:
            clientOs = clientOs.lower()
            product, _shelves = hallstore.findProductByPayOrder(
                self.gameId, userId, clientId, payOrder)
            if product:
                buyType = ''
                btnTxt = ''
                if ex.fee.assetKindId == hallitem.ASSET_CHIP_KIND_ID and clientOs == 'winpc':
                    user_diamond = userdata.getAttrInt(userId, '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)
                mp = TodoTaskHelper.makeTodoTaskMsg(self.gameId, userId,
                                                    orderShow)
                router.sendToUser(mp, userId)
                return True
        mp = TodoTaskHelper.makeTodoTaskMsg(self.gameId, userId,
                                            TodoTaskShowInfo(ex.fee.failure))
        router.sendToUser(mp, userId)
Пример #13
0
 def _sendChargeLeadTodoTask(cls, userId, roomId, clientId, mixId):
     bigRoomId = gdata.getBigRoomId(roomId)
     ctrRoomId = bigRoomId * 10000 + 1000
     roomConfig = gdata.roomIdDefineMap()[ctrRoomId].configure
     mixConfRoomId = cls.getMixConf(roomConfig, mixId).get('roomId', 0)
     if roomConfig.get('isMix', 0) and mixConfRoomId:
         roomId = mixConfRoomId
     product, _ = hallproductselector.selectLessbuyProduct(DIZHU_GAMEID, userId, clientId, roomId)
     t = TodoTaskPayOrder(product)
     msg = TodoTaskHelper.makeTodoTaskMsg(DIZHU_GAMEID, userId, t)
     router.sendToUser(msg, userId)
Пример #14
0
 def _sendTodoTaskToUserWithTip(cls, userId, tip):
     t = TodoTaskShowInfo(tip, True)
     try:
         if cls._useSelfPopWnd(userId):
             Alert.sendNormalAlert(DIZHU_GAMEID, userId, '提示', tip, None, '确定')
             return
     except:
         ftlog.error('DizhuQuickStart _sendTodoTaskToUserWithTip userId = ', userId,
                     'tip = ', tip)
     msg = TodoTaskHelper.makeTodoTaskMsg(DIZHU_GAMEID, userId, t)
     router.sendToUser(msg, userId)
Пример #15
0
    def getPray(cls, userId, foodId):
        '''
        获取奖励 
        '''
        food = cls.getFood(foodId)
        if not food:
            return None, None

        if not cls.consumeExpenses(userId, food):
            ftlog.warn('WorshipHelper.getPray',
                       'userId=', userId,
                       'foodId=', foodId,
                       'userChip=', userchip.getChip(userId),
                       'consumeChip=', food.chip)
            payOrder = {
                "contains": {
                    "count": userchip.getChip(userId),
                    "itemId": "user:chip"
                },
                "shelves": [
                    "lessbuychip"
                ]
            }
            clientId = sessiondata.getClientId(userId)
            product, _shelves = hallstore.findProductByPayOrder(DIZHU_GAMEID, userId, clientId, payOrder)
            if not product:
                Alert.sendNormalAlert(DIZHU_GAMEID, userId, '金币不足', '金币不足了, 请去充值吧', None, None)
                return None, None

            buyType = ''
            orderShow = TodoTaskOrderShow.makeByProduct('金币不足', '', product, buyType)
            orderShow.setParam('sub_action_btn_text', '确定')
            mo = TodoTaskHelper.makeTodoTaskMsg(DIZHU_GAMEID, userId, orderShow)
            router.sendToUser(mo, userId)
            return None, None

        # 更新用户花费
        cls.updateUserCost(userId, food.chip)

        # 拜到的奖励
        prayChip = food.choiceReward()
        UserBag.sendAssetsToUser(DIZHU_GAMEID, userId, {'itemId': 'user:chip', 'count': prayChip}, 'DDZ_WORSHIP_SYSTEM')

        # 保存的消息
        msg = cls.getMessageByFoodId(foodId)
        cls.pushRecord(strutil.dumps({
            'userId': userId,
            'msg': msg,
            'chip': prayChip,
            'costChip': food.chip,
        }))
        return {'chip': prayChip, 'msg': msg, 'costChip': food.chip}, userchip.getChip(userId)
Пример #16
0
 def _sendTodoTaskToUser(self, userId):
     tip = '当前版本较低,请前往商城购买记牌器~'
     t = TodoTaskShowInfo(tip, True)
     try:
         if ftlog.is_debug():
             ftlog.debug('DizhuTableCtr._sendTodoTaskToUser userId = ',
                         userId, 'roomId=', self.roomId, 'tableId=',
                         self.tableId, 'tip=', tip)
         msg = TodoTaskHelper.makeTodoTaskMsg(self.gameId, userId, t)
         router.sendToUser(msg, userId)
     except:
         ftlog.error('DizhuTableCtr._sendTodoTaskToUser userId=', userId,
                     'roomId=', self.roomId, 'tableId=', self.tableId,
                     'tip=', tip)
Пример #17
0
 def _sendTodoTaskToUser(cls, userId, errorCode):
     tip = dizhuconf.getQuickStartErrorMsg(errorCode)
     t = TodoTaskShowInfo(tip, True)
     try:
         if ftlog.is_debug():
             ftlog.debug('DizhuQuickStart test ddz pop TodoTaskShowInfo come in userId = ', userId)
         if cls._useSelfPopWnd(userId):
             Alert.sendNormalAlert(DIZHU_GAMEID, userId, '提示', tip, None, '确定')
             return
     except:
         ftlog.error('DizhuQuickStart _sendTodoTaskToUser userId=', userId,
                     'tip=', tip)
     msg = TodoTaskHelper.makeTodoTaskMsg(DIZHU_GAMEID, userId, t)
     router.sendToUser(msg, userId)
Пример #18
0
def sendTableInviteShareTodoTask(userId, gameId, tableNo, playMode, cardCount,
                                 contentStr):
    '''牌桌上邀请处理
    '''
    shareId = hallshare.getShareId('mj_invite_play_share', userId, gameId)
    if shareId:
        share = hallshare.findShare(shareId)
        if not share:
            return

        retDesc = ''
        play_mode_dict = majiang_conf.get_room_other_config(gameId).get(
            'playmode_desc_map', {})

        if gameId == 715:
            retDesc = contentStr
        else:
            retDesc += play_mode_dict.get(playMode, '') if playMode else ''
            retDesc += contentStr
        ftlog.debug('sendTableInviteShareTodoTask last retDesc:', retDesc)
        share.setDesc(retDesc)

        if gameId == 715:
            title = play_mode_dict.get(playMode, '') if playMode else ''
            title += ' - 房号:' + tableNo
        else:
            title = share.title.getValue(userId, gameId)
            title = '房间号:' + tableNo + ',' + title
        share.setTitle(title)
        ftlog.debug('sendTableInviteShareTodoTask newTitle:', title)

        url = share.url.getValue(userId, gameId)
        url += "?ftId=" + tableNo
        url += "?from=magicWindow"
        eParams = {}
        eParams['action'] = 'hall_enter_friend_table_direct'
        fParam = {}
        fParam['ftId'] = tableNo
        eParams['params'] = fParam
        paramStr = json.dumps(eParams)
        base64Str = base64.b64encode(paramStr)
        from urllib import quote
        url += "&enterParams=" + quote(base64Str)
        share.setUrl(url)
        ftlog.debug('sendTableInviteShareTodoTask newUrl:', url, ' ftId:',
                    tableNo, ' paramStr:', paramStr, ' base64Str:', base64Str)

        todotask = share.buildTodotask(gameId, userId, 'mj_invite_play_share')
        mo = TodoTaskHelper.makeTodoTaskMsg(gameId, userId, todotask)
        router.sendToUser(mo, userId)
Пример #19
0
def sendTableInviteShareTodoTask(userId, gameId, tableNo, playMode, cardCount, contentStr):
    '''牌桌上邀请处理
    '''
    shareId = hallshare.getShareId('mj_invite_play_share', userId, gameId)
    if shareId:
        share =  hallshare.findShare(shareId)
        if not share:
            return
        
        retDesc = ''
        play_mode_dict = majiang_conf.get_room_other_config(gameId).get('playmode_desc_map', {})

        if gameId == 715:
            retDesc = contentStr;
        else:
            retDesc += play_mode_dict.get(playMode,'') if playMode else ''
            retDesc += contentStr
        ftlog.debug('sendTableInviteShareTodoTask last retDesc:', retDesc)
        share.setDesc(retDesc)
        
        if gameId == 715:
            title = play_mode_dict.get(playMode,'') if playMode else ''
            title += ' - 房号:' + tableNo
        else:
            title = share.title.getValue(userId, gameId)
            title = '房间号:' + tableNo + ',' + title
        share.setTitle(title)
        ftlog.debug('sendTableInviteShareTodoTask newTitle:', title)
        
        url = share.url.getValue(userId, gameId)
        url += "?ftId=" + tableNo
        url += "?from=magicWindow"
        eParams = {}
        eParams['action'] = 'hall_enter_friend_table_direct'
        fParam = {}
        fParam['ftId'] = tableNo
        eParams['params'] = fParam
        paramStr = json.dumps(eParams)
        base64Str = base64.b64encode(paramStr)
        from urllib import quote
        url += "&enterParams=" + quote(base64Str)
        share.setUrl(url)
        ftlog.debug('sendTableInviteShareTodoTask newUrl:', url
                    , ' ftId:', tableNo
                    , ' paramStr:', paramStr
                    , ' base64Str:', base64Str)
        
        todotask = share.buildTodotask(gameId, userId, 'mj_invite_play_share')
        mo = TodoTaskHelper.makeTodoTaskMsg(gameId, userId, todotask)
        router.sendToUser(mo, userId)
Пример #20
0
 def _sendTodoTaskToUser(self, userId):
     tip = ''
     t = TodoTaskShowInfo(tip, True)
     try:
         if ftlog.is_debug():
             ftlog.debug('DizhuTableCtrMix._sendTodoTaskToUser userId = ',
                         userId, 'roomId=', self.roomId, 'tableId=',
                         self.tableId, 'tip=', tip)
         msg = TodoTaskHelper.makeTodoTaskMsg(DIZHU_GAMEID, userId, t)
         router.sendToUser(msg, userId)
     except:
         ftlog.error('DizhuTableCtrMix._sendTodoTaskToUser userId=', userId,
                     'roomId=', self.roomId, 'tableId=', self.tableId,
                     'tip=', tip)
Пример #21
0
    def _handleSigninFeeNotEnoughException_V3_772(self, ex, userId, mo):
        payOrder = ex.fee.getParam('payOrder')
        clientId = sessiondata.getClientId(userId)
        if ftlog.is_debug():
            ftlog.debug('DizhuCtrlRoomGroupMatch._handleSigninFeeNotEnoughException_V3_772',
                        'roomId=', self.roomId,
                        'userId=', userId,
                        'feeItem=', ex.fee.assetKindId,
                        'feeParams=', ex.fee.params)
        if payOrder:
            product, _shelves = hallstore.findProductByPayOrder(self.gameId, userId, clientId, payOrder)
            if not product:
                self.sendDizhuFailureMsg(self.gameId, userId, '报名失败', ex.fee.failure, None)
                return

            buyType = ''
            btnTxt = ''
            if ex.fee.assetKindId == hallitem.ASSET_CHIP_KIND_ID or ex.fee.assetKindId == hallitem.ASSET_DIAMOND_KIND_ID:
                buyType = 'charge'
                btnTxt = '确定'
            orderShow = TodoTaskOrderShow.makeByProduct(ex.fee.failure, '', product, buyType, ex.fee.count, ex.fee.assetKindId)
            orderShow.setParam('sub_action_btn_text', btnTxt)
            mo = TodoTaskHelper.makeTodoTaskMsg(self.gameId, userId, orderShow)
            router.sendToUser(mo, userId)
            return

        ## 其他报名费/gotoshop
        title = '报名失败'
        todotask = ex.fee.getParam('todotask')
        todotask_str = None
        button_title = None
        if todotask:
            button_title = "去商城"
            todotaskObj = hallpopwnd.decodeTodotaskFactoryByDict(todotask).newTodoTask(self.gameId, userId, clientId)
            if todotaskObj:
                todotask_str = todotaskObj.toDict()
        itemCount = 0
        itemName = ''
        itemDes = ''
        itemUrl = ''
        if 'item' in ex.fee.assetKindId and ex.fee.count > 0:
            assetKind = hallitem.itemSystem.findAssetKind(ex.fee.assetKindId)
            if assetKind:
                title = '道具不足'
                itemCount = ex.fee.count
                itemName = assetKind.displayName
                itemDes = assetKind.desc
                itemUrl = assetKind.pic
        self.sendDizhuFailureMsg(self.gameId, userId, title, ex.fee.failure, todotask_str, button_title, itemCount,
                                 itemName, itemDes, itemUrl)
Пример #22
0
def sendFriendInviteEnterGameTodotask(userId, gameId, play_mode, roomId, tableId, info_str):
    """ 构造从大厅主界面进桌子的todotask
    """
    enter_param = {
        'type': 'quickstart',
        'pluginParams': {
            'play_mode': play_mode,
            'roomId': roomId,
            'tableId': tableId,
            'gameType': 9  # TODO: 写死了9,因为目前只有贵宾桌使用到了这个功能
        }
    }
    todotask = TodoTaskEnterGameNew(gameId, enter_param)
    show_info_ = TodoTaskShowInfo(info_str, True)
    show_info_.setSubCmd(todotask)
    msg = TodoTaskHelper.makeTodoTaskMsg(gameId, userId, show_info_)
    router.sendToUser(msg, userId)
Пример #23
0
def sendFriendInviteEnterGameTodotask(userId, gameId, play_mode, roomId, tableId, info_str):
    """ 构造从大厅主界面进桌子的todotask
    """
    enter_param = {
                 'type':         'quickstart',
                 'pluginParams': {
                     'play_mode':       play_mode,
                     'roomId':          roomId,
                     'tableId':         tableId,
                     'gameType':        9   # TODO: 写死了9,因为目前只有贵宾桌使用到了这个功能
                 }
            }
    todotask = TodoTaskEnterGameNew(gameId, enter_param)
    show_info_ = TodoTaskShowInfo(info_str, True)
    show_info_.setSubCmd(todotask)
    msg = TodoTaskHelper.makeTodoTaskMsg(gameId, userId, show_info_)
    router.sendToUser(msg, userId)
Пример #24
0
    def _sendToDoTaskJumpToStore(cls, userId):
        if not cls._useSelfPopWnd(userId):
            win = hallpopwnd.makeTodotaskJumpToStoreOrHall("您的金币不足,请购买金币或参加免费比赛~")
            msg = TodoTaskHelper.makeTodoTaskMsg(DIZHU_GAMEID, userId, win)
            router.sendToUser(msg, userId)
            return

        message = "您的金币不足,请购买金币或参加免费比赛~"
        confirmTodotask = TodoTaskDiZhuEvent('dizhu_goto_store')
        cancelTodotask = TodoTaskDiZhuEvent('dizhu_back_hall')
        if ftlog.is_debug():
            ftlog.debug('DizhuQuickStart _sendToDoTaskJumpToStore',
                        'userId=', userId,
                        'confirmTodotask=', confirmTodotask,
                        'cancelTodotask=', cancelTodotask.toDict())
        Alert.sendNormalAlert2Button(DIZHU_GAMEID, userId, '提示', message,
                                     confirmTodotask.toDict(), '确定',
                                     cancelTodotask.toDict(), '取消')
Пример #25
0
    def payOrder(payOrderParams, userId, failure):
        '''
        比赛报名费不足的充值引导
        '''
        ftlog.debug('userId:', userId
                    , ' payOrderParams:', payOrderParams
                    , ' failure:', failure)
        clientId = sessiondata.getClientId(userId)
        product, _shelves = hallstore.findProductByPayOrder(DIZHU_GAMEID, userId, clientId, payOrderParams)
        ftlog.debug('product:', product
                    , ' shelves:', _shelves)
        
        if not product:
            return False

        orderShow = TodoTaskOrderShow.makeByProduct(failure, '', product, '')
        mo = TodoTaskHelper.makeTodoTaskMsg(DIZHU_GAMEID, userId, orderShow)
        router.sendToUser(mo, userId)
        return True
Пример #26
0
    def _handleSigninFeeNotEnoughException_V3_772(self, ex, userId, mo):
        payOrder = ex.fee.getParam('payOrder')
        clientId = sessiondata.getClientId(userId)
        if ftlog.is_debug():
            ftlog.debug(
                'DizhuErdayiMatchCtrlRoomProtocol._handleSigninFeeNotEnoughException_V3_772',
                'roomId=', self.roomId, 'userId=', userId, 'feeItem=',
                ex.fee.assetKindId, 'feeParams=', ex.fee.params)
        if payOrder:
            product, _shelves = hallstore.findProductByPayOrder(
                self.gameId, userId, clientId, payOrder)
            if not product:
                self._sendDizhuFailureMsg(self.gameId, userId, '报名失败',
                                          ex.fee.failure, None)
                return

            buyType = ''
            btnTxt = ''
            if ex.fee.assetKindId == hallitem.ASSET_CHIP_KIND_ID or ex.fee.assetKindId == hallitem.ASSET_DIAMOND_KIND_ID:
                buyType = 'charge'
                btnTxt = '确定'
            orderShow = TodoTaskOrderShow.makeByProduct(
                ex.fee.failure, '', product, buyType)
            orderShow.setParam('sub_action_btn_text', btnTxt)
            mo = TodoTaskHelper.makeTodoTaskMsg(self.gameId, userId, orderShow)
            router.sendToUser(mo, userId)
            return

        ## 其他报名费/gotoshop
        todotask = ex.fee.getParam('todotask')
        todotask_str = None
        button_title = None
        if todotask:
            button_title = "去商城"
            todotaskObj = hallpopwnd.decodeTodotaskFactoryByDict(
                todotask).newTodoTask(self.gameId, userId, clientId)
            if todotaskObj:
                todotask_str = todotaskObj.toDict()
        self._sendDizhuFailureMsg(self.gameId, userId, '报名失败', ex.fee.failure,
                                  todotask_str, button_title)
Пример #27
0
    def sendShare(self, gameId, userId, shareLoc):
        '''
        通用活动todotask调用接口
        '''
        try:
            share, playground = shareLoc.handler(userId)
            if not share:
                if ftlog.is_debug():
                    ftlog.debug('Share.sendShare notFoundShare gameId=',
                                gameId, 'userId=', userId, 'shareLoc=',
                                shareLoc.name)
                return

            if ftlog.is_debug():
                ftlog.debug('Share.sendShare notFoundShare gameId=', gameId,
                            'userId=', userId, 'shareLoc=', shareLoc.name,
                            'shareId=', share.shareId, 'playground=',
                            playground)

            canReward, rewardCount = hallshare.checkCanReward(
                userId, share, pktimestamp.getCurrentTimestamp())
            if not canReward:
                if ftlog.is_debug():
                    ftlog.debug('Share.sendShare gameId=', gameId, 'userId=',
                                userId, 'shareLoc=', shareLoc.name, 'shareId=',
                                share.shareId, 'playground=', playground,
                                'rewardCount=', rewardCount, 'maxRewardCount=',
                                share.maxRewardCount)
                return

            ftlog.debug('Share.sendShare gameId=', gameId, 'userId=', userId,
                        'shareLoc=', shareLoc.name, 'shareId=', share.shareId,
                        'playground=', playground, 'rewardCount=', rewardCount)

            todotask = share.buildTodotask(gameId, userId, shareLoc.name)
            mo = TodoTaskHelper.makeTodoTaskMsg(gameId, userId, todotask)
            router.sendToUser(mo, userId)
        except:
            ftlog.error('Share.sendShare notFoundShare gameId=', gameId,
                        'userId=', userId, 'shareLoc=', shareLoc.name)
Пример #28
0
def sendTableInviteShareTodoTask(userId, gameId, tableNo, playMode, cardCount, contentStr):
    '''牌桌上邀请处理
    '''
    shareId = hallshare.getShareId('mj_invite_play_share', userId, gameId)
    if shareId:
        share = hallshare.findShare(shareId)
        if not share:
            return

        retDesc = ''
        play_mode_dict = majiang_conf.get_room_other_config(gameId).get('playmode_desc_map', {})
        retDesc += play_mode_dict.get(playMode, '') if playMode else ''
        retDesc += contentStr
        ftlog.debug('sendTableInviteShareTodoTask last retDesc:', retDesc)
        share.setDesc(retDesc)

        title = share.title.getValue(userId, gameId)
        title = '房间号:' + tableNo + ',' + title
        share.setTitle(title)

        todotask = share.buildTodotask(gameId, userId, 'mj_invite_play_share')
        mo = TodoTaskHelper.makeTodoTaskMsg(gameId, userId, todotask)
        router.sendToUser(mo, userId)
Пример #29
0
 def _sendTodoTaskJumpHighRoom(cls, userId, playMode, clientId, **kwargs):
     if not playMode in dizhuconf.PLAYMODE_ALLSET:
         playMode = dizhuconf.PLAYMODE_DEFAULT
     ctrlRoomIds, _ = cls._getQuickStartRoomList(userId, playMode, rankId=kwargs.get('rankId', '-1'))  # 快开列表
     chosenRoomId, reason, mixId = cls._chooseRoom(userId, ctrlRoomIds, rankId=kwargs.get('rankId', '-1'))
     if chosenRoomId and reason == ENTER_ROOM_REASON_OK:
         quick_start_ = TodoTaskQuickStart(DIZHU_GAMEID, chosenRoomId)
         quick_start_.setParam('mixId', mixId)
         info_str_ = dizhuconf.getQuickStartErrorMsg(ENTER_ROOM_REASON_GREATER_MAX)
         show_info_ = TodoTaskShowInfo(info_str_, True)
         show_info_.setSubCmd(quick_start_)
         try:
             if cls._useSelfPopWnd(userId):
                 todoTaskObj = TodoTaskHelper.encodeTodoTasks(quick_start_)
                 Alert.sendNormalAlert2Button(DIZHU_GAMEID, userId, '提示', info_str_, todoTaskObj[0], '确定', None, '取消')
                 return
         except:
             ftlog.error('DizhuQuickStart _sendTodoTaskJumpHighRoom error userId = ', userId,
                         ' clientId = ', clientId,
                         'playMode = ', playMode)
         msg = TodoTaskHelper.makeTodoTaskMsg(DIZHU_GAMEID, userId, show_info_)
         router.sendToUser(msg, userId)
     else:
         cls._sendTodoTaskToUser(userId, ENTER_ROOM_REASON_GREATER_ALL)
Пример #30
0
 def sendTodoTask(self, gameId, userId, info):
     task = TodoTaskShowInfo(info, True)
     mo = TodoTaskHelper.makeTodoTaskMsg(gameId, userId, task)
     router.sendToUser(mo, userId)
Пример #31
0
def sendPopTipMsg(userId, msg):
    task = TodoTaskPopTip(msg)
    task.setParam('duration', 3)
    mo = TodoTaskHelper.makeTodoTaskMsg(HALL_GAMEID, userId, task)
    router.sendToUser(mo, userId) 
Пример #32
0
 def sendPopTip(cls, userId, text):
     todotask = TodoTaskPopTip(text)
     mo = TodoTaskHelper.makeTodoTaskMsg(DIZHU_GAMEID, userId, todotask)
     router.sendToUser(mo, userId)
Пример #33
0
def sendPopTipMsg(userId, msg):
    task = TodoTaskPopTip(msg)
    task.setParam('duration', 3)
    mo = TodoTaskHelper.makeTodoTaskMsg(HALL_GAMEID, userId, task)
    router.sendToUser(mo, userId)
Пример #34
0
    def _openCardNote(self, seat):
        # 比赛场局记牌器在下发此消息时扣除背包金币,非比赛场局记牌器在结算时扣除带入金币
        #self.isMatch or self.table.runConf.cardNoteChipConsumeUserChip:
        if seat.player.getCardNoteCount() <= 0:
            cardNoteDiamondCount = seat.player.mixConf.get(
                'tableConf', {}).get('cardNoteDiamond', 0)
            try:
                if cardNoteDiamondCount == 0:

                    trueDelta, _final = user_remote.incrUserChip(
                        seat.userId, self.table.gameId,
                        -seat.player.mixConf.get('tableConf', {}).get(
                            'cardNoteChip', 0), 'MATCH_CARDNOTE_BETCHIP', 0,
                        seat.player.clientId)
                    if ftlog.is_debug():
                        ftlog.debug(
                            'DizhuTableCtrlMix._openCardNote', 'tableId=',
                            self.tableId, 'userId=', seat.userId,
                            'cardNoteChip=',
                            seat.player.mixConf.get('tableConf',
                                                    {}).get('cardNoteChip',
                                                            0), 'chip=',
                            seat.player.datas.get('chip'))
                    if trueDelta != -seat.player.mixConf.get(
                            'tableConf', {}).get('cardNoteChip', 0):
                        if ftlog.is_debug():
                            ftlog.warn('DizhuTableCtrlMix._openCardNote',
                                       'tableId=', self.tableId, 'userId=',
                                       seat.userId, 'cardNoteCount=',
                                       seat.player.getCardNoteCount(), 'chip=',
                                       seat.player.datas.get('chip'), 'err=',
                                       'ChipNotEnough')
                        return
                else:
                    # 钻石购买 10钻石 = 1日记牌器

                    # 兼容pc端
                    clientOs, clientVer, _ = strutil.parseClientId(
                        seat.player.clientId)
                    clientOs = clientOs.lower()
                    if clientOs == 'winpc':
                        self._sendTodoTaskToUser(seat.player.userId)
                        return

                    # 大厅版本4.56以上直接弹出贵族月卡购买弹窗
                    if clientVer > 4.56:
                        userId = seat.player.userId
                        clientId = sessiondata.getClientId(userId)
                        template, templateName = findTodotaskTemplate(
                            DIZHU_GAMEID, userId, clientId, 'monthlyBuy')
                        todoTaskObj = template.newTodoTask(
                            DIZHU_GAMEID, userId,
                            clientId) if template else None
                        if ftlog.is_debug():
                            ftlog.debug(
                                'mixTable.findTodotaskTemplate.monthlyBuy',
                                'userId=', userId, 'template=', template,
                                'templateName=', templateName, 'templateDict=',
                                todoTaskObj.toDict() if todoTaskObj else None)
                        if todoTaskObj:
                            TodoTaskHelper.sendTodoTask(
                                DIZHU_GAMEID, userId, todoTaskObj)
                            return

                    consumeCount, final = user_remote.consumeAsset(
                        DIZHU_GAMEID, seat.player.userId,
                        ASSET_DIAMOND_KIND_ID, cardNoteDiamondCount,
                        'MATCH_CARDNOTE_BETDIAMOND',
                        seat.player.mixConf.get('roomId') or self.roomId)
                    if consumeCount != cardNoteDiamondCount:
                        # 弹出提示商城购买钻石todotask
                        clientId = sessiondata.getClientId(seat.player.userId)
                        payOrder = {
                            "priceDiamond": {
                                "count": cardNoteDiamondCount,
                                "minCount": cardNoteDiamondCount,
                                "maxCount": -1
                            },
                            "buyTypes": ["charge"]
                        }
                        product, _shelves = hallstore.findProductByPayOrder(
                            self.gameId, seat.player.userId, clientId,
                            payOrder)
                        if product:
                            buyType = 'charge'
                            btnTxt = '确定'
                            orderShow = TodoTaskOrderShow.makeByProduct(
                                '您的钻石不足%s个,请去商城购买' % cardNoteDiamondCount, '',
                                product, buyType)
                            orderShow.setParam('sub_action_btn_text', btnTxt)
                            mo = TodoTaskHelper.makeTodoTaskMsg(
                                self.gameId, seat.player.userId, orderShow)
                            router.sendToUser(mo, seat.player.userId)
                        return
                    # 获得一日记牌器
                    user_remote.addAsset(
                        DIZHU_GAMEID, seat.player.userId,
                        'item:' + str(ITEM_CARD_NOTE_KIND_ID), 1,
                        'MATCH_CARDNOTE_BETDIAMOND',
                        seat.player.mixConf.get('roomId') or self.roomId)
            except:
                if ftlog.is_debug():
                    ftlog.error('DizhuTableCtrlMix._openCardNote', 'tableId=',
                                self.tableId, 'userId=',
                                seat.userId, 'cardNoteCount=',
                                seat.player.getCardNoteCount(), 'chip=',
                                seat.player.datas.get('chip'))
                return
        if seat.player.openCardNote():
            ftlog.info('DizhuTableCtrlMix._openCardNote', 'tableId=',
                       self.tableId, 'userId=', seat.userId, 'cardNoteCount=',
                       seat.player.getCardNoteCount(), 'buyinChip=',
                       seat.player.datas.get('chip'))
            self.table.fire(CardNoteOpenedEvent(self.table, seat))
Пример #35
0
 def sendToDoTask(self, userId, todotasks):
     mo = TodoTaskHelper.makeTodoTaskMsg(DIZHU_GAMEID, userId, todotasks)
     router.sendToUser(mo, userId)
Пример #36
0
 def sendTodoTask(self, gameId, userId, info):
     task = TodoTaskShowInfo(info, True)
     mo = TodoTaskHelper.makeTodoTaskMsg(gameId, userId, task)
     router.sendToUser(mo, userId)
Пример #37
0
    def _do_room__revival(self, msg):
        userId = msg.getParam('userId')
        isOK = msg.getParam('isOk', 0)
        player = self.match.findPlayer(userId)
        reviveCondition = player.stage.stageConf.reviveCondition
        if player and reviveCondition:
            itemId = reviveCondition.get('fee', {}).get('itemId')
            count = reviveCondition.get('fee', {}).get('count')
            if itemId and count and isOK:
                userAssets = hallitem.itemSystem.loadUserAssets(player.userId)
                timestamp = pktimestamp.getCurrentTimestamp()
                balance = userAssets.balance(HALL_GAMEID, itemId, timestamp)
                if balance and balance >= count:
                    _, consumeCount, _ = userAssets.consumeAsset(DIZHU_GAMEID, itemId, count, timestamp, 'MATCH_REVIVE', 0)
                    if consumeCount == count:
                        # 消费成功, 考虑锁的关系,时间竞争
                        ret = self.match.currentInstance.doUserRevive(player, True)
                        if not ret:
                            # 退费
                            userAssets.addAsset(DIZHU_GAMEID, itemId, count, timestamp, 'MATCH_REVIVE', 0)
                            ftlog.info('DizhuCtrlRoomArenaMatch._do_room__m_revive returnFee',
                                       'gameId=', self.gameId,
                                       'roomId=', self.roomId,
                                       'userId=', userId,
                                       'stageIndex=', player.stage.index,
                                       'reviveCondition=', reviveCondition)
                        if ret:
                            # 日志记录
                            try:
                                sequence = int(player.matchInst.instId.split('.')[1])
                                matchutil.report_bi_game_event('MATCH_REVIVE', player.userId, player.matchInst.matchId, 0, sequence, 0, 0, 0,
                                                               [int(player.mixId) if player.mixId else 0, player.stage.index, count], 'match_revive')

                                ftlog.info('DizhuCtrlRoomArenaMatch._do_room__m_revive success',
                                           'gameId=', self.gameId,
                                           'roomId=', self.roomId,
                                           'userId=', userId,
                                           'stageIndex=', player.stage.index,
                                           'reviveCondition=', reviveCondition)
                            except Exception, e:
                                ftlog.error('DizhuCtrlRoomArenaMatch._do_room__m_revive',
                                            'gameId=', self.gameId,
                                            'userId=', userId,
                                            'err=', e.message)

                else:
                    # 发送不够的todotask
                    payOrder = reviveCondition.get('fee', {}).get('params', {}).get('payOrder')
                    failure = reviveCondition.get('fee', {}).get('params', {}).get('failure')
                    mo = TodoTaskHelper.makeTodoTaskMsg(self.gameId, player.userId, TodoTaskShowInfo(failure))
                    if payOrder:
                        clientId = sessiondata.getClientId(player.userId)
                        product, _shelves = hallstore.findProductByPayOrder(self.gameId, player.userId, clientId, payOrder)
                        if product:
                            orderShow = TodoTaskOrderShow.makeByProduct(failure, '', product, 'charge', reviveCondition.get('fee', {}).get('count', 0), reviveCondition.get('fee', {}).get('itemId', ''))
                            orderShow.setParam('sub_action_btn_text', '购买')
                            mo = TodoTaskHelper.makeTodoTaskMsg(self.gameId, player.userId, orderShow)
                    router.sendToUser(mo, userId)

            else:
                self.match.currentInstance.doUserRevive(player, False)