예제 #1
0
def getItemPricesViewModel(statsMoney, *itemPrices, **kwargs):
    result = []
    for itemPrice in itemPrices:
        priceModels = []
        if itemPrice.isDefined():
            for currency in Currency.ALL:
                currencyValue = itemPrice.price.get(currency)
                if currencyValue is not None:
                    actionPriceModel = ActionPriceModel()
                    isEnough = statsMoney.get(currency) >= currencyValue
                    if not isEnough and 'exchangeRate' in kwargs and currency == Currency.CREDITS:
                        isEnough = canBuyWithGoldExchange(itemPrice.price, statsMoney, kwargs.get('exchangeRate'))
                    actionPriceModel.setIsEnough(isEnough)
                    currencyAction = itemPrice.getActionPrcAsMoney().get(currency)
                    hasAction = currencyAction is not None
                    if hasAction:
                        updateActionInViewModel(currency, actionPriceModel, itemPrice)
                    actionPriceModel.setType(currency)
                    actionPriceModel.setIsWithAction(hasAction)
                    actionPriceModel.setPrice(backport.getIntegralFormat(currencyValue))
                    defPrice = backport.getIntegralFormat(itemPrice.defPrice.get(currency, 0))
                    actionPriceModel.setDefPrice(defPrice)
                    if 'isBootcamp' in kwargs:
                        actionPriceModel.setIsBootcamp(kwargs.get('isBootcamp'))
                    priceModels.append(actionPriceModel)

        else:
            actionPriceModel = ActionPriceModel()
            actionPriceModel.setIsFree(True)
            priceModels.append(actionPriceModel)
        if priceModels:
            result.append(priceModels)

    return result
 def update(self):
     super(PriceBottomContent, self).update()
     with self._viewModel.transaction() as model:
         price = model.getPrice()
         defPrice = model.getDefPrice()
         price.clear()
         defPrice.clear()
         if self.__price:
             BuyPriceModelBuilder.fillPriceModel(priceModel=model, price=self.__price, defPrice=self.__defPrice)
         isEnabled = not self.__price.isDefined() or canBuyWithGoldExchange(self.__price, self.__itemsCache.items.stats.money, self.__itemsCache.items.shop.exchangeRate)
         model.setIsDisabled(not isEnabled)
예제 #3
0
 def _needExchange(self):
     canBuy = canBuyWithGoldExchange(
         self.__price, self._stats.money,
         self._itemsCache.items.shop.exchangeRate)
     return canBuy and self._needItemsForExchange() > 0
예제 #4
0
 def _updateDisabled(cls, prices, dealPanelModel):
     buyMoney = prices[cls._MONEY]
     isEnabled = not buyMoney.isDefined() or canBuyWithGoldExchange(
         buyMoney, cls._itemsCache.items.stats.money,
         cls._itemsCache.items.shop.exchangeRate)
     dealPanelModel.setIsDisabled(not isEnabled)
 def _needExchange(self):
     canBuy = canBuyWithGoldExchange(
         self.__price, self._stats.money,
         self._itemsCache.items.shop.exchangeRate)
     return canBuy and self._needMoney().get(Currency.CREDITS,
                                             default=0) > 0