Esempio n. 1
0
def __readProgressLevel(xmlCtx, section):
    level = {}
    for sectionName, subSections in section.items():
        if sectionName == 'price':
            level.update({
                'price': ix.readPrice(xmlCtx, section, 'price'),
                'notInShop': section.readBool('notInShop', False)
            })
        if sectionName == 'condition':
            conditions = level.setdefault('conditions', list())
            condition = {}
            for subSection in subSections.values():
                sectionName = subSection.name
                if sectionName == 'description':
                    condition.update({
                        'description':
                        ix.readNonEmptyString(xmlCtx, subSection, '')
                    })
                condition.update(
                    __readCondition((xmlCtx, subSection.name), subSection,
                                    [sectionName]))

            if not condition:
                ix.raiseWrongXml(xmlCtx, 'progression',
                                 "Customization don't have conditions")
            conditions.append(condition)

    return level
Esempio n. 2
0
 def typeShell(self, effectsIndex):
     if (self.data['attackerID'] == 0) or (self.data['attackReasonID']
                                           not in [0, 100]):
         self.data['costShell'] = 'do_not_know'
         self.data['shellKind'] = 'not_shell'
         return
     player = BigWorld.player()
     attacker = player.arena.vehicles.get(self.data['attackerID'])
     self.data['costShell'] = 'do_not_know'
     for shell in attacker['vehicleType'].gun['shots']:
         if effectsIndex == shell['shell']['effectsIndex']:
             self.data['shellKind'] = str(shell['shell']['kind']).lower()
             xmlPath = ITEM_DEFS_PATH + 'vehicles/' + nations.NAMES[
                 shell['shell']['id'][0]] + '/components/shells.xml'
             for name, subsection in ResMgr.openSection(xmlPath).items():
                 if name != 'icons':
                     xmlCtx = (None, xmlPath + '/' + name)
                     if _xml.readInt(xmlCtx, subsection, 'id', 0,
                                     65535) == shell['shell']['id'][1]:
                         price = _xml.readPrice(xmlCtx, subsection, 'price')
                         self.data['costShell'] = 'gold-shell' if price[
                             1] else 'silver-shell'
                         break
             ResMgr.purge(xmlPath, True)
             break
Esempio n. 3
0
 def typeShell(self, effectsIndex):
     self.data['costShell'] = 'unknown'
     self.data['shellKind'] = 'not_shell'
     if (self.data['attackerID'] == 0) or (self.data['attackReasonID'] != 0):
         return
     player = BigWorld.player()
     attacker = player.arena.vehicles.get(self.data['attackerID'])
     if (attacker is None) or not attacker['vehicleType']:
         self.data['shellKind'] = None
         self.data['caliber'] = None
         self.data['costShell'] = None
         return
     for shell in attacker['vehicleType'].gun['shots']:
         if effectsIndex == shell['shell']['effectsIndex']:
             self.data['shellKind'] = str(shell['shell']['kind']).lower()
             self.data['caliber'] = shell['shell']['caliber']
             xmlPath = ITEM_DEFS_PATH + 'vehicles/' + nations.NAMES[shell['shell']['id'][0]] + '/components/shells.xml'
             for name, subsection in ResMgr.openSection(xmlPath).items():
                 if name != 'icons':
                     xmlCtx = (None, xmlPath + '/' + name)
                     if _xml.readInt(xmlCtx, subsection, 'id', 0, 65535) == shell['shell']['id'][1]:
                         price = _xml.readPrice(xmlCtx, subsection, 'price')
                         self.data['costShell'] = 'gold-shell' if price[1] else 'silver-shell'
                         break
             ResMgr.purge(xmlPath, True)
             break
def _readPriceForItem(pricesDest, xmlCtx, section, compactDescr):
    if pricesDest is not None:
        pricesDest['itemPrices'][compactDescr] = _xml.readPrice(
            xmlCtx, section, 'price')
        if section.readBool('notInShop', False):
            pricesDest['notInShopItems'].add(compactDescr)
    return
Esempio n. 5
0
def load_shell_prices(nation):
    xml_path = ITEM_DEFS_PATH + 'vehicles/' + nation + '/components/shells.xml'
    section = ResMgr.openSection(xml_path)
    prices = {}
    for name, subsection in section.items():
        if name in ('icons', 'xmlns:xmlref'):
            continue
        xml_ctx = (None, xml_path + '/' + name)
        shell_id = _xml.readInt(xml_ctx, subsection, 'id', 0, 65535)
        prices[shell_id] = _xml.readPrice(xml_ctx, subsection, 'price')
    ResMgr.purge(xml_path, True)
    return prices
Esempio n. 6
0
            def getShellPrice(nationID, shellID):
                import ResMgr, nations
                from items import _xml, vehicles
                from constants import ITEM_DEFS_PATH

                price = {}
                xmlPath = ITEM_DEFS_PATH + 'vehicles/' + nations.NAMES[nationID] + '/components/shells.xml'
                for name, subsection in ResMgr.openSection(xmlPath).items():
                    if name != 'icons':
                        xmlCtx = (None, xmlPath + '/' + name)
                        if _xml.readInt(xmlCtx, subsection, 'id', 0, 65535) == shellID:
                            price = _xml.readPrice(xmlCtx, subsection, 'price')
                            break
                ResMgr.purge(xmlPath, True)

                return price
Esempio n. 7
0
            def getShellPrice(nationID, shellID):
                import ResMgr, nations
                from items import _xml, vehicles
                from constants import ITEM_DEFS_PATH

                price = {}
                xmlPath = ITEM_DEFS_PATH + 'vehicles/' + nations.NAMES[nationID] + '/components/shells.xml'
                for name, subsection in ResMgr.openSection(xmlPath).items():
                    if name != 'icons':
                        xmlCtx = (None, xmlPath + '/' + name)
                        if _xml.readInt(xmlCtx, subsection, 'id', 0, 65535) == shellID:
                            price = _xml.readPrice(xmlCtx, subsection, 'price')
                            break
                ResMgr.purge(xmlPath, True)

                return price
Esempio n. 8
0
    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': _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
Esempio n. 9
0
    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
Esempio n. 10
0
 def isGoldShell(n, s):
     if n != 'icons':
         xmlCtx = (None, xmlPath + '/' + n)
         price = 'gold' in _xml.readPrice(xmlCtx, s, 'price')
         return _xml.readInt(xmlCtx, s, 'id', 0, 65535) if price else None