Esempio n. 1
0
 def sendReward(self, gameId, userId, clientId, contentItem, eventId,
                intEventParam):
     try:
         timestamp = pktimestamp.getCurrentTimestamp()
         userAssets = hallitem.itemSystem.loadUserAssets(userId)
         assetKind, count, final = userAssets.addAsset(
             gameId, contentItem.assetKindId, contentItem.count, timestamp,
             eventId, intEventParam)
         if assetKind.keyForChangeNotify:
             datachangenotify.sendDataChangeNotify(
                 gameId, userId, [assetKind.keyForChangeNotify])
         contentStr = TYAssetUtils.buildContent((assetKind, count, final))
         ftlog.info(
             'ActivityPCHandler.sendReward gameId=', gameId, 'userId=',
             userId, 'clientId=', clientId, 'reward=',
             '(%s,%s)' % (contentItem.assetKindId, contentItem.count),
             'eventId=', eventId, 'intEventParam=', intEventParam)
         return '恭喜您获得%s!' % (contentStr)
     except TYBizException, e:
         ftlog.warn(
             'ActivityPCHandler.sendReward gameId=', gameId, 'userId=',
             userId, 'clientId=', clientId, 'reward=',
             '(%s,%s)' % (contentItem.assetKindId, contentItem.count),
             'eventId=', eventId, 'intEventParam=', intEventParam, 'err=',
             str(e))
         return '领取失败'
Esempio n. 2
0
 def flipCard(self, userId, index, timestamp=None):
     if timestamp is None:
         timestamp = pktimestamp.getCurrentTimestamp()
     status = self.loadStatus(userId, timestamp)
     remFlipCount = status.getRemFlipCount()
     if remFlipCount <= 0:
         ftlog.debug('DizhuFlipCard.flipCard userId=', userId,
                     'index=', index,
                     'nslogin='******'timestamp=', datetime.fromtimestamp(timestamp).strftime('%Y-%m-%d %H:%M:%S'),
                     'remFlipCount=', remFlipCount)
         return False, status, None
     
     contentItem = status.findItemByIndex(index)
     if contentItem:
         ftlog.debug('DizhuFlipCard.flipCard userId=', userId,
                     'index=', index,
                     'nslogin='******'timestamp=', datetime.fromtimestamp(timestamp).strftime('%Y-%m-%d %H:%M:%S'),
                     'alreadyFlipped=', '%s:%s' % (contentItem.assetKindId, contentItem.count))
         return False, status, None
     
     regDays = self._calcRegDays(userId, timestamp)
     contentItem = self._flipCard(regDays)
     if not contentItem:
         ftlog.debug('DizhuFlipCard.flipCard userId=', userId,
                     'index=', index,
                     'nslogin='******'regDays=', regDays,
                     'timestamp=', datetime.fromtimestamp(timestamp).strftime('%Y-%m-%d %H:%M:%S'),
                     'flipped=', None)
         return False, status, None
     
     status.addItem(index, contentItem)
     status.flipTime = timestamp
     remFlipCount = status.getRemFlipCount()
     if remFlipCount <= 0:
         status.paddings = self._makePaddings(userId)
     self._dao.saveStatus(userId, status)
     userAssets = hallitem.itemSystem.loadUserAssets(userId)
     assetItem = userAssets.addAsset(DIZHU_GAMEID, contentItem.assetKindId, contentItem.count,
                                     timestamp, 'NSLOGIN_REWARD', status.nslogin)
     contentString = TYAssetUtils.buildContent(assetItem)
     if self._rewardMail:
         mail = strutil.replaceParams(self._rewardMail, {'rewardContent':contentString})
         pkmessage.sendPrivate(DIZHU_GAMEID, userId, 0, mail)
         datachangenotify.sendDataChangeNotify(DIZHU_GAMEID, userId, 'message')
         
     ftlog.debug('DizhuFlipCard.flipCard userId=', userId,
                'index=', index,
                'nslogin='******'regDays=', regDays,
                'timestamp=', datetime.fromtimestamp(timestamp).strftime('%Y-%m-%d %H:%M:%S'),
                'reward=', contentString)
     return True, status, assetItem