示例#1
0
    def buildFlipCardResponse(cls, gameId, userId, roomId, flipIndex,
                              flippedCardList, benefitsSend, userBenefits):
        assert (flipIndex >= 0 and flipIndex <= len(flippedCardList))
        flippedCard = flippedCardList[flipIndex]
        mo = MsgPack()
        mo.setCmd('flip_card_luck')
        mo.setResult('action', 'flip')
        mo.setResult('index', flipIndex)
        mo.setResult('userId', userId)
        mo.setResult('gameId', gameId)

        mo.setResult('cards', cls.encodeFlippedCardList(flippedCardList, flipIndex))
        mo.setResult('desc', cls.getFlippedCardDesc(flippedCard))

        if isinstance(flippedCard, FlippedCardProduct):
            payOrder = TodoTaskPayOrder(flippedCard.product)
            mo.setResult('sub_action', payOrder.toDict())
            mo.setResult('sub_text', hallflipcardluck.getString('product.subText', '立即购买'))

            if benefitsSend:
                mo.setResult('sub_action_ext',
                             TodoTaskHelper.makeTodoTaskBenefitsInfo(benefitsSend, userBenefits).toDict())
            else:
                mo.setResult('sub_action_ext', TodoTaskNoop().toDict())
            mo.setResult('sub_text_ext', hallflipcardluck.getString('product.subTextExt', '取消'))
        elif isinstance(flippedCard, FlippedCardAsset):
            if benefitsSend:
                mo.setResult('sub_action', TodoTaskHelper.makeTodoTaskBenefitsInfo(benefitsSend, userBenefits).toDict())
            else:
                mo.setResult('sub_action', TodoTaskNoop().toStr())
            mo.setResult('sub_text', hallflipcardluck.getString('item.subText', '确定'))
        return mo
示例#2
0
def sendMasterGiftTodoTask(userId, gameId, clientId, pic, pay_order, roomId):
    """ 推送高手礼包弹窗
    @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
    todotask = TodoTaskPayOrder(product)
    task = {
            'action':   'cache_wnd_gaoshou',
            'params':   {
                         'pic':     pic,
                         'tasks':   [todotask.toDict()]
                         }
            }
    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 getConfigForClient(self, gameId, userId, clientId):
        if day1st.isDayFirstLogin(userId, gameId):
            return None
        clientConf = strutil.cloneData(self._clientConf)
        firstChargeHasSent = hallstore.isGetFirstRechargeReward(userId)
        if firstChargeHasSent:
            return None
        tyGame = gdata.getGame(gameId)
        if not tyGame:
            return None
        userGameInnings = tyGame.getPlayGameCount(userId, clientId)
        if userGameInnings < 5:
            return None
        isFirstRecharged = hallstore.isFirstRecharged(userId)
        try:
            if not isFirstRecharged:
                rechargeFactory = TodoTaskFirstRechargeFactory().decodeFromDict(
                    self._serverConf.get("firstCharge", {})
                )
                product = rechargeFactory._getProduct(gameId, userId)
                todoTask = TodoTaskPayOrder(product)
                clientConf["config"]["button"]["todoTask"] = todoTask.toDict()
            else:
                rewardFactory = TodoTaskFirstRechargeRewardFactory.decodeFromDict(
                    self._serverConf.get("firstChargeReward", {})
                )
                clientConf["config"]["button"]["todoTask"] = rewardFactory.newTodoTask(gameId, userId,
                                                                                       clientId).toDict()
        except:
            ftlog.exception("TYActivityFirstCharge.getConfigForClient error")
            return None

        return clientConf
示例#4
0
 def dict_pay_order(cls, userid, product):
     """ 根据商品信息生成payOrder的字典
     action: pop_pay_order
     Args:
         userid: 玩家userid
         product: 商品信息
     """
     from hall.entity.todotask import TodoTaskPayOrder
     payorder = TodoTaskPayOrder(product)
     payorder = payorder.toDict()
     if not isinstance(payorder, dict):
         raise TYBizConfException(payorder, 'MahjongTodoTaskBuilder.dict_pay_order must be dict!')
     else:
         return payorder
示例#5
0
    def getConfigForClient(self, gameId, userId, clientId):
        """
        预期实现功能。配置中,配置payOrder后台自动生成该商品的todotask
        
        """
        clientConf = strutil.cloneData(self._clientConf)
        payOrder = clientConf["config"]["button"]["payOrder"]

        product, _ = hallstore.findProductByPayOrder(gameId, userId, clientId, payOrder)
        ftlog.debug("TYActivitySale product: ", product)
        payOrder = TodoTaskPayOrder(product)
        ftlog.debug("TYActivitySale params: ", payOrder)
        try:
            clientConf["config"]["button"]["todoTask"] = payOrder.toDict()
        except:
            ftlog.exception("getConfigForClient error, can not set todotask, clientId:", clientId)
            return None
        return clientConf
示例#6
0
 def __init__(self, payOrderProduct):
     super(TodoTaskWinStreakBuffGift,
           self).__init__('ddz_pop_libao_gaoshou')
     clientParams = payOrderProduct.clientParams
     if clientParams:
         self.setParam('originalPrice',
                       str(clientParams.get('originalPrice', '')))
         self.setParam('descExtra', clientParams.get('descExtra', ''))
     if payOrderProduct:
         self.setParam('price', payOrderProduct.price)
         self.setParam('desc', payOrderProduct.desc)
         self.setSubCmd(TodoTaskPayOrder(payOrderProduct))
示例#7
0
    def _doChangeNameTry(self, userId, clientId, newName):
#         renameConf = hallconf.getClientRenameConf(clientId)
#         if (renameConf
#             and not renameConf.get('containsSensitive', 1)
#             and keywords.isContains(newName)):
#             info = TodoTaskShowInfo(hallrename.stringRenameContainsSensitive)
#             return TodoTaskHelper.sendTodoTask(HALL_GAMEID, userId, info)
        code, info = hallrename.tryRename(HALL_GAMEID, userId, newName)
        if ftlog.is_debug():
            ftlog.debug('hallrename._doChangeNameTry->', code, info)

        CLIENT_VER = 4.57
        _, clientVer, _ = strutil.parseClientId(clientId)

        if ftlog.is_debug():
            ftlog.debug("_doChangeNameTry clientVer", userId, clientId, newName, code, info, clientVer)

        reInfo = ""
        if code == -3 :
            reInfo = "昵称没有变化"
        elif code == -2 :
            # 没有改名卡
            info = TodoTaskShowInfo(hallrename.stringRenameCardRequired, True)
            if hallrename.payOrder:
                product, _ = hallstore.findProductByPayOrder(HALL_GAMEID, userId, clientId, hallrename.payOrder)
                if product:
                    info.setSubCmd(TodoTaskPayOrder(product))
            return TodoTaskHelper.sendTodoTask(HALL_GAMEID, userId, info)
        elif code == 0 :
            reInfo = "昵称修改成功"
            # 改名成功
            if clientVer < CLIENT_VER:
                if ftlog.is_debug():
                    ftlog.debug("_doChangeNameTry ok", userId, clientId, newName, code, info, clientVer)
                return TodoTaskHelper.sendTodoTask(HALL_GAMEID, userId, TodoTaskPopTip(hallrename.stringRenameSuccessed))
        else:
            #reInfo = "修改昵称失败,请重试"
            reInfo = info
            # SDK改名失败
            if clientVer < CLIENT_VER:
                if ftlog.is_debug():
                    ftlog.debug("_doChangeNameTry fail", userId, clientId, newName, code, info, clientVer)
                return TodoTaskHelper.sendTodoTask(HALL_GAMEID, userId, TodoTaskPopTip(info))
                    
        mo = MsgPack()
        mo.setCmd('change_name')
        mo.setResult('action', 'try')
        mo.setResult('userId', userId)
        mo.setResult('code', code)
        mo.setResult('reInfo', reInfo)
        router.sendToUser(mo, userId)
        if ftlog.is_debug():
            ftlog.debug("_doChangeNameTry result",userId, clientId, newName, code, reInfo)
 def __init__(self, title, imgUrl, payOrder=None, confirm=0, confirmDesc=None, subText=None):
     super(TodoTaskFirstRecharge, self).__init__('pop_first_recharge')
     self.setParam('title', title)
     self.setParam('imgUrl', imgUrl)
     if subText:
         self.setParam('subText', subText)
         self.setParam('sub_action_text', subText)
     if payOrder:
         subCmd = payOrder
         if isinstance(payOrder, TYProduct):
             subCmd = TodoTaskPayOrder(payOrder)
         if confirm:
             confirmDesc = confirmDesc or ''
             if confirmDesc:
                 confirmDesc = strutil.replaceParams(confirmDesc, {
                                                         'product.displayName':subCmd.getParam('name', ''),
                                                         'product.price':subCmd.getParam('price', '')
                                                     })
             info = TodoTaskShowInfo(confirmDesc, True)
             info.setSubCmd(subCmd)
             subCmd = info
         self.setSubCmd(subCmd)
示例#9
0
 def _doChangeNameCheck(self, userId, clientId):
     canRename, desc = hallrename.checkRename(HALL_GAMEID, userId)
     if canRename:
         return TodoTaskHelper.sendTodoTask(HALL_GAMEID, userId,
                                            TodoTaskRename(desc))
     else:
         info = TodoTaskShowInfo(desc, True)
         if hallrename.payOrder:
             product, _ = hallstore.findProductByPayOrder(
                 HALL_GAMEID, userId, clientId, hallrename.payOrder)
             if product:
                 info.setSubCmd(TodoTaskPayOrder(product))
         return TodoTaskHelper.sendTodoTask(HALL_GAMEID, userId, info)
示例#10
0
def newTodoTask(self, gameId, userId, clientId, timestamp, **kwargs):
    subMemberStatus = kwargs.get(
        'subMemberStatus') or hallsubmember.loadSubMemberStatus(userId)
    if subMemberStatus.isSub:
        todotask = TodoTaskMemberBuy(self.descForMember, self.pic)
        todotask.setParam('tip_bottom', self.tipForSubMember)
        return todotask

    memberInfo = kwargs.get('memberInfo') or hallitem.getMemberInfo(
        userId, timestamp)
    remainDays = memberInfo[0]
    todotask = None
    subActionText = None

    product, _ = hallstore.findProductByPayOrder(gameId, userId, clientId,
                                                 self.payOrder)

    if not product:
        return None

    if remainDays > 0:
        todotask = TodoTaskMemberBuy(self.descForMember, self.pic)
        tipForMember = strutil.replaceParams(self.tipForMember,
                                             {'remainDays': str(remainDays)})
        todotask.setParam('tip_bottom_left', tipForMember)
        todotask.setParam('sub_action_text', self.subActionTextForMember)
    else:
        price = product.price
        priceUnits = '元'
        if product.buyType == 'consume':
            price = product.priceDiamond
            priceUnits = '钻石'
        params = {
            'product.price': str(price),
            'product.priceUnits': priceUnits
        }
        if product.content and product.content.desc:
            params['product.content.desc'] = product.content.desc
        desc = strutil.replaceParams(self.desc, params)
        todotask = TodoTaskMemberBuy(desc, self.pic)
        todotask.setSubText(self.subActionText)
        todotask.setParam('sub_action_text', self.subActionText)

    todotask.setSubCmdWithText(TodoTaskPayOrder(product), subActionText)

    if remainDays <= 0 and self.closeAction:
        closeAction = decodeTodotaskFactoryByDict(
            self.closeAction).newTodoTask(gameId, userId, clientId, **kwargs)
        if closeAction:
            todotask.setParam('sub_action_close', closeAction)
    return todotask
示例#11
0
 def buildUpLevelTodoTasks(cls, gameId, userVip, clientId):
     deltaExp = userVip.deltaExpToNextLevel()
     if deltaExp > 0:
         payOrder = strutil.cloneData(
             hallvip.vipSystem.getLevelUpPayOrder())
         payOrder['priceDiamond'] = {
             'count': deltaExp,
             'minCount': 0,
             'maxCount': -1
         }
         product, _ = hallstore.findProductByPayOrder(
             gameId, userVip.userId, clientId, payOrder)
         if product:
             return TodoTaskHelper.encodeTodoTasks(
                 TodoTaskPayOrder(product))
     return []
示例#12
0
    def on_praise_friend(cls, gameId, uid, clientId, mo):
        code = mo.getResult('code', 0)
        # vip = mo.getResult('vip')
        if code == 0:
            friend_uid = int(mo.getResult('friend_uid'))
            nick_name = mo.getResult('nick_name')
            friend_nick_name = mo.getResult('friend_nick_name')
            my_add_charm = mo.getResult('my_add_charm')
            friend_add_charm = mo.getResult('friend_add_charm')
            my_charm = mo.getResult('my_charm')
            friend_charm = mo.getResult('friend_charm')

            msg1 = '给"' + friend_nick_name + '"点赞获得' + str(
                my_add_charm) + '个魅力值'
            msg2 = '"' + nick_name + '"给您点赞获得' + str(friend_add_charm) + '个魅力值'
            from poker.entity.biz.message import message
            message.send(gameId, message.MESSAGE_TYPE_SYSTEM, int(uid), msg1)
            message.send(gameId, message.MESSAGE_TYPE_SYSTEM, int(friend_uid),
                         msg2)
            ftlog.debug('on praise friend.... ' + msg1)
            ftlog.debug('on praise friend.... ' + msg2)

            datachangenotify.sendDataChangeNotify(gameId, uid, 'charm')

            from hall.entity.hallranking import rankingSystem, TYRankingInputTypes
            timestamp = pktimestamp.getCurrentTimestamp()
            rankingSystem.setUserByInputType(gameId, TYRankingInputTypes.CHARM,
                                             uid, my_charm, timestamp)
            rankingSystem.setUserByInputType(gameId, TYRankingInputTypes.CHARM,
                                             friend_uid, friend_charm,
                                             timestamp)
            # 历史获赞次数
            history_praised_num = gamedata.incrGameAttr(
                friend_uid, gameId, 'history_praised_num', 1)
            mo.setResult('friend_history_praised_num', history_praised_num)

        if code != 2:
            return

        from hall.entity.todotask import TodoTaskPayOrder, TodoTaskShowInfo
        from hall.entity.todotask import TodoTaskHelper
        from hall.entity import hallvip, hallitem

        user_vip = hallvip.userVipSystem.getUserVip(uid)
        delta_exp = user_vip.deltaExpToNextLevel()

        product, _ = hallstore.findProductByContains(
            gameId, uid, clientId, ['coin'], None, hallitem.ASSET_CHIP_KIND_ID,
            delta_exp * 1000)

        pay_order = TodoTaskPayOrder(product)
        if user_vip == 0:
            msg = '点赞次数已达今日上限,开通VIP可提高点赞次数上限获得更多福利哦~'
            btnTxt = '开通VIP'
        else:
            msg = '点赞次数已达今日上限,升级VIP等级可提高点赞次数上限获得更多福利哦~'
            btnTxt = '升级VIP'
        dialog_task = TodoTaskShowInfo(msg, True)
        dialog_task.setSubCmd(pay_order)
        dialog_task.setSubText(btnTxt)
        TodoTaskHelper.sendTodoTask(gameId, uid, [dialog_task])
示例#13
0
    def makeClientConf(self, clientconf, gameId, userId, clientId):
        '''
        构造客户端的活动协议配置
        '''
        conf = strutil.cloneData(clientconf)
        activateconf = conf.get("config", {}).get("activate", {})
        subconf = conf.get('config', {})

        task = self._taskWrapper
        
        # New: 要统计的房间列表
        roomid_tocount = activateconf.get('countRoomId', [])
        roomids_tocount = [roomid_tocount] if isstring(roomid_tocount) else roomid_tocount
            
        key_tocount = activateconf.get('countByKey')
        finish_taskcount = task.getFinishTaskCount(gameId, userId, clientconf)
        gain_taskcount = task.getRecvTaskCount(gameId, userId)
        total_tablecount = task.getTablePlayCount(userId)
        
        # New: 统计多个房间的数量
        roomid_tablecount = 0
        for roomid in roomids_tocount:
            roomid_tablecount += task.getRoomTablePlayCount(userId, roomid)
        
        is_activited = ActivityDdzFund.loadFundStatus(userId).isActivated
        ftlog.debug("TYActivityFund.makeClientConf: userId=", userId,
                    "roomids_tocount=",roomids_tocount,
                    "total_tablecount=", total_tablecount,
                    "finish_taskcount=", finish_taskcount,
                    "roomid_tablecount=", roomid_tablecount,
                    "gain_taskcount=", gain_taskcount,
                    "is_activited=",is_activited,
                    'key_tocount=', key_tocount)

        # subconf['overCnt'] = finish_taskcount # 已经完成的任务数量
        if key_tocount:
            subconf['overCnt'] = task.getPlayCountByKey(userId, key_tocount)
        elif len(roomids_tocount) > 0:
            subconf['overCnt'] = roomid_tablecount # 已经完成的局数
        else:
            subconf['overCnt'] = total_tablecount # 已经完成的局数
        subconf['getRewardYetCnt'] = gain_taskcount # 已经领取的任务数量
        subconf['isActive'] = is_activited # 是否已经激活基金活动
        subconf['activeYetHint'] = strutil.replaceParams(subconf.get("activeYetHint",""), {
            "finishcount":subconf['overCnt'],
            "finishcount_room": str(roomid_tablecount),
        })

        reward_btn_map = subconf.get('rewardButton', {})
        normal_tip = reward_btn_map.get('normalTip', '')
        activate_map = subconf.get('activate', {})
        reward_list = activate_map.get('reward', [])

        if len(reward_list)>gain_taskcount:
            desc = reward_list[gain_taskcount].get('desc', '')
            reward_btn_map['normalTip'] = strutil.replaceParams(normal_tip, {"assets":desc})

        # TodoTask
        activatebtn_map = subconf.get("activateButton", {})
        todotask = activatebtn_map.get("todoTask", {})
        payOrder = todotask.get("payOrder")
        ftlog.debug("TYActivityFund.makeClientConf: userId=", userId, "payOrder=", payOrder)

        if payOrder:
            product, _ = hallstore.findProductByPayOrder(gameId, userId, clientId, payOrder)
            ftlog.debug("TYActivityFund.makeClientConf: userId=", userId, "product=", product)
            payOrder = TodoTaskPayOrder(product)
            ftlog.debug("TYActivityFund.makeClientConf: userId=", userId, "params=", payOrder)
            activatebtn_map["todoTask"] = payOrder.toDict()

        # 激活日期限制
        ok = self.checkCanActivateDate(conf)
        activateconf['isOutdate'] = not ok
        if ok:
            activateconf['outdateTip'] = None
        ftlog.debug("TYActivityFund.makeClientConf: userId=", userId, "isOutdate", activateconf['isOutdate'])
        ftlog.debug("TYActivityFund.makeClientConf: userId=", userId, "conf=", conf)
        return conf
示例#14
0
    def _doFlipcard(self, userId, gameId, clientId, activityId, coin):
        result = {}
        key = "TYActivity:%d:%d:%s:%s" % (gameId, userId, clientId, activityId)
        ftlog.debug("_doFlipcard key:", key)
        conf = {
            "design": {
                "1": {
                    "name": "豹子A",
                    "payrate": 20,
                    "probability": 0.0001
                },
                "2": {
                    "name": "豹子",
                    "payrate": 20,
                    "probability": 0.0012
                },
                "3": {
                    "name": "同花顺",
                    "payrate": 15,
                    "probability": 0.001
                },
                "4": {
                    "name": "同花",
                    "payrate": 3,
                    "probability": 0.01
                },
                "5": {
                    "name": "顺子",
                    "payrate": 3,
                    "probability": 0.01
                },
                "6": {
                    "name": "对子",
                    "payrate": 1.5,
                    "probability": 0.1
                },
                "7": {
                    "name": "K以上单张",
                    "payrate": 1.2,
                    "probability": 0.3
                },
                "8": {
                    "name": "单张",
                    "payrate": 0,
                    "probability": 0.5777
                }
            }
        }

        # 判断用户金币是否足够
        chipNow = userchip.getChip(userId)
        if coin == 1000 and chipNow < 5000:
            payOrder = {
                "shelves": ["coin"],
                "buyTypes": ["direct"],
                "priceDiamond": {
                    "count": 20,
                    "minCount": 0,
                    "maxCount": -1
                }
            }
            product, _ = hallstore.findProductByPayOrder(gameId, userId, clientId, payOrder)
            payOrder = TodoTaskPayOrder(product)
            result["tip"] = payOrder.toDict()
            return result
        elif coin == 5000 and chipNow < 50000:

            payOrder = {
                "shelves": ["coin"],
                "buyTypes": ["direct"],
                "priceDiamond": {
                    "count": 80,
                    "minCount": 0,
                    "maxCount": -1
                }
            }
            product, _ = hallstore.findProductByPayOrder(gameId, userId, clientId, payOrder)
            payOrder = TodoTaskPayOrder(product)
            result["tip"] = payOrder.toDict()
            return result
        elif coin == 10000 and chipNow < 50000:
            payOrder = {
                "shelves": ["coin"],
                "buyTypes": ["direct"],
                "priceDiamond": {
                    "count": 80,
                    "minCount": 0,
                    "maxCount": -1
                }
            }
            product, _ = hallstore.findProductByPayOrder(gameId, userId, clientId, payOrder)
            payOrder = TodoTaskPayOrder(product)
            result["tip"] = payOrder.toDict()
            return result
        elif coin == 50000 and chipNow < 300000:
            payOrder = {
                "shelves": ["coin"],
                "buyTypes": ["direct"],
                "priceDiamond": {
                    "count": 300,
                    "minCount": 0,
                    "maxCount": -1
                }
            }
            product, _ = hallstore.findProductByPayOrder(gameId, userId, clientId, payOrder)
            payOrder = TodoTaskPayOrder(product)
            result["tip"] = payOrder.toDict()
            return result
        else:
            result = doFlipCard(conf)
            ftlog.debug("_doFlipcard result..cardtype:", result["cardtype"])
            # 减金币操作
            coinDel = 0 - coin
            userchip.incrChip(userId, gameId, coinDel, daoconst.CHIP_NOT_ENOUGH_OP_MODE_CLEAR_ZERO, 'HALL_FLIPCARD', 0,
                              clientId)
            datachangenotify.sendDataChangeNotify(gameId, userId, 'chip')
            ftlog.info("用户名,用户减少了金币,", userId, coinDel)
            if result["cardtype"] != '8':
                design = conf.get('design', {})
                cardTypeNumber = design[result["cardtype"]].get('payrate', 0)

                # 加金币操作
                coinAdd = int(coin * cardTypeNumber)
                cardText = "恭喜你赢得了%d" % coinAdd + "金币"
                ftlog.debug("_doFlipcard get money:", cardText)
                userchip.incrChip(userId, gameId, coinAdd, daoconst.CHIP_NOT_ENOUGH_OP_MODE_CLEAR_ZERO, 'HALL_FLIPCARD',
                                  0, clientId)
                datachangenotify.sendDataChangeNotify(gameId, userId, 'chip')
                ftlog.info("用户名,用户增加了金币,", userId, coinAdd)
                result["todoTask"] = {"action": "pop_tip",
                                      "params": {
                                          "text": cardText,
                                          "duration": 2
                                      }
                                      }
                return result
            else:
                cardText = "再接再厉,下次就会赢哦";
                result["todoTask"] = {"action": "pop_tip",
                                      "params": {
                                          "text": cardText,
                                          "duration": 2
                                      }
                                      }
                ftlog.debug("_doFlipcard key over:", key)
                return result

        '''
示例#15
0
    def _doFlipcard(self, userId, gameId, clientId, activityId, coin):
        result = {}
        key = "TYActivity:%d:%d:%s:%s" % (gameId, userId, clientId, activityId)
        ftlog.debug("_doFlipcard key:", key)
        conf = {
            "design": {
                "1": {
                    "name": "豹子A",
                    "payrate": 20,
                    "probability": 0.0001
                },
                "2": {
                    "name": "豹子",
                    "payrate": 20,
                    "probability": 0.0012
                },
                "3": {
                    "name": "同花顺",
                    "payrate": 15,
                    "probability": 0.001
                },
                "4": {
                    "name": "同花",
                    "payrate": 3,
                    "probability": 0.01
                },
                "5": {
                    "name": "顺子",
                    "payrate": 3,
                    "probability": 0.01
                },
                "6": {
                    "name": "对子",
                    "payrate": 1.5,
                    "probability": 0.1
                },
                "7": {
                    "name": "K以上单张",
                    "payrate": 1.2,
                    "probability": 0.3
                },
                "8": {
                    "name": "单张",
                    "payrate": 0,
                    "probability": 0.5777
                }
            }
        }

        # 判断用户金币是否足够
        chipNow = userchip.getChip(userId)
        if coin == 1000 and chipNow < 5000:
            payOrder = {
                "shelves": ["coin"],
                "buyTypes": ["direct"],
                "priceDiamond": {
                    "count": 20,
                    "minCount": 0,
                    "maxCount": -1
                }
            }
            product, _ = hallstore.findProductByPayOrder(
                gameId, userId, clientId, payOrder)
            payOrder = TodoTaskPayOrder(product)
            result["tip"] = payOrder.toDict()
            return result
        elif coin == 5000 and chipNow < 50000:

            payOrder = {
                "shelves": ["coin"],
                "buyTypes": ["direct"],
                "priceDiamond": {
                    "count": 80,
                    "minCount": 0,
                    "maxCount": -1
                }
            }
            product, _ = hallstore.findProductByPayOrder(
                gameId, userId, clientId, payOrder)
            payOrder = TodoTaskPayOrder(product)
            result["tip"] = payOrder.toDict()
            return result
        elif coin == 10000 and chipNow < 50000:
            payOrder = {
                "shelves": ["coin"],
                "buyTypes": ["direct"],
                "priceDiamond": {
                    "count": 80,
                    "minCount": 0,
                    "maxCount": -1
                }
            }
            product, _ = hallstore.findProductByPayOrder(
                gameId, userId, clientId, payOrder)
            payOrder = TodoTaskPayOrder(product)
            result["tip"] = payOrder.toDict()
            return result
        elif coin == 50000 and chipNow < 300000:
            payOrder = {
                "shelves": ["coin"],
                "buyTypes": ["direct"],
                "priceDiamond": {
                    "count": 300,
                    "minCount": 0,
                    "maxCount": -1
                }
            }
            product, _ = hallstore.findProductByPayOrder(
                gameId, userId, clientId, payOrder)
            payOrder = TodoTaskPayOrder(product)
            result["tip"] = payOrder.toDict()
            return result
        else:
            result = doFlipCard(conf)
            ftlog.debug("_doFlipcard result..cardtype:", result["cardtype"])
            # 减金币操作
            coinDel = 0 - coin
            userchip.incrChip(userId, gameId, coinDel,
                              daoconst.CHIP_NOT_ENOUGH_OP_MODE_CLEAR_ZERO,
                              'HALL_FLIPCARD', 0, clientId)
            datachangenotify.sendDataChangeNotify(gameId, userId, 'chip')
            ftlog.info("用户名,用户减少了金币,", userId, coinDel)
            if result["cardtype"] != '8':
                design = conf.get('design', {})
                cardTypeNumber = design[result["cardtype"]].get('payrate', 0)

                # 加金币操作
                coinAdd = int(coin * cardTypeNumber)
                cardText = "恭喜你赢得了%d" % coinAdd + "金币"
                ftlog.debug("_doFlipcard get money:", cardText)
                userchip.incrChip(userId, gameId, coinAdd,
                                  daoconst.CHIP_NOT_ENOUGH_OP_MODE_CLEAR_ZERO,
                                  'HALL_FLIPCARD', 0, clientId)
                datachangenotify.sendDataChangeNotify(gameId, userId, 'chip')
                ftlog.info("用户名,用户增加了金币,", userId, coinAdd)
                result["todoTask"] = {
                    "action": "pop_tip",
                    "params": {
                        "text": cardText,
                        "duration": 2
                    }
                }
                return result
            else:
                cardText = "再接再厉,下次就会赢哦"
                result["todoTask"] = {
                    "action": "pop_tip",
                    "params": {
                        "text": cardText,
                        "duration": 2
                    }
                }
                ftlog.debug("_doFlipcard key over:", key)
                return result
        '''
示例#16
0
 def _sendChargeLeadTodoTask(cls, userId, roomId, clientId):
     product, _ = hallproductselector.selectLessbuyProduct(
         DIZHU_GAMEID, userId, clientId, roomId)
     t = TodoTaskPayOrder(product)
     msg = TodoTaskHelper.makeTodoTaskMsg(DIZHU_GAMEID, userId, t)
     router.sendToUser(msg, userId)