コード例 #1
0
ファイル: __init__.py プロジェクト: mahmoudimus/WOT-0.9.20.0
 def __getItemRentInfo(self, item):
     """
     Get formatted vehicle rent info
     :param item: <Vehicle>
     :return:  <str>
     """
     if item.isRented:
         formatter = RentLeftFormatter(item.rentInfo, item.isPremiumIGR)
         return formatter.getRentLeftStr(
             '#tooltips:vehicle/rentLeft/%s',
             formatter=lambda key, countType, count, _=None: ''.join(
                 [makeString(key % countType), ': ',
                  str(count)]))
     elif item.isRentable and item.isRentAvailable:
         minRentPricePackage = item.getRentPackage()
         priceText = ''
         discountText = ''
         if minRentPricePackage:
             minRentPriceValue = minRentPricePackage['rentPrice']
             actionPrc = item.getRentPackageActionPrc(
                 minRentPricePackage['days'])
             currency = minRentPriceValue.getCurrency()
             price = minRentPriceValue.getSignValue(currency)
             priceText = makeHtmlString(
                 'html_templates:lobby/quests/actions', currency,
                 {'value': price})
             if actionPrc != 0:
                 discountText = makeString(
                     '#menu:shop/menu/vehicle/rent/discount',
                     discount=text_styles.gold('{} %'.format(actionPrc)))
         rentText = makeString('#menu:shop/menu/vehicle/rent/available',
                               price=priceText)
         return '{}  {}'.format(rentText, discountText)
     else:
         return ''
コード例 #2
0
ファイル: inventory.py プロジェクト: webiumsk/WOT0.10.0
 def itemWrapper(self, packedItem):
     module, inventoryCount, vehicleCount, disable, statusMessage, isEnabledBuyingGoldShellsForCredits, isEnabledBuyingGoldEqsForCredits, extraModuleInfo = (
         packedItem
     )
     credits, gold = g_itemsCache.items.stats.money
     statusLevel = Vehicle.VEHICLE_STATE_LEVEL.INFO
     inventoryId = None
     isRented = False
     rentLeftTimeStr = ""
     if module.itemTypeID == GUI_ITEM_TYPE.VEHICLE:
         statusLevel = module.getState()[1]
         if module.isRented:
             isRented = True
             formatter = RentLeftFormatter(module.rentInfo, module.isPremiumIGR)
             rentLeftTimeStr = formatter.getRentLeftStr(
                 "#tooltips:vehicle/rentLeft/%s",
                 formatter=lambda key, countType, count, _=None: "".join(
                     [makeString(key % countType), ": ", str(count)]
                 ),
             )
         if module.isInInventory:
             inventoryId = module.invID
     name = module.userName if module.itemTypeID in GUI_ITEM_TYPE.ARTEFACTS else module.longUserName
     action = None
     if module.sellPrice != module.defaultSellPrice and not isRented:
         action = getItemActionTooltipData(module, False)
     return {
         "id": str(module.intCD),
         "name": name,
         "desc": module.getShortInfo(),
         "inventoryId": inventoryId,
         "inventoryCount": inventoryCount,
         "vehicleCount": vehicleCount,
         "credits": credits,
         "gold": gold,
         "price": module.sellPrice,
         "currency": "credits" if module.sellPrice[1] == 0 else "gold",
         "level": module.level,
         "nation": module.nationID,
         "type": module.itemTypeName
         if module.itemTypeID
         not in (GUI_ITEM_TYPE.VEHICLE, GUI_ITEM_TYPE.OPTIONALDEVICE, GUI_ITEM_TYPE.SHELL, GUI_ITEM_TYPE.EQUIPMENT)
         else module.icon,
         "disabled": disable,
         "statusMessage": statusMessage,
         "statusLevel": statusLevel,
         "removable": module.isRemovable if module.itemTypeID == GUI_ITEM_TYPE.OPTIONALDEVICE else True,
         "tankType": module.type if module.itemTypeID == GUI_ITEM_TYPE.VEHICLE else None,
         "isPremium": module.isPremium if module.itemTypeID == GUI_ITEM_TYPE.VEHICLE else False,
         "isElite": module.isElite if module.itemTypeID == GUI_ITEM_TYPE.VEHICLE else False,
         "itemTypeName": module.itemTypeName,
         "goldShellsForCredits": isEnabledBuyingGoldShellsForCredits,
         "goldEqsForCredits": isEnabledBuyingGoldEqsForCredits,
         "actionPriceData": action,
         "rentLeft": rentLeftTimeStr,
         "moduleLabel": module.getGUIEmblemID(),
         EXTRA_MODULE_INFO: extraModuleInfo,
     }
コード例 #3
0
 def _getItemRentLeftTime(self, item):
     if item.isRented:
         formatter = RentLeftFormatter(item.rentInfo, item.isPremiumIGR)
         return formatter.getRentLeftStr(
             '#tooltips:vehicle/rentLeft/%s',
             formatter=lambda key, countType, count, _=None: ''.join(
                 [makeString(key % countType), ': ',
                  str(count)]))
     else:
         return None
コード例 #4
0
ファイル: tabs__init__.py プロジェクト: aevitas/wotsdk
 def __getItemRentInfo(self, item):
     """
     Get formatted vehicle rent info
     :param item: <Vehicle>
     :return:  <str>
     """
     if item.isRented:
         formatter = RentLeftFormatter(item.rentInfo, item.isPremiumIGR)
         return formatter.getRentLeftStr('#tooltips:vehicle/rentLeft/%s', formatter=lambda key, countType, count, _ = None: ''.join([makeString(key % countType), ': ', str(count)]))
     elif item.isRentable and item.isRentAvailable:
         return makeString('#menu:shop/menu/vehicle/rent/available')
     else:
         return ''
コード例 #5
0
 def __getItemRentInfo(self, item):
     """
     Get formatted vehicle rent info
     :param item: <Vehicle>
     :return:  <str>
     """
     if item.isRented:
         formatter = RentLeftFormatter(item.rentInfo, item.isPremiumIGR)
         return formatter.getRentLeftStr('#tooltips:vehicle/rentLeft/%s', formatter=lambda key, countType, count, _ = None: ''.join([makeString(key % countType), ': ', str(count)]))
     elif item.isRentable and item.isRentAvailable:
         return makeString('#menu:shop/menu/vehicle/rent/available')
     else:
         return ''
コード例 #6
0
ファイル: inventory.py プロジェクト: webiumsk/WOT-0.9.15-CT
 def itemWrapper(self, packedItem):
     module, inventoryCount, vehicleCount, disable, statusMessage, isEnabledBuyingGoldShellsForCredits, isEnabledBuyingGoldEqsForCredits, extraModuleInfo = packedItem
     credits, gold = g_itemsCache.items.stats.money
     statusLevel = Vehicle.VEHICLE_STATE_LEVEL.INFO
     inventoryId = None
     isRented = False
     rentLeftTimeStr = ''
     if module.itemTypeID == GUI_ITEM_TYPE.VEHICLE:
         statusLevel = module.getState()[1]
         if module.isRented:
             isRented = True
             formatter = RentLeftFormatter(module.rentInfo, module.isPremiumIGR)
             rentLeftTimeStr = formatter.getRentLeftStr('#tooltips:vehicle/rentLeft/%s', formatter=lambda key, countType, count, _ = None: ''.join([makeString(key % countType), ': ', str(count)]))
         if module.isInInventory:
             inventoryId = module.invID
     name = module.userName if module.itemTypeID in GUI_ITEM_TYPE.ARTEFACTS else module.longUserName
     action = None
     if module.sellPrice != module.defaultSellPrice and not isRented:
         action = getItemActionTooltipData(module, False)
     return {'id': str(module.intCD),
      'name': name,
      'desc': module.getShortInfo(),
      'inventoryId': inventoryId,
      'inventoryCount': inventoryCount,
      'vehicleCount': vehicleCount,
      'credits': credits,
      'gold': gold,
      'price': module.sellPrice,
      'currency': 'credits' if module.sellPrice[1] == 0 else 'gold',
      'level': module.level,
      'nation': module.nationID,
      'type': module.itemTypeName if module.itemTypeID not in (GUI_ITEM_TYPE.VEHICLE,
               GUI_ITEM_TYPE.OPTIONALDEVICE,
               GUI_ITEM_TYPE.SHELL,
               GUI_ITEM_TYPE.EQUIPMENT) else module.icon,
      'disabled': disable,
      'statusMessage': statusMessage,
      'statusLevel': statusLevel,
      'removable': module.isRemovable if module.itemTypeID == GUI_ITEM_TYPE.OPTIONALDEVICE else True,
      'tankType': module.type if module.itemTypeID == GUI_ITEM_TYPE.VEHICLE else None,
      'isPremium': module.isPremium if module.itemTypeID == GUI_ITEM_TYPE.VEHICLE else False,
      'isElite': module.isElite if module.itemTypeID == GUI_ITEM_TYPE.VEHICLE else False,
      'itemTypeName': module.itemTypeName,
      'goldShellsForCredits': isEnabledBuyingGoldShellsForCredits,
      'goldEqsForCredits': isEnabledBuyingGoldEqsForCredits,
      'actionPriceData': action,
      'rentLeft': rentLeftTimeStr,
      'moduleLabel': module.getGUIEmblemID(),
      EXTRA_MODULE_INFO: extraModuleInfo}
コード例 #7
0
ファイル: vehicle.py プロジェクト: webiumsk/WOT-0.9.15.1
 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
     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.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 and not (self.vehicle.isDisabledForBuy or self.vehicle.isPremiumIGR or self.vehicle.isTelecom):
             price = self.vehicle.buyPrice
             money = g_itemsCache.items.stats.money
             actionPrc = self.vehicle.actionPrc
             defaultPrice = self.vehicle.defaultPrice
             currency = price.getCurrency()
             buyPriceText = price.get(currency)
             oldPrice = defaultPrice.get(currency)
             neededValue = price.get(currency) - money.get(currency)
             neededValue = neededValue if neededValue > 0 else None
             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.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'])
                 money = g_itemsCache.items.stats.money
                 currency = minRentPriceValue.getCurrency()
                 price = minRentPriceValue.get(currency)
                 oldPrice = minDefaultRentPriceValue.get(currency)
                 neededValue = minRentPriceValue.get(currency) - money.get(currency)
                 neededValue = neededValue if neededValue > 0 else None
                 block.append(makePriceBlock(price, CURRENCY_SETTINGS.getRentSetting(currency), neededValue, oldPrice, actionPrc, valueWidth=self._valueWidth))
         if rentals and not self.vehicle.isPremiumIGR:
             rentFormatter = RentLeftFormatter(self.vehicle.rentInfo)
             rentLeftInfo = rentFormatter.getRentLeftStr('#tooltips:vehicle/rentLeft/%s', 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)
コード例 #8
0
ファイル: tooltipsvehicle.py プロジェクト: Difrex/wotsdk
 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)
コード例 #9
0
ファイル: __init__.py プロジェクト: webiumsk/WOT-0.9.15.1
 def _getItemRentLeftTime(self, item):
     if item.isRented:
         formatter = RentLeftFormatter(item.rentInfo, item.isPremiumIGR)
         return formatter.getRentLeftStr('#tooltips:vehicle/rentLeft/%s', formatter=lambda key, countType, count, _ = None: ''.join([makeString(key % countType), ': ', str(count)]))
     else:
         return None
コード例 #10
0
ファイル: vehicle.py プロジェクト: kblw/wot_client
 def _getValue(self):
     result = []
     vehicle = self._tooltip.item
     configuration = self._tooltip.context.getStatsConfiguration(vehicle)
     xp = configuration.xp
     dailyXP = configuration.dailyXP
     unlockPrice = configuration.unlockPrice
     buyPrice = configuration.buyPrice
     sellPrice = configuration.sellPrice
     techTreeNode = configuration.node
     minRentPrice = configuration.minRentPrice
     rentals = configuration.rentals
     if buyPrice and sellPrice:
         LOG_ERROR('You are not allowed to use buyPrice and sellPrice at the same time')
         return
     isUnlocked = vehicle.isUnlocked
     isInInventory = vehicle.isInInventory
     isRented = vehicle.isRented
     isNextToUnlock = False
     parentCD = None
     if techTreeNode is not None:
         isNextToUnlock = bool(int(techTreeNode.state) & NODE_STATE.NEXT_2_UNLOCK)
         parentCD = techTreeNode.unlockProps.parentID
     if xp:
         xpValue = vehicle.xp
         if xpValue:
             result.append(('xp', xpValue))
     if dailyXP:
         attrs = g_itemsCache.items.stats.attributes
         if attrs & constants.ACCOUNT_ATTR.DAILY_MULTIPLIED_XP and vehicle.dailyXPFactor:
             result.append(('dailyXPFactor', vehicle.dailyXPFactor))
     if unlockPrice:
         isAvailable, cost, need = getUnlockPrice(vehicle.intCD, parentCD)
         unlockPriceStat = [cost]
         if isAvailable and not isUnlocked and need > 0 and techTreeNode is not None:
             unlockPriceStat.append(need)
         if cost > 0:
             result.append(('unlock_price', unlockPriceStat))
     if buyPrice and not (vehicle.isDisabledForBuy or vehicle.isPremiumIGR):
         price = vehicle.buyPrice
         needed = (0, 0)
         if not isInInventory and (isNextToUnlock or isUnlocked) or isRented:
             credits, gold = g_itemsCache.items.stats.money
             creditsNeeded = price[0] - credits if price[0] else 0
             goldNeeded = price[1] - gold if price[1] else 0
             needed = (max(0, creditsNeeded), max(0, goldNeeded))
         result.append(('buy_price', (price, needed)))
         result.append(('def_buy_price', vehicle.defaultPrice))
         result.append(('action_prc', vehicle.actionPrc))
     if sellPrice:
         result.append(('sell_price', vehicle.sellPrice))
         result.append(('def_sell_price', vehicle.defaultSellPrice))
         result.append(('action_prc', vehicle.sellActionPrc))
     if minRentPrice and not vehicle.isPremiumIGR:
         minRentPricePackage = vehicle.getRentPackage()
         if minRentPricePackage:
             minRentPriceValue = minRentPricePackage['rentPrice']
             minDefaultRentPriceValue = minRentPricePackage['defaultRentPrice']
             rentActionPrc = vehicle.getRentPackageActionPrc(minRentPricePackage['days'])
             credits, gold = g_itemsCache.items.stats.money
             enoughGoldForRent = gold - minRentPriceValue[1] >= 0
             enoughCreditsForRent = credits - minRentPriceValue[0] >= 0
             result.append(('minRentalsPrice', (minRentPriceValue, (enoughCreditsForRent, enoughGoldForRent))))
             result.append(('defRentPrice', minDefaultRentPriceValue))
             result.append(('rentActionPrc', rentActionPrc))
     if rentals and not vehicle.isPremiumIGR:
         rentFormatter = RentLeftFormatter(vehicle.rentInfo)
         rentLeftInfo = rentFormatter.getRentLeftStr('#tooltips:vehicle/rentLeft/%s', formatter=lambda key, countType, count, _ = None: {'left': count,
          'descr': i18n.makeString(key % countType)})
         if rentLeftInfo:
             result.append(('rentals', rentLeftInfo))
     return result
コード例 #11
0
ファイル: vehicle.py プロジェクト: webiumsk/WOT-0.9.14-CT
 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
     if buyPrice and sellPrice:
         LOG_ERROR('You are not allowed to use buyPrice and sellPrice at the same time')
         return
     else:
         priceBlock = []
         isUnlocked = self.vehicle.isUnlocked
         isInInventory = self.vehicle.isInInventory
         isRented = self.vehicle.isRented
         isNextToUnlock = False
         parentCD = None
         if techTreeNode is not None:
             isNextToUnlock = bool(int(techTreeNode.state) & NODE_STATE.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
                 priceBlock.append(formatters.packTextParameterWithIconBlockData(name=text_styles.main(_ms(TOOLTIPS.VEHICLE_XP)), value=xPText, icon=icon, valueWidth=self._valueWidth, padding=formatters.packPadding(left=self.leftPadding, right=self.rightPadding)))
         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)))
                 priceBlock.append(formatters.packTextParameterWithIconBlockData(name=text_styles.main(_ms(TOOLTIPS.VEHICLE_DAILYXPFACTOR)), value=dailyXPText, icon=ICON_TEXT_FRAMES.DOUBLE_XP_FACTOR, valueWidth=self._valueWidth, padding=formatters.packPadding(left=self.leftPadding, right=self.rightPadding)))
         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 = self._makePriceBlock(cost, _ms(TOOLTIPS.VEHICLE_UNLOCK_PRICE), ICON_TEXT_FRAMES.XP, neededValue)
                 priceBlock.append(block)
         if buyPrice and not (self.vehicle.isDisabledForBuy or self.vehicle.isPremiumIGR or self.vehicle.isTelecom):
             price = self.vehicle.buyPrice
             credits, gold = g_itemsCache.items.stats.money
             creditsBuyPrice = price[0]
             goldBuyPrice = price[1]
             creditsNeeded = creditsBuyPrice - credits if creditsBuyPrice else 0
             goldNeeded = goldBuyPrice - gold if goldBuyPrice else 0
             neededValue = None
             actionPrc = self.vehicle.actionPrc
             defaultPrice = self.vehicle.defaultPrice
             if goldBuyPrice == 0:
                 currencyType = ICON_TEXT_FRAMES.CREDITS
                 buyPriceText = creditsBuyPrice
                 oldPrice = defaultPrice[0]
                 if creditsNeeded > 0:
                     neededValue = creditsNeeded
             else:
                 currencyType = ICON_TEXT_FRAMES.GOLD
                 buyPriceText = goldBuyPrice
                 oldPrice = defaultPrice[1]
                 if goldNeeded > 0:
                     neededValue = goldNeeded
             text = _ms(TOOLTIPS.VEHICLE_BUY_PRICE)
             if isInInventory or not isInInventory and not isUnlocked and not isNextToUnlock:
                 neededValue = None
             block = self._makePriceBlock(buyPriceText, text, currencyType, neededValue, oldPrice, actionPrc)
             priceBlock.append(block)
         if sellPrice and not self.vehicle.isTelecom:
             creditsPrice = self.vehicle.sellPrice[0]
             goldPrice = self.vehicle.sellPrice[1]
             if goldPrice == 0:
                 sellPriceText = text_styles.credits(_int(creditsPrice))
                 sellPriceIcon = ICON_TEXT_FRAMES.CREDITS
             else:
                 sellPriceText = text_styles.gold(_int(goldPrice))
                 sellPriceIcon = ICON_TEXT_FRAMES.GOLD
             priceBlock.append(formatters.packTextParameterWithIconBlockData(name=text_styles.main(_ms(TOOLTIPS.VEHICLE_SELL_PRICE)), value=sellPriceText, icon=sellPriceIcon, valueWidth=self._valueWidth, padding=formatters.packPadding(left=self.leftPadding, right=self.rightPadding)))
         if minRentPrice and not self.vehicle.isPremiumIGR:
             minRentPricePackage = self.vehicle.getRentPackage()
             if minRentPricePackage:
                 minRentPriceValue = minRentPricePackage['rentPrice']
                 minDefaultRentPriceValue = minRentPricePackage['defaultRentPrice']
                 rentActionPrc = self.vehicle.getRentPackageActionPrc(minRentPricePackage['days'])
                 credits, gold = g_itemsCache.items.stats.money
                 creditsPrice = minRentPriceValue[0]
                 goldPrice = minRentPriceValue[1]
                 enoughCreditsForRent = credits - creditsPrice >= 0
                 enoughGoldForRent = gold - goldPrice >= 0
                 neededValue = None
                 if goldPrice == 0:
                     price = creditsPrice
                     oldPrice = minDefaultRentPriceValue[0]
                     currencyType = ICON_TEXT_FRAMES.CREDITS
                     if not enoughCreditsForRent:
                         neededValue = credits - creditsPrice
                 else:
                     price = goldPrice
                     oldPrice = minDefaultRentPriceValue[1]
                     currencyType = ICON_TEXT_FRAMES.GOLD
                     if not enoughGoldForRent:
                         neededValue = gold - goldPrice
                 text = _ms(TOOLTIPS.VEHICLE_MINRENTALSPRICE)
                 block = self._makePriceBlock(price, text, currencyType, neededValue, oldPrice, rentActionPrc)
                 priceBlock.append(block)
         if rentals and not self.vehicle.isPremiumIGR:
             rentFormatter = RentLeftFormatter(self.vehicle.rentInfo)
             rentLeftInfo = rentFormatter.getRentLeftStr('#tooltips:vehicle/rentLeft/%s', formatter=lambda key, countType, count, _ = None: {'left': count,
              'descr': i18n.makeString(key % countType)})
             if rentLeftInfo:
                 priceBlock.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=self.leftPadding, right=self.rightPadding)))
         return priceBlock
コード例 #12
0
 def _getValue(self):
     result = []
     vehicle = self._tooltip.item
     configuration = self._tooltip.context.getStatsConfiguration(vehicle)
     xp = configuration.xp
     dailyXP = configuration.dailyXP
     unlockPrice = configuration.unlockPrice
     buyPrice = configuration.buyPrice
     sellPrice = configuration.sellPrice
     techTreeNode = configuration.node
     minRentPrice = configuration.minRentPrice
     rentals = configuration.rentals
     if buyPrice and sellPrice:
         LOG_ERROR(
             'You are not allowed to use buyPrice and sellPrice at the same time'
         )
         return
     isUnlocked = vehicle.isUnlocked
     isInInventory = vehicle.isInInventory
     isRented = vehicle.isRented
     isNextToUnlock = False
     parentCD = None
     if techTreeNode is not None:
         isNextToUnlock = bool(
             int(techTreeNode.state) & NODE_STATE.NEXT_2_UNLOCK)
         parentCD = techTreeNode.unlockProps.parentID
     if xp:
         xpValue = vehicle.xp
         if xpValue:
             result.append(('xp', xpValue))
     if dailyXP:
         attrs = g_itemsCache.items.stats.attributes
         if attrs & constants.ACCOUNT_ATTR.DAILY_MULTIPLIED_XP and vehicle.dailyXPFactor:
             result.append(('dailyXPFactor', vehicle.dailyXPFactor))
     if unlockPrice:
         isAvailable, cost, need = getUnlockPrice(vehicle.intCD, parentCD)
         unlockPriceStat = [cost]
         if isAvailable and not isUnlocked and need > 0 and techTreeNode is not None:
             unlockPriceStat.append(need)
         if cost > 0:
             result.append(('unlock_price', unlockPriceStat))
     if buyPrice and not (vehicle.isDisabledForBuy or vehicle.isPremiumIGR):
         price = vehicle.buyPrice
         needed = (0, 0)
         if not isInInventory and (isNextToUnlock
                                   or isUnlocked) or isRented:
             credits, gold = g_itemsCache.items.stats.money
             creditsNeeded = price[0] - credits if price[0] else 0
             goldNeeded = price[1] - gold if price[1] else 0
             needed = (max(0, creditsNeeded), max(0, goldNeeded))
         result.append(('buy_price', (price, needed)))
         result.append(('def_buy_price', vehicle.defaultPrice))
         result.append(('action_prc', vehicle.actionPrc))
     if sellPrice:
         result.append(('sell_price', vehicle.sellPrice))
         result.append(('def_sell_price', vehicle.defaultSellPrice))
         result.append(('action_prc', vehicle.sellActionPrc))
     if minRentPrice and not vehicle.isPremiumIGR:
         minRentPricePackage = vehicle.getRentPackage()
         if minRentPricePackage:
             minRentPriceValue = minRentPricePackage['rentPrice']
             minDefaultRentPriceValue = minRentPricePackage[
                 'defaultRentPrice']
             rentActionPrc = vehicle.getRentPackageActionPrc(
                 minRentPricePackage['days'])
             credits, gold = g_itemsCache.items.stats.money
             enoughGoldForRent = gold - minRentPriceValue[1] >= 0
             enoughCreditsForRent = credits - minRentPriceValue[0] >= 0
             result.append(('minRentalsPrice', (minRentPriceValue,
                                                (enoughCreditsForRent,
                                                 enoughGoldForRent))))
             result.append(('defRentPrice', minDefaultRentPriceValue))
             result.append(('rentActionPrc', rentActionPrc))
     if rentals and not vehicle.isPremiumIGR:
         rentFormatter = RentLeftFormatter(vehicle.rentInfo)
         rentLeftInfo = rentFormatter.getRentLeftStr(
             '#tooltips:vehicle/rentLeft/%s',
             formatter=lambda key, countType, count, _=None: {
                 'left': count,
                 'descr': i18n.makeString(key % countType)
             })
         if rentLeftInfo:
             result.append(('rentals', rentLeftInfo))
     return result
コード例 #13
0
ファイル: tooltipsvehicle.py プロジェクト: aevitas/wotsdk
 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)