def __init__(self, strCompactDescr, inventoryID=-1, vehicle=None, dismissedAt=None, proxy=None):
     GUIItem.__init__(self, proxy)
     HasStrCD.__init__(self, strCompactDescr)
     self.__descriptor = None
     self._invID = inventoryID
     self._nationID = self.descriptor.nationID
     self._itemTypeID = GUI_ITEM_TYPE.TANKMAN
     self._itemTypeName = ITEM_TYPE_NAMES[self.itemTypeID]
     self._combinedRoles = (self.descriptor.role,)
     self._dismissedAt = dismissedAt
     self._isDismissed = self.dismissedAt is not None
     self._areClassesCompatible = False
     self._vehicleNativeDescr = vehicles.VehicleDescr(typeID=(self.nationID, self.descriptor.vehicleTypeID))
     self._vehicleInvID = -1
     self._vehicleDescr = None
     self._vehicleBonuses = dict()
     self._vehicleSlotIdx = -1
     if vehicle is not None:
         self._vehicleInvID = vehicle.invID
         self._vehicleDescr = vehicle.descriptor
         self._vehicleBonuses = dict(vehicle.bonuses)
         self._vehicleSlotIdx = vehicle.crewIndices.get(inventoryID, -1)
         crewRoles = self.vehicleDescr.type.crewRoles
         if -1 < self.vehicleSlotIdx < len(crewRoles):
             self._combinedRoles = crewRoles[self.vehicleSlotIdx]
         self._areClassesCompatible = bool(VEHICLE_CLASS_TAGS & self.vehicleDescr.type.tags & self.vehicleNativeDescr.type.tags)
     self._skills = self._buildSkills(proxy)
     self._skillsMap = self._buildSkillsMap()
     self.__cmp__ = TankmenComparator()
     return
Esempio n. 2
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