def getStorageVehicleVo(vehicle):
    name = getVehicleName(vehicle)
    description = _getVehicleDescription(vehicle)
    imageSmall = func_utils.makeFlashPath(
        vehicle.getShopIcon(STORE_CONSTANTS.ICON_SIZE_SMALL))
    stateIcon, stateText = _getVehicleInfo(vehicle)
    if not imageSmall and not stateText:
        stateText = text_styles.vehicleStatusInfoText(
            _ms(STORAGE.INHANGAR_NOIMAGE))
    vo = createStorageDefVO(
        vehicle.intCD,
        name,
        description,
        vehicle.inventoryCount,
        getItemPricesVO(vehicle.getSellPrice())[0],
        imageSmall,
        RES_SHOP.getVehicleIcon(STORE_CONSTANTS.ICON_SIZE_SMALL, 'empty_tank'),
        itemType=vehicle.getHighlightType(),
        nationFlagIcon=RES_SHOP.getNationFlagIcon(
            nations.NAMES[vehicle.nationID]),
        contextMenuId=CONTEXT_MENU_HANDLER_TYPE.STORAGE_VEHICLES_REGULAR_ITEM)
    vo.update({'infoImgSrc': stateIcon, 'infoText': stateText})
    if vehicle.canTradeOff:
        vo.update(
            {'tradeOffPrice': {
                'price': getMoneyVO(vehicle.tradeOffPrice)
            }})
    return vo
def _createVehicleVO(rawItem, itemsCache):
    intCD = int(rawItem.id)
    vehicle = itemsCache.items.getItemByCD(intCD)
    if vehicle is not None:
        icon = func_utils.makeFlashPath(vehicle.getShopIcon(STORE_CONSTANTS.ICON_SIZE_SMALL))
        cd = vehicle.intCD
        label = vehicle.shortUserName
        nation = vehicle.nationID
        level = RES_ICONS.getLevelIcon(vehicle.level)
        tankType = Vehicle.getTypeSmallIconPath(vehicle.type, vehicle.isElite)
    else:
        icon = rawItem.iconSource
        cd = 0
        label = ''
        nation = nations.NONE_INDEX
        level = ''
        tankType = ''
    return {'icon': icon,
     'iconAlt': RES_ICONS.MAPS_ICONS_LIBRARY_VEHICLE_DEFAULT,
     'intCD': cd,
     'label': label,
     'nation': nation,
     'hasCompensation': getCompensateItemsCount(rawItem, itemsCache) > 0,
     'level': level,
     'tankType': tankType}
Ejemplo n.º 3
0
def _fillVehicleBlueprintCongratsModel(vehicle, model, itemsCache,
                                       congratsType, showCongrats):
    if vehicle.level < _MIN_VEHICLE_LVL_BLUEPRINT_AWARD:
        return
    else:
        blueprintData = itemsCache.items.blueprints.getBlueprintData(
            vehicle.intCD, vehicle.level)
        if blueprintData is None:
            return
        filledCount, totalCount, canConvert = blueprintData
        with model.congratsViewModel.transaction() as tx:
            vehicleType = formatEliteVehicle(vehicle.isElite, vehicle.type)
            image = makeFlashPath(vehicle.getShopIcon())
            tx.setShowCongrats(showCongrats)
            tx.setVehicleIsElite(vehicle.isElite)
            tx.setVehicleType(vehicleType)
            tx.setVehicleLvl(int2roman(vehicle.level))
            tx.setVehicleName(vehicle.userName)
            tx.setVehicleImage(image)
            tx.setCongratsType(congratsType)
            tx.setCongratsSourceId(str(vehicle.intCD))
            tx.setFragments(filledCount)
            tx.setFragmentsTotal(totalCount)
            tx.setCanConvert(canConvert)
            tx.setShineSwfAlias(CongratsViewModel.SHINE_BLUE_ALIAS)
            tx.setAdvancedShineName(CongratsViewModel.ADVANCED_SHINE_BLUE)
        return
def getStorageItemIcon(item, size=STORE_CONSTANTS.ICON_SIZE_MEDIUM):
    if item.itemTypeID in GUI_ITEM_TYPE.VEHICLE_COMPONENTS:
        icon = func_utils.makeFlashPath(item.getShopIcon(size))
    elif item.itemTypeID == GUI_ITEM_TYPE.CREW_BOOKS:
        icon = item.getOldStyleIcon()
    else:
        icon = item.icon
    return icon
Ejemplo n.º 5
0
 def _formatVehicle(self, vehicle, model, showCongrats):
     with model.congratsViewModel.transaction() as tx:
         vehicleType = formatEliteVehicle(vehicle.isElite, vehicle.type)
         image = makeFlashPath(vehicle.getShopIcon())
         tx.setVehicleIsElite(vehicle.isElite)
         tx.setVehicleType(vehicleType)
         tx.setVehicleLvl(int2roman(vehicle.level))
         tx.setVehicleName(vehicle.userName)
         tx.setVehicleImage(image)
         tx.setCongratsType(LootCongratsTypes.CONGRAT_TYPE_VEHICLE)
         tx.setCongratsSourceId(str(vehicle.intCD))
         tx.setShowCongrats(showCongrats)
 def __showCongratulationsView(self):
     if self.viewStatus != ViewStatus.LOADED:
         _logger.warning(
             'Can not show congratulations! The view is not loaded anymore.'
         )
         return
     else:
         self.viewModel.setIsContentHidden(True)
         with self.viewModel.congratulationAnim.transaction() as vm:
             vehicleType = '{}_elite'.format(
                 self.__vehicle.type
             ) if self.__vehicle.isElite else self.__vehicle.type
             image = func_utils.makeFlashPath(
                 self.__vehicle.getShopIcon(
                     size=STORE_CONSTANTS.ICON_SIZE_LARGE))
             defaultImage = RES_SHOP.getVehicleIcon(
                 STORE_CONSTANTS.ICON_SIZE_LARGE, 'empty_tank')
             settings = self.__congratsViewSettings
             if settings and 'bgSource' in settings:
                 self.viewModel.setBgSource(settings['bgSource'])
             if settings and 'backBtnEnabled' in settings:
                 vm.setNeedBackBtn(settings['backBtnEnabled'])
             if settings and 'backBtnLabel' in settings:
                 vm.setBackBtnLbl(settings['backBtnLabel'])
             vm.setIsElite(self.__vehicle.isElite)
             vm.setIsCollectible(self.__vehicle.isCollectible)
             vm.setVehicleType(vehicleType)
             vm.setLvl(int2roman(self.__vehicle.level))
             vm.setVName(self.__vehicle.userName)
             vm.setImage(image if image is not None else defaultImage)
             vm.setImageAlt(defaultImage)
             vm.setTitle(R.strings.store.congratulationAnim.restoreLabel(
             ) if self.viewModel.getIsRestore() else R.strings.store.
                         congratulationAnim.buyingLabel())
             vm.setBtnLbl(
                 R.strings.store.congratulationAnim.showPreviewBtnLabel())
         return
Ejemplo n.º 7
0
 def _buildVehicle(self, item):
     bpRequester = self._itemsCache.items.blueprints
     name = getVehicleName(vehicle=item)
     intelligenceIcon = RES_ICONS.getBlueprintFragment(
         'special', 'intelligence')
     current, total = bpRequester.getBlueprintCount(item.intCD, item.level)
     _, intelligenceCost = bpRequester.getRequiredIntelligenceAndNational(
         item.level)
     nationalsCost = bpRequester.getNationalRequiredOptions(
         item.intCD, item.level)
     availableCount = bpRequester.getConvertibleFragmentCount(
         item.intCD, item.level)
     if availableCount > 0:
         description = makeString(
             STORAGE.BLUEPRINTS_CARD_CONVERTAVAILABLE,
             count=text_styles.stats(
                 backport.getIntegralFormat(availableCount)))
     else:
         description = text_styles.error(
             STORAGE.BLUEPRINTS_CARD_CONVERTREQUIRED)
     availableToUnlock, _ = g_techTreeDP.isNext2Unlock(
         item.intCD,
         unlocked=self._itemsCache.items.stats.unlocks,
         xps=self._itemsCache.items.stats.vehiclesXPs,
         freeXP=self._itemsCache.items.stats.actualFreeXP,
         level=item.level)
     intelligenceCostText, fragmentsCost = self.__formatFragmentsCost(
         intelligenceCost=intelligenceCost,
         intelligenceIcon=intelligenceIcon,
         nationalsCost=nationalsCost)
     discount = bpRequester.getBlueprintDiscount(item.intCD, item.level)
     fragmentsProgress = self.__formatFragmentProgress(
         current, total, discount)
     image = func_utils.makeFlashPath(
         item.getShopIcon(STORE_CONSTANTS.ICON_SIZE_SMALL))
     return {
         'id':
         item.intCD,
         'title':
         name,
         'description':
         description,
         'image':
         image,
         'imageAlt':
         RES_SHOP.getVehicleIcon(STORE_CONSTANTS.ICON_SIZE_SMALL,
                                 'empty_tank'),
         'fragmentsCost':
         fragmentsCost,
         'intelligenceCostText':
         intelligenceCostText,
         'fragmentsProgress':
         fragmentsProgress,
         'hasDiscount':
         discount > 0,
         'availableToUnlock':
         availableToUnlock,
         'convertAvailable':
         availableCount > 0,
         'contextMenuId':
         CONTEXT_MENU_HANDLER_TYPE.STORAGE_BLUEPRINTS_ITEM
     }
Ejemplo n.º 8
0
    def __onUpdateBoosters(self, *args):
        activeBoostersCount = len(
            self._goodiesCache.getBoosters(
                criteria=REQ_CRITERIA.BOOSTER.ACTIVE).values())
        totalBoostersCount = len(
            self._goodiesCache.getBoosters(
                criteria=REQ_CRITERIA.BOOSTER.IN_ACCOUNT).values())
        filteredBoostersCount = 0
        criteria = REQ_CRITERIA.BOOSTER.IN_ACCOUNT | REQ_CRITERIA.BOOSTER.ENABLED
        criteria |= getCriteriaFromFilterMask(self.__filterMask)
        boosters = self._goodiesCache.getBoosters(criteria=criteria).values()
        dataProviderValues = []
        showDummyScreen = False
        filterWarningVO = None
        if boosters:
            for booster in sorted(boosters, cmp=self.__sort):
                influence = backport.text(
                    R.strings.menu.booster.influence.dyn(
                        booster.boosterGuiType)())
                limitResource = R.strings.menu.booster.limit.dyn(
                    booster.boosterGuiType)
                if limitResource:
                    additionalInfo = text_styles.alert(
                        backport.text(limitResource()))
                else:
                    additionalInfo = ''
                vo = createStorageDefVO(
                    booster.boosterID,
                    text_styles.hightlight(
                        _ms(MENU.BOOSTER_DESCRIPTION_EFFECTVALUETIME,
                            effectValue=booster.getFormattedValue(),
                            effectTime=booster.getEffectTimeStr(
                                hoursOnly=True))),
                    text_styles.main(influence),
                    booster.count,
                    getItemPricesVO(booster.getSellPrice())[0],
                    func_utils.makeFlashPath(
                        booster.getShopIcon(STORE_CONSTANTS.ICON_SIZE_SMALL)),
                    func_utils.makeFlashPath(booster.getShopIcon()),
                    'altimage',
                    enabled=booster.isReadyToActivate,
                    available=booster.isAvailable,
                    active=booster.state,
                    contextMenuId=CONTEXT_MENU_HANDLER_TYPE.
                    STORAGE_PERSONAL_RESERVE_ITEM,
                    additionalInfo=additionalInfo)
                dataProviderValues.append(vo)
                filteredBoostersCount += 1

        elif totalBoostersCount == 0:
            showDummyScreen = True
        else:
            filterWarningVO = self._makeFilterWarningVO(
                STORAGE.FILTER_WARNINGMESSAGE,
                STORAGE.FILTER_NORESULTSBTN_LABEL,
                TOOLTIPS.STORAGE_FILTER_NORESULTSBTN)
        self._dataProvider.buildList(dataProviderValues)
        self.__updateFilterCounter(filteredBoostersCount, totalBoostersCount)
        self.__updateActiveBoostersCounter(activeBoostersCount,
                                           totalBoostersCount)
        self.as_showFilterWarningS(filterWarningVO)
        self.as_showDummyScreenS(showDummyScreen)
        return
 def _buildVehicle(self, item):
     bpRequester = self._itemsCache.items.blueprints
     name = getVehicleName(vehicle=item)
     intelligenceIcon = RES_ICONS.getBlueprintFragment(
         'small', 'intelligence')
     nationalIcon = RES_ICONS.getBlueprintFragment('small', item.nationName)
     current, total = bpRequester.getBlueprintCount(item.intCD, item.level)
     nationalCost, intelligenceCost = bpRequester.getRequiredIntelligenceAndNational(
         item.level)
     availableCount = bpRequester.getConvertibleFragmentCount(
         item.intCD, item.level)
     if availableCount > 0:
         description = self.__getConvertAvailableDescription(availableCount)
     else:
         existingNational = bpRequester.getNationalFragments(item.intCD)
         existingIntelligence = bpRequester.getIntelligenceData()
         intelligenceRequired = max(
             (0, intelligenceCost - existingIntelligence))
         nationalRequired = max((0, nationalCost - existingNational))
         description = self.__getConvertRequiredDescription(
             intelligenceRequired, intelligenceIcon, nationalRequired,
             nationalIcon)
     availableToUnlock, _ = g_techTreeDP.isNext2Unlock(
         item.intCD,
         unlocked=self._itemsCache.items.stats.unlocks,
         xps=self._itemsCache.items.stats.vehiclesXPs,
         freeXP=self._itemsCache.items.stats.actualFreeXP,
         level=item.level)
     fragmentsCostText = self.__formatFragmentsCost(
         intelligenceCost=intelligenceCost,
         intelligenceIcon=intelligenceIcon,
         nationalCost=nationalCost,
         nationalIcon=nationalIcon)
     discount = bpRequester.getBlueprintDiscount(item.intCD, item.level)
     fragmentsProgress = self.__formatFragmentProgress(
         current, total, discount)
     image = func_utils.makeFlashPath(
         item.getShopIcon(STORE_CONSTANTS.ICON_SIZE_SMALL))
     return {
         'id':
         item.intCD,
         'title':
         name,
         'description':
         description,
         'image':
         image,
         'imageAlt':
         RES_SHOP.getVehicleIcon(STORE_CONSTANTS.ICON_SIZE_SMALL,
                                 'empty_tank'),
         'fragmentsCostText':
         fragmentsCostText,
         'fragmentsProgress':
         fragmentsProgress,
         'hasDiscount':
         discount > 0,
         'availableToUnlock':
         availableToUnlock,
         'convertAvailable':
         availableCount > 0,
         'contextMenuId':
         CONTEXT_MENU_HANDLER_TYPE.STORAGE_BLUEPRINTS_ITEM
     }