def getItemsIterator(data, nationID=None, itemTypeID=None): if 'itemPrices' in data: prices = data['itemPrices'] else: prices = ItemsPrices() getters = _MODULES_GETTERS if itemTypeID is None: itemTypeIDs = getters.iterkeys() elif itemTypeID in getters: itemTypeIDs = (itemTypeID, ) else: raise SoftException('itemTypeID is invalid: {}'.format(itemTypeID)) if nationID is None: nationIDs = nations.INDICES.itervalues() else: nationIDs = (nationID, ) for nextID in nationIDs: for typeID in itemTypeIDs: getter = getters[typeID] for item in getter(nextID): intCD = item.compactDescr if intCD in prices: yield intCD return
def __readTiles(self): xmlPath = _POTAPOV_QUEST_XML_PATH + '/tiles.xml' section = ResMgr.openSection(xmlPath) if section is None: _xml.raiseWrongXml(None, xmlPath, 'can not open or read') self.__tilesInfo = idToTile = {} ids = {} for tname, tsection in section.items(): if tname == 'quests': continue ctx = (None, xmlPath) if tname in ids: _xml.raiseWrongXml(ctx, '', 'tile name is not unique') seasonID = _xml.readInt(ctx, tsection, 'seasonID') g_seasonCache.getSeasonInfo(seasonID) tileID = _xml.readInt(ctx, tsection, 'id', 0, 15) if tileID in idToTile: _xml.raiseWrongXml(ctx, 'id', 'is not unique') chainsCount = _xml.readInt(ctx, tsection, 'chainsCount', 1, 15) chainsCountToUnlockNext = _xml.readInt(ctx, tsection, 'chainsCountToUnlockNext', 0, 15) nextTileID = _xml.readInt(ctx, tsection, 'nextTileID', 0, 15) achievements = {} basicInfo = {'name': tname, 'chainsCount': chainsCount, 'nextTileID': nextTileID, 'chainsCountToUnlockNext': chainsCountToUnlockNext, 'questsInChain': _xml.readInt(ctx, tsection, 'questsInChain', 1, 100), 'price': ItemsPrices._tuplePrice(_xml.readPrice(ctx, tsection, 'price')), 'achievements': achievements, 'seasonID': seasonID, 'tokens': set(_xml.readString(ctx, tsection, 'tokens').split())} if tsection.has_key('achievements'): for aname, asection in tsection['achievements'].items(): _, aid = aname.split('_') achievements[int(aid)] = asection.asString if len(achievements) < basicInfo['chainsCount']: _xml.raiseWrongXml(ctx, 'achievements', 'wrong achievement number') if IS_CLIENT or IS_WEB: basicInfo['userString'] = i18n.makeString(tsection.readString('userString')) basicInfo['description'] = i18n.makeString(tsection.readString('description')) basicInfo['iconID'] = i18n.makeString(tsection.readString('iconID')) ids[tname] = tileID idToTile[tileID] = basicInfo return
def getPrices(self): try: return self.getItemsData()['itemPrices'] except KeyError: return ItemsPrices()
def getPrices(self): return self.getItemsData().get('itemPrices', ItemsPrices())
def getPrices(self): return self.data.get('itemPrices', ItemsPrices())