Exemple #1
0
 def getRentInfo(self, vehicle):
     """ Get rental info for the given vehicle.
     """
     if not self.isRentable:
         return RentalInfoProvider()
     battlesLeft = self.boundInventoryCount.get(
         vehicle.descriptor.type.compactDescr, 0)
     return RentalInfoProvider(battles=battlesLeft)
 def getRentInfo(self, vehicle):
     if not self.isRentable:
         return RentalInfoProvider()
     battlesLeft = self.boundInventoryCount(vehicle.intCD)
     return RentalInfoProvider(battles=battlesLeft)
Exemple #3
0
 def construct(self):
     xp = self.configuration.xp
     dailyXP = self.configuration.dailyXP
     buyPrice = self.configuration.buyPrice
     sellPrice = self.configuration.sellPrice
     unlockPrice = self.configuration.unlockPrice
     techTreeNode = self.configuration.node
     minRentPrice = self.configuration.minRentPrice
     rentals = self.configuration.rentals
     futureRentals = self.configuration.futureRentals
     paddings = formatters.packPadding(left=-5)
     neededValue = 0
     actionPrc = 0
     if buyPrice and sellPrice:
         LOG_ERROR('You are not allowed to use buyPrice and sellPrice at the same time')
         return
     else:
         block = []
         isUnlocked = self.vehicle.isUnlocked
         isInInventory = self.vehicle.isInInventory
         isNextToUnlock = False
         parentCD = None
         if techTreeNode is not None:
             isNextToUnlock = bool(int(techTreeNode.state) & NODE_STATE_FLAGS.NEXT_2_UNLOCK)
             parentCD = techTreeNode.unlockProps.parentID
         if xp:
             xpValue = self.vehicle.xp
             if xpValue:
                 xPText = text_styles.expText(_int(xpValue))
                 icon = ICON_TEXT_FRAMES.FREE_XP if self.vehicle.isPremium else ICON_TEXT_FRAMES.XP
                 block.append(formatters.packTextParameterWithIconBlockData(name=text_styles.main(TOOLTIPS.VEHICLE_XP), value=xPText, icon=icon, valueWidth=self._valueWidth, padding=paddings))
         if dailyXP:
             attrs = self.itemsCache.items.stats.attributes
             if attrs & constants.ACCOUNT_ATTR.DAILY_MULTIPLIED_XP and self.vehicle.dailyXPFactor > 0:
                 dailyXPText = text_styles.main(text_styles.expText('x' + _int(self.vehicle.dailyXPFactor)))
                 block.append(formatters.packTextParameterWithIconBlockData(name=text_styles.main(TOOLTIPS.VEHICLE_DAILYXPFACTOR), value=dailyXPText, icon=ICON_TEXT_FRAMES.DOUBLE_XP_FACTOR, valueWidth=self._valueWidth, padding=paddings))
         if unlockPrice:
             isAvailable, cost, need = getUnlockPrice(self.vehicle.intCD, parentCD)
             if cost > 0:
                 neededValue = None
                 if isAvailable and not isUnlocked and need > 0 and techTreeNode is not None:
                     neededValue = need
                 block.append(makePriceBlock(cost, CURRENCY_SETTINGS.UNLOCK_PRICE, neededValue, valueWidth=self._valueWidth))
         if buyPrice:
             if self.vehicle.isRestorePossible():
                 price = self.vehicle.restorePrice
                 defaultPrice = price
                 currency = price.getCurrency()
                 buyPriceText = price.get(currency)
                 oldPrice = defaultPrice.get(currency)
                 neededValue = _getNeedValue(price, currency)
                 if isInInventory or not isInInventory and not isUnlocked and not isNextToUnlock:
                     neededValue = None
                 block.append(makePriceBlock(buyPriceText, CURRENCY_SETTINGS.RESTORE_PRICE, neededValue, oldPrice, actionPrc, valueWidth=self._valueWidth))
                 if self.vehicle.hasLimitedRestore():
                     timeKey, formattedTime = getTimeLeftInfo(self.vehicle.restoreInfo.getRestoreTimeLeft(), None)
                     block.append(formatters.packTextParameterWithIconBlockData(name=text_styles.main('#tooltips:vehicle/restoreLeft/%s' % timeKey), value=text_styles.main(formattedTime), icon=ICON_TEXT_FRAMES.ALERT if timeKey == 'hours' else ICON_TEXT_FRAMES.EMPTY, valueWidth=self._valueWidth, padding=formatters.packPadding(left=-5)))
             elif not (self.vehicle.isDisabledForBuy or self.vehicle.isPremiumIGR or self.vehicle.isTelecom):
                 itemPrice = self.vehicle.buyPrices.itemPrice
                 price = itemPrice.price
                 actionPrc = itemPrice.getActionPrc()
                 defaultPrice = itemPrice.defPrice
                 currency = price.getCurrency()
                 buyPriceText = price.get(currency)
                 oldPrice = defaultPrice.get(currency)
                 neededValue = _getNeedValue(price, currency)
                 if isInInventory or not isInInventory and not isUnlocked and not isNextToUnlock:
                     neededValue = None
                 block.append(makePriceBlock(buyPriceText, CURRENCY_SETTINGS.getBuySetting(currency), neededValue, oldPrice, actionPrc, valueWidth=self._valueWidth))
         if sellPrice and not self.vehicle.isTelecom:
             sellPrice = self.vehicle.sellPrices.itemPrice.price
             sellCurrency = sellPrice.getCurrency(byWeight=True)
             currencyTextFormatter = getattr(text_styles, sellCurrency, text_styles.credits)
             sellPriceText = currencyTextFormatter(_int(sellPrice.get(sellCurrency, 0)))
             sellPriceIcon = sellCurrency
             block.append(formatters.packTextParameterWithIconBlockData(name=text_styles.main(TOOLTIPS.VEHICLE_SELL_PRICE), value=sellPriceText, icon=sellPriceIcon, valueWidth=self._valueWidth, padding=paddings))
         if minRentPrice and not self.vehicle.isPremiumIGR:
             minRentPricePackage = self.vehicle.getRentPackage()
             if minRentPricePackage:
                 minRentPriceValue = minRentPricePackage['rentPrice']
                 minDefaultRentPriceValue = minRentPricePackage['defaultRentPrice']
                 actionPrc = self.vehicle.getRentPackageActionPrc(minRentPricePackage['days'])
                 currency = minRentPriceValue.getCurrency()
                 price = minRentPriceValue.getSignValue(currency)
                 oldPrice = minDefaultRentPriceValue.getSignValue(currency)
                 neededValue = _getNeedValue(minRentPriceValue, currency)
                 block.append(makePriceBlock(price, CURRENCY_SETTINGS.getRentSetting(currency), neededValue, oldPrice, actionPrc, valueWidth=self._valueWidth))
                 if not self.vehicle.isRented or self.vehicle.rentalIsOver:
                     block.append(formatters.packTextParameterWithIconBlockData(name=text_styles.main('#tooltips:vehicle/rentAvailable'), value='', icon=ICON_TEXT_FRAMES.RENTALS, valueWidth=self._valueWidth, padding=paddings))
         if rentals and not self.vehicle.isPremiumIGR:
             if futureRentals:
                 rentLeftKey = '#tooltips:vehicle/rentLeftFuture/%s'
                 rentInfo = RentalInfoProvider(time=self._rentExpiryTime, battles=self._rentBattlesLeft, wins=self._rentWinsLeft, isRented=True)
             else:
                 rentLeftKey = '#tooltips:vehicle/rentLeft/%s'
                 rentInfo = self.vehicle.rentInfo
             rentFormatter = RentLeftFormatter(rentInfo)
             rentLeftInfo = rentFormatter.getRentLeftStr(rentLeftKey, formatter=lambda key, countType, count, _ = None: {'left': count,
              'descr': i18n.makeString(key % countType)})
             if rentLeftInfo:
                 block.append(formatters.packTextParameterWithIconBlockData(name=text_styles.main(rentLeftInfo['descr']), value=text_styles.main(rentLeftInfo['left']), icon=ICON_TEXT_FRAMES.RENTALS, valueWidth=self._valueWidth, padding=formatters.packPadding(left=-5, bottom=-16)))
         if self.vehicle.canTradeIn:
             block.append(formatters.packTextParameterWithIconBlockData(name=text_styles.main(TOOLTIPS.VEHICLE_TRADE), value='', icon=ICON_TEXT_FRAMES.TRADE, valueWidth=self._valueWidth, padding=formatters.packPadding(left=-5, bottom=-10)))
         notEnoughMoney = neededValue > 0
         hasAction = actionPrc > 0
         return (block, notEnoughMoney or hasAction)