Exemplo n.º 1
0
 def _getVehicleData(self, node, item):
     nodeCD = node['id']
     tags = item.tags
     credits, gold = node['GUIPrice']
     status, statusLevel = self._getRentStatus(item)
     return {
         'id': nodeCD,
         'state': node['state'],
         'type': item.itemTypeName,
         'nameString': item.shortUserName,
         'primaryClass': self._vClassInfo.getInfoByTags(tags),
         'level': item.level,
         'longName': item.longUserName,
         'iconPath': item.icon,
         'smallIconPath': item.iconSmall,
         'earnedXP': node['earnedXP'],
         'shopPrice': (credits, gold, getActionPriceData(item)),
         'displayInfo': node['displayInfo'],
         'unlockProps': node['unlockProps']._makeTuple(),
         'status': status,
         'statusLevel': statusLevel,
         'isRemovable': item.isRented,
         'isPremiumIGR': item.isPremiumIGR,
         'vehCompareTreeNodeData': getTreeNodeCompareData(item)
     }
Exemplo n.º 2
0
 def __getBtnState(self):
     vehicle = g_currentPreviewVehicle.item
     if vehicle.isUnlocked:
         money = g_itemsCache.items.stats.money
         exchangeRate = g_itemsCache.items.shop.exchangeRate
         price = vehicle.rentOrBuyPrice
         currency = price.getCurrency(byWeight=True)
         action = getActionPriceData(vehicle)
         isPurchaseEnabled = vehicle.isPurchaseEnabled(money, exchangeRate)
         if currency == Currency.GOLD:
             currencyIcon = RES_ICONS.MAPS_ICONS_LIBRARY_GOLDICONBIG
             formatter = text_styles.goldTextBig if isPurchaseEnabled else text_styles.errCurrencyTextBig
         else:
             currencyIcon = RES_ICONS.MAPS_ICONS_LIBRARY_CREDITSICONBIG
             formatter = text_styles.creditsTextBig if isPurchaseEnabled else text_styles.errCurrencyTextBig
         return _ButtonState(
             isPurchaseEnabled,
             formatter(BigWorld.wg_getIntegralFormat(price.get(currency))),
             VEHICLE_PREVIEW.BUYINGPANEL_BUYBTN_LABEL_BUY, action
             is not None, currencyIcon, ItemsActionsFactory.BUY_VEHICLE,
             action)
     else:
         nodeCD = vehicle.intCD
         currencyIcon = RES_ICONS.MAPS_ICONS_LIBRARY_XPCOSTICONBIG
         isAvailableToUnlock, xpCost, possibleXp = g_techTreeDP.isVehicleAvailableToUnlock(
             nodeCD)
         formatter = text_styles.creditsTextBig if possibleXp >= xpCost else text_styles.errCurrencyTextBig
         return _ButtonState(
             isAvailableToUnlock,
             formatter(BigWorld.wg_getIntegralFormat(xpCost)),
             VEHICLE_PREVIEW.BUYINGPANEL_BUYBTN_LABEL_RESEARCH, False,
             currencyIcon, ItemsActionsFactory.UNLOCK_ITEM, None)
         return None
Exemplo n.º 3
0
 def _getItemData(self, node, item, rootItem):
     nodeCD = node['id']
     vClass = {'name': ''}
     status = statusLevel = ''
     vehicleBtnLabel = ''
     if item.itemTypeID == GUI_ITEM_TYPE.VEHICLE:
         status, statusLevel = self._getRentStatus(item)
         if item.isInInventory:
             vehicleBtnLabel = MENU.RESEARCH_LABELS_BUTTON_SHOWINHANGAR
         else:
             vehicleBtnLabel = MENU.RESEARCH_SHOWINPREVIEWBTN_LABEL
     else:
         vClass.update({'name': item.itemTypeName})
     credits, gold = node['GUIPrice']
     data = {'longName': item.longUserName,
      'smallIconPath': item.iconSmall,
      'earnedXP': node['earnedXP'],
      'shopPrice': (credits, gold, getActionPriceData(item)),
      'unlockProps': node['unlockProps']._makeTuple(),
      'status': status,
      'statusLevel': statusLevel,
      'isPremiumIGR': item.isPremiumIGR,
      'showVehicleBtnLabel': i18n.makeString(vehicleBtnLabel),
      'showVehicleBtnEnabled': item.isInInventory or item.isPreviewAllowed(),
      'vehCompareRootData': getBtnCompareData(item) if nodeCD == rootItem.intCD else {},
      'vehCompareTreeNodeData': getTreeNodeCompareData(item) if item.itemTypeID == GUI_ITEM_TYPE.VEHICLE else {}}
     commonData = super(ResearchItemsObjDumper, self)._getItemData(node, item, rootItem)
     data.update(commonData)
     return data
Exemplo n.º 4
0
 def _getItemData(self, node, item, rootItem):
     nodeCD = node['id']
     vClass = {'name': ''}
     status = statusLevel = ''
     vehicleBtnLabel = ''
     if item.itemTypeID == GUI_ITEM_TYPE.VEHICLE:
         status, statusLevel = self._getRentStatus(item)
         if item.isInInventory:
             vehicleBtnLabel = MENU.RESEARCH_LABELS_BUTTON_SHOWINHANGAR
         else:
             vehicleBtnLabel = MENU.RESEARCH_SHOWINPREVIEWBTN_LABEL
     else:
         vClass.update({'name': item.itemTypeName})
     credits, gold = node['GUIPrice']
     data = {
         'longName': item.longUserName,
         'smallIconPath': item.iconSmall,
         'earnedXP': node['earnedXP'],
         'shopPrice': (credits, gold, getActionPriceData(item)),
         'unlockProps': node['unlockProps']._makeTuple(),
         'status': status,
         'statusLevel': statusLevel,
         'isPremiumIGR': item.isPremiumIGR,
         'showVehicleBtnLabel': i18n.makeString(vehicleBtnLabel),
         'showVehicleBtnEnabled': item.isInInventory
         or item.isPreviewAllowed(),
         'vehCompareRootData':
         getBtnCompareData(item) if nodeCD == rootItem.intCD else {},
         'vehCompareTreeNodeData': getTreeNodeCompareData(item)
         if item.itemTypeID == GUI_ITEM_TYPE.VEHICLE else {}
     }
     commonData = super(ResearchItemsObjDumper,
                        self)._getItemData(node, item, rootItem)
     data.update(commonData)
     return data
 def __getBtnDataUnlockedVehicle(self, vehicle):
     money = self.itemsCache.items.stats.money
     money = self.tradeIn.addTradeInPriceIfNeeded(vehicle, money)
     tooltip = ''
     exchangeRate = self.itemsCache.items.shop.exchangeRate
     price = getGUIPrice(vehicle, money, exchangeRate)
     currency = price.getCurrency(byWeight=True)
     action = getActionPriceData(vehicle)
     mayObtainForMoney = self.__isHeroTank or vehicle.mayObtainWithMoneyExchange(
         money, exchangeRate)
     isBuyingAvailable = not vehicle.isHidden or vehicle.isRentable or vehicle.isRestorePossible(
     )
     if currency == Currency.GOLD:
         if not mayObtainForMoney:
             if isBuyingAvailable:
                 tooltip = _buildBuyButtonTooltip('notEnoughGold')
                 if isIngameShopEnabled():
                     mayObtainForMoney = True
     elif not mayObtainForMoney and isBuyingAvailable:
         tooltip = _buildBuyButtonTooltip('notEnoughCredits')
     if self._disableBuyButton:
         mayObtainForMoney = False
     return _ButtonState(
         mayObtainForMoney,
         [currency, price.getSignValue(currency)],
         VEHICLE_PREVIEW.BUYINGPANEL_BUYBTN_LABEL_RESTORE
         if vehicle.isRestorePossible() else
         VEHICLE_PREVIEW.BUYINGPANEL_BUYBTN_LABEL_BUY, action, tooltip,
         self.__packTitle)
Exemplo n.º 6
0
 def __getBtnDataUnlockedVehicle(self, vehicle):
     money = self._itemsCache.items.stats.money
     money = self._tradeIn.addTradeInPriceIfNeeded(vehicle, money)
     buyButtonTooltip = ''
     actionTooltip = getActionPriceData(vehicle)
     exchangeRate = self._itemsCache.items.shop.exchangeRate
     priceType, price = getPriceTypeAndValue(vehicle, money, exchangeRate)
     itemPrice = chooseItemPriceVO(priceType, price)
     currency = price.getCurrency(byWeight=True)
     walletAvailable = self.__walletAvailableForCurrency(currency)
     buttonLabel = self.__getUnlockedVehicleBtnLabel(priceType)
     buttonIcon = None
     buttonIconAlign = None
     isAction = False
     minRentPricePackage = vehicle.getRentPackage()
     if minRentPricePackage:
         isAction = minRentPricePackage['rentPrice'] != minRentPricePackage[
             'defaultRentPrice']
     elif not vehicle.isRestoreAvailable():
         isAction = vehicle.buyPrices.getSum().isActionPrice()
     mayObtain = self.__isHeroTank or walletAvailable and vehicle.mayObtainWithMoneyExchange(
         money, exchangeRate)
     isBuyingAvailable = not vehicle.isHidden or vehicle.isRentable or vehicle.isRestorePossible(
     )
     isMoneyEnough = True
     if not walletAvailable:
         buyButtonTooltip = _buildBuyButtonTooltip('walletUnavailable')
     elif not mayObtain and isBuyingAvailable:
         if currency == Currency.GOLD:
             mayObtain = True
         else:
             buyButtonTooltip = _buildBuyButtonTooltip('notEnoughCredits')
             isMoneyEnough = False
     if self._disableBuyButton or self.__isHeroTank and self._vehicleCD != self._heroTanks.getCurrentTankCD(
     ):
         mayObtain = False
         isMoneyEnough = False
     return _ButtonState(enabled=mayObtain,
                         itemPrice=itemPrice,
                         label=buttonLabel,
                         icon=buttonIcon,
                         iconAlign=buttonIconAlign,
                         isAction=isAction,
                         actionTooltip=actionTooltip,
                         tooltip=buyButtonTooltip,
                         title=self.__title,
                         isMoneyEnough=isMoneyEnough,
                         isUnlock=False,
                         isPrevItemsUnlock=True,
                         customOffer=None,
                         isShowSpecial=False)
Exemplo n.º 7
0
 def __getBtnData(self):
     vehicle = g_currentPreviewVehicle.item
     stats = self.itemsCache.items.stats
     tooltip = ''
     if vehicle.isUnlocked:
         money = stats.money
         money = self.tradeIn.addTradeInPriceIfNeeded(vehicle, money)
         exchangeRate = self.itemsCache.items.shop.exchangeRate
         price = getGUIPrice(vehicle, money, exchangeRate)
         currency = price.getCurrency(byWeight=True)
         action = getActionPriceData(vehicle)
         mayObtainForMoney = vehicle.mayObtainWithMoneyExchange(money, exchangeRate)
         if currency == Currency.GOLD:
             currencyIcon = RES_ICONS.MAPS_ICONS_LIBRARY_GOLDICONBIG
             if mayObtainForMoney:
                 formatter = text_styles.goldTextBig
             else:
                 formatter = text_styles.errCurrencyTextBig
                 tooltip = _buildBuyButtonTooltip('notEnoughGold')
         else:
             currencyIcon = RES_ICONS.MAPS_ICONS_LIBRARY_CREDITSICONBIG
             formatter = text_styles.creditsTextBig if mayObtainForMoney else text_styles.errCurrencyTextBig
             if not mayObtainForMoney:
                 tooltip = _buildBuyButtonTooltip('notEnoughCredits')
         if self._disableBuyButton:
             mayObtainForMoney = False
         return _ButtonState(mayObtainForMoney, formatter(BigWorld.wg_getIntegralFormat(price.getSignValue(currency))), VEHICLE_PREVIEW.BUYINGPANEL_BUYBTN_LABEL_RESTORE if vehicle.isRestorePossible() else VEHICLE_PREVIEW.BUYINGPANEL_BUYBTN_LABEL_BUY, action is not None, currencyIcon, action, tooltip)
     else:
         nodeCD = vehicle.intCD
         currencyIcon = RES_ICONS.MAPS_ICONS_LIBRARY_XPCOSTICONBIG
         isAvailableToUnlock, xpCost, possibleXp = g_techTreeDP.isVehicleAvailableToUnlock(nodeCD)
         formatter = text_styles.creditsTextBig if possibleXp >= xpCost else text_styles.errCurrencyTextBig
         if not isAvailableToUnlock:
             unlocks = self.itemsCache.items.stats.unlocks
             next2Unlock, _ = g_techTreeDP.isNext2Unlock(nodeCD, unlocked=set(unlocks), xps=stats.vehiclesXPs, freeXP=stats.freeXP)
             if next2Unlock:
                 tooltip = _buildBuyButtonTooltip('notEnoughXp')
             elif any(map(lambda cd: cd in unlocks, g_techTreeDP.getTopLevel(nodeCD))):
                 tooltip = _buildBuyButtonTooltip('parentModuleIsLocked')
             else:
                 tooltip = _buildBuyButtonTooltip('parentVehicleIsLocked')
         return _ButtonState(isAvailableToUnlock, formatter(BigWorld.wg_getIntegralFormat(xpCost)), VEHICLE_PREVIEW.BUYINGPANEL_BUYBTN_LABEL_RESEARCH, False, currencyIcon, None, tooltip)
         return None
 def __getBtnState(self):
     vehicle = g_currentPreviewVehicle.item
     if vehicle.isUnlocked:
         money = g_itemsCache.items.stats.money
         exchangeRate = g_itemsCache.items.shop.exchangeRate
         price = getGUIPrice(vehicle, money, exchangeRate)
         currency = price.getCurrency(byWeight=True)
         action = getActionPriceData(vehicle)
         mayObtainForMoney = vehicle.mayObtainWithMoneyExchange(money, exchangeRate)
         if currency == Currency.GOLD:
             currencyIcon = RES_ICONS.MAPS_ICONS_LIBRARY_GOLDICONBIG
             formatter = text_styles.goldTextBig if mayObtainForMoney else text_styles.errCurrencyTextBig
         else:
             currencyIcon = RES_ICONS.MAPS_ICONS_LIBRARY_CREDITSICONBIG
             formatter = text_styles.creditsTextBig if mayObtainForMoney else text_styles.errCurrencyTextBig
         return _ButtonState(mayObtainForMoney, formatter(BigWorld.wg_getIntegralFormat(price.get(currency))), VEHICLE_PREVIEW.BUYINGPANEL_BUYBTN_LABEL_RESTORE if vehicle.isRestorePossible() else VEHICLE_PREVIEW.BUYINGPANEL_BUYBTN_LABEL_BUY, action is not None, currencyIcon, ItemsActionsFactory.BUY_VEHICLE, action)
     else:
         nodeCD = vehicle.intCD
         currencyIcon = RES_ICONS.MAPS_ICONS_LIBRARY_XPCOSTICONBIG
         isAvailableToUnlock, xpCost, possibleXp = g_techTreeDP.isVehicleAvailableToUnlock(nodeCD)
         formatter = text_styles.creditsTextBig if possibleXp >= xpCost else text_styles.errCurrencyTextBig
         return _ButtonState(isAvailableToUnlock, formatter(BigWorld.wg_getIntegralFormat(xpCost)), VEHICLE_PREVIEW.BUYINGPANEL_BUYBTN_LABEL_RESEARCH, False, currencyIcon, ItemsActionsFactory.UNLOCK_ITEM, None)
         return None
Exemplo n.º 9
0
 def _getVehicleData(self, node, item):
     nodeCD = node['id']
     tags = item.tags
     credits, gold = node['GUIPrice']
     status, statusLevel = self._getRentStatus(item)
     return {'id': nodeCD,
      'state': node['state'],
      'type': item.itemTypeName,
      'nameString': item.shortUserName,
      'primaryClass': self._vClassInfo.getInfoByTags(tags),
      'level': item.level,
      'longName': item.longUserName,
      'iconPath': item.icon,
      'smallIconPath': item.iconSmall,
      'earnedXP': node['earnedXP'],
      'shopPrice': (credits, gold, getActionPriceData(item)),
      'displayInfo': node['displayInfo'],
      'unlockProps': node['unlockProps']._makeTuple(),
      'status': status,
      'statusLevel': statusLevel,
      'isRemovable': item.isRented,
      'isPremiumIGR': item.isPremiumIGR,
      'vehCompareTreeNodeData': getTreeNodeCompareData(item)}
Exemplo n.º 10
0
 def _getItemActionData(self, item):
     actionData = None
     if self._isItemOnDiscount(item):
         actionData = getActionPriceData(item)
     return actionData
Exemplo n.º 11
0
 def getActionPrice(self):
     from gui.shared.tooltips.formatters import getActionPriceData
     return getActionPriceData(self.__item)
Exemplo n.º 12
0
 def _getItemActionData(self, item):
     return getActionPriceData(item)
Exemplo n.º 13
0
 def _getItemActionData(self, item):
     return getActionPriceData(item)