Exemplo n.º 1
0
 def __setTotalData(self, *_):
     cart = getTotalPurchaseInfo(self._purchaseItems)
     totalPriceVO = getItemPricesVO(cart.totalPrice)
     state = g_currentVehicle.getViewState()
     shortage = self.itemsCache.items.stats.money.getShortage(
         cart.totalPrice.price)
     inFormationAlert = ''
     if not state.isCustomizationEnabled():
         inFormationAlert = text_styles.concatStylesWithSpace(
             icons.markerBlocked(),
             text_styles.error(
                 VEHICLE_CUSTOMIZATION.WINDOW_PURCHASE_FORMATION_ALERT))
     self.as_setTotalDataS({
         'totalLabel':
         text_styles.highTitle(
             _ms(VEHICLE_CUSTOMIZATION.WINDOW_PURCHASE_TOTALCOST,
                 selected=cart.numSelected,
                 total=cart.numApplying)),
         'enoughMoney':
         getItemPricesVO(ItemPrice(shortage, shortage))[0],
         'inFormationAlert':
         inFormationAlert,
         'totalPrice':
         totalPriceVO[0]
     })
 def getItemPrices(self):
     item = self.__item
     unlockProps = self.getUnlockProps()
     if item.canTradeIn:
         return getItemPricesVO(self.__tradeIn.getTradeInPrice(item))
     elif not item.isUnlocked and unlockProps is not None and not item.isCollectible:
         return getItemUnlockPricesVO(unlockProps)
     else:
         return getItemRestorePricesVO(
             item.restorePrice) if item.isRestoreAvailable(
             ) else getItemPricesVO(item.getBuyPrice())
Exemplo n.º 3
0
    def _generateOptions(self, ctx=None):
        item = self.itemsCache.items.getItemByCD(self._intCD)
        buyPriceVO = getItemPricesVO(item.getBuyPrice())
        sellPriceVO = getItemPricesVO(item.getSellPrice())
        inventoryCount = self._c11nView.getItemInventoryCount(item)
        availableForSale = inventoryCount > 0 and item.getSellPrice(
        ) != ITEM_PRICE_EMPTY and not item.isRentable and not item.isHidden
        style = self._c11nView.getModifiedStyle()
        removeFromTankEnabled = style.intCD == item.intCD if style is not None else False
        for outfit in (self._c11nView.getModifiedOutfit(season)
                       for season in SeasonType.COMMON_SEASONS):
            if outfit.has(item):
                removeFromTankEnabled = True
                break

        accountMoney = self.itemsCache.items.stats.money
        availableForPurchase = not item.isHidden and not item.getBuyPrice(
        ) == ITEM_PRICE_EMPTY and item.getBuyPrice().price <= accountMoney
        showAlert = len(sellPriceVO[0]) > 1
        tooltipVO = None
        if showAlert:
            tooltipVO = packActionTooltipData(
                ACTION_TOOLTIPS_TYPE.ITEM, str(item.intCD), False,
                item.sellPrices.getSum().price,
                item.sellPrices.getSum().defPrice)
            price = sellPriceVO[0]['price']
            sellPriceVO[0] = {}
            sellPriceVO[0]['price'] = price
        return [
            self._makeItem(
                CustomizationOptions.BUY,
                MENU.cst_item_ctx_menu(CustomizationOptions.BUY), {
                    'data': {
                        'price': first(buyPriceVO)
                    } if availableForPurchase else None,
                    'enabled': availableForPurchase
                }, None, 'CurrencyContextMenuItem'),
            self._makeSeparator(),
            self._makeItem(
                CustomizationOptions.SELL,
                MENU.cst_item_ctx_menu(CustomizationOptions.SELL), {
                    'data': {
                        'price': first(sellPriceVO)
                    } if availableForSale else None,
                    'enabled': availableForSale,
                    'showAlert': showAlert,
                    'tooltipVO': tooltipVO
                }, None, 'CurrencyContextMenuItem'),
            self._makeSeparator(),
            self._makeItem(
                CustomizationOptions.REMOVE_FROM_TANK,
                MENU.cst_item_ctx_menu(CustomizationOptions.REMOVE_FROM_TANK),
                {'enabled': removeFromTankEnabled})
        ]
 def __init__(self,
              intCD,
              typeId,
              isWide,
              icon,
              hasBonus,
              locked,
              buyPrice,
              quantity=None,
              isRental=False,
              showDetailItems=True,
              isNonHistoric=False,
              showAlert=False,
              buyOperationAllowed=True,
              extraName='',
              showRareIcon=False,
              isEquipped=False,
              rentalInfoText=''):
     self.intCD = intCD
     self.typeId = typeId
     self.isWide = isWide
     self.icon = icon
     self.hasBonus = hasBonus
     self.locked = locked
     self.buyPrice = getItemPricesVO(buyPrice)[0]
     self.quantity = quantity
     self.isRental = isRental
     self.showDetailItems = showDetailItems
     self.isNonHistoric = isNonHistoric
     self.showAlert = showAlert
     self.buyOperationAllowed = buyOperationAllowed
     self.extraName = extraName
     self.showRareIcon = showRareIcon
     self.isEquipped = isEquipped
     self.rentalInfoText = rentalInfoText
 def _buildModuleData(self, module, isInstalledInSlot, stats):
     itemPrice = module.buyPrices.itemPrice
     inInventory = module.isInInventory
     isInstalled = module.isInstalled(self._vehicle)
     isBought = inInventory or isInstalled
     if module.itemTypeID == GUI_ITEM_TYPE.OPTIONALDEVICE and not isInstalled and module.hasSimilarDevicesInstalled(self._vehicle):
         isFit, reason = False, GUI_ITEM_ECONOMY_CODE.ITEM_IS_DUPLICATED
     elif isBought:
         isFit, reason = module.mayInstall(self._vehicle, self._slotIndex)
         if reason == 'already installed' or isFit:
             isFit, reason = True, GUI_ITEM_ECONOMY_CODE.UNDEFINED
     else:
         isFit, reason = module.mayPurchase(stats['money'])
         if not isFit:
             if GUI_ITEM_ECONOMY_CODE.isMoneyError(reason):
                 isFit = module.mayPurchaseWithExchange(stats['money'], stats['exchangeRate'])
     if isFit and reason != GUI_ITEM_ECONOMY_CODE.UNLOCK_ERROR:
         reason = _getInstallReason(module, self._vehicle, reason, self._slotIndex)
     moduleData = self._buildCommonModuleData(module, reason)
     moduleData.update({'targetVisible': isBought,
      'showPrice': not isBought,
      'isSelected': isInstalledInSlot,
      'disabled': not isFit or isInstalled and not isInstalledInSlot,
      'removeButtonLabel': MENU.MODULEFITS_REMOVENAME,
      'removeButtonTooltip': MENU.MODULEFITS_REMOVETOOLTIP,
      'itemPrices': getItemPricesVO(itemPrice)})
     return moduleData
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
Exemplo n.º 7
0
 def _populate(self):
     super(IconPriceDialog, self)._populate()
     self.as_setPriceLabelS(i18n.makeString(DIALOGS.REMOVECONFIRMATIONNOTREMOVABLEMONEY_MESSAGEPRICE))
     itemPrice = self._meta.getMessagePrice()
     pricesVO = getItemPricesVO(itemPrice)
     self.as_setMessagePriceS({'itemPrices': pricesVO,
      'actionPrice': self._meta.getAction()})
 def _makeVO(self,
             itemGroupDescription,
             isAlreadyPurchased,
             isFromInventory=False):
     imageIcon = ''
     userName = ''
     numItemsStr = ''
     price = None
     item = self.service.getItemByCD(itemGroupDescription.item.intCD)
     regionIdListVO = []
     if item is not None:
         imageIcon = item.icon
         userName = text_styles.main(item.userName)
         if not isAlreadyPurchased and not isFromInventory:
             numItemsStr = text_styles.main('{} x  '.format(
                 itemGroupDescription.numItems))
             price = getItemPricesVO(item.buyPrices.itemPrice)[0]
         else:
             numItemsStr = text_styles.main('{} '.format(
                 itemGroupDescription.numItems))
         regionIdListVO = [
             regionId._asdict()
             for regionId in itemGroupDescription.regionIdList
         ]
     return _DisplayedItemsVO(item.intCD, imageIcon, userName, numItemsStr,
                              item.isHistorical(), price,
                              isAlreadyPurchased, item.isWide(),
                              regionIdListVO)._asdict()
    def __onUpdateBoosters(self, *args):
        self.__updateActiveBoostersCount()
        criteria = REQ_CRITERIA.BOOSTER.IN_ACCOUNT | REQ_CRITERIA.BOOSTER.ENABLED
        boosters = self.goodiesCache.getBoosters(criteria=criteria).values()
        if boosters:
            dataProviderValues = []
            for booster in sorted(boosters, cmp=self.__sort):
                mainText = text_styles.main(
                    booster.getBonusDescription(
                        valueFormatter=text_styles.neutral))
                romanLvl = self._QUALITY_TO_LEVEL.get(booster.quality)
                vo = createStorageDefVO(
                    booster.boosterID,
                    mainText,
                    mainText,
                    booster.count,
                    getItemPricesVO(booster.getSellPrice())[0],
                    booster.getShopIcon(STORE_CONSTANTS.ICON_SIZE_SMALL),
                    booster.getShopIcon(),
                    'altimage',
                    enabled=booster.isReadyToActivate,
                    level=int2roman(romanLvl) if romanLvl is not None else '')
                dataProviderValues.append(vo)

            self._dataProvider.buildList(*dataProviderValues)
        else:
            self.as_showDummyScreenS(True)
        return
Exemplo n.º 10
0
 def __makeItemDataVO(itemData, isModified):
     item = itemData.item
     progressionLevel = item.getLatestOpenedProgressionLevel(
         g_currentVehicle.item)
     icon = item.icon if progressionLevel == -1 else item.iconByProgressionLevel(
         progressionLevel)
     name = text_styles.main(item.userName)
     if isModified and not itemData.isFromInventory:
         countLabel = text_styles.main('{} x '.format(len(
             itemData.slotsIds)))
         price = getItemPricesVO(item.buyPrices.itemPrice)[0]
     else:
         countLabel = text_styles.main('{} '.format(len(itemData.slotsIds)))
         price = None
     isApplied = not isModified
     itemDataVO = {
         'id': item.intCD,
         'icon': icon,
         'userName': name,
         'numItems': countLabel,
         'customizationDisplayType': item.customizationDisplayType(),
         'price': price,
         'isApplied': isApplied,
         'isWide': item.isWide(),
         'itemsList': itemData.slotsIds,
         'isDim': item.isDim()
     }
     return itemDataVO
def getItemVo(item):
    def getItemNationID(item):
        compatibleNations = []
        if item.itemTypeName == STORE_CONSTANTS.EQUIPMENT:
            item.descriptor.compatibleNations()
        return compatibleNations[0] if len(
            compatibleNations) == 1 else item.nationID

    priceVO = getItemPricesVO(item.getSellPrice())[0]
    itemNationID = getItemNationID(item)
    nationFlagIcon = RES_SHOP.getNationFlagIcon(
        nations.NAMES[itemNationID]
    ) if itemNationID != nations.NONE_INDEX else ''
    serverSettings = dependency.instance(ILobbyContext).getServerSettings()
    upgradable = item.itemTypeID == GUI_ITEM_TYPE.OPTIONALDEVICE and item.isUpgradable and serverSettings.isTrophyDevicesEnabled(
    )
    vo = createStorageDefVO(
        item.intCD,
        getStorageItemName(item),
        getStorageItemDescr(item),
        item.inventoryCount,
        priceVO,
        getStorageItemIcon(item, STORE_CONSTANTS.ICON_SIZE_SMALL),
        'altimage',
        itemType=item.getOverlayType(),
        nationFlagIcon=nationFlagIcon,
        enabled=item.isForSale,
        contextMenuId=_getContextMenuHandlerID(item),
        upgradable=upgradable,
        upgradeButtonTooltip=makeTooltip(body=backport.text(
            R.strings.storage.buttonUpgrade.tooltip.body())),
        extraParams=getItemExtraParams(item),
        specializations=getCategoriesIcons(item)
        if item.itemTypeID == GUI_ITEM_TYPE.OPTIONALDEVICE else ())
    return vo
 def __setTotalData(self, *_):
     cart = getTotalPurchaseInfo(self.__purchaseItems)
     totalPriceVO = getItemPricesVO(cart.totalPrice)
     state = g_currentVehicle.getViewState()
     inFormationAlert = ''
     if not state.isCustomizationEnabled():
         inFormationAlert = text_styles.concatStylesWithSpace(icons.markerBlocked(), text_styles.error(VEHICLE_CUSTOMIZATION.WINDOW_PURCHASE_FORMATION_ALERT))
     price = cart.totalPrice.price
     money = self.itemsCache.items.stats.money
     exchangeRate = self.itemsCache.items.shop.exchangeRate
     shortage = money.getShortage(price)
     if not shortage:
         self.__moneyState = _MoneyForPurchase.ENOUGH
     else:
         money = money - price + shortage
         price = shortage
         money = money.exchange(Currency.GOLD, Currency.CREDITS, exchangeRate, default=0)
         shortage = money.getShortage(price)
         if not shortage:
             self.__moneyState = _MoneyForPurchase.ENOUGH_WITH_EXCHANGE
         else:
             self.__moneyState = _MoneyForPurchase.NOT_ENOUGH
     validTransaction = self.__moneyState != _MoneyForPurchase.NOT_ENOUGH or Currency.GOLD in shortage.getCurrency() and isIngameShopEnabled()
     self.as_setTotalDataS({'totalLabel': text_styles.highTitle(_ms(VEHICLE_CUSTOMIZATION.WINDOW_PURCHASE_TOTALCOST, selected=cart.numSelected, total=cart.numApplying)),
      'enoughMoney': validTransaction,
      'inFormationAlert': inFormationAlert,
      'totalPrice': totalPriceVO[0]})
     self.__setBuyButtonState(validTransaction)
Exemplo n.º 13
0
 def __makeModulePurchaseVO(self, item, unlockProps, price):
     return {'title': _ms(BATTLE_RESULTS.COMMON_FITTING_PURCHASE),
      'description': text_styles.main(item.userName),
      'fittingType': item.itemTypeName,
      'lvlIcon': getLevelIconPath(item.level),
      'price': getItemPricesVO(ItemPrice(price=price, defPrice=price)),
      'linkEvent': PROGRESS_ACTION.PURCHASE_UNLOCK_TYPE,
      'linkId': unlockProps.parentID}
 def getVO(self):
     itemVO = super(_SeparateItemPurchaseDescription, self).getVO()
     itemVO.update({
         'compoundPrice': getItemPricesVO(self.compoundPrice)[0],
         'isFromStorage': self.isFromInventory,
         'selected': self.selected
     })
     return itemVO
Exemplo n.º 15
0
 def __getVO(self):
     self.__updateTradeVehicles()
     statusText, statusOk, tradeOffAvailable = self.__getStatus()
     return {'currentPrice': getItemPricesVO(self.__tradeIn.getTradeInPrice(self.__tradeInVehicle)),
      'selectedPrice': self.__getSelectedPrice(),
      'statusText': statusText,
      'statusOk': statusOk,
      'tradeOffAvailable': tradeOffAvailable}
Exemplo n.º 16
0
 def __makeVehiclePurchaseVO(self, item, unlockProps, price):
     return {'title': _ms(BATTLE_RESULTS.COMMON_VEHICLE_PURCHASE),
      'description': self.__makeVehicleDescription(item),
      'vehicleIcon': item.iconSmall,
      'lvlIcon': getLevelIconPath(item.level),
      'price': getItemPricesVO(ItemPrice(price=price, defPrice=price)),
      'linkEvent': PROGRESS_ACTION.PURCHASE_UNLOCK_TYPE,
      'linkId': unlockProps.parentID}
Exemplo n.º 17
0
    def _generateOptions(self, ctx=None):
        """ Generate a list of options for  the context menu.
        """
        item = self.itemsCache.items.getItemByCD(self._intCD)
        buyPriceVO = getItemPricesVO(item.getBuyPrice())
        sellPriceVO = getItemPricesVO(item.getSellPrice())
        inventoryCount = self._c11nView.getItemInventoryCount(item)
        availableForSale = inventoryCount > 0 and item.getSellPrice(
        ) != ITEM_PRICE_EMPTY and not item.isRentable and not item.isHidden
        style = self._c11nView.getModifiedStyle()
        removeFromTankEnabled = style.intCD == item.intCD if style is not None else False
        for outfit in (self._c11nView.getModifiedOutfit(season)
                       for season in SeasonType.COMMON_SEASONS):
            if outfit.has(item):
                removeFromTankEnabled = True
                break

        availableForPurchase = not item.isHidden and item.getBuyPrice(
        ) != ITEM_PRICE_EMPTY
        return [
            self._makeItem(
                CustomizationOptions.BUY,
                MENU.cst_item_ctx_menu(CustomizationOptions.BUY), {
                    'data': {
                        'price': first(buyPriceVO)
                    } if availableForPurchase else None,
                    'enabled': availableForPurchase
                }, None, 'CurrencyContextMenuItem'),
            self._makeSeparator(),
            self._makeItem(
                CustomizationOptions.SELL,
                MENU.cst_item_ctx_menu(CustomizationOptions.SELL), {
                    'data': {
                        'price': first(sellPriceVO)
                    } if availableForSale else None,
                    'enabled': availableForSale
                }, None, 'CurrencyContextMenuItem'),
            self._makeSeparator(),
            self._makeItem(
                CustomizationOptions.REMOVE_FROM_TANK,
                MENU.cst_item_ctx_menu(CustomizationOptions.REMOVE_FROM_TANK),
                {'enabled': removeFromTankEnabled})
        ]
Exemplo n.º 18
0
 def __setBuyingPanelData(self, *_):
     purchaseItems = self.getPurchaseItems()
     cartInfo = getTotalPurchaseInfo(purchaseItems)
     totalPriceVO = getItemPricesVO(cartInfo.totalPrice)
     cleanSettings = self._cleanSettings(self._currentSettings, checkSeasons=False)
     keys = []
     if cartInfo.numTotal:
         keys.append('install')
     if cartInfo.totalPrice != ITEM_PRICE_EMPTY:
         self.as_showBuyingPanelS()
     else:
         self.as_hideBuyingPanelS()
     if any(cleanSettings.itervalues()) or not keys:
         keys.append('apply')
     label = g_config.i18n['UI_flash_commit_' + '_and_'.join(keys)]
     isApplyEnabled = bool(cartInfo.numTotal) or any(cleanSettings.itervalues())
     shortage = self.itemsCache.items.stats.money.getShortage(cartInfo.totalPrice.price)
     self.as_setBottomPanelHeaderS({'buyBtnEnabled': isApplyEnabled,
                                    'buyBtnLabel': label,
                                    'enoughMoney': getItemPricesVO(ItemPrice(shortage, shortage))[0],
                                    'pricePanel': totalPriceVO[0]})
    def __setBottomPanelBillData(self, *_):
        purchaseItems = self.__ctx.getPurchaseItems()
        cartInfo = getTotalPurchaseInfo(purchaseItems)
        totalPriceVO = getItemPricesVO(cartInfo.totalPrice)
        if cartInfo.totalPrice != ITEM_PRICE_EMPTY:
            label = _ms(VEHICLE_CUSTOMIZATION.COMMIT_BUY)
        else:
            label = _ms(VEHICLE_CUSTOMIZATION.COMMIT_APPLY)
        tooltip = VEHICLE_CUSTOMIZATION.CUSTOMIZATION_BUYDISABLED_BODY
        fromStorageCount = 0
        toByeCount = 0
        for item in purchaseItems:
            if item.isFromInventory:
                fromStorageCount += 1
            if not item.isDismantling:
                toByeCount += 1

        if fromStorageCount > 0 or toByeCount > 0:
            self.__showBill()
        else:
            self.__hideBill()
            tooltip = VEHICLE_CUSTOMIZATION.CUSTOMIZATION_NOTSELECTEDITEMS
        fromStorageCount = text_styles.stats('({})'.format(fromStorageCount))
        toByeCount = text_styles.stats('({})'.format(toByeCount))
        outfitsModified = self.__ctx.isOutfitsModified()
        self.as_setBottomPanelPriceStateS({
            'buyBtnEnabled':
            outfitsModified,
            'buyBtnLabel':
            label,
            'buyBtnTooltip':
            tooltip,
            'isHistoric':
            self.__ctx.currentOutfit.isHistorical(),
            'billVO': {
                'title':
                text_styles.highlightText(
                    _ms(VEHICLE_CUSTOMIZATION.BUYPOPOVER_RESULT)),
                'priceLbl':
                text_styles.main('{} {}'.format(
                    _ms(VEHICLE_CUSTOMIZATION.BUYPOPOVER_PRICE), toByeCount)),
                'fromStorageLbl':
                text_styles.main('{} {}'.format(
                    _ms(VEHICLE_CUSTOMIZATION.BUYPOPOVER_FROMSTORAGE),
                    fromStorageCount)),
                'isEnoughStatuses':
                getMoneyVO(
                    Money(outfitsModified, outfitsModified, outfitsModified)),
                'pricePanel':
                totalPriceVO[0]
            }
        })
Exemplo n.º 20
0
    def __setBottomPanelBillData(self, *_):
        purchaseItems = self.__ctx.getPurchaseItems()
        cartInfo = getTotalPurchaseInfo(purchaseItems)
        totalPriceVO = getItemPricesVO(cartInfo.totalPrice)
        label = _ms(CUSTOMIZATION.COMMIT_APPLY)
        tooltip = CUSTOMIZATION.CUSTOMIZATION_NOTSELECTEDITEMS
        fromStorageCount = 0
        toBuyCount = 0
        for item in purchaseItems:
            if item.isFromInventory:
                fromStorageCount += 1
            if not item.isDismantling:
                toBuyCount += 1

        if cartInfo.totalPrice != ITEM_PRICE_EMPTY:
            label = _ms(CUSTOMIZATION.COMMIT_BUY)
        outfitsModified = self.__ctx.isOutfitsModified()
        fromStorageCount = text_styles.stats('({})'.format(fromStorageCount))
        toBuyCount = text_styles.stats('({})'.format(toBuyCount))
        self.as_setBottomPanelPriceStateS({
            'buyBtnEnabled':
            outfitsModified,
            'buyBtnLabel':
            label,
            'buyBtnTooltip':
            tooltip,
            'isHistoric':
            self.__ctx.currentOutfit.isHistorical(),
            'billVO': {
                'title':
                text_styles.highlightText(_ms(
                    CUSTOMIZATION.BUYPOPOVER_RESULT)),
                'priceLbl':
                text_styles.main('{} {}'.format(
                    _ms(CUSTOMIZATION.BUYPOPOVER_PRICE), toBuyCount)),
                'fromStorageLbl':
                text_styles.main('{} {}'.format(
                    _ms(CUSTOMIZATION.BUYPOPOVER_FROMSTORAGE),
                    fromStorageCount)),
                'isEnoughStatuses':
                getMoneyVO(Money(True, True, True)),
                'pricePanel':
                totalPriceVO[0]
            }
        })
        self.as_setItemsPopoverBtnEnabledS(
            any(i[1].isFilled() for i in self.__ctx.currentOutfit.itemsFull()))
        if outfitsModified:
            BigWorld.callback(0, self.__showBill)
        else:
            self.__hideBill()
    def __setBuyingPanelData(self, *_):
        purchaseItems = self.getPurchaseItems()
        cartInfo = getTotalPurchaseInfo(purchaseItems)
        totalPriceVO = getItemPricesVO(cartInfo.totalPrice)
        accountMoney = self.itemsCache.items.stats.money
        if cartInfo.totalPrice != ITEM_PRICE_EMPTY:
            label = _ms(VEHICLE_CUSTOMIZATION.COMMIT_BUY)
            self.as_showBuyingPanelS()
        else:
            label = _ms(VEHICLE_CUSTOMIZATION.COMMIT_APPLY)
            self.as_hideBuyingPanelS()
        isAtLeastOneOufitNotEmpty = False
        for season in SeasonType.COMMON_SEASONS:
            if not self._modifiedOutfits[season].isEmpty():
                isAtLeastOneOufitNotEmpty = True
                break

        isApplyEnabled = cartInfo.minPriceItem.isDefined() and cartInfo.minPriceItem <= accountMoney or cartInfo.isAtLeastOneItemFromInventory or cartInfo.isAtLeastOneItemDismantled or self._mode == C11nMode.CUSTOM and not self._originalOutfits[self._currentSeason].isInstalled() and isAtLeastOneOufitNotEmpty
        shortage = self.itemsCache.items.stats.money.getShortage(cartInfo.totalPrice.price)
        self.as_setBottomPanelHeaderS({'buyBtnEnabled': isApplyEnabled,
         'buyBtnLabel': label,
         'enoughMoney': getItemPricesVO(ItemPrice(shortage, shortage))[0],
         'pricePanel': totalPriceVO[0]})
 def _buildVehicle(self, item):
     vo = super(_RestoreVehiclesDataProvider, self)._buildVehicle(item)
     restoreCreditsPrice = item.restorePrice.credits
     restorePrice = ItemPrice(item.restorePrice, item.restorePrice)
     enoughCredits, _ = enoughCreditsForRestore(restoreCreditsPrice, self._itemsCache)
     restoreAvailable, timerText, description, timerIcon = getVehicleRestoreInfo(item)
     vo.update({'price': getItemPricesVO(restorePrice)[0],
      'isMoneyEnough': enoughCredits,
      'enabled': enoughCredits and restoreAvailable,
      'description': description,
      'timerText': timerText,
      'timerIcon': timerIcon,
      'contextMenuId': CONTEXT_MENU_HANDLER_TYPE.STORAGE_VEHICLES_RESTORE_ITEM})
     return vo
Exemplo n.º 23
0
    def buildList(self, purchaseItems):
        self.clear()
        elementGroups = {group:[] for group in PURCHASE_GROUPS}
        elementSets = {group:[] for group in PURCHASE_GROUPS}
        purchaseItemsCopy = self._purchaseItems[:]
        while purchaseItemsCopy:
            element = purchaseItemsCopy[0]
            if element.isDismantling:
                purchaseItemsCopy.pop(0)
                continue

            def filterItems(otherElement):
                correctType = otherElement.item.intCD == element.item.intCD
                correctSeason = otherElement.group == element.group
                correctAction = otherElement.isFromInventory == element.isFromInventory and otherElement.isDismantling == element.isDismantling
                return correctSeason and correctType and correctAction

            matchedItems = filter(filterItems, purchaseItemsCopy)
            for delItem in matchedItems:
                purchaseItemsCopy.remove(delItem)

            quantity = len(matchedItems)
            if quantity == 1:
                itemName = element.item.userName
            else:
                itemName = '{} x{}'.format(element.item.userName, quantity)
            priceItem = {'id': element.item.intCD,
             'selected': element.selected,
             'itemImg': buildCustomizationItemDataVO(element.item, None, True, False, False),
             'itemName': itemName,
             'titleMode': False,
             'compoundPrice': getItemPricesVO(element.price * quantity)[0],
             'isFromStorage': element.isFromInventory}
            group = element.group
            elementGroups[group].append(priceItem)
            elementSets[group].append(matchedItems)

        self._list = []
        self._purchaseItemSets = []
        for group in PURCHASE_GROUPS:
            items = elementGroups[group]
            sets = elementSets[group]
            if items:
                title = _CUSTOMIZATION_SEASON_TITLES[group]
                self._list.append({'titleMode': True,
                 'titleText': _ms(text_styles.middleTitle(title))})
                self._list.extend(items)
                self._purchaseItemSets.extend(sets)

        return
Exemplo n.º 24
0
 def __createVO(self, item):
     priceVO = getItemPricesVO(item.getSellPrice())[0]
     nationFlagIcon = RES_SHOP.getNationFlagIcon(nations.NAMES[
         item.nationID]) if item.nationID != nations.NONE_INDEX else ''
     return createStorageDefVO(
         item.intCD,
         getStorageItemName(item),
         getStorageItemDescr(item),
         item.inventoryCount,
         priceVO,
         getStorageItemIcon(item, STORE_CONSTANTS.ICON_SIZE_SMALL),
         'altimage',
         itemType=item.getOverlayType(),
         nationFlagIcon=nationFlagIcon,
         contextMenuId=CONTEXT_MENU_HANDLER_TYPE.STORAGE_FOR_SELL_ITEM)
 def __createVO(self, item):
     priceVO = getItemPricesVO(item.getSellPrice())[0]
     nationFlagIcon = RES_SHOP.getNationFlagIcon(nations.NAMES[
         item.nationID]) if item.nationID != nations.NONE_INDEX else ''
     return createStorageDefVO(item.intCD,
                               getStorageModuleName(item),
                               getStorageItemDescr(item),
                               item.inventoryCount,
                               priceVO,
                               getStorageItemIcon(
                                   item, STORE_CONSTANTS.ICON_SIZE_SMALL),
                               getStorageItemIcon(item),
                               'altimage',
                               itemType=getBoosterType(item),
                               nationFlagIcon=nationFlagIcon)
Exemplo n.º 26
0
 def _populate(self):
     super(CrewSkinsCompensationDialog, self)._populate()
     itemPrice = self.__meta.getMessagePrice()
     if itemPrice is not None:
         pricesVO = getItemPricesVO(itemPrice)
         self.as_setMessagePriceS({
             'itemPrices': pricesVO,
             'actionPrice': None
         })
         self.as_setPriceLabelS(
             i18n.makeString(self.__meta.getCompensationMessage()))
     itemsList = self.__meta.getItems()
     items = [self.__convertCrewSkinData(item) for item in itemsList]
     self.as_setListS(items)
     return
    def __setBottomPanelBillData(self, *_):
        purchaseItems = self.__ctx.getPurchaseItems()
        cartInfo = getTotalPurchaseInfo(purchaseItems)
        totalPriceVO = getItemPricesVO(cartInfo.totalPrice)
        if cartInfo.totalPrice != ITEM_PRICE_EMPTY:
            label = _ms(VEHICLE_CUSTOMIZATION.COMMIT_BUY)
        else:
            label = _ms(VEHICLE_CUSTOMIZATION.COMMIT_APPLY)
        money = self.itemsCache.items.stats.money
        exchangeRate = self.itemsCache.items.shop.exchangeRate
        moneyExchanged = money.exchange(Currency.GOLD, Currency.CREDITS, exchangeRate, default=0)
        minPriceItemAvailable = cartInfo.minPriceItem.isDefined() and (cartInfo.minPriceItem <= money or cartInfo.minPriceItem <= moneyExchanged)
        isApplyEnabled = (minPriceItemAvailable or not cartInfo.minPriceItem.isDefined()) and self.__ctx.isOutfitsModified()
        shortage = money.getShortage(cartInfo.totalPrice.price)
        fromStorageCount = 0
        toByeCount = 0
        for item in purchaseItems:
            if item.isFromInventory:
                fromStorageCount += 1
            if not item.isDismantling:
                toByeCount += 1

        if fromStorageCount > 0 or toByeCount > 0:
            self.__showBill()
        else:
            self.__hideBill()
        fromStorageCount = text_styles.stats('({})'.format(fromStorageCount))
        toByeCount = text_styles.stats('({})'.format(toByeCount))
        self.as_setBottomPanelPriceStateS({'buyBtnEnabled': isApplyEnabled,
         'buyBtnLabel': label,
         'isHistoric': self.__ctx.currentOutfit.isHistorical(),
         'billVO': {'title': text_styles.highlightText(_ms(VEHICLE_CUSTOMIZATION.BUYPOPOVER_RESULT)),
                    'priceLbl': text_styles.main('{} {}'.format(_ms(VEHICLE_CUSTOMIZATION.BUYPOPOVER_PRICE), toByeCount)),
                    'fromStorageLbl': text_styles.main('{} {}'.format(_ms(VEHICLE_CUSTOMIZATION.BUYPOPOVER_FROMSTORAGE), fromStorageCount)),
                    'enoughMoney': getItemPricesVO(ItemPrice(shortage, shortage))[0],
                    'pricePanel': totalPriceVO[0]}})
Exemplo n.º 28
0
 def _buildVehicle(self, item):
     vo = super(_RestoreVehiclesDataProvider, self)._buildVehicle(item)
     restoreCreditsPrice = item.restorePrice.credits
     restorePrice = ItemPrice(item.restorePrice, item.restorePrice)
     enoughCredits, _ = _enoughCreditsForRestore(restoreCreditsPrice,
                                                 self._itemsCache)
     restoreAvailable, timerText, description, timerIcon = _getVehicleRestoreInfo(
         item)
     vo.update({
         'price': getItemPricesVO(restorePrice)[0],
         'isMoneyEnough': enoughCredits,
         'enabled': enoughCredits and restoreAvailable,
         'description': description,
         'timerText': timerText,
         'timerIcon': timerIcon
     })
     return vo
Exemplo n.º 29
0
 def __getVO(self):
     statusText, statusOk, tradeOffAvailable, isFreeExchange = self.__getStatus(
     )
     return {
         'currentPrice':
         getItemPricesVO(
             self.__tradeIn.getTradeInPrice(self.__tradeInVehicleToBuy)),
         'selectedPrice':
         None if isFreeExchange else self.__getSelectedPrice(),
         'statusText':
         text_styles.greenText(statusText)
         if isFreeExchange else statusText,
         'statusOk':
         statusOk,
         'tradeOffAvailable':
         tradeOffAvailable
     }
Exemplo n.º 30
0
 def _getVO(self, item):
     priceVO = getItemPricesVO(item.getSellPrice())[0]
     itemNationID = self._getItemNationID(item)
     nationFlagIcon = RES_SHOP.getNationFlagIcon(
         nations.NAMES[itemNationID]
     ) if itemNationID != nations.NONE_INDEX else ''
     vo = storage_helpers.createStorageDefVO(
         item.intCD,
         storage_helpers.getStorageModuleName(item),
         storage_helpers.getStorageItemDescr(item),
         item.inventoryCount,
         priceVO,
         storage_helpers.getStorageItemIcon(item, SC.ICON_SIZE_SMALL),
         storage_helpers.getStorageItemIcon(item),
         'altimage',
         itemType=getBoosterType(item),
         nationFlagIcon=nationFlagIcon,
         enabled=item.itemTypeID != GUI_ITEM_TYPE.BATTLE_BOOSTER)
     return vo