コード例 #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
 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
ファイル: 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 ''
コード例 #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
 def _buildVehicle(self, item):
     vo = super(_RentVehiclesDataProvider, self)._buildVehicle(item)
     rentText = RentLeftFormatter(item.rentInfo, item.isPremiumIGR).getRentLeftStr() or _ms(MENU.STORE_VEHICLESTATES_RENTALISOVER)
     vo.update({'isMoneyEnough': True,
      'enabled': item.canSell and item.rentalIsOver and not item.isTelecomRent,
      'rentText': rentText,
      'rentIcon': RES_ICONS.MAPS_ICONS_LIBRARY_CLOCKICON_1,
      'contextMenuId': CONTEXT_MENU_HANDLER_TYPE.STORAGE_VEHICLES_RENTED_ITEM})
     return vo
コード例 #8
0
 def __getRootStatusStr(root):
     return text_styles.concatStylesToSingleLine(
         icons.makeImageTag(backport.image(
             R.images.gui.maps.icons.library.ClockIcon_1()),
                            width=38,
                            height=38,
                            vSpace=-14),
         RentLeftFormatter(root.rentInfo).getRentLeftStr(
             strForSpecialTimeFormat=backport.text(
                 R.strings.menu.research.status.rentLeft()))
     ) if root.isRented and not root.rentalIsOver and not root.isTelecom and not root.isPremiumIGR else ''
コード例 #9
0
    def updateVehicles(self, vehicles=None, updateFallout=True):
        isSet = vehicles is None
        filterCriteria = REQ_CRITERIA.INVENTORY
        if vehicles is not None:
            filterCriteria |= REQ_CRITERIA.IN_CD_LIST(vehicles)
        items = g_itemsCache.items
        filteredVehs = items.getVehicles(filterCriteria)
        if vehicles is None:
            vehicles = filteredVehs.keys()
        isSuitablePredicate = lambda vehIntCD: True
        if self.preQueueFunctional.getQueueType(
        ) == constants.QUEUE_TYPE.HISTORICAL:
            battle = self.preQueueFunctional.getItemData()
            if battle is not None:
                isSuitablePredicate = battle.canParticipateWith
        hasEmptySlots = self.__multiselectionMode and len(
            self.__falloutCtrl.getEmptySlots()) > 0
        vehsData = {}
        for intCD in vehicles:
            vehicle = filteredVehs.get(intCD)
            if vehicle is not None:
                vState, vStateLvl = vehicle.getState()
                isSuitableVeh = vState != Vehicle.VEHICLE_STATE.BATTLE and not isSuitablePredicate(
                    vehicle.intCD)
                isSuitableVeh |= self.__multiselectionMode and not vehicle.isFalloutAvailable
                if isSuitableVeh:
                    vState, vStateLvl = Vehicle.VEHICLE_STATE.NOT_SUITABLE, Vehicle.VEHICLE_STATE_LEVEL.WARNING
                canSelect, tooltip = self.__falloutCtrl.canSelectVehicle(
                    vehicle)
                rentInfoStr = RentLeftFormatter(
                    vehicle.rentInfo, vehicle.isPremiumIGR).getRentLeftStr()
                vehsData[intCD] = self._getVehicleData(vehicle, vState,
                                                       vStateLvl, rentInfoStr,
                                                       hasEmptySlots,
                                                       canSelect, tooltip)

        LOG_DEBUG('Updating carousel vehicles: ',
                  vehsData if not isSet else 'full sync')
        self.as_updateVehiclesS(vehsData, isSet)
        self.showVehicles()
        isVehTypeLock = sum(
            (len(v) for v in items.stats.vehicleTypeLocks.itervalues()))
        isGlobalVehLock = sum(
            (len(v) for v in items.stats.globalVehicleLocks.itervalues()))
        if self.__updateVehiclesTimerId is None and (isVehTypeLock
                                                     or isGlobalVehLock):
            self.__updateVehiclesTimerId = BigWorld.callback(
                self.UPDATE_LOCKS_PERIOD, self.updateLockTimers)
            LOG_DEBUG('Lock timer updated')
        if updateFallout:
            self._updateFallout()
コード例 #10
0
 def _getRentStatus(self, item):
     status = ''
     statusLevel = ''
     if item.isRented:
         if item.rentalIsOver:
             if item.isPremiumIGR:
                 status = i18n.makeString('#menu:currentVehicleStatus/igrRentalIsOver')
             else:
                 status = i18n.makeString('#menu:currentVehicleStatus/rentalIsOver')
             statusLevel = InventoryVehicle.STATE_LEVEL.CRITICAL
         elif not item.isPremiumIGR:
             status = RentLeftFormatter(item.rentInfo).getRentLeftStr()
             statusLevel = InventoryVehicle.STATE_LEVEL.RENTED
     return (status, statusLevel)
コード例 #11
0
 def _getVehicleDataVO(self, vehicle):
     rentInfoText = RentLeftFormatter(
         vehicle.rentInfo, vehicle.isPremiumIGR).getRentLeftStr()
     vState, vStateLvl = vehicle.getState()
     smallStatus, largeStatus = _getStatusStrings(
         vState,
         vStateLvl,
         substitute=rentInfoText,
         ctx={'icon': icons.premiumIgrSmall()})
     if vehicle.dailyXPFactor > 1:
         bonusImage = getButtonsAssetPath('bonus_x{}'.format(
             vehicle.dailyXPFactor))
     else:
         bonusImage = ''
     label = vehicle.shortUserName if vehicle.isPremiumIGR else vehicle.userName
     labelStyle = text_styles.premiumVehicleName if vehicle.isPremium else text_styles.vehicleName
     return {
         'id':
         vehicle.invID,
         'infoText':
         largeStatus,
         'smallInfoText':
         smallStatus,
         'clanLock':
         vehicle.clanLock,
         'lockBackground':
         vStateLvl == Vehicle.VEHICLE_STATE_LEVEL.CRITICAL,
         'icon':
         vehicle.icon,
         'iconSmall':
         vehicle.iconSmall,
         'label':
         labelStyle(label),
         'level':
         vehicle.level,
         'premium':
         vehicle.isPremium,
         'favorite':
         vehicle.isFavorite,
         'nation':
         vehicle.nationID,
         'xpImgSource':
         bonusImage,
         'tankType':
         '{}_elite'.format(vehicle.type)
         if vehicle.isElite else vehicle.type,
         'rentLeft':
         rentInfoText
     }
コード例 #12
0
 def itemWrapper(self, packedItem):
     module, inventoryCount, vehicleCount, disable, statusMessage, isEnabledBuyingGoldShellsForCredits, isEnabledBuyingGoldEqsForCredits, extraModuleInfo = packedItem
     credits, gold = g_itemsCache.items.stats.money
     statusLevel = InventoryVehicle.STATE_LEVEL.INFO
     inventoryId = None
     isRented = False
     rentLeftTimeStr = ''
     if module.itemTypeID == GUI_ITEM_TYPE.VEHICLE:
         statusLevel = module.getState()[1]
         if module.isRented:
             isRented = True
             rentLeftTimeStr = RentLeftFormatter(module.rentInfo, module.isPremiumIGR).getRentTimeLeftStr()
         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}
コード例 #13
0
 def itemWrapper(self, packedItem):
     module, inventoryCount, vehicleCount, disabled, statusMessage, isEnabledBuyingGoldShellsForCredits, isEnabledBuyingGoldEqsForCredits, extraModuleInfo = packedItem
     credits, gold = g_itemsCache.items.stats.money
     name = module.userName if module.itemTypeID in GUI_ITEM_TYPE.ARTEFACTS else module.longUserName
     price = module.altPrice or module.buyPrice
     defaultPrice = module.defaultAltPrice or module.defaultPrice
     rentLeftTimeStr = RentLeftFormatter(module.rentInfo).getRentLeftStr()
     minRentPricePackage = module.getRentPackage()
     action = None
     if price != defaultPrice and not minRentPricePackage:
         action = getItemActionTooltipData(module)
     elif minRentPricePackage:
         price = minRentPricePackage['rentPrice']
         if minRentPricePackage['rentPrice'] != minRentPricePackage['defaultRentPrice']:
             action = getItemRentActionTooltipData(module, minRentPricePackage)
     return {'id': str(module.intCD),
      'name': name,
      'desc': module.getShortInfo(),
      'inventoryId': None,
      'inventoryCount': inventoryCount,
      'vehicleCount': vehicleCount,
      'credits': credits,
      'gold': gold,
      'price': price,
      'currency': 'credits' if price[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': disabled,
      'statusMessage': statusMessage,
      'statusLevel': InventoryVehicle.STATE_LEVEL.WARNING,
      'removable': module.isRemovable if module.itemTypeID == GUI_ITEM_TYPE.OPTIONALDEVICE else True,
      'tankType': module.type if module.itemTypeID == GUI_ITEM_TYPE.VEHICLE else type,
      '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}
コード例 #14
0
ファイル: dumpers.py プロジェクト: webiumsk/WOT-0.9.17-CT
 def _getRentStatus(item):
     status = ''
     statusLevel = ''
     if item.isRented and not item.isTelecom:
         if item.rentalIsOver:
             if item.isPremiumIGR:
                 status = i18n.makeString(
                     MENU.CURRENTVEHICLESTATUS_IGRRENTALISOVER)
             else:
                 status = i18n.makeString(
                     MENU.CURRENTVEHICLESTATUS_RENTALISOVER)
             statusLevel = Vehicle.VEHICLE_STATE_LEVEL.CRITICAL
         elif not item.isPremiumIGR:
             status = RentLeftFormatter(item.rentInfo).getRentLeftStr()
             statusLevel = Vehicle.VEHICLE_STATE_LEVEL.RENTED
     elif item.isRentable and item.isRentAvailable:
         status = i18n.makeString(MENU.CURRENTVEHICLESTATUS_ISRENTABLE)
         statusLevel = Vehicle.VEHICLE_STATE_LEVEL.RENTED
     return (status, statusLevel)
コード例 #15
0
ファイル: nodes.py プロジェクト: kusaku/wot_scripts
 def getStatus(self):
     status, statusLevel = ('', '')
     item = self.__item
     if item is not None and item.itemTypeID == GUI_ITEM_TYPE.VEHICLE:
         if item.isRented and not item.isTelecom:
             if item.rentalIsOver:
                 if item.isPremiumIGR:
                     status = i18n.makeString(
                         MENU.CURRENTVEHICLESTATUS_IGRRENTALISOVER)
                 else:
                     status = i18n.makeString(
                         MENU.CURRENTVEHICLESTATUS_RENTALISOVER)
                 statusLevel = Vehicle.VEHICLE_STATE_LEVEL.CRITICAL
             elif not item.isPremiumIGR:
                 status = RentLeftFormatter(item.rentInfo).getRentLeftStr()
                 statusLevel = Vehicle.VEHICLE_STATE_LEVEL.RENTED
         elif item.isRentable and item.isRentAvailable:
             status = i18n.makeString(MENU.CURRENTVEHICLESTATUS_ISRENTABLE)
             statusLevel = Vehicle.VEHICLE_STATE_LEVEL.RENTED
         elif item.canTradeIn:
             status = i18n.makeString(MENU.TRADE_IN)
             statusLevel = Vehicle.VEHICLE_STATE_LEVEL.INFO
     return (status, statusLevel)
コード例 #16
0
def getVehicleDataVO(vehicle):
    rentInfoText = RentLeftFormatter(vehicle.rentInfo, vehicle.isPremiumIGR).getRentLeftStr()
    vState, vStateLvl = vehicle.getState()
    if vehicle.isRotationApplied():
        if vState in (Vehicle.VEHICLE_STATE.AMMO_NOT_FULL, Vehicle.VEHICLE_STATE.LOCKED):
            vState = Vehicle.VEHICLE_STATE.ROTATION_GROUP_UNLOCKED
    smallStatus, largeStatus = getStatusStrings(vState, vStateLvl, substitute=rentInfoText, ctx={'icon': icons.premiumIgrSmall(),
     'battlesLeft': getBattlesLeft(vehicle)})
    if vehicle.dailyXPFactor > 1:
        bonusImage = getButtonsAssetPath('bonus_x{}'.format(vehicle.dailyXPFactor))
    else:
        bonusImage = ''
    label = vehicle.shortUserName if vehicle.isPremiumIGR else vehicle.userName
    labelStyle = text_styles.premiumVehicleName if vehicle.isPremium else text_styles.vehicleName
    return {'id': vehicle.invID,
     'intCD': vehicle.intCD,
     'infoText': largeStatus,
     'smallInfoText': smallStatus,
     'clanLock': vehicle.clanLock,
     'lockBackground': _isLockedBackground(vState, vStateLvl),
     'icon': vehicle.icon,
     'iconAlt': getIconPath('noImage'),
     'iconSmall': vehicle.iconSmall,
     'iconSmallAlt': getSmallIconPath('noImage'),
     'label': labelStyle(label),
     'level': vehicle.level,
     'premium': vehicle.isPremium,
     'favorite': vehicle.isFavorite,
     'nation': vehicle.nationID,
     'xpImgSource': bonusImage,
     'tankType': '{}_elite'.format(vehicle.type) if vehicle.isElite else vehicle.type,
     'rentLeft': rentInfoText,
     'clickEnabled': vehicle.isInInventory,
     'alpha': 1,
     'infoImgSrc': getVehicleStateIcon(vState),
     'isCritInfo': vStateLvl == Vehicle.VEHICLE_STATE_LEVEL.CRITICAL}
コード例 #17
0
 def _getVehicleDataVO(self, vehicle):
     rentInfoStr = RentLeftFormatter(vehicle.rentInfo,
                                     vehicle.isPremiumIGR).getRentLeftStr()
     vState, vStateLvl = vehicle.getState()
     infoText = _getStatusString(vState, vStateLvl)
     return {
         'id': vehicle.invID,
         'showInfoText': bool(infoText),
         'infoText': infoText,
         'clanLock': vehicle.clanLock,
         'lockBackground':
         vStateLvl == Vehicle.VEHICLE_STATE_LEVEL.CRITICAL,
         'tankIconData': {
             'image':
             vehicle.icon,
             'label':
             vehicle.shortUserName
             if vehicle.isPremiumIGR else vehicle.userName,
             'level':
             vehicle.level,
             'elite':
             vehicle.isElite,
             'premium':
             vehicle.isPremium,
             'favorite':
             vehicle.isFavorite,
             'nation':
             vehicle.nationID,
             'doubleXPReceived':
             vehicle.dailyXPFactor,
             'tankType':
             vehicle.type,
             'rentLeft':
             rentInfoStr
         }
     }
コード例 #18
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)
コード例 #19
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)
コード例 #20
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
コード例 #21
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
コード例 #22
0
ファイル: hangartankcarousel.py プロジェクト: Difrex/wotsdk
    def updateVehicles(self,
                       vehicles=None,
                       filterCriteria=None,
                       updateFallout=True):
        isSet = vehicles is None and filterCriteria is None
        filterCriteria = filterCriteria or REQ_CRITERIA.INVENTORY
        if vehicles is not None:
            filterCriteria |= REQ_CRITERIA.IN_CD_LIST(vehicles)
        items = g_itemsCache.items
        filteredVehs = items.getVehicles(filterCriteria)
        if vehicles is None:
            vehicles = filteredVehs.keys()
        hasEmptySlots = self.__multiselectionMode and len(
            self.__falloutCtrl.getEmptySlots()) > 0
        hasRequiredVehicles = self.__falloutCtrl.getConfig(
        ).hasRequiredVehicles()
        vehsData = {}
        multiselectionsData = {}
        for intCD in vehicles:
            vehicle = filteredVehs.get(intCD)
            vehData = None
            if vehicle is not None:
                vState, vStateLvl = vehicle.getState()
                isNotSuitableVeh = not self.__falloutCtrl.isSuitableVeh(
                    vehicle)
                if isNotSuitableVeh:
                    vState, vStateLvl = Vehicle.VEHICLE_STATE.NOT_SUITABLE, Vehicle.VEHICLE_STATE_LEVEL.WARNING
                rentInfoStr = RentLeftFormatter(
                    vehicle.rentInfo, vehicle.isPremiumIGR).getRentLeftStr()
                vehData = self._getVehicleData(vehicle, vState, vStateLvl,
                                               rentInfoStr)
                multiselectionsData[intCD] = self.__packMultiselectionFlags(
                    self.__multiselectionMode and vehicle.isFalloutSelected,
                    self.__falloutCtrl.canSelectVehicle(vehicle),
                    hasRequiredVehicles and hasEmptySlots
                    or vehicle.isFalloutSelected)
            vehsData[intCD] = vehData

        LOG_DEBUG('Updating carousel vehicles: {0}'.format(
            vehsData if not isSet else 'full sync'))
        self.as_updateVehiclesS(vehsData, isSet)
        self.as_setMultiselectionButtonLabelsS(
            FALLOUT.TANKCAROUSELSLOT_ACTIVATEBUTTON,
            FALLOUT.TANKCAROUSELSLOT_DEACTIVATEBUTTON,
            self.__falloutCtrl.carouselSelectionButtonTooltip())
        self.as_updateMultiselectionDataS(multiselectionsData)
        isVehTypeLock = sum(
            (len(v) for v in items.stats.vehicleTypeLocks.itervalues()))
        isGlobalVehLock = sum(
            (len(v) for v in items.stats.globalVehicleLocks.itervalues()))
        if self.__updateVehiclesTimerId is None and (isVehTypeLock
                                                     or isGlobalVehLock):
            self.__updateVehiclesTimerId = BigWorld.callback(
                _UPDATE_LOCKS_PERIOD, self.updateLockTimers)
            LOG_DEBUG('Lock timer updated')
        self._initializeFilters()
        if self.__multiselectionMode and updateFallout and not isSet:
            self._updateFallout()
        else:
            self.showVehicles()
        return
コード例 #23
0
def getVehicleDataVO(vehicle):
    lowTierMMController = dependency.instance(ILowTierMMController)
    rentInfoText = RentLeftFormatter(vehicle.rentInfo,
                                     vehicle.isPremiumIGR).getRentLeftStr()
    vState, vStateLvl = vehicle.getState()
    if vehicle.isRotationApplied():
        if vState in (Vehicle.VEHICLE_STATE.AMMO_NOT_FULL,
                      Vehicle.VEHICLE_STATE.LOCKED):
            vState = Vehicle.VEHICLE_STATE.ROTATION_GROUP_UNLOCKED
    if not vehicle.activeInNationGroup:
        vState = Vehicle.VEHICLE_STATE.NOT_PRESENT
    customStateExt = ''
    if vState in (Vehicle.VEHICLE_STATE.RENTABLE,
                  Vehicle.VEHICLE_STATE.RENTABLE_AGAIN):
        rentPackagesInfo = vehicle.getRentPackagesInfo
        if rentPackagesInfo.seasonType:
            customStateExt = '/' + SEASON_NAME_BY_TYPE.get(
                rentPackagesInfo.seasonType)
    smallStatus, largeStatus = getStatusStrings(vState + customStateExt,
                                                vStateLvl,
                                                substitute=rentInfoText,
                                                ctx={
                                                    'icon':
                                                    icons.premiumIgrSmall(),
                                                    'battlesLeft':
                                                    getBattlesLeft(vehicle)
                                                })
    smallHoverStatus, largeHoverStatus = smallStatus, largeStatus
    if vState == Vehicle.VEHICLE_STATE.RENTABLE:
        smallHoverStatus, largeHoverStatus = getStatusStrings(
            vState + '/hover',
            vStateLvl,
            substitute=rentInfoText,
            ctx={
                'icon': icons.premiumIgrSmall(),
                'battlesLeft': getBattlesLeft(vehicle)
            })
    if vehicle.dailyXPFactor > 1:
        bonusImage = getButtonsAssetPath('bonus_x{}'.format(
            vehicle.dailyXPFactor))
    else:
        bonusImage = ''
    label = vehicle.shortUserName if vehicle.isPremiumIGR else vehicle.userName
    labelStyle = text_styles.premiumVehicleName if vehicle.isPremium else text_styles.vehicleName
    tankType = '{}_elite'.format(
        vehicle.type) if vehicle.isElite else vehicle.type
    current, maximum = vehicle.getCrystalsEarnedInfo()
    isCrystalsLimitReached = current == maximum
    return {
        'id':
        vehicle.invID,
        'intCD':
        vehicle.intCD,
        'infoText':
        largeStatus,
        'infoHoverText':
        largeHoverStatus,
        'smallInfoText':
        smallStatus,
        'smallInfoHoverText':
        smallHoverStatus,
        'clanLock':
        vehicle.clanLock,
        'lockBackground':
        _isLockedBackground(vState, vStateLvl),
        'icon':
        vehicle.icon,
        'iconAlt':
        getIconPath('noImage'),
        'iconSmall':
        vehicle.iconSmall,
        'iconSmallAlt':
        getSmallIconPath('noImage'),
        'label':
        labelStyle(label),
        'level':
        vehicle.level,
        'premium':
        vehicle.isPremium,
        'favorite':
        vehicle.isFavorite,
        'giveaway':
        vehicle.isLowTierEvent and lowTierMMController.isEnabled(),
        'nation':
        vehicle.nationID,
        'xpImgSource':
        bonusImage,
        'tankType':
        tankType,
        'rentLeft':
        rentInfoText,
        'clickEnabled':
        vehicle.isInInventory and vehicle.activeInNationGroup
        or vehicle.isRentPromotion,
        'alpha':
        1,
        'infoImgSrc':
        getVehicleStateIcon(vState),
        'additionalImgSrc':
        getVehicleStateAddIcon(vState),
        'isCritInfo':
        vStateLvl == Vehicle.VEHICLE_STATE_LEVEL.CRITICAL,
        'isRentPromotion':
        vehicle.isRentPromotion and not vehicle.isRented,
        'isNationChangeAvailable':
        vehicle.hasNationGroup,
        'isEarnCrystals':
        vehicle.isEarnCrystals,
        'isCrystalsLimitReached':
        isCrystalsLimitReached,
        'isUseRightBtn':
        True,
        'tooltip':
        TOOLTIPS_CONSTANTS.CAROUSEL_VEHICLE
    }
コード例 #24
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
コード例 #25
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
コード例 #26
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)