Example #1
0
    def exchange_user_vip_charge(cls, gameId, userId, grade):
        """
        用户兑换vip充值金币
        """
        ftlog.debug('exchange_user_vip_charge', gameId, userId, grade)
        grade = str(grade)
        vip_charge_info = cls.get_user_vip_charge(userId)
        if not vip_charge_info:
            return 1

        grade_data = vip_charge_info.get(str(grade))
        if not grade_data:
            return 1

        ftlog.debug('exchange_user_vip_charge exchanged',
                    grade_data['exchanged'])
        if grade_data['exchanged']:
            return 2

        grade_data['exchanged'] = 1
        daobase.executeMixCmd('hset', cls.key_vip_charge, userId,
                              json.dumps(vip_charge_info))

        chip = cls.VIP_COIN_CONFIG[grade]
        try:
            userchip.incrChip(userId, gameId, chip, 0,
                              'H5_YOUKU_DIZHU_VIP_EXCHANGE_CHIP', 0, None)
        except:
            import traceback
            traceback.print_exc()
        datachangenotify.sendDataChangeNotify(gameId, userId, 'chip')
        return 0
Example #2
0
    def testQuickStart(self):
        '''测试快速开始'''
        gameId = 6
        userId = 1234
        roomId = 0
        tableId = 0
        chip = 800
        clientId = "Android_3.501_tuyoo.YDJD.0-hall6.apphui.happy"

        onlinedata.setOnlineState(userId, onlinedata.ONLINE)
        onlinedata.cleanOnlineLoc(userId)

        userdata.setAttr(userId, "sessionClientId", clientId)
        #         datas = sessiondata._getUserSessionValues(userId)
        #         ftlog.debug("|userId, session:", userId, datas)

        oldChip = userchip.getChip(userId)
        userchip.incrChip(userId, gameId, chip - oldChip, 0, "GM_ADJUST_COIN",
                          0, 0)

        msg = MsgPack()
        msg.setCmd("quick_start")
        msg.setParam("gameId", gameId)
        msg.setParam("userId", userId)
        msg.setParam("roomId", roomId)
        msg.setParam("tableId", tableId)
        msg.setParam("clientId", clientId)
        print '=' * 30
        print msg
        DizhuQuickStartDispatcher.dispatchQuickStart(msg)
        print '=' * 30
Example #3
0
    def sendBenefits(self, gameId, userBenefits):
        assert (isinstance(userBenefits.privilege, TYBenefitsPrivilegeVIPLevel))
        if (userBenefits.times > userBenefits.maxTimes
            and userBenefits.extTimes > 0):
            _trueDelta, final = pkuserchip.incrChip(userBenefits.userId, gameId, userBenefits.sendChip,
                                                    pkdaoconst.CHIP_NOT_ENOUGH_OP_MODE_NONE,
                                                    'BENE_SEND_VIP_EXT_TIMES', self.vipLevel.level,
                                                    None)
            ftlog.debug('TYBenefitsPrivilegeVIPLevel.sendBenefits gameId=', gameId,
                        'userId=', userBenefits.userId,
                        'sendChip=', userBenefits.sendChip,
                        'times=', userBenefits.times,
                        'maxTimes=', userBenefits.maxTimes,
                        'extTimes=', userBenefits.extTimes,
                        'final=', final)

        if userBenefits.extSendChip > 0:
            ftlog.debug('TYBenefitsPrivilegeVIPLevel.sendBenefits gameId=', gameId,
                        'userId=', userBenefits.userId,
                        'extSendChip=', userBenefits.extSendChip)
            _trueDelta, final = pkuserchip.incrChip(userBenefits.userId, gameId, userBenefits.extSendChip,
                                                    pkdaoconst.CHIP_NOT_ENOUGH_OP_MODE_NONE,
                                                    'BENE_SEND_VIP_EXT', self.vipLevel.level,
                                                    None)
        return userBenefits
Example #4
0
    def testQuickStart(self):
        '''测试快速开始'''
        gameId = 6
        userId = random.randint(10000, 20000)
        roomId = 0
        tableId = 0
        chip = 800
        clientId = "Android_3.501_tuyoo.YDJD.0-hall6.apphui.happy"
        playMode = "happy"
        
        onlinedata.setOnlineState(userId, onlinedata.ONLINE)
        onlinedata.cleanOnlineLoc(userId)
        
        userdata.setAttr(userId, "sessionClientId", clientId)
#         datas = sessiondata._getUserSessionValues(userId)
#         ftlog.debug("|userId, session:", userId, datas)
        
        oldChip = userchip.getChip(userId)
        userchip.incrChip(userId, gameId, chip - oldChip, 0, "GM_ADJUST_COIN", 0, clientId)
        
        msg = MsgPack()
        msg.setCmd("quick_start")
        msg.setParam("gameId", gameId)
        msg.setParam("userId", userId)
#         msg.setParam("roomId", roomId)
#         msg.setParam("tableId", tableId)
        msg.setParam("clientId", clientId)
        print '='*30
        print msg
        BaseQuickStartDispatcher.dispatchQuickStart(msg, userId, gameId, roomId, tableId, playMode, clientId)
        print '='*30
Example #5
0
    def sendBenefits(self, gameId, userBenefits):
        assert (isinstance(userBenefits.privilege, TYBenefitsPrivilegeVIPLevel))
        if (userBenefits.times > userBenefits.maxTimes
            and userBenefits.extTimes > 0):
            _trueDelta, final = pkuserchip.incrChip(userBenefits.userId, gameId, userBenefits.sendChip,
                                                    pkdaoconst.CHIP_NOT_ENOUGH_OP_MODE_NONE,
                                                    'BENE_SEND_VIP_EXT_TIMES', self.vipLevel.level,
                                                    None)
            ftlog.debug('TYBenefitsPrivilegeVIPLevel.sendBenefits gameId=', gameId,
                       'userId=', userBenefits.userId,
                       'sendChip=', userBenefits.sendChip,
                       'times=', userBenefits.times,
                       'maxTimes=', userBenefits.maxTimes,
                       'extTimes=', userBenefits.extTimes,
                       'final=', final)

        if userBenefits.extSendChip > 0:
            ftlog.debug('TYBenefitsPrivilegeVIPLevel.sendBenefits gameId=', gameId,
                       'userId=', userBenefits.userId,
                       'extSendChip=', userBenefits.extSendChip)
            _trueDelta, final = pkuserchip.incrChip(userBenefits.userId, gameId, userBenefits.extSendChip,
                                                    pkdaoconst.CHIP_NOT_ENOUGH_OP_MODE_NONE,
                                                    'BENE_SEND_VIP_EXT', self.vipLevel.level,
                                                    None)
        return userBenefits
Example #6
0
def _incrWinLoseChip(roomId, tableId, userId, isSupportBuyin, seat_delta,
                     chou_cheng, clientId):
    trueDelta = 0
    trueDelta_cc = 0
    finalChip = 0
    if isSupportBuyin:
        trueDelta, finalChip = userchip.incrTableChip(
            userId, DIZHU_GAMEID, seat_delta,
            daoconst.CHIP_NOT_ENOUGH_OP_MODE_CLEAR_ZERO, 'GAME_WINLOSE',
            roomId, clientId, tableId)
        if chou_cheng < 0:
            trueDelta_cc, finalChip = userchip.incrTableChip(
                userId, DIZHU_GAMEID, chou_cheng,
                daoconst.CHIP_NOT_ENOUGH_OP_MODE_CLEAR_ZERO, 'WINNER_TAX',
                roomId, clientId, tableId)
        _recordLastTableChip(userId, finalChip, isSupportBuyin)
        finalChip += userchip.getChip(userId)
    else:
        trueDelta, finalChip = userchip.incrChip(
            userId, DIZHU_GAMEID, seat_delta,
            daoconst.CHIP_NOT_ENOUGH_OP_MODE_CLEAR_ZERO, 'GAME_WINLOSE',
            roomId, clientId)
        if chou_cheng < 0:
            trueDelta_cc, finalChip = userchip.incrChip(
                userId, DIZHU_GAMEID, chou_cheng,
                daoconst.CHIP_NOT_ENOUGH_OP_MODE_CLEAR_ZERO, 'WINNER_TAX',
                roomId, clientId)
    return trueDelta, trueDelta_cc, finalChip
Example #7
0
    def sendBenefits(self, gameId, userBenefits):
        from hall.entity import hallsubmember
        assert (isinstance(userBenefits.privilege, TYBenefitsPrivilegeMember))
        status = hallsubmember.loadSubMemberStatus(userBenefits.userId)
        isSubExpires = status.isSubExpires(datetime.now())
        if (userBenefits.times > userBenefits.maxTimes
            and userBenefits.extTimes > 0):
            eventId = 'BENE_SEND_MEMBER_EXT_TIMES' if isSubExpires else 'BENE_SEND_SUB_MEMBER_EXT_TIMES'
            _trueDelta, final = pkuserchip.incrChip(userBenefits.userId, gameId, userBenefits.sendChip,
                                                    pkdaoconst.CHIP_NOT_ENOUGH_OP_MODE_NONE,
                                                    eventId, 0, None)
            ftlog.debug('TYBenefitsPrivilegeMember.sendBenefits gameId=', gameId,
                       'userId=', userBenefits.userId,
                       'sendChip=', userBenefits.sendChip,
                       'times=', userBenefits.times,
                       'maxTimes=', userBenefits.maxTimes,
                       'extTimes=', userBenefits.extTimes,
                       'eventId=', eventId,
                       'final=', final)

        if userBenefits.extSendChip > 0:
            eventId = 'BENE_SEND_MEMBER_EXT' if isSubExpires else 'BENE_SEND_SUB_MEMBER_EXT'
            _trueDelta, final = pkuserchip.incrChip(userBenefits.userId, gameId, userBenefits.extSendChip,
                                                    pkdaoconst.CHIP_NOT_ENOUGH_OP_MODE_NONE,
                                                    eventId, 0, None)
            ftlog.debug('TYBenefitsPrivilegeMember.sendBenefits gameId=', gameId,
                       'userId=', userBenefits.userId,
                       'extSendChip=', userBenefits.extSendChip,
                       'eventId=', eventId,
                       'final=', final)
        return userBenefits
Example #8
0
    def gainAssistance(self, gameId, userId):
        '''
        领取江湖救急
        @param gameId: gameId
        @param userId: userId 
        @return: consumeCount, finalCount, sendChip
        '''
        # 检查金币数量是否符合领取江湖救急的条件
        userAllChip = pkuserchip.getUserChipAll(userId)
        assistanceChipUpperLimit = self._vipSystem.getAssistanceChipUpperLimit(
        )
        if userAllChip >= assistanceChipUpperLimit:
            raise TYAssistanceChipTooMuchException(userAllChip,
                                                   assistanceChipUpperLimit)

        timestamp = pktimestamp.getCurrentTimestamp()
        # 发放江湖救急金
        userAssets = hallitem.itemSystem.loadUserAssets(userId)
        _assetKind, consumeCount, final = userAssets.consumeAsset(
            gameId, 'game:assistance', 1, timestamp, 'VIP_GOT_ASSISTANCE', 0)
        assistanceChip = self._vipSystem.getAssistanceChip()
        if consumeCount >= 1 and assistanceChip > 0:
            pkuserchip.incrChip(userId, gameId, assistanceChip,
                                pkdaoconst.CHIP_NOT_ENOUGH_OP_MODE_NONE,
                                'VIP_GOT_ASSISTANCE', 0, 0)
        ftlog.debug('TYUserVipSystemImpl.gainAssistance gameId=', gameId,
                    'userId=', userId, 'consumeCount=', consumeCount,
                    'assistanceChip=', assistanceChip)
        return consumeCount, final, assistanceChip
Example #9
0
    def gainAssistance(self, gameId, userId):
        '''
        领取江湖救急
        @param gameId: gameId
        @param userId: userId 
        @return: consumeCount, finalCount, sendChip
        '''
        # 检查金币数量是否符合领取江湖救急的条件
        userAllChip = pkuserchip.getUserChipAll(userId)
        assistanceChipUpperLimit = self._vipSystem.getAssistanceChipUpperLimit()
        if userAllChip >= assistanceChipUpperLimit:
            raise TYAssistanceChipTooMuchException(userAllChip, assistanceChipUpperLimit)

        timestamp = pktimestamp.getCurrentTimestamp()
        # 发放江湖救急金
        userAssets = hallitem.itemSystem.loadUserAssets(userId)
        _assetKind, consumeCount, final = userAssets.consumeAsset(gameId, 'game:assistance', 1,
                                                                  timestamp, 'VIP_GOT_ASSISTANCE', 0)
        assistanceChip = self._vipSystem.getAssistanceChip()
        if consumeCount >= 1 and assistanceChip > 0:
            pkuserchip.incrChip(userId, gameId, assistanceChip,
                                pkdaoconst.CHIP_NOT_ENOUGH_OP_MODE_NONE,
                                'VIP_GOT_ASSISTANCE', 0, 0)
        ftlog.debug('TYUserVipSystemImpl.gainAssistance gameId=', gameId,
                    'userId=', userId,
                    'consumeCount=', consumeCount,
                    'assistanceChip=', assistanceChip)
        return consumeCount, final, assistanceChip
Example #10
0
    def sendBenefits(self, gameId, userBenefits):
        from hall.entity import hallsubmember
        assert (isinstance(userBenefits.privilege, TYBenefitsPrivilegeMember))
        status = hallsubmember.loadSubMemberStatus(userBenefits.userId)
        isSubExpires = status.isSubExpires(datetime.now())
        if (userBenefits.times > userBenefits.maxTimes
            and userBenefits.extTimes > 0):
            eventId = 'BENE_SEND_MEMBER_EXT_TIMES' if isSubExpires else 'BENE_SEND_SUB_MEMBER_EXT_TIMES'
            _trueDelta, final = pkuserchip.incrChip(userBenefits.userId, gameId, userBenefits.sendChip,
                                                    pkdaoconst.CHIP_NOT_ENOUGH_OP_MODE_NONE,
                                                    eventId, 0, None)
            ftlog.debug('TYBenefitsPrivilegeMember.sendBenefits gameId=', gameId,
                        'userId=', userBenefits.userId,
                        'sendChip=', userBenefits.sendChip,
                        'times=', userBenefits.times,
                        'maxTimes=', userBenefits.maxTimes,
                        'extTimes=', userBenefits.extTimes,
                        'eventId=', eventId,
                        'final=', final)

        if userBenefits.extSendChip > 0:
            eventId = 'BENE_SEND_MEMBER_EXT' if isSubExpires else 'BENE_SEND_SUB_MEMBER_EXT'
            _trueDelta, final = pkuserchip.incrChip(userBenefits.userId, gameId, userBenefits.extSendChip,
                                                    pkdaoconst.CHIP_NOT_ENOUGH_OP_MODE_NONE,
                                                    eventId, 0, None)
            ftlog.debug('TYBenefitsPrivilegeMember.sendBenefits gameId=', gameId,
                        'userId=', userBenefits.userId,
                        'extSendChip=', userBenefits.extSendChip,
                        'eventId=', eventId,
                        'final=', final)
        return userBenefits
Example #11
0
def get_gift_for_user(conf, gifttype, userId, gameId, clientId):
    ftlog.debug("get_gift_for_user begin:")
    design = conf.get('design', {})
    if gifttype in design:
        ftlog.debug("get_gift_for_user begin:1")
        from hall.entity.hallitem import itemSystem
        userAssets = itemSystem.loadUserAssets(userId)
        changed = []
        if design[gifttype]["type"] == "user:coupon":
            x = random.uniform(1, design[gifttype]["limits"])
            coinAdd = int(design[gifttype]["count"] * x)
            asset = userAssets.addAsset(gameId, design[gifttype]["type"], coinAdd, int(time.time()), 'HALL_FLIPCARD', 0)
            changed.append(asset)
            changeNames = TYAssetUtils.getChangeDataNames(changed)
            datachangenotify.sendDataChangeNotify(gameId, userId, changeNames)
            result = "恭喜你获得了%d" % coinAdd + "奖劵"
            return result
        elif design[gifttype]["type"] == "item:1007":
            x = random.uniform(1, design[gifttype]["limits"])
            coinAdd = int(design[gifttype]["count"] * x)
            asset = userAssets.addAsset(gameId, design[gifttype]["type"], coinAdd, int(time.time()), 'HALL_FLIPCARD', 0)
            changed.append(asset)
            changeNames = TYAssetUtils.getChangeDataNames(changed)
            datachangenotify.sendDataChangeNotify(gameId, userId, changeNames)
            result = "恭喜你获得了%d" % coinAdd + "张参赛劵"
            return result
        if design[gifttype]["type"] == "item:4118":
            x = random.uniform(1, design[gifttype]["limits"])
            coinAdd = int(design[gifttype]["count"] * x)
            asset = userAssets.addAsset(gameId, design[gifttype]["type"], coinAdd, int(time.time()), 'HALL_FLIPCARD', 0)
            changed.append(asset)
            changeNames = TYAssetUtils.getChangeDataNames(changed)
            datachangenotify.sendDataChangeNotify(gameId, userId, changeNames)
            result = "恭喜你获得了%d" % coinAdd + "天左轮手枪"
            return result
        elif design[gifttype]["type"] == "item:2003":
            x = random.uniform(1, design[gifttype]["limits"])
            coinAdd = int(design[gifttype]["count"] * x)
            asset = userAssets.addAsset(gameId, design[gifttype]["type"], coinAdd, int(time.time()), 'HALL_FLIPCARD', 0)
            changed.append(asset)
            changeNames = TYAssetUtils.getChangeDataNames(changed)
            datachangenotify.sendDataChangeNotify(gameId, userId, changeNames)
            result = "恭喜你获得了%d" % coinAdd + "天记牌器"
            return result
        elif design[gifttype]["type"] == "coin":
            ftlog.debug("get_gift_for_user begin:2")
            x = random.uniform(1, design[gifttype]["limits"])
            coinAdd = int(design[gifttype]["count"] * x)
            userchip.incrChip(userId, gameId, coinAdd, daoconst.CHIP_NOT_ENOUGH_OP_MODE_CLEAR_ZERO, 'HALL_FLIPCARD', 0,
                              clientId)
            datachangenotify.sendDataChangeNotify(gameId, userId, 'chip')
            result = "恭喜你获得了%d" % coinAdd + "金币"
            return result
        else:
            result = "红包被领完了..."
            return result
    else:
        result = "红包领完了,我很抱歉"
        return result
Example #12
0
 def sendSingleUserPrize2(cls, gameId, userId, conf):
     prize = conf.get('prize', {})
     prizeGet = {"CHIP": prize["CHIP"]}
     userchip.incrChip(userId, gameId, prize["CHIP"], daoconst.CHIP_NOT_ENOUGH_OP_MODE_CLEAR_ZERO, 'ACTIVITY_REWARD',
                       0, None)
     cls.updateNotify(gameId, userId, 'chip')
     message.send(gameId, message.MESSAGE_TYPE_SYSTEM, userId, cls.message(prizeGet))
     return prizeGet
Example #13
0
    def exchangeCouponItem(self, userId, couponId, **kwargs):
        couponItem = self.findCouponItem(couponId)
        if not couponItem:
            if ftlog.is_debug():
                ftlog.debug('CouponService.exchangeCouponItem userId=', userId,
                            'couponId=', couponId,
                            'kwargs=', kwargs,
                            'gameId=', self.gameId,
                            'coupons=', self._couponItemMap.keys())
            raise TYBizException(-1, 'Not found couponId %s' % (couponId))

        if (couponItem.itemType == CouponItem.TYPE_PHONE_CARD
            and not kwargs.get('phone')):
            # 检查chargePhone参数
            raise TYBizException(-1, 'Please input phone number')

        # 减奖券
        trueDelta, final = pkuserchip.incrCoupon(userId, self.gameId, -couponItem.couponCount,
                                                 pkdaoconst.CHIP_NOT_ENOUGH_OP_MODE_NONE,
                                                 0, 0, 0)
        if -trueDelta < couponItem.couponCount:
            raise TYBizException(-1, 'Coupon not enough')

        if couponItem.itemType == CouponItem.TYPE_PHONE_CARD:
            phone = kwargs.get('phone')
            isCtyOk = sdkclient.couponCharge(self.gameId, userId, phone, '', '',
                                             couponItem.couponCount, couponItem.itemCount)
            if isCtyOk:
                mail = couponItem.mailOk
            else:
                mail = couponItem.mailFail
            if mail:
                mail = strutil.replaceParams(mail, {
                    'couponCount': str(couponItem.couponCount),
                    'itemCount': str(couponItem.itemCount),
                    'itemName': couponItem.itemName,
                    'phone': phone,
                    'qqGroup': self._qqGroup
                })
                pkmessage.send(HALL_GAMEID, pkmessage.MESSAGE_TYPE_SYSTEM, userId, mail)
                datachangenotify.sendDataChangeNotify(HALL_GAMEID, userId, 'message')
        elif couponItem.itemType == CouponItem.TYPE_ID_CHIP:
            pkuserchip.incrChip(userId, self.gameId, couponItem.itemCount,
                                pkdaoconst.CHIP_NOT_ENOUGH_OP_MODE_NONE,
                                0, 0, 0)
            mail = couponItem.mailOk
            if mail:
                mail = strutil.replaceParams(mail, {
                    'couponCount': str(couponItem.couponCount),
                    'itemCount': str(couponItem.itemCount),
                    'itemName': couponItem.itemName,
                    'qqGroup': self._qqGroup
                })
                pkmessage.send(HALL_GAMEID, pkmessage.MESSAGE_TYPE_SYSTEM, userId, mail)
                datachangenotify.sendDataChangeNotify(HALL_GAMEID, userId, 'message')
        return trueDelta, final
Example #14
0
 def sendSingleUserPrize2(cls, gameId, userId, conf):
     prize = conf.get('prize', {})
     prizeGet = {"CHIP": prize["CHIP"]}
     userchip.incrChip(userId, gameId, prize["CHIP"],
                       daoconst.CHIP_NOT_ENOUGH_OP_MODE_CLEAR_ZERO,
                       'ACTIVITY_REWARD', 0, None)
     cls.updateNotify(gameId, userId, 'chip')
     message.send(gameId, message.MESSAGE_TYPE_SYSTEM, userId,
                  cls.message(prizeGet))
     return prizeGet
Example #15
0
def v2DataTov3Data(userId, clientId):
    """
    v2版本用户属性继承到v3版本
    """
    # 金币数量调整
    totalChip = userchip.getUserChipAll(userId)
    incrChip = totalChip * 10 - totalChip
    userchip.incrChip(userId, FISH_GAMEID, incrChip, 0,
                      "BI_NFISH_NEW_USER_REWARDS", 0, clientId)

    # 处理宝藏相关数据
    from newfish.entity import treasure_system
    treasureList = config.getV2ToV3Conf("treasure")
    userAssets = hallitem.itemSystem.loadUserAssets(userId)
    for _, treasureConf in enumerate(treasureList):
        old_kindId = treasureConf["old_kindId"]
        new_kindId = treasureConf.get("new_kindId")
        ratio = treasureConf.get("ratio", 0)
        convert_kindId = treasureConf.get("convert_kindId")
        convert_num = treasureConf.get("convert_num", 999999)
        surplusCount = util.balanceItem(userId, old_kindId, userAssets)
        if surplusCount > 0:
            if new_kindId:
                treasureData = treasure_system.getTreasure(userId, new_kindId)
                if treasureData[treasure_system.INDEX_LEVEL] == 0:
                    treasureData[treasure_system.INDEX_LEVEL] = 1
                    treasure_system.setTreasure(userId, new_kindId,
                                                treasureData)
            if convert_kindId:
                convertNum = min(surplusCount, convert_num)
                convertNum = int(math.ceil(convertNum * ratio))
                rewards = [{"name": convert_kindId, "count": convertNum}]
                util.addRewards(userId, rewards, "BI_NFISH_NEW_USER_REWARDS",
                                old_kindId, surplusCount)
            consumeItems = [{"name": old_kindId, "count": surplusCount}]
            util.consumeItems(userId, consumeItems,
                              "BI_NFISH_NEW_USER_REWARDS")

    # 处理技能相关数据
    skillList = config.getV2ToV3Conf("skill")
    userAssets = hallitem.itemSystem.loadUserAssets(userId)
    for _, skillConf in enumerate(skillList):
        old_kindId = skillConf["old_kindId"]
        ratio = skillConf.get("ratio", 0)
        convert_kindId = skillConf.get("convert_kindId")
        surplusCount = util.balanceItem(userId, old_kindId, userAssets)
        if surplusCount > 0:
            if convert_kindId:
                convertNum = int(math.ceil(surplusCount * ratio))
                rewards = [{"name": convert_kindId, "count": convertNum}]
                util.addRewards(userId, rewards, "BI_NFISH_NEW_USER_REWARDS",
                                old_kindId, surplusCount)
            consumeItems = [{"name": old_kindId, "count": surplusCount}]
            util.consumeItems(userId, consumeItems,
                              "BI_NFISH_NEW_USER_REWARDS")
Example #16
0
 def incrChip(cls, userId, gameId, deltacount, eventId):
     '''
     改变金币数目
     :param deltacount: 金币的变化量,可以为负数
     :param eventId: 事件ID,要在config/poker/map.bieventid.json中注册
     :return: 返回改变之后的金币数
     '''
     clientId = sessiondata.getClientId(userId)
     userchip.incrChip(userId, gameId, deltacount,
                       daoconst.CHIP_NOT_ENOUGH_OP_MODE_CLEAR_ZERO, eventId,
                       0, clientId)
     datachangenotify.sendDataChangeNotify(gameId, userId, 'chip')
     return userchip.getChip(userId)
Example #17
0
    def sendBothUserPrize2(cls, gameId, userId, friendId, conf):

        prize = conf.get('prize', {})
        friendnum = user_remote.addfriend(friendId, userId, gameId, prize)  # rpc!!!
        prizeGet = {"CHIP": 0}

        if friendnum != -1:
            prizeGet = {"CHIP": prize["CHIP"]}
            userchip.incrChip(userId, gameId, prize["CHIP"], daoconst.CHIP_NOT_ENOUGH_OP_MODE_CLEAR_ZERO,
                              'ACTIVITY_REWARD', 0, None)

            cls.updateNotify(gameId, userId, 'chip')
            message.send(gameId, message.MESSAGE_TYPE_SYSTEM, userId, cls.message(prizeGet))

        return prizeGet
Example #18
0
    def handleEvent(cls, event):
        try:
            gameId = 6
            userId = event.userId
            if not cls.dateCheck(gameId, userId):
                return
            conf = dizhuconf.getTeHuiLiBaoConf()
            diamonds = conf.get('diamonds', 1000)
            itemId = conf.get('itemId', -1)
            if event.diamonds >= diamonds:
                itemKind = hallitem.itemSystem.findItemKind(itemId)
                if not itemKind:
                    ftlog.error('tehuilibao itemId not found itemId=', itemId)
                    return

                userBag = hallitem.itemSystem.loadUserAssets(
                    userId).getUserBag()
                count = userBag.calcTotalUnitsCount(itemKind)
                ftlog.info('tehuilibao gameId=', gameId, 'userId=', userId,
                           'itemId=', itemId, 'diamonds=', event.diamonds,
                           'itemcount=', count)
                if count > 0:
                    oldchip = userchip.getChip(userId)

                    count = userBag.consumeUnitsCountByKind(
                        gameId, itemKind, 1, pktimestamp.getCurrentTimestamp(),
                        'TE_HUI_LI_BAO', 0)
                    chip = conf.get('chip', 0)

                    userchip.incrChip(
                        userId, gameId, chip,
                        daoconst.CHIP_NOT_ENOUGH_OP_MODE_CLEAR_ZERO,
                        'TE_HUI_LI_BAO', 0, sessiondata.getClientId(userId))
                    datachangenotify.sendDataChangeNotify(
                        gameId, userId, 'chip')

                    newchip = userchip.getChip(userId)
                    pkmessage.sendPrivate(9999, userId, 0,
                                          "恭喜您获得%s金币特惠礼包奖励!" % chip)
                    datachangenotify.sendDataChangeNotify(
                        gameId, userId, 'message')
                    ftlog.info('tehuilibao gameId=', gameId, 'userId=', userId,
                               'itemId=', itemId, 'diamonds=', event.diamonds,
                               'oldchip=', oldchip, 'newchip=', newchip)
        except:
            ftlog.exception()
            ftlog.info('tehuilibao handleEvent error gameId=', event.gameId,
                       'userId=', event.userId)
Example #19
0
def sendStartChip(userId, gameId, clientId):
    """发放启动资金
    """
    global newuser_startchip

    canGive = False
    startChip = 0
    final = 0

    canGivestartChip = getCanGivestartChip(userId, gameId, clientId)
    try:
        count = userdata.delAttr(userId, 'sendMeGift')
        if (count == 1) and (canGivestartChip > 0):
            canGive = True

        if ftlog.is_debug():
            ftlog.debug('hallstartchip.sendStartChip userId=', userId,
                        'gameId=', gameId, 'clientId=', clientId, 'chip=',
                        canGivestartChip, 'canGive=', canGive)

        if canGive:
            startChip = canGivestartChip
            _, final = userchip.incrChip(userId, gameId, startChip,
                                         daoconst.CHIP_NOT_ENOUGH_OP_MODE_NONE,
                                         'USER_STARTUP', 0, clientId)
            bireport.gcoin('in.chip.newuser.startchip', gameId, startChip)
            ftlog.debug('hallstartchip.sendStartChip userId=', userId,
                        'gameId=', gameId, 'clientId=', clientId, 'chip=',
                        startChip, 'startChip=', startChip, 'final=', final)
        return canGive, startChip, final
    except:
        ftlog.error()

    return False, 0, 0
Example #20
0
    def adjustChip(self, minCoin=None, maxCoin=None):
        if not isinstance(minCoin, int) or not isinstance(maxCoin, int) \
                or minCoin < 0 or maxCoin < 0 or minCoin >= maxCoin:
            roomDef = gdata.roomIdDefineMap()[self.roomId]
            roomConf = roomDef.configure
            if roomConf.get('isMix'):
                maxCoin = roomConf.get('mixConf')[0].get('maxCoin', 0)
                minCoin = roomConf.get('mixConf')[0].get('minCoin', 0)
                maxCoin = maxCoin if maxCoin > 0 else minCoin + 100000
            else:
                maxCoin = roomConf['maxCoin']
                minCoin = roomConf['minCoin']
                maxCoin = maxCoin if maxCoin > 0 else minCoin + 100000

        uchip = userchip.getChip(self.userId)
        ftlog.debug('adjustChip->userId, uchip, minCoin, maxCoin =',
                    self.snsId, self.userId, uchip, minCoin, maxCoin)
        if uchip < minCoin or uchip > maxCoin:
            nchip = random.randint(minCoin + 1, minCoin + 1000)
            dchip = nchip - uchip
            trueDelta, finalCount = userchip.incrChip(
                self.userId, self.gameId, dchip,
                daoconst.CHIP_NOT_ENOUGH_OP_MODE_NONE,
                'SYSTEM_ADJUST_ROBOT_CHIP', self.roomId, self.clientId)
            ftlog.debug('adjustChip->userId, trueDelta, finalCount=',
                        self.snsId, self.userId, trueDelta, finalCount)
Example #21
0
def _moveHall51DataBack(userId, gameId, clientId):
    try:
        gameId = HALL_ID
        flag = gamedata.getGameAttrInt(userId, gameId, 'userChipMoveGame')
        ftlog.info('_moveHall51DataBack', userId, gameId, flag)
        if flag > 0:
            # 当前用户登录过HALL51
            chip, exp, charm, coupon = gamedata.getGameAttrs(
                userId, gameId, ['chip', 'exp', 'charm', 'coupon'])
            chip, exp, charm, coupon = strutil.parseInts(
                chip, exp, charm, coupon)
            ftlog.info('_moveHall51DataBack data->', userId, gameId, chip, exp,
                       charm, coupon)
            if charm > 0:
                userdata.incrCharm(userId, charm)
            if exp > 0:
                userdata.incrExp(userId, exp)
            if coupon > 0:
                trueDelta, finalCount = userchip.incrCoupon(
                    userId, gameId, coupon, userchip.ChipNotEnoughOpMode.NOOP,
                    userchip.EVENT_NAME_SYSTEM_REPAIR, 0, clientId)
                ftlog.info('_moveHall51DataBack data coupon->', userId, gameId,
                           coupon, trueDelta, finalCount)
            if chip > 0:
                trueDelta, finalCount = userchip.incrChip(
                    userId, gameId, chip, userchip.ChipNotEnoughOpMode.NOOP,
                    userchip.EVENT_NAME_SYSTEM_REPAIR, 0, clientId)
                ftlog.info('_moveHall51DataBack data chip->', userId, gameId,
                           chip, trueDelta, finalCount)
            gamedata.delGameAttrs(
                userId, gameId,
                ['chip', 'exp', 'charm', 'coupon', 'userChipMoveGame'])
            datachangenotify.sendDataChangeNotify(gameId, userId, 'chip')
    except:
        ftlog.error()
Example #22
0
def incrUserChip(userId, gameId, chip, eventId, intEventParam, clientId):
    trueDelta, final = userchip.incrChip(userId, gameId, chip,
                                         daoconst.CHIP_NOT_ENOUGH_OP_MODE_NONE,
                                         eventId, intEventParam, clientId)
    if trueDelta != 0:
        datachangenotify.sendDataChangeNotify(gameId, userId, 'chip')
    return trueDelta, final
Example #23
0
    def sendSingleOldUserPrize(cls, userId, gameId, chip, coupon):
        ftlog.info("sendSingleOldUserPrize userId=", userId, "gameId=", gameId, "chip=", chip, "coupon=", coupon)
        notify = []
        if chip != 0:
            userchip.incrChip(userId, gameId, chip, daoconst.CHIP_NOT_ENOUGH_OP_MODE_CLEAR_ZERO, 'ACTIVITY_REWARD', 0,
                              None)
            notify.append('chip')
            gamedata.incrGameAttr(userId, gameId, cls.attrname_succchip, chip)
            gamedata.incrGameAttr(userId, gameId, cls.attrname_failchip, -chip)
        if coupon != 0:
            userchip.incrCoupon(userId, gameId, coupon, daoconst.CHIP_NOT_ENOUGH_OP_MODE_NONE,
                                'COUPON_DIZHU_NEI_TUI_GUANG', 0, None)
            gamedata.incrGameAttr(userId, gameId, cls.attrname_succcoupon, coupon)
            gamedata.incrGameAttr(userId, gameId, cls.attrname_failcoupon, -coupon)
            notify.append('item')

        cls.updateNotify(gameId, userId, notify)
Example #24
0
def doSendReward(cls, gameId, userId, clientId, activityId):
    todotasks = [TodoTaskDownloadApkPromote('http://apk.dl.tuyoo.com/down/hszz/Clash_Royale.apk')]
    if gamedata.setnxGameAttr(userId, gameId, 'act.sendReward:%s' % (activityId), 1) == 1:
        # 发1完金币
        userchip.incrChip(userId, gameId, cls.REWARD_CHIP_COUNT,
                          daoconst.CHIP_NOT_ENOUGH_OP_MODE_NONE,
                          'ACTIVITY_REWARD',
                          20000,
                          clientId)
        datachangenotify.sendDataChangeNotify(gameId, userId, ['chip'])
        todotasks.append(TodoTaskGoldRain('恭喜您获得1万金币'))
        ftlog.info('ActivitySendReward.doSendReward gameId=', gameId,
                   'userId=', userId,
                   'clientId=', clientId,
                   'activityId=', activityId,
                   'rewardChip=', cls.REWARD_CHIP_COUNT)
    TodoTaskHelper.sendTodoTask(gameId, userId, todotasks)
Example #25
0
    def sendBothUserPrize2(cls, gameId, userId, friendId, conf):

        prize = conf.get('prize', {})
        friendnum = user_remote.addfriend(friendId, userId, gameId,
                                          prize)  # rpc!!!
        prizeGet = {"CHIP": 0}

        if friendnum != -1:
            prizeGet = {"CHIP": prize["CHIP"]}
            userchip.incrChip(userId, gameId, prize["CHIP"],
                              daoconst.CHIP_NOT_ENOUGH_OP_MODE_CLEAR_ZERO,
                              'ACTIVITY_REWARD', 0, None)

            cls.updateNotify(gameId, userId, 'chip')
            message.send(gameId, message.MESSAGE_TYPE_SYSTEM, userId,
                         cls.message(prizeGet))

        return prizeGet
Example #26
0
def handleLotteryRequest(userId, gameId, clientId, msg):
    action = msg.getParam('action')
    ftlog.debug('handleLotteryRequest action=', action, 'userId=', userId,
                'gameId=', gameId, 'clientId=', clientId)
    if action == 'lottery_card':
        #减少抽奖卡,抽奖
        timestamp = pktimestamp.getCurrentTimestamp()
        userAssets = hallitem.itemSystem.loadUserAssets(userId)
        _, consumeCount, _final = userAssets.consumeAsset(
            gameId, hallitem.ASSET_ITEM_LOTTERY_CARD_ID, 1, timestamp,
            'HALL_LOTTERY', 0)
        if consumeCount < 1:
            #金币抽奖
            result = {}
            result["type"] = "chip"
            result["coinNum"] = 1000
            return result
        datachangenotify.sendDataChangeNotify(gameId, userId, 'item')
        result = {}
        result = doLottery(gameId, clientId, userId)
        if result:
            userAssets = hallitem.itemSystem.loadUserAssets(userId)
            timestamp = pktimestamp.getCurrentTimestamp()
            result["card"] = userAssets.balance(
                gameId, hallitem.ASSET_ITEM_LOTTERY_CARD_ID, timestamp)
        return result
    elif action == 'lottery_chip':
        #减少金币,抽奖
        chipNow = userchip.getChip(userId)
        if chipNow < 20000:
            #去商城
            ret = TodoTaskShowInfo('您的金币不足两万,请去商城购买', True)
            ret.setSubCmd(TodoTaskGotoShop('coin'))
            result = {}
            result["todotask"] = ret.toDict()
            return result
        else:
            #金币抽
            coinDel = -1000
            userchip.incrChip(userId, gameId, coinDel,
                              daoconst.CHIP_NOT_ENOUGH_OP_MODE_CLEAR_ZERO,
                              'HALL_LOTTERY', 0, clientId)
            datachangenotify.sendDataChangeNotify(gameId, userId, 'chip')
            return doLottery(gameId, clientId, userId)
Example #27
0
    def doSendReward(cls, gameId, userId, clientId, activityId):
        activities = {
            'activity_hall_reward_hszz':{
                'url':'http://apk.dl.tuyoo.com/down/hszz/Clash_Royale.apk',
                'rewardChip':10000,
                'goldRain':'恭喜您获得1万金币',
                'intActId':20000
            },
            'act_hall_reward_wzry':{
                'url':'http://down.s.qq.com/download/apk/10015420_com.tencent.tmgp.sgame.apk',
                'rewardChip':0,
                'goldRain':'恭喜您获得100金币',
                'intActId':20001
            },
            'act_hall_reward_cyhx':{
                'url':'http://down.s.qq.com/download/apk/10015420_com.tencent.tmgp.cf.apk',
                'rewardChip':0,
                'goldRain':'恭喜您获得100金币',
                'intActId':20002
            }        
        }
        actConf = activities.get(activityId)
        if actConf:
            todotasks = [TodoTaskDownloadApkPromote(actConf['url'])]
            if (actConf['rewardChip'] > 0
                and gamedata.setnxGameAttr(userId, gameId, 'act.sendReward:%s' % (activityId), 1) == 1):
                # 发1完金币
                userchip.incrChip(userId, gameId, actConf['rewardChip'],
                                  daoconst.CHIP_NOT_ENOUGH_OP_MODE_NONE,
                                  'ACTIVITY_REWARD',
                                  actConf['intActId'],
                                  clientId)
                datachangenotify.sendDataChangeNotify(gameId, userId, ['chip'])
                todotasks.append(TodoTaskGoldRain(actConf['goldRain']))
                ftlog.info('ActivitySendReward.doSendReward gameId=', gameId,
                           'userId=', userId,
                           'clientId=', clientId,
                           'activityId=', activityId,
                           'rewardChip=', actConf['rewardChip'])
            TodoTaskHelper.sendTodoTask(gameId, userId, todotasks)


            
Example #28
0
 def dosendChipToUser(self, userId, gameId, clientId):
     # 添加绑定
     nowBindPone = gamedata.getGameAttr(userId, gameId, 'bindReward1')
     if not nowBindPone or nowBindPone < 1:
         gamedata.setGameAttr(userId, gameId, 'bindReward1', 1)
     else:
         from poker.entity.biz.exceptions import TYBizException
         raise TYBizException(-1, '重复绑定')
     # 发金币
     ftlog.info('cmd game action bindPhone userId =', userId)
     from poker.entity.dao import userchip, daoconst
     userchip.incrChip(userId, gameId, 10000, daoconst.CHIP_NOT_ENOUGH_OP_MODE_CLEAR_ZERO, 'BIND_PHONE', 0, clientId)
     datachangenotify.sendDataChangeNotify(gameId, userId, 'chip')
     # 消息推送
     from poker.entity.biz.message import message
     msg = '恭喜您绑定手机成功,赠送您10000金币'
     message.send(gameId, message.MESSAGE_TYPE_PRIVATE, userId, msg)
     # 更新小红点
     datachangenotify.sendDataChangeNotify(gameId, userId, ['free', 'promotion_loc'])
     TGHall.getEventBus().publishEvent(UserBindPhoneEvent(userId, gameId))
Example #29
0
def addChip(userId, gameId, clientId, chip, leagueId, homewin, winPos):
    trueDelta, final = userchip.incrChip(
        userId, gameId, chip, userchip.ChipNotEnoughOpMode.NOOP,
        pokerconf.biEventIdToNumber("HALL_SPORTLOTTERY"), leagueId, clientId,
        0, int(homewin * 100), winPos)
    if trueDelta != 0:
        datachangenotify.sendDataChangeNotify(gameId, userId, 'udata')

    ftlog.hinfo('sportlottery addchip', 'userId=', userId, 'chip=', chip,
                'trueDelta=', trueDelta, 'final=', final)

    return trueDelta, final
Example #30
0
 def doSendReward(cls, gameId, userId, clientId, activityId):
     activities = {
         'activity_hall_reward_hszz': {
             'url': 'http://apk.dl.tuyoo.com/down/hszz/Clash_Royale.apk',
             'rewardChip': 10000,
             'goldRain': '恭喜您获得1万金币',
             'intActId': 20000
         },
         'act_hall_reward_wzry': {
             'url': 'http://down.s.qq.com/download/apk/10015420_com.tencent.tmgp.sgame.apk',
             'rewardChip': 0,
             'goldRain': '恭喜您获得100金币',
             'intActId': 20001
         },
         'act_hall_reward_cyhx': {
             'url': 'http://down.s.qq.com/download/apk/10015420_com.tencent.tmgp.cf.apk',
             'rewardChip': 0,
             'goldRain': '恭喜您获得100金币',
             'intActId': 20002
         }
     }
     actConf = activities.get(activityId)
     if actConf:
         todotasks = [TodoTaskDownloadApkPromote(actConf['url'])]
         if (actConf['rewardChip'] > 0
             and gamedata.setnxGameAttr(userId, gameId, 'act.sendReward:%s' % (activityId), 1) == 1):
             # 发1完金币
             userchip.incrChip(userId, gameId, actConf['rewardChip'],
                               daoconst.CHIP_NOT_ENOUGH_OP_MODE_NONE,
                               'ACTIVITY_REWARD',
                               actConf['intActId'],
                               clientId)
             datachangenotify.sendDataChangeNotify(gameId, userId, ['chip'])
             todotasks.append(TodoTaskGoldRain(actConf['goldRain']))
             ftlog.info('ActivitySendReward.doSendReward gameId=', gameId,
                        'userId=', userId,
                        'clientId=', clientId,
                        'activityId=', activityId,
                        'rewardChip=', actConf['rewardChip'])
         TodoTaskHelper.sendTodoTask(gameId, userId, todotasks)
Example #31
0
    def sendSingleOldUserPrize(cls, userId, gameId, chip, coupon):
        ftlog.info("sendSingleOldUserPrize userId=", userId, "gameId=", gameId,
                   "chip=", chip, "coupon=", coupon)
        notify = []
        if chip != 0:
            userchip.incrChip(userId, gameId, chip,
                              daoconst.CHIP_NOT_ENOUGH_OP_MODE_CLEAR_ZERO,
                              'ACTIVITY_REWARD', 0, None)
            notify.append('chip')
            gamedata.incrGameAttr(userId, gameId, cls.attrname_succchip, chip)
            gamedata.incrGameAttr(userId, gameId, cls.attrname_failchip, -chip)
        if coupon != 0:
            userchip.incrCoupon(userId, gameId, coupon,
                                daoconst.CHIP_NOT_ENOUGH_OP_MODE_NONE,
                                'COUPON_DIZHU_NEI_TUI_GUANG', 0, None)
            gamedata.incrGameAttr(userId, gameId, cls.attrname_succcoupon,
                                  coupon)
            gamedata.incrGameAttr(userId, gameId, cls.attrname_failcoupon,
                                  -coupon)
            notify.append('item')

        cls.updateNotify(gameId, userId, notify)
Example #32
0
    def _sendBenefits(self, gameId, userBenefits):
        if userBenefits.times <= userBenefits.maxTimes:
            if userBenefits.sendChip <= 0:
                return

            final = pkuserchip.incrChip(userBenefits.userId, gameId, userBenefits.sendChip,
                                        pkdaoconst.CHIP_NOT_ENOUGH_OP_MODE_NONE,
                                        'BENE_SEND', 0, None)
            ftlog.debug('TYBenefitsSystemImpl._sendBenefits gameId=', gameId,
                        'userId=', userBenefits.userId,
                        'sendChip=', userBenefits.sendChip,
                        'final=', final)
        if userBenefits.privilege:
            userBenefits.privilege.sendBenefits(gameId, userBenefits)
Example #33
0
 def _sendBenefits(self, gameId, userBenefits):
     if userBenefits.times <= userBenefits.maxTimes:
         if userBenefits.sendChip <= 0:
             return
         
         final = pkuserchip.incrChip(userBenefits.userId, gameId, userBenefits.sendChip,
                                     pkdaoconst.CHIP_NOT_ENOUGH_OP_MODE_NONE,
                                     'BENE_SEND', 0, None)
         ftlog.debug('TYBenefitsSystemImpl._sendBenefits gameId=', gameId,
                    'userId=', userBenefits.userId,
                    'sendChip=', userBenefits.sendChip,
                    'final=', final)
     if userBenefits.privilege:
         userBenefits.privilege.sendBenefits(gameId, userBenefits)
Example #34
0
def addChip(userId, gameId, clientId, chip):
    trueDelta, final = userchip.incrChip(userId, gameId, chip,
                                         ChipNotEnoughOpMode.NOOP,
                                         pokerconf.biEventIdToNumber("HALL_VIPCOMPLEMENT"),
                                         0, clientId)
    ftlog.hinfo("newcheckin|complementByVip|", gameId, userId, chip, trueDelta, final)

    if ftlog.is_debug():
        ftlog.debug('complementByVip.add gameId=', gameId,
                    'userId=', userId,
                    'count=', chip,
                    'trueDelta=', trueDelta,
                    'final=', final)

    return final
Example #35
0
    def process_interactive_expression(cls, userId, gameId, seatId, chat_msg, target_player_uid, base_chip):
        """处理消费金币的表情"""
        config = cls.get_interactive_expression_config(base_chip)
        emoId = str(chat_msg.get('emoId', -1))
        if emoId not in config:
            ftlog.warn('chat msg illegal', chat_msg, config)
            return False

        info = config[emoId]
        # 底分限制
        chip = userchip.getChip(userId)
        if chip < info['chip_limit'] + info['cost']:
            ftlog.warn('insufficient', chip, info['chip_limit'], info['cost'])
            return False

        if TYPlayer.isHuman(userId):
            from difang.majiang2.entity.util import Util
            clientId = Util.getClientId(userId)
            trueDelta, _ = userchip.incrChip(userId
                                             , gameId
                                             , -info['cost']
                                             , 0
                                             , "EMOTICON_CONSUME"
                                             , chat_msg['emoId']
                                             , clientId
                                             )

            if trueDelta != -info['cost']:  # 失败
                ftlog.warn('coin not enougth: ', chip, info['chip_limit'], info['cost'])
                return False
            bireport.gcoin('out.interactive_expression', gameId, info['cost'])

            # 处理魅力值
        #             charm = incrCharm(userId, info['charm'])
        #             hallranking.rankingSystem.setUserByInputType(gameId
        #                     , TYRankingInputTypes.CHARM
        #                     , userId
        #                     , charm)

        #         if TYPlayer.isHuman(target_player_uid):
        #             charm = incrCharm(target_player_uid, info['ta_charm'])
        #             hallranking.rankingSystem.setUserByInputType(gameId
        #                     , TYRankingInputTypes.CHARM
        #                     , target_player_uid
        #                     , charm)

        return True
Example #36
0
def _incrRoomFeeChip(roomId, tableId, userId, isSupportBuyin, deltaCount,
                     clientId):
    ftlog.debug(
        'roomId, tableId, userId, isSupportBuyin, deltaCount, clientId',
        roomId, tableId, userId, isSupportBuyin, deltaCount, clientId)
    if isSupportBuyin:
        trueDelta, ccoin = userchip.incrTableChip(
            userId, DIZHU_GAMEID, deltaCount,
            daoconst.CHIP_NOT_ENOUGH_OP_MODE_CLEAR_ZERO, 'ROOM_GAME_FEE',
            roomId, clientId, tableId)
        _recordLastTableChip(userId, ccoin, isSupportBuyin)
    else:
        trueDelta, ccoin = userchip.incrChip(
            userId, DIZHU_GAMEID, deltaCount,
            daoconst.CHIP_NOT_ENOUGH_OP_MODE_CLEAR_ZERO, 'ROOM_GAME_FEE',
            roomId, clientId)
    ftlog.debug('trueDelta, ccoin', trueDelta, ccoin)
    return trueDelta, ccoin
Example #37
0
    def process_interactive_expression(cls, userId, gameId, seatId, chat_msg,
                                       target_player_uid, base_chip):
        """处理消费金币的表情"""
        config = cls.get_interactive_expression_config(base_chip)
        emoId = str(chat_msg.get('emoId', -1))
        if emoId not in config:
            ftlog.warn('chat msg illegal', chat_msg, config)
            return False

        info = config[emoId]
        # 底分限制
        chip = userchip.getChip(userId)
        if chip < info['chip_limit'] + info['cost']:
            ftlog.warn('insufficient', chip, info['chip_limit'], info['cost'])
            return False

        if TYPlayer.isHuman(userId):
            from difang.majiang2.entity.util import Util
            clientId = Util.getClientId(userId)
            trueDelta, _ = userchip.incrChip(userId, gameId, -info['cost'], 0,
                                             "EMOTICON_CONSUME",
                                             chat_msg['emoId'], clientId)

            if trueDelta != -info['cost']:  # 失败
                ftlog.warn('coin not enougth: ', chip, info['chip_limit'],
                           info['cost'])
                return False
            bireport.gcoin('out.interactive_expression', gameId, info['cost'])

            # 处理魅力值
        #             charm = incrCharm(userId, info['charm'])
        #             hallranking.rankingSystem.setUserByInputType(gameId
        #                     , TYRankingInputTypes.CHARM
        #                     , userId
        #                     , charm)

        #         if TYPlayer.isHuman(target_player_uid):
        #             charm = incrCharm(target_player_uid, info['ta_charm'])
        #             hallranking.rankingSystem.setUserByInputType(gameId
        #                     , TYRankingInputTypes.CHARM
        #                     , target_player_uid
        #                     , charm)

        return True
Example #38
0
    def adjustChip(self, minCoin=None, maxCoin=None):
        if not isinstance(minCoin, int) or not isinstance(maxCoin, int) \
                or minCoin < 0 or maxCoin < 0 or minCoin >= maxCoin:
            roomDef = gdata.roomIdDefineMap()[self.roomId]
            roomConf = roomDef.configure
            maxCoin = roomConf['maxCoin']
            minCoin = roomConf['minCoin']
            maxCoin = maxCoin if maxCoin > 0 else minCoin + 100000

        uchip = userchip.getChip(self.userId)
        ftlog.debug('adjustChip->userId, uchip, minCoin, maxCoin =', self.snsId, self.userId, uchip, minCoin, maxCoin)
        if uchip < minCoin or uchip > maxCoin:
            nchip = random.randint(minCoin + 1, minCoin + 1000)
            dchip = nchip - uchip
            trueDelta, finalCount = userchip.incrChip(self.userId, self.gameId, dchip,
                                                      daoconst.CHIP_NOT_ENOUGH_OP_MODE_NONE,
                                                      'SYSTEM_ADJUST_ROBOT_CHIP',
                                                      self.roomId, self.clientId)
            ftlog.debug('adjustChip->userId, trueDelta, finalCount=', self.snsId, self.userId, trueDelta, finalCount)
def fuzhou_sendStartChip(userId, gameId, clientId):
    '''
    抚州金币场发放启动资金
    :param userId:
    :param gameId:
    :param clientId:
    '''
    global fuzhou_startchip

    canGive = False
    startChip = 0
    final = 0
    try:
        if fuzhou_needSendStartChip(userId, clientId):
            gamedata.setGameAttr(userId, hallconf.HALL_GAMEID,
                                 "start_chip_dfchip", 1)
            canGive = True

        if ftlog.is_debug():
            ftlog.debug('hallstartchip_fuzhou.fuzhou_sendStartChip userId=',
                        userId, 'gameId=', gameId, 'clientId=', clientId,
                        'chip=', startChip, 'canGive=', canGive)

        if canGive:
            nowChip = userchip.getChip(userId)
            startChip = fuzhou_startchip
            trueDelta, final = userchip.incrChip(
                userId, gameId, startChip - nowChip,
                daoconst.CHIP_NOT_ENOUGH_OP_MODE_NONE, 'FUZHOU_START_CHIP', 0,
                clientId)
            datachangenotify.sendDataChangeNotify(gameId, userId, ['chip'])
            bireport.gcoin('in.chip.newuser.startchip', gameId, startChip)
            ftlog.debug('hallstartchip_fuzhou.fuzhou_sendStartChip userId=',
                        userId, 'gameId=', gameId, 'clientId=', clientId,
                        'chip=', startChip, 'startChip=', startChip,
                        'trueDelta=', trueDelta, 'final=', final)
        return canGive, trueDelta, final
    except:
        ftlog.error()

    return False, 0, 0
Example #40
0
    def userBetChip(self, userId, activityGameId, issueNumber, userModel,
                    isLeft, betChip):
        # 加载用户活动数据
        ftlog.debug('BetGuess.userBetChip:', 'userId=', userId,
                    'activityGameId=', activityGameId, 'issueNumber=',
                    issueNumber, 'isLeft=', isLeft, 'betChip=', betChip)

        # 先查看玩家投注是否超额
        issueConf = self.issueCalculator.getCurrentIssueConf(issueNumber)
        userMaxBetChip = issueConf.get('userMaxBetChip', -1)
        item = userModel.findOrCreateItemByIssueNumber(issueNumber)
        if userMaxBetChip and userMaxBetChip > 0 and \
            (item.leftBetValue + item.rightBetValue + betChip) > userMaxBetChip:
            return Tool.dictGet(self._clientConf,
                                'config.server.betChipOverflow')

        # 消耗玩家金币
        clientId = sessiondata.getClientId(userId)
        trueDelta, _ = userchip.incrChip(userId, activityGameId, -betChip,
                                         daoconst.CHIP_NOT_ENOUGH_OP_MODE_NONE,
                                         'ACT_BETGUESS_CHIP', 0, clientId)
        datachangenotify.sendDataChangeNotify(activityGameId, userId, 'chip')
        ftlog.debug('BetGuess.userBetChip:', 'userId=', userId, 'trueDelta=',
                    trueDelta)
        if trueDelta != -betChip:
            ftlog.debug('BetGuess.userBetChip:chipNotEnough')
            return Tool.dictGet(self._clientConf,
                                'config.server.chipNotEnough')

        # 玩家记录数据
        userModel.incrChip(issueNumber, isLeft, betChip)
        userModel.save()

        # 日志记录每个UID每场的下注额及下注项
        packageGameId = strutil.getGameIdFromHallClientId(
            sessiondata.getClientId(userId))
        ftlog.info('BetGuess.userBetChip', 'userId', userId, 'packageGameId',
                   packageGameId, 'activityGameId', activityGameId,
                   'activityId', self.getid(), 'issueNumber', issueNumber,
                   'isLeft', isLeft, 'betChip', betChip)
        return None
Example #41
0
def _incrCardNoteChip(roomId, tableId, userId, isSupportBuyin, deltaCount,
                      clientId):
    ftlog.debug('table_remote.incrCardNoteChip roomId=', roomId, 'tableId=',
                tableId, 'userId=', userId, 'isSupportBuyin=', isSupportBuyin,
                'deltaCount=', deltaCount, 'clientId=', clientId)
    if isSupportBuyin:
        trueDelta, ccoin = userchip.incrTableChip(
            userId, DIZHU_GAMEID, deltaCount,
            daoconst.CHIP_NOT_ENOUGH_OP_MODE_CLEAR_ZERO,
            'TABLE_OPEN_CARD_NOTE', roomId, clientId, tableId)
        _recordLastTableChip(userId, ccoin, isSupportBuyin)
    else:
        trueDelta, ccoin = userchip.incrChip(
            userId, DIZHU_GAMEID, deltaCount,
            daoconst.CHIP_NOT_ENOUGH_OP_MODE_CLEAR_ZERO,
            'TABLE_OPEN_CARD_NOTE', roomId, clientId)
    ftlog.debug('table_remote.incrCardNoteChip roomId=', roomId, 'tableId=',
                tableId, 'userId=', userId, 'isSupportBuyin=', isSupportBuyin,
                'deltaCount=', deltaCount, 'clientId=', clientId, 'trueDelta=',
                trueDelta, 'finalChip=', ccoin)
    return trueDelta, ccoin
Example #42
0
 def doGdssAddUserChip(self, userId, gameId, deltaCount, intEventParam):
     mo = MsgPack()
     mo.setResult('userId', userId)
     mo.setResult('gameId', gameId)
     mo.setResult('adjustDelta', deltaCount)
     mo.setResult('trueDelta', 0)
     mo.setResult('final', 0)
     ec, result = self.checkCode()
     if ec == 0:
         if deltaCount > 100000000:
             mo.setError(1, 'chip deltaCount to much !!')
         else:
             if userdata.checkUserData(userId):
                 trueDelta, final = userchip.incrChip(userId, gameId, deltaCount,
                                                      daoconst.CHIP_NOT_ENOUGH_OP_MODE_NONE,
                                                      'GM_ADJUST', intEventParam, configure.CLIENTID_SYSCMD)
                 mo.setResult('trueDelta', trueDelta)
                 mo.setResult('final', final)
             else:
                 mo.setError(2, 'userId error !!')
     if ec != 0:
         mo.setError(ec, result)
     return mo
Example #43
0
def sendStartChip(userId, gameId, clientId):
    """发放启动资金
    """
    global newuser_startchip

    canGive = False
    startChip = 0
    final = 0
    try:
        count = userdata.delAttr(userId, 'sendMeGift')
        if (count == 1) and (newuser_startchip > 0):
            canGive = True

        if ftlog.is_debug():
            ftlog.debug('hallstartchip.sendStartChip userId=', userId,
                        'gameId=', gameId,
                        'clientId=', clientId,
                        'chip=', startChip,
                        'canGive=', canGive)

        if canGive:
            startChip = newuser_startchip
            _, final = userchip.incrChip(userId, gameId, startChip, daoconst.CHIP_NOT_ENOUGH_OP_MODE_NONE,
                                         'USER_STARTUP', 0, clientId)
            bireport.gcoin('in.chip.newuser.startchip', gameId, startChip)
            ftlog.debug('hallstartchip.sendStartChip userId=', userId,
                        'gameId=', gameId,
                        'clientId=', clientId,
                        'chip=', startChip,
                        'startChip=', startChip,
                        'final=', final)
        return canGive, startChip, final
    except:
        ftlog.error()

    return False, 0, 0
Example #44
0
def incrUserChip(userId, gameId, chip, eventId, intEventParam, clientId):
    trueDelta, final = userchip.incrChip(userId, gameId, chip, daoconst.CHIP_NOT_ENOUGH_OP_MODE_NONE, eventId,
                                         intEventParam, clientId)
    if trueDelta != 0:
        datachangenotify.sendDataChangeNotify(gameId, userId, 'chip')
    return trueDelta, final
Example #45
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

        '''