Exemple #1
0
def makeTodoTaskZhuanyun_(gameId, userId, clientId, benefitsSend, userBenefits, roomId):
    from hall.entity import hallproductselector
    if ftlog.is_debug():
        ftlog.debug('hallpopwnd.makeTodoTaskZhuanyun gameId=', gameId,
                    'userId=', userId,
                    'clientId=', clientId,
                    'benefitsSend=', benefitsSend,
                    'userBenefits=', userBenefits.__dict__,
                    'roomId=', roomId)
    clientOs, _clientVer, _ = strutil.parseClientId(clientId)
    clientOs = clientOs.lower()

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

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

    user_diamond = pkuserdata.getAttr(userId, 'diamond')
    if user_diamond >= int(product.priceDiamond):
        chip = product.getMinFixedAssetCount(hallitem.ASSET_CHIP_KIND_ID)
        show_str = u'运气不好,来个转运礼包!%s元得%s万金币。' % (product.price, chip)
        buy_type = 'consume'
        btn_txt = u'兑换'
    else:
        show_str = u'运气不好~,买点金币战个痛快吧!'
        buy_type = 'charge'
        btn_txt = u'去充值'
    orderShow = TodoTaskOrderShow.makeByProduct(show_str, '', product, buy_type)
    orderShow.setParam('sub_action_btn_text', btn_txt)
    return orderShow
Exemple #2
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)
Exemple #3
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)
Exemple #4
0
    def _onEnterRoomFailed(cls,
                           msg,
                           checkResult,
                           userId,
                           gameId,
                           clientId,
                           roomId=0):
        '''进入房间失败回调函数'''
        ftlog.warn("|userId, reason, roomId:",
                   userId,
                   checkResult,
                   roomId,
                   caller=cls)  # 调用最小房间金币不够充值提醒的todotask
        if not roomId:
            roomId = msg.getParam('candidateRoomId', 0)
        if checkResult == TYRoom.ENTER_ROOM_REASON_LESS_MIN or checkResult == 104:
            from hall.entity import hallproductselector
            product, _ = hallproductselector.selectLessbuyProduct(
                gameId, userId, clientId, roomId)
            if product:
                from hall.entity.todotask import TodoTaskOrderShow
                todotask = TodoTaskOrderShow.makeByProduct(
                    "金币不够啦,买一个超值礼包吧!", "", product)
                if todotask:
                    TodoTaskHelper.sendTodoTask(gameId, userId, todotask)

        mo = MsgPack()
        mo.setCmd('quick_start')
        mo.setResult('gameId', gameId)
        mo.setResult('userId', userId)
        mo.setError(checkResult, '进入房间失败,请稍后重试')
        router.sendToUser(mo, userId)
Exemple #5
0
def makeTodoTaskZhuanyun_(gameId, userId, clientId, benefitsSend, userBenefits,
                          roomId):
    from hall.entity import hallproductselector
    if ftlog.is_debug():
        ftlog.debug('hallpopwnd.makeTodoTaskZhuanyun gameId=', gameId,
                    'userId=', userId, 'clientId=', clientId, 'benefitsSend=',
                    benefitsSend, 'userBenefits=', userBenefits.__dict__,
                    'roomId=', roomId)
    clientOs, _clientVer, _ = strutil.parseClientId(clientId)
    clientOs = clientOs.lower()

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

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

    user_diamond = pkuserdata.getAttr(userId, 'diamond')
    if user_diamond >= int(product.priceDiamond):
        chip = product.getMinFixedAssetCount(hallitem.ASSET_CHIP_KIND_ID)
        show_str = u'运气不好,来个转运礼包!%s元得%s万金币。' % (product.price, chip)
        buy_type = 'consume'
        btn_txt = u'兑换'
    else:
        show_str = u'运气不好~,买点金币战个痛快吧!'
        buy_type = 'charge'
        btn_txt = u'去充值'
    orderShow = TodoTaskOrderShow.makeByProduct(show_str, '', product,
                                                buy_type)
    orderShow.setParam('sub_action_btn_text', btn_txt)
    return orderShow
Exemple #6
0
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)
Exemple #7
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)
Exemple #8
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)
    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
Exemple #10
0
 def _onEnterRoomFailed(cls, msg, checkResult, userId, gameId, clientId, roomId=0):
     '''进入房间失败回调函数'''
     ftlog.warn("|userId, reason, roomId:", userId, checkResult, roomId, caller=cls)  # 调用最小房间金币不够充值提醒的todotask
     if not roomId:
         roomId = msg.getParam('candidateRoomId', 0)
     if checkResult == TYRoom.ENTER_ROOM_REASON_LESS_MIN or checkResult == 104:
         from hall.entity import hallproductselector
         product, _ = hallproductselector.selectLessbuyProduct(gameId, userId, clientId, roomId)
         if product:
             from hall.entity.todotask import TodoTaskOrderShow
             todotask = TodoTaskOrderShow.makeByProduct("金币不够啦,买一个超值礼包吧!", "", product)
             if todotask:
                 TodoTaskHelper.sendTodoTask(gameId, userId, todotask)
     mo = MsgPack()
     mo.setCmd('quick_start')
     mo.setResult('gameId', gameId)
     mo.setResult('userId', userId)
     mo.setResult('reason', checkResult)
     router.sendToUser(mo, userId)
Exemple #11
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)
Exemple #12
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)
Exemple #13
0
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)
Exemple #14
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))
Exemple #15
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)
Exemple #16
0
    def getFishReward(cls, userId, baitId):
        # 钓到没钓到标志
        rewardCount = 0
        record = ''
        fishPic = ''
        couponFishPic = ''
        exchangeDes = ''
        deltaChip = 0
        deltaCouponCount = 0

        # 检查用户Id, baitId 是否匹配, 获取 bait 消费金币
        userName = str(userdata.getAttrs(userId, ['name'])[0])
        bait = cls.getBait(baitId)
        consumeChip = bait.chip if bait else 0

        if not consumeChip or not cls.consumeExpenses(
                userId,
                TYContentItem.decodeFromDict({
                    'itemId': 'user:chip',
                    'count': consumeChip
                })):
            ftlog.warn('FishHelper.getFishReward', 'userId=',
                       userId, 'baitId=', baitId, 'userChip=',
                       userchip.getChip(userId), 'consumeChip=', consumeChip)
            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

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

        # 随机获得珍珠, 存入数据库
        couponFish = cls.getCouponFishList()[0]
        # 判断鱼饵有没有奖券鱼的配置
        item = dizhu_util.getItemByWeight(
            bait.couponFishRewards) if bait.couponFishRewards else None
        couponCount = item.count if item else 0
        count = loadUserFishingCount(userId, couponFish.id)
        if couponCount:
            assetKind = hallitem.itemSystem.findAssetKind('user:coupon')
            couponCount = couponCount * 1.0 / assetKind.displayRate
            couponCount = int(couponCount) if couponCount.is_integer(
            ) else round(couponCount, 2)
            rewardCount += 1
            count += 1
            couponFishPic = couponFish.pic
            if count >= couponFish.needNum:
                count = 0
                # 发送奖券
                dictionary = {
                    'zhenzhu_count': couponFish.needNum,
                    'coupon_count': couponCount
                }
                record = json.dumps(
                    cls.getRealUserMail(cls.getMail(couponFish, True, False),
                                        dictionary))
                exchangeDes = json.dumps(
                    cls.getRealUserMail(cls.getMail(couponFish, True, True),
                                        dictionary))
                dictionary2 = {
                    'user_name': userName,
                    'zhenzhu_count': couponFish.needNum,
                    'coupon_count': couponCount
                }
                record2 = json.dumps(
                    cls.getRealUserMail(cls.getMail(couponFish, False, True),
                                        dictionary2))
                saveUserFishingCount(userId, couponFish.id, count)
                UserBag.sendAssetsToUser(DIZHU_GAMEID, userId, {
                    'itemId': item.assetKindId,
                    'count': item.count
                }, 'DDZ_FISHING_SYSTEM')
                deltaCouponCount = item.count
                cls.pushRecord(record2)
                if ftlog.is_debug():
                    ftlog.debug('FishHelper.getFishReward coupon exchangeDes',
                                'userId=', userId, 'fishId=', couponFish.id,
                                'exchangeDes=', exchangeDes)
            else:
                # 获得一个奖券鱼
                dictionary = {
                    'zhenzhu_count': couponFish.needNum,
                    'coupon_count': couponCount
                }
                record = json.dumps(
                    cls.getRealUserMail(cls.getMail(couponFish, True, False),
                                        dictionary))
                dictionary2 = {
                    'user_name': userName,
                    'zhenzhu_count': couponFish.needNum,
                    'coupon_count': couponCount
                }
                record2 = json.dumps(
                    cls.getRealUserMail(cls.getMail(couponFish, False, False),
                                        dictionary2))
                saveUserFishingCount(userId, couponFish.id, count)
                cls.pushRecord(record2)
                if ftlog.is_debug():
                    ftlog.debug('FishHelper.getFishReward coupon', 'userId=',
                                userId, 'fishId=', couponFish.id, 'record=',
                                record)

        # 随机获取金币奖励,对应bait下普通鱼
        userBaits = filter(lambda x: x.id == baitId, _fishingConf.baits)
        fish = userBaits[0].choiceFish()
        if fish.id:  # 钓到鱼了
            reward = fish.choiceReward()
            chip = reward.count
            if chip:
                rewardCount += 1
                bigFish = cls.getSuperFishList()[0]
                bigReward = dizhu_util.getItemByWeight(
                    bait.superFishRewards) if bait.superFishRewards else None
                if bigReward and bigReward.count and fish.id == bait.fishList[
                        -1].id:  # roll 大鱼的机会
                    fish = bigFish
                    chip = bigReward.count
                fishPic = fish.pic
                dictionary = {
                    'random_message': cls.getMessageByFishId(fish.id),
                    'fish_name': fish.name,
                    'chip_count': chip
                }
                if rewardCount == 2:
                    record = json.dumps(
                        cls.getRealUserMail(cls.getCombinationMail(),
                                            dictionary))
                else:
                    record = json.dumps(
                        cls.getRealUserMail(cls.getMail(fish, True),
                                            dictionary))
                dictionary2 = {
                    'user_name': userName,
                    'fish_name': fish.name,
                    'chip_count': chip,
                    'random_message': cls.getMessageByFishId(fish.id)
                }
                record2 = json.dumps(
                    cls.getRealUserMail(cls.getMail(fish, False), dictionary2))
                UserBag.sendAssetsToUser(DIZHU_GAMEID, userId, {
                    'itemId': 'user:chip',
                    'count': chip
                }, 'DDZ_FISHING_SYSTEM')
                cls.pushRecord(record2)
                deltaChip = chip

                if ftlog.is_debug():
                    ftlog.debug('FishHelper.getFishReward', 'userId=', userId,
                                'fishId=', fish.id, 'record=', record)
        return {
            'rewardCount':
            rewardCount,
            'desc':
            json.loads(record)
            if rewardCount and record else cls.getailureMail(),
            'couponFishPic':
            couponFishPic,
            'fishPic':
            fishPic,
            'exchangeDes':
            json.loads(exchangeDes) if exchangeDes else '',
            'finalCouponCount':
            userdata.getAttr(userId, 'coupon'),
            'finalChip':
            userchip.getChip(userId),
            'couponFishCount':
            count,
            'deltaChip':
            deltaChip,
            'deltaCouponCount':
            deltaCouponCount
        }