コード例 #1
0
    def getChouJiangReward(self, gameId, userId, clientId):
        from dizhu.activities.choujiang_360 import ChouJiang360
        status = 0
        all_count = 0
        get_count = 0
        tip = ''
        ecode = 0
        try:
            data = gamedata.getGameAttrJson(userId, gameId,
                                            ChouJiang360.attr_act, {})
            if data:
                if data["get_count"] < data["current_count"]:
                    tip = self.sendReward(gameId, userId, clientId,
                                          TYContentItem('item:4147', 1),
                                          'HUI_YUAN_360', 0)
                    tip = ''.join([tip, ' 请去背包查收'])
                    data["get_count"] += 1

                all_count = data["all_count"]
                get_count = data["get_count"]

                status = int(data["get_count"] < data["current_count"])

                gamedata.setGameAttr(userId, gameId, ChouJiang360.attr_act,
                                     json.dumps(data))
        except:
            ftlog.exception()
            tip = "领取失败"
            ecode = 1

        return tip, ecode, status, all_count, get_count
コード例 #2
0
 def loadStatus(self, userId):
     try:
         itemMap = {}
         paddingList = []
         d = pkgamedata.getGameAttrJson(userId, 6, 'flipcard')
         if d:
             flipTime = int(d['ut'])
             items = d.get('items', [])
             for item in items:
                 itemMap[item['idx']] = TYContentItem(item['assetId'], item['count'])
             paddings = d.get('paddings', [])
             for item in paddings:
                 paddingList.append(TYContentItem(item['assetId'], item['count']))
             return DizhuFlipCardStatus(flipTime, itemMap, paddingList) 
     except:
         ftlog.error()
     return None
コード例 #3
0
    def exchange(self, userId):
        if not self.checkActivityActive():
            if ftlog.is_debug():
                ftlog.debug('christmas.exchange.checkActive.failed. userId=', userId)
            return u"不在活动时间内"

        assetList = None

        collectList = self.getUserCollectList(userId)
        timestamp = pktimestamp.getCurrentTimestamp()
        userAssets = hallitem.itemSystem.loadUserAssets(userId)

        collectCountList = []
        for items in collectList:
            if items[1] and items[2]:
                collectCountList.append(int(items[1] / items[2]))
            else:
                collectCountList.append(0)
        collectCount = min(collectCountList)
        if collectCount:
            for item in collectList:
                itemId = item[0]
                consumeSockCount = item[2] * collectCount
                _, consumeCount, final = userAssets.consumeAsset(DIZHU_GAMEID,
                                                                 itemId,
                                                                 consumeSockCount,
                                                                 timestamp,
                                                                 'DIZHU_ACT_CHRISTMAS_EXCHANGE',
                                                                 0)
                if ftlog.is_debug():
                    ftlog.debug('christmas.exchange.warning userId=', userId,
                                'consumeCount=', consumeCount,
                                'collectCount=', collectCount,
                                'finalCount=', final,
                                'collectList=', collectList)

            collectTimes = daobase.executeUserCmd(userId, 'HINCRBY', 'act:christmas:6:' + str(userId), 'reward', collectCount)

            # 根据VIP等级发奖励
            userRewards = self.getUserRewardByVip(userId)
            if not userRewards:
                ftlog.warn('christmas.exchange.warning.rewardError',
                           'userId=', userId, 'reward=', userRewards)
                return u""

            if ftlog.is_debug():
                ftlog.debug('christmas.exchange',
                            'userId=', userId,
                            'userRewards=', userRewards,
                            'userRewardsId=', id(userRewards))

            contentItems = []
            for rewardItem in userRewards:
                contentItems.append(TYContentItem(rewardItem['itemId'], int(rewardItem['count'] * collectCount)))

            assetList = dizhu_util.sendRewardItems(userId, contentItems, self._mail, 'DIZHU_ACT_CHRISTMAS_REWARD', 0)

            ftlog.info('gainChristmasFinalReward userId=', userId,
                       'collectTimes=', collectTimes,
                       'rewards=', [(atp[0].kindId, atp[1]) for atp in assetList])
        if ftlog.is_debug():
            ftlog.debug('christmas.exchange.info userId=', userId,
                        'collectCount=', collectCount,
                        'collectList=', collectList,
                        'assetList=', [(atp[0].kindId, atp[1]) for atp in assetList] if assetList else None)
        return u""