def __getItemRestoreInfo(self, item): """ Get formatted vehicle restore info :param item: <Vehicle> :return: <str> """ if item.isRestorePossible(): if constants.IS_CHINA and item.rentalIsActive: return text_styles.alert( MENU.VEHICLE_RESTORELEFT_DISABLEDBYRENT) if item.hasLimitedRestore(): restoreLeftTime = item.restoreInfo.getRestoreTimeLeft() timeKey, formattedTime = getTimeLeftInfo(restoreLeftTime) msg = i18n.makeString('#menu:vehicle/restoreLeft/%s' % timeKey, time=formattedTime) if restoreLeftTime < time_utils.ONE_DAY: return icons.alert() + text_styles.alert(msg) return text_styles.stats(msg) if item.hasRestoreCooldown(): timeKey, formattedTime = getTimeLeftInfo( item.restoreInfo.getRestoreCooldownTimeLeft()) msg = i18n.makeString('#menu:vehicle/restoreCooldownLeft/%s' % timeKey, time=formattedTime) return text_styles.stats(msg) return ''
def _successHandler(self, code, ctx=None): restoreInfo = '' sellForGold = self.vehicle.getSellPrice(preferred=True).getCurrency(byWeight=True) == Currency.GOLD if self.vehicle.isPremium and not self.vehicle.isUnique and not self.vehicle.isUnrecoverable and self.__lobbyContext.getServerSettings().isVehicleRestoreEnabled() and not sellForGold: timeKey, formattedTime = getTimeLeftInfo(self.itemsCache.items.shop.vehiclesRestoreConfig.restoreDuration) restoreInfo = backport.text(R.strings.system_messages.vehicle.restoreDuration.dyn(timeKey, R.invalid)(), time=formattedTime) additionalMsgs = [] if self.__compensationRequired: additionalMsgs.append(makeCrewSkinCompensationMessage(self.__compensationAmount)) if self.__hasPairModification: additionalMsgs.append(makeAllPairsDiscardMsg(self.vehicle.userName)) g_tankActiveCamouflage[self.vehicle.intCD] = SeasonType.UNDEFINED msgCtx = {'vehName': self.vehicle.userName} if self.usedDemountKitsCount: msgCtx['countDK'] = self.usedDemountKitsCount if self.isDismantlingForMoney: msgCtx['gainMoney'] = formatPrice(self.gainMoney) msgCtx['spendMoney'] = formatPrice(self.spendMoney) else: msgCtx['money'] = formatPrice(self.gainMoney) if not self.isRemovedAfterRent: msgCtx['restoreInfo'] = restoreInfo sysMsgR = R.strings.system_messages.dyn('vehicle_remove' if self.isRemovedAfterRent else 'vehicle_sell', R.invalid) if sysMsgR: sysMsgR = sysMsgR.dyn('success_dismantling' if self.isDismantlingForMoney else 'success', R.invalid) if sysMsgR and self.usedDemountKitsCount: sysMsgR = sysMsgR.dyn('with_demount_kit', R.invalid) if self.isRemovedAfterRent: smType = SM_TYPE.Remove elif sellForGold: smType = SM_TYPE.SellingForGold else: smType = SM_TYPE.Selling return makeSuccess(userMsg=backport.text(sysMsgR(), **msgCtx), msgType=smType, auxData=additionalMsgs)
def _successHandler(self, code, ctx=None): restoreInfo = '' sellForGold = self.vehicle.getSellPrice(preferred=True).getCurrency( byWeight=True) == Currency.GOLD if self.vehicle.isPremium and not self.vehicle.isUnique and not self.vehicle.isUnrecoverable and self.lobbyContext.getServerSettings( ).isVehicleRestoreEnabled() and not sellForGold: timeKey, formattedTime = getTimeLeftInfo( self.itemsCache.items.shop.vehiclesRestoreConfig. restoreDuration) restoreInfo = makeString( '#system_messages:vehicle/restoreDuration/%s' % timeKey, time=formattedTime) if self.isDismantlingForMoney: localKey = 'vehicle_sell/success_dismantling' smType = SM_TYPE.Selling if self.isRemovedAfterRent: localKey = 'vehicle_remove/success_dismantling' smType = SM_TYPE.Remove return makeI18nSuccess(localKey, vehName=self.vehicle.userName, gainMoney=formatPrice(self.gainMoney), spendMoney=formatPrice(self.spendMoney), restoreInfo=restoreInfo, type=smType) else: localKey = 'vehicle_sell/success' smType = SM_TYPE.Selling if self.isRemovedAfterRent: localKey = 'vehicle_remove/success' smType = SM_TYPE.Remove return makeI18nSuccess(localKey, vehName=self.vehicle.userName, money=formatPrice(self.gainMoney), restoreInfo=restoreInfo, type=smType)
def _populate(self): super(BCQuestsView, self)._populate() bonuses = g_bootcamp.getBonuses()['battle'][g_bootcamp.getLessonNum()] timeKey, time = getTimeLeftInfo(bonuses.get('premium', 0) * 3600) voData = {'premiumText': time + ' ' + makeString('#menu:header/account/premium/%s' % timeKey), 'goldText': str(bonuses['gold']), 'showRewards': bonuses['showRewards'], 'premiumIcon': RES_ICONS.MAPS_ICONS_BOOTCAMP_REWARDS_BCPREMIUM3D, 'goldIcon': RES_ICONS.MAPS_ICONS_BOOTCAMP_REWARDS_BCGOLD} self.as_setDataS(voData)
def __getVehicleStatus(self, showCustomStates, vehicle): if showCustomStates: isInInventory = vehicle.isInInventory level = Vehicle.VEHICLE_STATE_LEVEL.WARNING if not isInInventory and vehicle.hasRestoreCooldown( ) and vehicle.isHidden: timeKey, formattedTime = getTimeLeftInfo( self.vehicle.restoreInfo.getRestoreCooldownTimeLeft()) return { 'header': _ms('#tooltips:vehicleStatus/restoreCooldown/%s' % timeKey, time=formattedTime), 'text': '', 'level': level } isUnlocked = vehicle.isUnlocked mayObtain, reason = vehicle.mayObtainForMoney( g_itemsCache.items.stats.money) msg = None if not isUnlocked: msg = 'notUnlocked' elif isInInventory: msg = 'inHangar' elif not mayObtain: level = Vehicle.VEHICLE_STATE_LEVEL.CRITICAL if reason == 'gold_error': msg = 'notEnoughGold' elif reason == 'credits_error': msg = 'notEnoughCredits' else: msg = 'operationError' if msg is not None: header, text = getComplexStatus('#tooltips:vehicleStatus/%s' % msg) return {'header': header, 'text': text, 'level': level} return else: state, level = vehicle.getState() if state == Vehicle.VEHICLE_STATE.SERVER_RESTRICTION: return isSuitableVeh = getFalloutCtrl().isSuitableVeh(vehicle) if not isSuitableVeh: header, text = getComplexStatus( '#tooltips:vehicleStatus/%s' % Vehicle.VEHICLE_STATE.NOT_SUITABLE) level = Vehicle.VEHICLE_STATE_LEVEL.WARNING else: header, text = getComplexStatus('#tooltips:vehicleStatus/%s' % state) if header is None and text is None: return return {'header': header, 'text': text, 'level': level}
def __getItemRestoreInfo(self, item): """ Get formatted vehicle restore info :param item: <Vehicle> :return: <str> """ if item.isRestorePossible(): if constants.IS_CHINA and item.rentalIsActive: return text_styles.alert(MENU.VEHICLE_RESTORELEFT_DISABLEDBYRENT) if item.hasLimitedRestore(): restoreLeftTime = item.restoreInfo.getRestoreTimeLeft() timeKey, formattedTime = getTimeLeftInfo(restoreLeftTime) msg = i18n.makeString('#menu:vehicle/restoreLeft/%s' % timeKey, time=formattedTime) if restoreLeftTime < time_utils.ONE_DAY: return icons.alert() + text_styles.alert(msg) return text_styles.stats(msg) if item.hasRestoreCooldown(): timeKey, formattedTime = getTimeLeftInfo(item.restoreInfo.getRestoreCooldownTimeLeft()) msg = i18n.makeString('#menu:vehicle/restoreCooldownLeft/%s' % timeKey, time=formattedTime) return text_styles.stats(msg) return ''
def __getVehicleStatus(self, showCustomStates, vehicle): if showCustomStates: isInInventory = vehicle.isInInventory level = Vehicle.VEHICLE_STATE_LEVEL.WARNING if not isInInventory and vehicle.hasRestoreCooldown() and vehicle.isHidden: timeKey, formattedTime = getTimeLeftInfo(self.vehicle.restoreInfo.getRestoreCooldownTimeLeft()) return {'header': _ms('#tooltips:vehicleStatus/restoreCooldown/%s' % timeKey, time=formattedTime), 'text': '', 'level': level} isUnlocked = vehicle.isUnlocked mayObtain, reason = vehicle.mayObtainForMoney(self.itemsCache.items.stats.money) msg = None if not isUnlocked: msg = 'notUnlocked' elif isInInventory: msg = 'inHangar' elif not mayObtain: level = Vehicle.VEHICLE_STATE_LEVEL.CRITICAL if reason == GUI_ITEM_ECONOMY_CODE.NOT_ENOUGH_GOLD: msg = 'notEnoughGold' elif reason == GUI_ITEM_ECONOMY_CODE.NOT_ENOUGH_CREDITS: msg = 'notEnoughCredits' else: msg = 'operationError' if msg is not None: header, text = getComplexStatus('#tooltips:vehicleStatus/%s' % msg) return {'header': header, 'text': text, 'level': level} return else: state, level = vehicle.getState() if state == Vehicle.VEHICLE_STATE.SERVER_RESTRICTION: return if state == Vehicle.VEHICLE_STATE.ROTATION_GROUP_UNLOCKED: header, text = getComplexStatus('#tooltips:vehicleStatus/%s' % state, groupNum=vehicle.rotationGroupNum, battlesLeft=getBattlesLeft(vehicle)) else: header, text = getComplexStatus('#tooltips:vehicleStatus/%s' % state) if header is None and text is None: return return {'header': header, 'text': text, 'level': level}
def __getVehicleStatus(self, showCustomStates, vehicle): if showCustomStates: isInInventory = vehicle.isInInventory level = Vehicle.VEHICLE_STATE_LEVEL.WARNING if not isInInventory and vehicle.hasRestoreCooldown() and vehicle.isHidden: timeKey, formattedTime = getTimeLeftInfo(self.vehicle.restoreInfo.getRestoreCooldownTimeLeft()) return { "header": _ms("#tooltips:vehicleStatus/restoreCooldown/%s" % timeKey, time=formattedTime), "text": "", "level": level, } isUnlocked = vehicle.isUnlocked mayObtain, reason = vehicle.mayObtainForMoney(g_itemsCache.items.stats.money) msg = None if not isUnlocked: msg = "notUnlocked" elif isInInventory: msg = "inHangar" elif not mayObtain: level = Vehicle.VEHICLE_STATE_LEVEL.CRITICAL if reason == "gold_error": msg = "notEnoughGold" elif reason == "credits_error": msg = "notEnoughCredits" else: msg = "operationError" if msg is not None: header, text = getComplexStatus("#tooltips:vehicleStatus/%s" % msg) return {"header": header, "text": text, "level": level} return else: state, level = vehicle.getState() if state == Vehicle.VEHICLE_STATE.SERVER_RESTRICTION: return isSuitableVeh = getFalloutCtrl().isSuitableVeh(vehicle) if not isSuitableVeh: header, text = getComplexStatus("#tooltips:vehicleStatus/%s" % Vehicle.VEHICLE_STATE.NOT_SUITABLE) level = Vehicle.VEHICLE_STATE_LEVEL.WARNING else: header, text = getComplexStatus("#tooltips:vehicleStatus/%s" % state) if header is None and text is None: return return {"header": header, "text": text, "level": level}
def _successHandler(self, code, ctx = None): restoreInfo = '' if self.vehicle.isPremium and not self.vehicle.isUnique and not self.vehicle.isUnrecoverable and g_lobbyContext.getServerSettings().isVehicleRestoreEnabled() and not self.vehicle.sellForGold: timeKey, formattedTime = getTimeLeftInfo(g_itemsCache.items.shop.vehiclesRestoreConfig.restoreDuration) restoreInfo = makeString('#system_messages:vehicle/restoreDuration/%s' % timeKey, time=formattedTime) if self.isDismantlingForGold: localKey = 'vehicle_sell/success_dismantling' smType = SM_TYPE.Selling if self.isRemovedAfterRent: localKey = 'vehicle_remove/success_dismantling' smType = SM_TYPE.Remove return makeI18nSuccess(localKey, vehName=self.vehicle.userName, gainMoney=formatPrice(self.gainMoney), spendMoney=formatPrice(self.spendMoney), restoreInfo=restoreInfo, type=smType) else: localKey = 'vehicle_sell/success' smType = SM_TYPE.Selling if self.isRemovedAfterRent: localKey = 'vehicle_remove/success' smType = SM_TYPE.Remove return makeI18nSuccess(localKey, vehName=self.vehicle.userName, money=formatPrice(self.gainMoney), restoreInfo=restoreInfo, type=smType)
def _successHandler(self, code, ctx=None): restoreInfo = '' sellForGold = self.vehicle.getSellPrice(preferred=True).getCurrency( byWeight=True) == Currency.GOLD if self.vehicle.isPremium and not self.vehicle.isUnique and not self.vehicle.isUnrecoverable and self.lobbyContext.getServerSettings( ).isVehicleRestoreEnabled() and not sellForGold: timeKey, formattedTime = getTimeLeftInfo( self.itemsCache.items.shop.vehiclesRestoreConfig. restoreDuration) restoreInfo = makeString( '#system_messages:vehicle/restoreDuration/{}'.format(timeKey), time=formattedTime) compMsg = None if self.__compensationRequired: compMsg = makeCrewSkinCompensationMessage( self.__compensationAmount) g_tankActiveCamouflage[self.vehicle.intCD] = SeasonType.UNDEFINED makeMsg = partial(makeI18nSuccess, vehName=self.vehicle.userName, auxData=compMsg) if self.usedDemountKitsCount: makeMsg = partial(makeMsg, countDK=self.usedDemountKitsCount) if self.isDismantlingForMoney: makeMsg = partial(makeMsg, gainMoney=formatPrice(self.gainMoney), spendMoney=formatPrice(self.spendMoney)) else: makeMsg = partial(makeMsg, money=formatPrice(self.gainMoney)) if not self.isRemovedAfterRent: makeMsg = partial(makeMsg, restoreInfo=restoreInfo) sysMsgKey = '{}{}{}'.format( 'vehicle_remove' if self.isRemovedAfterRent else 'vehicle_sell', '/success_dismantling' if self.isDismantlingForMoney else '/success', '/with_demount_kit' if self.usedDemountKitsCount else '') if self.isRemovedAfterRent: smType = SM_TYPE.Remove elif sellForGold: smType = SM_TYPE.SellingForGold else: smType = SM_TYPE.Selling return makeMsg(sysMsgKey=sysMsgKey, type=smType)
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=-4) 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 = g_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=-4))) elif not (self.vehicle.isDisabledForBuy or self.vehicle.isPremiumIGR or self.vehicle.isTelecom): price = self.vehicle.buyPrice actionPrc = self.vehicle.actionPrc defaultPrice = self.vehicle.defaultPrice 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, 0, valueWidth=self._valueWidth)) if sellPrice and not self.vehicle.isTelecom: sellPrice = self.vehicle.sellPrice if sellPrice.isSet(Currency.GOLD): sellPriceText = text_styles.gold(_int(sellPrice.gold)) sellPriceIcon = ICON_TEXT_FRAMES.GOLD else: sellPriceText = text_styles.credits(_int( sellPrice.credits)) sellPriceIcon = ICON_TEXT_FRAMES.CREDITS 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 = Money( *minRentPricePackage['rentPrice']) minDefaultRentPriceValue = Money( *minRentPricePackage['defaultRentPrice']) actionPrc = self.vehicle.getRentPackageActionPrc( minRentPricePackage['days']) currency = minRentPriceValue.getCurrency() price = minRentPriceValue.get(currency) oldPrice = minDefaultRentPriceValue.get(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, 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=-4, bottom=-16))) notEnoughMoney = neededValue > 0 hasAction = actionPrc > 0 return (block, notEnoughMoney or hasAction)
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=-4) 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 = g_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=-4), ) ) elif not (self.vehicle.isDisabledForBuy or self.vehicle.isPremiumIGR or self.vehicle.isTelecom): price = self.vehicle.buyPrice actionPrc = self.vehicle.actionPrc defaultPrice = self.vehicle.defaultPrice 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, 0, valueWidth=self._valueWidth, ) ) if sellPrice and not self.vehicle.isTelecom: sellPrice = self.vehicle.sellPrice if sellPrice.isSet(Currency.GOLD): sellPriceText = text_styles.gold(_int(sellPrice.gold)) sellPriceIcon = ICON_TEXT_FRAMES.GOLD else: sellPriceText = text_styles.credits(_int(sellPrice.credits)) sellPriceIcon = ICON_TEXT_FRAMES.CREDITS 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 = Money(*minRentPricePackage["rentPrice"]) minDefaultRentPriceValue = Money(*minRentPricePackage["defaultRentPrice"]) actionPrc = self.vehicle.getRentPackageActionPrc(minRentPricePackage["days"]) currency = minRentPriceValue.getCurrency() price = minRentPriceValue.get(currency) oldPrice = minDefaultRentPriceValue.get(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, 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=-4, bottom=-16), ) ) notEnoughMoney = neededValue > 0 hasAction = actionPrc > 0 return (block, notEnoughMoney or hasAction)