示例#1
0
def generateDizhuLoseStreakBuffGift(userId, clientId):
    template, templateName = findTodotaskTemplate(DIZHU_GAMEID, userId, clientId, 'dizhuLoseStreakBuffGift')
    if ftlog.is_debug():
        ftlog.debug('dizhupopwnd.generateDizhuLoseStreakBuffGift template=', template,
                    'templateName=', templateName)
    if not template:
        return

    task = template.newTodoTask(DIZHU_GAMEID, userId, clientId)
    if ftlog.is_debug():
        ftlog.debug('dizhupopwnd.generateDizhuLoseStreakBuffGift task=', task.toDict() if task else None)

    return task if task else None
示例#2
0
def generateDizhuLuckyBoxTodoTask(userId, clientId):
    template, templateName = findTodotaskTemplate(DIZHU_GAMEID, userId, clientId, 'dizhuLuckyBox')
    if ftlog.is_debug():
        ftlog.debug('dizhupopwnd.generateDizhuLuckyBoxTodoTask template=', template, 'templateName=', templateName)
    if not template:
        if ftlog.is_debug():
            ftlog.debug('dizhupopwnd.generateDizhuLuckyBoxTodoTask not have todoTaskTemplate')
        return
    task = template.newTodoTask(DIZHU_GAMEID, userId, clientId)
    if not task:
        if ftlog.is_debug():
            ftlog.debug('dizhupopwnd.generateDizhuLuckyBoxTodoTask not have task')
        return
    return task
示例#3
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))
示例#4
0
def signinMatch(gameId, userId, contentItem, bigRoomId, instId, ctrlRoomId):
    if ftlog.is_debug():
        ftlog.debug('match_remote.signinMatch gameId=', gameId,
                    'userId=', userId,
                    'contentItem=', contentItem,
                    'bigRoomId=', bigRoomId,
                    'instId=', instId,
                    'ctrlRoomId=', ctrlRoomId)
    try:
        userMatchInfo = loadUserMatchInfo(gameId, userId, bigRoomId)
        if userMatchInfo:
            if userMatchInfo.instId == instId:
                if userMatchInfo.state == UserMatchInfo.ST_SIGNIN:
                    return ERR_ALREADY_SIGNIN, None
                return ERR_ALREADY_IN_MATCH, None
            else:
                ftlog.warn('match_remote.signinMatch gameId=', gameId,
                           'userId=', userId,
                           'contentItem=', contentItem,
                           'bigRoomId=', bigRoomId,
                           'instId=', instId,
                           'ctrlRoomId=', ctrlRoomId,
                           'recordInstId=', userMatchInfo.instId)
                
        userMatchInfo = UserMatchInfo(gameId, userId, bigRoomId)
        userMatchInfo.ctrlRoomId = ctrlRoomId
        userMatchInfo.instId = instId
        if contentItem:
            userMatchInfo.feeItem = TYContentItem.decodeFromDict(contentItem)
        if userId > 10000 and contentItem:
            if ftlog.is_debug():
                userAssets = hallitem.itemSystem.loadUserAssets(userId)
                ftlog.debug('match_remote.signinMatch gameId=', gameId,
                            'userId=', userId,
                            'itemId=', contentItem['itemId'],
                            'strItemId=', str(contentItem['itemId']),
                            'items=', matchutil.getMatchSigninFeeWithoutCollect(),
                            'balance=', userAssets.balance(HALL_GAMEID, contentItem['itemId'], pktimestamp.getCurrentTimestamp()),
                            'isIn=', str(contentItem['itemId']) in matchutil.getMatchSigninFeeWithoutCollect())

            if str(contentItem['itemId']) in matchutil.getMatchSigninFeeWithoutCollect():
                userAssets = hallitem.itemSystem.loadUserAssets(userId)
                balance = userAssets.balance(HALL_GAMEID, contentItem['itemId'], pktimestamp.getCurrentTimestamp())
                if balance:
                    if ftlog.is_debug():
                        ftlog.debug('match_remote.signinMatch gameId=', gameId,
                                    'userId=', userId,
                                    'balance=', balance)
                    userMatchInfo.feeItem = None
                    from poker.entity.biz import bireport
                    bireport.reportGameEvent('MONTH_CARD_MATCH_SIGNIN', userId, 6, bigRoomId, bigRoomId, 0, 0, 0, 0, 0, 0, 0, 0)
                else:
                    if ftlog.is_debug():
                        ftlog.debug('match_remote.signinMatch gameId=', gameId,
                                    'userId=', userId, 'notBalance')
                    userAssets = hallitem.itemSystem.loadUserAssets(userId)
                    assetTuple = userAssets.consumeAsset(gameId, contentItem['itemId'], contentItem['count'],
                                                         pktimestamp.getCurrentTimestamp(), 'MATCH_SIGNIN_FEE',
                                                         bigRoomId)
                    if assetTuple[1] < contentItem['count']:
                        clientId = sessiondata.getClientId(userId)

                        # 大厅4.56以上版本弹出月卡购买
                        _, clientVer, _ = strutil.parseClientId(clientId)
                        if clientVer <= 4.56:
                            raise TYAssetNotEnoughException(assetTuple[0], contentItem['count'], assetTuple[2])

                        if contentItem['itemId'] == hallitem.ASSET_ITEM_CROWN_MONTHCARD_KIND_ID:
                            popwndName = 'monthlyBuy'
                        elif contentItem['itemId'] == hallitem.ASSET_ITEM_HONOR_MONTHCARD_KIND_ID:
                            popwndName = 'monthcard_star'
                        else:
                            raise TYAssetNotEnoughException(assetTuple[0], contentItem['count'], assetTuple[2])

                        template, templateName = findTodotaskTemplate(gameId, userId, clientId, popwndName)
                        if ftlog.is_debug():
                            ftlog.debug('match_remote.findTodotaskTemplate.monthlyBuy',
                                        'userId=', userId,
                                        'popwndName=', popwndName,
                                        'template=', template,
                                        'templateName=', templateName)

                        todoTaskObj = template.newTodoTask(gameId, userId, clientId) if template else None
                        if not todoTaskObj:
                            raise TYAssetNotEnoughException(assetTuple[0], contentItem['count'], assetTuple[2])
                        TodoTaskHelper.sendTodoTask(gameId, userId, todoTaskObj)
                        return -4, None
                    datachangenotify.sendDataChangeNotify(gameId, userId, TYAssetUtils.getChangeDataNames([assetTuple]))
            else:
                # 折扣报名判断, 如果有其他的折扣如折扣券,月卡等,执行这些
                contentItem = match_signin_discount.changeItemToDiscount(userId, bigRoomId, contentItem)
                userMatchInfo.feeItem = TYContentItem.decodeFromDict(contentItem)
                userAssets = hallitem.itemSystem.loadUserAssets(userId)
                assetTuple = userAssets.consumeAsset(gameId,
                                                     contentItem['itemId'],
                                                     contentItem['count'],
                                                     pktimestamp.getCurrentTimestamp(),
                                                     'MATCH_SIGNIN_FEE', bigRoomId)
                if assetTuple[1] < contentItem['count']:
                    raise TYAssetNotEnoughException(assetTuple[0], contentItem['count'], assetTuple[2])
                # 记录用户
                datachangenotify.sendDataChangeNotify(gameId, userId, TYAssetUtils.getChangeDataNames([assetTuple]))
        saveUserMatchInfo(userMatchInfo)
        daobase.executeTableCmd(ctrlRoomId, 0, 'sadd', 'signs:' + str(ctrlRoomId), userId)
        return 0, None
    except TYAssetNotEnoughException, e:
        return ERR_FEE_NOT_ENOUGH, (e.assetKind.kindId, e.required - e.actually)