def getItems(self, itemTypeID=None, criteria=REQ_CRITERIA.EMPTY, nationID=None): result = ItemsCollection() if not isinstance(itemTypeID, tuple): itemTypeID = (itemTypeID, ) for typeID in itemTypeID: if typeID == GUI_ITEM_TYPE.VEHICLE and nationID is None and criteria.lookInInventory( ): vehGetter = self.getVehicle for vehInvID in (self.inventory.getItems(GUI_ITEM_TYPE.VEHICLE) or {}).iterkeys(): item = vehGetter(vehInvID) if criteria(item): result[item.intCD] = item itemGetter = self.getItemByCD protector = criteria.getIntCDProtector() if protector is not None and protector.isUnlinked(): return result for intCD in vehicle_items_getter.getItemsIterator( self.__shop.getItemsData(), nationID=nationID, itemTypeID=typeID): if protector is not None and protector.isTriggered(intCD): continue item = itemGetter(intCD) if criteria(item): result[intCD] = item return result
def _filterItem(self, item, nation=None, role=None, isInTank=None): if role is not None and item.descriptor.role != role: return False elif isInTank is not None and item.isInTank != isInTank: return False else: return ItemsCollection._filterItem(self, item, nation)
def getItems(self, itemTypeID=None, criteria=REQ_CRITERIA.EMPTY, nationID=None): shopParser = ShopDataParser(self.__shop.getItemsData()) result = ItemsCollection() if not isinstance(itemTypeID, tuple): itemTypeID = (itemTypeID, ) for typeID in itemTypeID: if typeID == GUI_ITEM_TYPE.VEHICLE and nationID is None and criteria.lookInInventory( ): vehGetter = self.getVehicle for vehInvID in (self.inventory.getItems(GUI_ITEM_TYPE.VEHICLE) or {}).iterkeys(): item = vehGetter(vehInvID) if criteria(item): result[item.intCD] = item else: itemGetter = self.getItemByCD for intCD, _, _, _ in shopParser.getItemsIterator( nationID=nationID, itemTypeID=typeID): item = itemGetter(intCD) if criteria(item): result[intCD] = item return result
def getItemsEx(self, itemTypeIDs, criteria=REQ_CRITERIA.EMPTY, nationID=None): shopParser = ShopDataParser(self.__shop.getItemsData()) result = ItemsCollection() if GUI_ITEM_TYPE.VEHICLE in itemTypeIDs and nationID is None and criteria.lookInInventory( ): vehGetter = self.getVehicle for vehInvID in (self.inventory.getItems(GUI_ITEM_TYPE.VEHICLE) or {}).iterkeys(): item = vehGetter(vehInvID) if criteria(item): result[item.intCD] = item itemTypeIDs.remove(GUI_ITEM_TYPE.VEHICLE) if not itemTypeIDs: return result else: itemGetter = self.getItemByCD protector = criteria.getIntCDProtector() if protector is not None and protector.isUnlinked(): return result for intCD in shopParser.getItemsIterator(nationID=nationID, itemTypeID=itemTypeIDs): if protector is not None and protector.isTriggered(intCD): continue item = itemGetter(intCD) if criteria(item): result[intCD] = item return result
def getBadges(self, criteria=REQ_CRITERIA.EMPTY): result = ItemsCollection() for badgeID, badgeData in self.__badges.available.iteritems(): item = self.itemsFactory.createBadge(badgeData, proxy=self) if criteria(item): result[badgeID] = item return result
def getVehicles(self, criteria=None): result = ItemsCollection() if self.__vehicles: for invID, vehicleType in enumerate(self.__vehicles): vehicle = self.itemsFactory.createVehicle(typeCompDescr=vehicleType.intCD, inventoryID=invID) result[vehicle.intCD] = vehicle return result
def getTankmen(self, criteria=REQ_CRITERIA.EMPTY): result = ItemsCollection() tmanInvData = self.inventory.getItemsData(GUI_ITEM_TYPE.TANKMAN) for invID, invData in tmanInvData.iteritems(): item = self.__makeTankman(invID, invData) if criteria(item): result[invID] = item return result
def getItems(self, itemTypeID=None, criteria=REQ_CRITERIA.EMPTY): from gui.shared.utils.requesters import ShopDataParser shopParser = ShopDataParser(self.shop.getItemsData()) result = ItemsCollection() for intCD, _, _, _ in shopParser.getItemsIterator( itemTypeID=itemTypeID): item = self.getItemByCD(intCD) if criteria(item): result[intCD] = item return result
def getItems(self, itemTypeID = None, criteria = REQ_CRITERIA.EMPTY, nationID = None): shopParser = ShopDataParser(self.shop.getItemsData()) result = ItemsCollection() if not isinstance(itemTypeID, tuple): itemTypeID = (itemTypeID,) for typeID in itemTypeID: for intCD, _, _, _ in shopParser.getItemsIterator(nationID=nationID, itemTypeID=typeID): item = self.getItemByCD(intCD) if criteria(item): result[intCD] = item return result
def getBadges(self, criteria=REQ_CRITERIA.EMPTY): """ Returns badges items collection. Unfortunately, no caching is available due to specific storing system. :return: ItemsCollection with badges """ result = ItemsCollection() for badgeID, badgeData in self.__badges.available.iteritems(): item = self.itemsFactory.createBadge(badgeData, proxy=self) if criteria(item): result[badgeID] = item return result
def _filterItem(self, item, nation = None, role = None, isInTank = None): """ Overriden method to filter collection items. @param item: item to check fo filtering @param nation: nation id to filter @param role: tankman role to filter @param isInTank: only tankmen in vehicles @return: is item match given conditions <bool> """ if role is not None and item.descriptor.role != role: return False if isInTank is not None and item.isInTank != isInTank: return False return ItemsCollection._filterItem(self, item, nation)
def _filterItem(self, item, nation=None, role=None, isInTank=None): """ Overriden method to filter collection items. @param item: item to check fo filtering @param nation: nation id to filter @param role: tankman role to filter @param isInTank: only tankmen in vehicles @return: is item match given conditions <bool> """ if role is not None and item.descriptor.role != role: return False elif isInTank is not None and item.isInTank != isInTank: return False else: return ItemsCollection._filterItem(self, item, nation)
def getTankmen(self, criteria=REQ_CRITERIA.TANKMAN.ACTIVE): result = ItemsCollection() activeTankmenInvData = self.__inventory.getItemsData(GUI_ITEM_TYPE.TANKMAN) for invID, tankmanInvData in activeTankmenInvData.iteritems(): item = self.__makeTankman(invID, tankmanInvData) if criteria(item): result[invID] = item duration = self.__shop.tankmenRestoreConfig.billableDuration dismissedTankmenData = self.__recycleBin.getTankmen(duration) for invID, tankmanData in dismissedTankmenData.iteritems(): item = self.__makeDismissedTankman(invID, tankmanData) if criteria(item): result[invID] = item return result