Пример #1
0
 def __init__(self, intCompactDescr, proxy=None, isBoughtForAltPrice=False):
     """
     Ctr.
     
     :param intCompactDescr: item's int compact descriptor
     :param proxy: instance of ItemsRequester
     :param isBoughtForAltPrice: indicates whether the item has been bought for credits(alt price)
     """
     GUIItem.__init__(self, proxy)
     HasIntCD.__init__(self, intCompactDescr)
     self._isBoughtForAltPrice = isBoughtForAltPrice
     self._rentInfo = RentalInfoProvider()
     self._restoreInfo = None
     self._personalDiscountPrice = None
     if proxy is not None and proxy.inventory.isSynced(
     ) and proxy.stats.isSynced() and proxy.shop.isSynced():
         self._mayConsumeWalletResources = proxy.stats.mayConsumeWalletResources
         defaultPrice = proxy.shop.defaults.getItemPrice(self.intCD)
         if defaultPrice is None:
             defaultPrice = MONEY_UNDEFINED
         buyPrice, self._isHidden = proxy.shop.getItem(self.intCD)
         if buyPrice is None:
             buyPrice = MONEY_UNDEFINED
         altPrice = self._getAltPrice(buyPrice, proxy.shop)
         defaultAltPrice = self._getAltPrice(defaultPrice,
                                             proxy.shop.defaults)
         self._buyPrices = ItemPrices(
             itemPrice=ItemPrice(price=buyPrice, defPrice=defaultPrice),
             itemAltPrice=ItemPrice(price=altPrice,
                                    defPrice=defaultAltPrice))
         defaultSellPrice = Money.makeFromMoneyTuple(
             BigWorld.player().shop.getSellPrice(
                 defaultPrice,
                 proxy.shop.defaults.sellPriceModifiers(intCompactDescr),
                 self.itemTypeID))
         sellPrice = Money.makeFromMoneyTuple(
             BigWorld.player().shop.getSellPrice(
                 buyPrice, proxy.shop.sellPriceModifiers(intCompactDescr),
                 self.itemTypeID))
         self._sellPrices = ItemPrices(itemPrice=ItemPrice(
             price=sellPrice, defPrice=defaultSellPrice),
                                       itemAltPrice=ITEM_PRICE_EMPTY)
         self._inventoryCount = proxy.inventory.getItems(
             self.itemTypeID, self.intCD)
         if self._inventoryCount is None:
             self._inventoryCount = 0
         self._isUnlocked = self.intCD in proxy.stats.unlocks
         self._isInitiallyUnlocked = self.intCD in proxy.stats.initialUnlocks
         self._fullyConfigured = True
     else:
         self._buyPrices = ITEM_PRICES_EMPTY
         self._sellPrices = ITEM_PRICES_EMPTY
         self._isHidden = False
         self._inventoryCount = 0
         self._isUnlocked = False
         self._mayConsumeWalletResources = False
         self._isInitiallyUnlocked = False
         self._fullyConfigured = False
     return
 def __init__(self,
              intCompactDescr,
              proxy=None,
              isBoughtForAltPrice=False,
              strCD=None):
     super(FittingItem, self).__init__(intCD=HasIntCD(intCompactDescr),
                                       strCD=strCD)
     self._isBoughtForAltPrice = isBoughtForAltPrice
     self._rentInfo = RentalInfoProvider(None, None, None, None, None, None)
     self._restoreInfo = None
     self._personalDiscountPrice = None
     self._descriptor = self._getDescriptor()
     if proxy is not None and proxy.inventory.isSynced(
     ) and proxy.stats.isSynced() and proxy.shop.isSynced():
         self._mayConsumeWalletResources = proxy.stats.mayConsumeWalletResources
         defaultPrice = proxy.shop.defaults.getItemPrice(self.intCD)
         if defaultPrice is None:
             defaultPrice = MONEY_UNDEFINED
         buyPrice, self._isHidden = proxy.shop.getItem(self.intCD)
         if buyPrice is None:
             buyPrice = MONEY_UNDEFINED
         altPrice = self._getAltPrice(buyPrice, proxy.shop)
         defaultAltPrice = self._getAltPrice(defaultPrice,
                                             proxy.shop.defaults)
         self._buyPrices = ItemPrices(
             itemPrice=ItemPrice(price=buyPrice, defPrice=defaultPrice),
             itemAltPrice=ItemPrice(price=altPrice,
                                    defPrice=defaultAltPrice))
         defaultSellPrice = Money.makeFromMoneyTuple(
             BigWorld.player().shop.getSellPrice(
                 defaultPrice,
                 proxy.shop.defaults.sellPriceModifiers(intCompactDescr),
                 self.itemTypeID))
         sellPrice = Money.makeFromMoneyTuple(
             BigWorld.player().shop.getSellPrice(
                 buyPrice, proxy.shop.sellPriceModifiers(intCompactDescr),
                 self.itemTypeID))
         self._sellPrices = ItemPrices(itemPrice=ItemPrice(
             price=sellPrice, defPrice=defaultSellPrice),
                                       itemAltPrice=ITEM_PRICE_EMPTY)
         self._inventoryCount = proxy.inventory.getItems(
             self.itemTypeID, self.intCD)
         if self._inventoryCount is None:
             self._inventoryCount = 0
         self._isUnlocked = self.intCD in proxy.stats.unlocks
         self._isInitiallyUnlocked = self.intCD in proxy.stats.initialUnlocks
         self._fullyConfigured = True
     else:
         self._buyPrices = ITEM_PRICES_EMPTY
         self._sellPrices = ITEM_PRICES_EMPTY
         self._isHidden = False
         self._inventoryCount = 0
         self._isUnlocked = False
         self._mayConsumeWalletResources = False
         self._isInitiallyUnlocked = False
         self._fullyConfigured = False
     return
Пример #3
0
    def __cmp__(self, other):
        if other is None:
            return 1
        else:
            res = HasIntCD.__cmp__(self, other)
            if res:
                return res
            res = self._sortByType(other)
            if res:
                return res
            res = self.level - other.level
            if res:
                return res
            buyMaxValues = self.buyPrices.getMaxValuesAsMoney()
            otherMaxValues = other.buyPrices.getMaxValuesAsMoney()
            for currency in Currency.BY_WEIGHT:
                res = buyMaxValues.get(currency, 0) - otherMaxValues.get(currency, 0)
                if res:
                    return res

            return cmp(self.userName, other.userName)