def _readConfig(self, xmlCtx, section): self.delay = _xml.readPositiveFloat(xmlCtx, section, 'delay') self.modelName = _xml.readString(xmlCtx, section, 'modelName') self.soundEvent = _xml.readString(xmlCtx, section, 'soundEvent') self.speed = _xml.readInt(xmlCtx, section, 'speed') self.heights = _xml.readTupleOfPositiveInts(xmlCtx, section, 'heights', 2) self.areaLength = _xml.readPositiveFloat(xmlCtx, section, 'areaLength') self.areaWidth = _xml.readPositiveFloat(xmlCtx, section, 'areaWidth') self.antepositions = _xml.readTupleOfFloats(xmlCtx, section, 'antepositions') self.lateropositions = _xml.readTupleOfFloats(xmlCtx, section, 'lateropositions') self.bombingMask = tuple((bool(v) for v in _xml.readTupleOfInts(xmlCtx, section, 'bombingMask'))) if not len(self.antepositions) == len(self.lateropositions) == len(self.bombingMask): _xml.raiseWrongSection(xmlCtx, 'bombers number mismatch') self.waveFraction = _xml.readPositiveFloat(xmlCtx, section, 'waveFraction') self.bombsNumber = _xml.readNonNegativeInt(xmlCtx, section, 'bombsNumber') self.shellCompactDescr = _xml.readInt(xmlCtx, section, 'shellCompactDescr') self.tracerKind = _xml.readInt(xmlCtx, section, 'tracerKind') self.piercingPower = _xml.readTupleOfPositiveInts(xmlCtx, section, 'piercingPower', 2) self.gravity = _xml.readPositiveFloat(xmlCtx, section, 'gravity') self.areaVisual = _xml.readStringOrNone(xmlCtx, section, 'areaVisual') self.areaColor = _xml.readIntOrNone(xmlCtx, section, 'areaColor') self.areaMarker = _xml.readStringOrNone(xmlCtx, section, 'areaMarker') self.reusable = _xml.readBool(xmlCtx, section, 'reusable') self.cooldownTime = _xml.readNonNegativeFloat(xmlCtx, section, 'cooldownTime') if self.reusable else 0.0 self.deployTime = _xml.readNonNegativeFloat(xmlCtx, section, 'deployTime')
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 __readSharedMetrics(self, shared, xmlCtx, section): precessed = _xml.getChildren(xmlCtx, section, 'grids') for name, gridSection in precessed: gridName = gridSection.asString xPath = '{0:>s}/{1:>s}/{2:>s}'.format(TREE_SHARED_REL_FILE_PATH, name, gridName) gridCtx = (None, xPath) subSec = _xml.getSubsection(xmlCtx, gridSection, 'root') xmlCtx = (None, '{0:>s}/root'.format(xPath)) rootPos = {'start': _xml.readVector2(xmlCtx, subSec, 'start').tuple(), 'step': _xml.readInt(xmlCtx, subSec, 'step')} subSec = _xml.getSubsection(gridCtx, gridSection, 'vertical') xmlCtx = (None, '{0:>s}/vertical'.format(xPath)) vertical = (_xml.readInt(xmlCtx, subSec, 'start'), _xml.readInt(xmlCtx, subSec, 'step')) subSec = _xml.getSubsection(gridCtx, gridSection, 'horizontal') xmlCtx = (None, '{0:>s}/horizontal'.format(xPath)) horizontal = (_xml.readInt(xmlCtx, subSec, 'start'), _xml.readInt(xmlCtx, subSec, 'step')) shared['grids'][gridName] = {'root': rootPos, 'vertical': vertical, 'horizontal': horizontal} precessed = _xml.getChildren(xmlCtx, section, 'lines') lines = shared['lines'] for name, sub in precessed: xPath = '{0:>s}/{1:>s}'.format(TREE_SHARED_REL_FILE_PATH, name) xmlCtx = (None, xPath) pinsSec = _xml.getChildren(xmlCtx, sub, 'inPin') inPins = dict(((pName, pSec.asVector2.tuple()) for pName, pSec in pinsSec)) pinsSec = _xml.getChildren(xmlCtx, sub, 'outPin') outPins = dict(((pName, pSec.asVector2.tuple()) for pName, pSec in pinsSec)) pinsSec = _xml.getChildren(xmlCtx, sub, 'viaPin') viaPins = defaultdict(dict) for outPin, setSec in pinsSec: for inPin, pSec in setSec.items(): viaPins[outPin][inPin] = map(lambda section: section[1].asVector2.tuple(), pSec.items()) defSec = sub['default'] default = {} if defSec is not None: xmlCtx = (None, '{0:>s}/default'.format(xPath)) default = {'outPin': _xml.readString(xmlCtx, defSec, 'outPin'), 'inPin': _xml.readString(xmlCtx, defSec, 'inPin')} lines[name] = {'inPins': inPins, 'outPins': outPins, 'viaPins': viaPins, 'default': default} return
def shell(self): xmlPath = '' for nation in nations.NAMES: xmlPath = '%s%s%s%s' % (ITEM_DEFS_PATH, 'vehicles/', nation, '/components/shells.xml') xmlCtx_s = (((None, '{}/{}'.format(xmlPath, n)), s) for n, s in ResMgr.openSection(xmlPath).items() if (n != 'icons') and (n != 'xmlns:xmlref')) id_xmlCtx_s = ((_xml.readInt(xmlCtx, s, 'id', 0, 65535), xmlCtx, s) for xmlCtx, s in xmlCtx_s) self.shells[nation] = [i for i, xmlCtx, s in id_xmlCtx_s if s.readBool('improved', False)] ResMgr.purge(xmlPath, True)
def _readTankmanLevelTriggerSection(xmlCtx, section, _, triggerID): role = _xml.readString(xmlCtx, section, 'role') roleLevel = _xml.readInt(xmlCtx, section, 'role-level') inVehicleFlagID = _xml.readString(xmlCtx, section, 'in-vehicle') specVehicleFlagID = section.readString('spec-vehicle') if not len(specVehicleFlagID): specVehicleFlagID = None setVarID = section.readString('set-var') if not len(setVarID): setVarID = None return triggers.TankmanLevelTrigger(triggerID, role, roleLevel, setVarID, inVehicleFlagID, specVehicleFlagID)
def __readBasicConfig(self, xmlCtx, section): self.itemTypeName = 'optionalDevice' self.name = section.name self.id = (nations.NONE_INDEX, _xml.readInt(xmlCtx, section, 'id', 0, 65535)) self.compactDescr = vehicles.makeIntCompactDescrByID('optionalDevice', *self.id) if IS_CLIENT or IS_WEB: self.userString = i18n.makeString(section.readString('userString')) self.description = i18n.makeString(section.readString('description')) self.icon = _xml.readIcon(xmlCtx, section, 'icon') if IS_CELLAPP or not section.has_key('vehicleFilter'): self.__filter = None else: self.__filter = _VehicleFilter((xmlCtx, 'vehicleFilter'), section['vehicleFilter']) self.removable = section.readBool('removable', False)
def _readConfig(self, xmlCtx, section): self.delay = _xml.readPositiveFloat(xmlCtx, section, 'delay') self.duration = _xml.readPositiveFloat(xmlCtx, section, 'duration') self.shotsNumber = _xml.readNonNegativeInt(xmlCtx, section, 'shotsNumber') self.areaRadius = _xml.readPositiveFloat(xmlCtx, section, 'areaRadius') self.shellCompactDescr = _xml.readInt(xmlCtx, section, 'shellCompactDescr') self.piercingPower = _xml.readTupleOfPositiveInts(xmlCtx, section, 'piercingPower', 2) self.areaVisual = _xml.readStringOrNone(xmlCtx, section, 'areaVisual') self.areaColor = _xml.readIntOrNone(xmlCtx, section, 'areaColor') self.areaMarker = _xml.readStringOrNone(xmlCtx, section, 'areaMarker') self.areaLength = self.areaWidth = self.areaRadius * 2 self.reusable = _xml.readBool(xmlCtx, section, 'reusable') self.cooldownTime = _xml.readNonNegativeFloat(xmlCtx, section, 'cooldownTime') if self.reusable else 0.0 self.deployTime = _xml.readNonNegativeFloat(xmlCtx, section, 'deployTime')
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
def onEnterWorld(self, vehicle): self.player = BigWorld.player() self.playerVehicleID = self.player.playerVehicleID self.ammo = self.guiSessionProvider.shared.ammo shots = vehicle.typeDescriptor.gun.shots nation = nations.NAMES[vehicle.typeDescriptor.type.id[0]] xmlPath = '%s%s%s%s' % (ITEM_DEFS_PATH, 'vehicles/', nation, '/components/shells.xml') xmlCtx_s = (((None, '{}/{}'.format(xmlPath, n)), s) for n, s in ResMgr.openSection(xmlPath).items() if (n != 'icons') and (n != 'xmlns:xmlref')) goldShells = [_xml.readInt(xmlCtx, s, 'id', 0, 65535) for xmlCtx, s in xmlCtx_s if s.readBool('improved', False)] for shot in shots: shell = shot.shell intCD = shell.compactDescr self.shells[intCD] = {} self.shells[intCD]['shellKind'] = shell.kind.lower() self.shells[intCD]['shellDamage'] = shell.damage[0] self.shells[intCD]['costShell'] = 'gold-shell' if shell.id[1] in goldShells else 'silver-shell' ResMgr.purge(xmlPath, True)
def __readSeasons(self): xmlPath = _POTAPOV_QUEST_XML_PATH + '/seasons.xml' section = ResMgr.openSection(xmlPath) if section is None: _xml.raiseWrongXml(None, xmlPath, 'can not open or read') self.__seasonsInfo = idToSeason = {} ids = {} for (sname, ssection,) in section.items(): ctx = (None, xmlPath) if sname in ids: _xml.raiseWrongXml(ctx, '', 'season name is not unique') seasonID = _xml.readInt(ctx, ssection, 'id', 0, 15) if seasonID in idToSeason: _xml.raiseWrongXml(ctx, 'id', 'is not unique') basicInfo = {'name': sname} if IS_CLIENT or IS_WEB: basicInfo['userString'] = i18n.makeString(ssection.readString('userString')) basicInfo['description'] = i18n.makeString(ssection.readString('description')) ids[sname] = seasonID idToSeason[seasonID] = basicInfo
def __readBasicConfig(self, xmlCtx, section): self.itemTypeName = 'equipment' self.name = section.name self.id = (nations.NONE_INDEX, _xml.readInt(xmlCtx, section, 'id', 0, 65535)) self.compactDescr = vehicles.makeIntCompactDescrByID('equipment', *self.id) if not section.has_key('tags'): self.tags = frozenset() else: self.tags = _readTags(xmlCtx, section, 'tags', 'equipment') if IS_CLIENT or IS_WEB: self.userString = i18n.makeString(section.readString('userString')) self.description = i18n.makeString(section.readString('description')) self.icon = _xml.readIcon(xmlCtx, section, 'icon') if IS_CELLAPP or not section.has_key('vehicleFilter'): self.__vehicleFilter = None else: self.__vehicleFilter = _VehicleFilter((xmlCtx, 'vehicleFilter'), section['vehicleFilter']) if not section.has_key('incompatibleTags'): self.__equipmentFilter = None else: self.__equipmentFilter = _EquipmentFilter((xmlCtx, 'incompatibleTags'), section['incompatibleTags'])
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
def _readInventoryItemTriggerSection(xmlCtx, section, _, triggerID): itemTypeID = _xml.readInt(xmlCtx, section, 'item-type-id') return sub_parsers._readValidateVarTriggerSection(xmlCtx, section, triggerID, triggers.InventoryItemTrigger, itemTypeID=itemTypeID)
def _readConfig(self, xmlCtx, section): self.crewLevelIncrease = _xml.readInt(xmlCtx, section, 'crewLevelIncrease', 1)
def isStunningShell(n, s): if n != 'icons': xmlCtx = (None, xmlPath + '/' + n) stunDuration = _xml.readStringOrNone(xmlCtx, s, 'stunDuration') return _xml.readInt(xmlCtx, s, 'id', 0, 65535) if stunDuration else None
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
def __readShared(self, clearCache = False): if clearCache: ResMgr.purge(TREE_SHARED_REL_FILE_PATH) shared = {'settings': {}, 'grids': {}, 'default': {}, 'lines': {}} section = ResMgr.openSection(TREE_SHARED_REL_FILE_PATH) if section is None: _xml.raiseWrongXml(None, TREE_SHARED_REL_FILE_PATH, 'can not open or read') xmlCtx = (None, TREE_SHARED_REL_FILE_PATH) precessed = _xml.getChildren(xmlCtx, section, 'settings-set') for name, settingsSec in precessed: settingsName = settingsSec.asString xPath = '{0:>s}/{1:>s}/{2:>s}'.format(TREE_SHARED_REL_FILE_PATH, name, settingsName) xmlCtx = (None, xPath) settings = {} for _, settingSec in settingsSec.items(): name = _xml.readString(xmlCtx, settingSec, 'name') if name not in DISPLAY_SETTINGS: LOG_ERROR('Setting is invalid', name) continue reader = DISPLAY_SETTINGS[name] value = getattr(_xml, reader)(xmlCtx, settingSec, 'value') settings[name] = value for name in DISPLAY_SETTINGS.iterkeys(): if name not in settings: raise _ConfigError(xmlCtx, 'Setting not found') shared['settings'][settingsName] = settings precessed = _xml.getChildren(xmlCtx, section, 'grids') for name, gridSection in precessed: gridName = gridSection.asString xPath = '{0:>s}/{1:>s}/{2:>s}'.format(TREE_SHARED_REL_FILE_PATH, name, gridName) gridCtx = (None, xPath) subSec = _xml.getSubsection(xmlCtx, gridSection, 'root') xmlCtx = (None, '{0:>s}/root'.format(xPath)) rootPos = {'start': _xml.readVector2(xmlCtx, subSec, 'start').tuple(), 'step': _xml.readInt(xmlCtx, subSec, 'step')} subSec = _xml.getSubsection(gridCtx, gridSection, 'vertical') xmlCtx = (None, '{0:>s}/vertical'.format(xPath)) vertical = (_xml.readInt(xmlCtx, subSec, 'start'), _xml.readInt(xmlCtx, subSec, 'step')) subSec = _xml.getSubsection(gridCtx, gridSection, 'horizontal') xmlCtx = (None, '{0:>s}/horizontal'.format(xPath)) horizontal = (_xml.readInt(xmlCtx, subSec, 'start'), _xml.readInt(xmlCtx, subSec, 'step')) shared['grids'][gridName] = {'root': rootPos, 'vertical': vertical, 'horizontal': horizontal} if self.__availableNations is None: self.__availableNations = self.__readAvailableNations((None, TREE_SHARED_REL_FILE_PATH), section) precessed = _xml.getChildren(xmlCtx, section, 'lines') lines = shared['lines'] for name, sub in precessed: xPath = '{0:>s}/{1:>s}'.format(TREE_SHARED_REL_FILE_PATH, name) xmlCtx = (None, xPath) pinsSec = _xml.getChildren(xmlCtx, sub, 'inPin') inPins = dict(((pName, pSec.asVector2.tuple()) for pName, pSec in pinsSec)) pinsSec = _xml.getChildren(xmlCtx, sub, 'outPin') outPins = dict(((pName, pSec.asVector2.tuple()) for pName, pSec in pinsSec)) pinsSec = _xml.getChildren(xmlCtx, sub, 'viaPin') viaPins = defaultdict(_makeDict) for outPin, setSec in pinsSec: for inPin, pSec in setSec.items(): viaPins[outPin][inPin] = map(lambda section: section[1].asVector2.tuple(), pSec.items()) defSec = sub['default'] default = {} if defSec is not None: xmlCtx = (None, '{0:>s}/default'.format(xPath)) default = {'outPin': _xml.readString(xmlCtx, defSec, 'outPin'), 'inPin': _xml.readString(xmlCtx, defSec, 'inPin')} lines[name] = {'inPins': inPins, 'outPins': outPins, 'viaPins': viaPins, 'default': default} defSec = _xml.getSubsection(xmlCtx, section, 'default-line') xPath = '{0:>s}/default-line'.format(TREE_SHARED_REL_FILE_PATH) xmlCtx = (None, xPath) name = _xml.readString(xmlCtx, defSec, 'line') outPin = _xml.readString(xmlCtx, defSec, 'outPin') inPin = _xml.readString(xmlCtx, defSec, 'inPin') self.__getLineInfo(xmlCtx, name, 0, outPin, inPin, lines) shared['default'] = {'line': name, 'inPin': inPin, 'outPin': outPin} return shared
def _readConfig(self, xmlCtx, section): self.enginePowerFactor = _xml.readPositiveFloat(xmlCtx, section, 'enginePowerFactor') self.durationSeconds = _xml.readInt(xmlCtx, section, 'durationSeconds', 1)
def __readQuestList(self): xmlPath = _POTAPOV_QUEST_XML_PATH + '/list.xml' section = ResMgr.openSection(xmlPath) if section is None: _xml.raiseWrongXml(None, xmlPath, 'can not open or read') self.__potapovQuestIDToQuestType = idToQuest = {} self.__questUniqueIDToPotapovQuestID = questUniqueNameToPotapovQuestID = {} self.__tileIDchainIDToPotapovQuestID = tileIDchainIDToPotapovQuestID = {} self.__tileIDchainIDToFinalPotapovQuestID = tileIDchainIDToFinalPotapovQuestID = {} self.__tileIDchainIDToInitialPotapovQuestID = tileIDchainIDToInitialPotapovQuestID = {} ids = {} curTime = int(time.time()) xmlSource = quest_xml_source.Source() for qname, qsection in section.items(): splitted = qname.split('_') ctx = (None, xmlPath) if qname in ids: _xml.raiseWrongXml(ctx, '', 'potapov quest name is not unique') potapovQuestID = _xml.readInt(ctx, qsection, 'id', 0, 1023) if potapovQuestID in idToQuest: _xml.raiseWrongXml(ctx, 'id', 'is not unique') questBranchName, tileID, chainID, internalID = splitted tileInfo = g_tileCache.getTileInfo(int(tileID)) if 1 <= chainID <= tileInfo['chainsCount']: _xml.raiseWrongXml(ctx, '', 'quest chainID must be between 1 and %s' % tileInfo['chainsCount']) if 1 <= internalID <= tileInfo['questsInChain']: _xml.raiseWrongXml(ctx, '', 'quest internalID must be between 1 and %s' % tileInfo['chainsCount']) minLevel = _xml.readInt(ctx, qsection, 'minLevel', 1, 10) maxLevel = _xml.readInt(ctx, qsection, 'maxLevel', minLevel, 10) basicInfo = {'name': qname, 'id': potapovQuestID, 'branch': PQ_BRANCH.NAME_TO_TYPE[questBranchName], 'tileID': int(tileID), 'chainID': int(chainID), 'internalID': int(internalID), 'minLevel': minLevel, 'maxLevel': maxLevel, 'requiredUnlocks': frozenset(map(int, _xml.readString(ctx, qsection, 'requiredUnlocks').split()))} rewardByDemand = qsection.readInt('rewardByDemand', 0) if rewardByDemand != 0 and rewardByDemand not in PQ_REWARD_BY_DEMAND.keys(): raise Exception('Unexpected value for rewardByDemand') basicInfo['rewardByDemand'] = rewardByDemand tags = _readTags(ctx, qsection, 'tags') basicInfo['tags'] = tags if questBranchName == 'regular': if 0 == len(tags & VEHICLE_CLASS_TAGS): _xml.raiseWrongXml(ctx, 'tags', 'quest vehicle class is not specified') if questBranchName == 'fallout': if 0 == len(tags & _FALLOUT_BATTLE_TAGS): _xml.raiseWrongXml(ctx, 'tags', 'quest fallout type is not specified') if IS_CLIENT or IS_WEB: basicInfo['userString'] = i18n.makeString(qsection.readString('userString')) basicInfo['description'] = i18n.makeString(qsection.readString('description')) basicInfo['advice'] = i18n.makeString(qsection.readString('advice')) basicInfo['condition_main'] = i18n.makeString(qsection.readString('condition_main')) basicInfo['condition_add'] = i18n.makeString(qsection.readString('condition_add')) questPath = ''.join([_POTAPOV_QUEST_XML_PATH, '/', questBranchName, '/tile_', tileID, '/chain_', chainID, '/', qname, '.xml']) questCtx = (None, questPath) nodes = xmlSource.readFromInternalFile(questPath, curTime) nodes = nodes.get(EVENT_TYPE.POTAPOV_QUEST, None) if nodes is None: _xml.raiseWrongXml(questCtx, 'potapovQuest', 'Potapov quests are not specified.') if len(nodes) != 2: _xml.raiseWrongXml(questCtx, 'potapovQuest', 'Main and additional quest should be presented.') qinfo = nodes[0].info if not qinfo['id'].endswith('main'): _xml.raiseWrongXml(questCtx, 'potapovQuest', 'Main quest must be first.') if qinfo['id'] in questUniqueNameToPotapovQuestID: _xml.raiseWrongXml(questCtx, 'potapovQuest', 'Duplicate name detected.') questUniqueNameToPotapovQuestID[qinfo['id']] = potapovQuestID basicInfo['mainQuestID'] = qinfo['id'] if IS_CLIENT or IS_WEB: basicInfo['mainQuestInfo'] = qinfo['questClientData'] qinfo = nodes[1].info if not qinfo['id'].endswith('add'): _xml.raiseWrongXml(questCtx, 'potapovQuest', 'Add quest must be second.') if qinfo['id'] in questUniqueNameToPotapovQuestID: _xml.raiseWrongXml(questCtx, 'potapovQuest', 'Duplicate name detected.') questUniqueNameToPotapovQuestID[qinfo['id']] = potapovQuestID basicInfo['addQuestID'] = qinfo['id'] if IS_CLIENT or IS_WEB: basicInfo['addQuestInfo'] = qinfo['questClientData'] idToQuest[potapovQuestID] = PQType(basicInfo) ids[qname] = potapovQuestID key = (int(tileID), int(chainID)) tileIDchainIDToPotapovQuestID.setdefault(key, set()).add(potapovQuestID) if 'final' in tags: tileIDchainIDToFinalPotapovQuestID[key] = potapovQuestID if 'initial' in tags: tileIDchainIDToInitialPotapovQuestID[key] = potapovQuestID ResMgr.purge(xmlPath, True) return
def _readSkillInt(paramName, minVal, xmlCtx, section, subsectionName): res, xmlCtx, section = _readSkillBasics(xmlCtx, section, subsectionName) res[paramName] = _xml.readInt(xmlCtx, section, paramName, minVal) return res
def __readNation(self, shared, nation, clearCache = False): xmlPath = NATION_TREE_REL_FILE_PATH % nation if clearCache: ResMgr.purge(xmlPath) section = ResMgr.openSection(xmlPath) if section is None: LOG_ERROR('can not open or read nation tree: ', nation, xmlPath) return {} else: xmlCtx = (None, xmlPath) settingsName = _xml.readString(xmlCtx, section, 'settings') if settingsName not in shared['settings']: LOG_ERROR('not found settings (<settings> tag): ', settingsName, xmlPath) return {} precessed = _xml.getSubsection(xmlCtx, section, 'grid') gridName = precessed.asString if gridName not in shared['grids']: LOG_ERROR('not found grid (<grid> tag): ', gridName, xmlPath) return {} xPath = '{0:>s}/grid'.format(xmlPath) xmlCtx = (None, xPath) grid = shared['grids'][gridName] settings = shared['settings'][settingsName] rows = _xml.readInt(xmlCtx, precessed, 'rows') columns = _xml.readInt(xmlCtx, precessed, 'columns') self.__displaySettings[nations.INDICES[nation]] = settings nationIndex = self.__availableNations.index(nation) hasRoot = settings['hasRoot'] if hasRoot: coords = self.__makeGridCoordsWithRoot(grid, nationIndex, rows, columns) else: coords = self.__makeGridCoordsWoRoot(grid, rows, columns) getIDsByName = vehicles.g_list.getIDsByName makeIntCDByID = vehicles.makeIntCompactDescrByID getVehicle = vehicles.g_cache.vehicle precessed = _xml.getChildren(xmlCtx, section, 'nodes') displayInfo = {} for name, nodeSection in precessed: xPath = '{0:>s}/nodes/{1:>s}'.format(xmlPath, name) xmlCtx = (None, xPath) uName = '{0:>s}:{1:>s}'.format(nation, name) try: nationID, vTypeID = getIDsByName(uName) except Exception: raise _ConfigError(xmlCtx, 'Unknown vehicle type name {0:>s}'.format(uName)) nodeCD = makeIntCDByID(_VEHICLE_TYPE_NAME, nationID, vTypeID) vType = getVehicle(nationID, vTypeID) nextLevel = filter(lambda data: getTypeOfCompactDescr(data[1][1]) == _VEHICLE, enumerate(vType.unlocksDescrs)) for unlockDescr in vType.unlocksDescrs: self.__unlockPrices[unlockDescr[1]][vType.compactDescr] = unlockDescr[0] for idx, data in nextLevel: xpCost = data[0] nextCD = data[1] required = data[2:] self.__nextLevels[nodeCD][nextCD] = (idx, xpCost, set(required)) self.__topLevels[nextCD].add(nodeCD) for itemCD in required: self.__topItems[itemCD].add(nodeCD) row = _xml.readInt(xmlCtx, nodeSection, 'row') column = _xml.readInt(xmlCtx, nodeSection, 'column') if hasRoot and row > 1 and column is 1: raise _ConfigError(xmlCtx, 'In first column must be one node - root node, {0:>s} '.format(uName)) elif row > rows or column > columns: raise _ConfigError(xmlCtx, 'Invalid row or column index: {0:>s}, {1:d}, {2:d}'.format(uName, row, column)) lines = self.__readNodeLines(nodeCD, nation, xmlCtx, nodeSection, shared) displayInfo[nodeCD] = {'row': row, 'column': column, 'position': coords[column - 1][row - 1], 'lines': lines} return displayInfo
def _readShotDamageTriggerSection(xmlCtx, section, _, triggerID): return _readDispatchableTriggerSection(xmlCtx, section, triggerID, triggers.ShotDamageTrigger, maxCount=_xml.readInt(xmlCtx, section, 'max-count'))