def _readConfig(self, xmlCtx, section): self.delay = _xml.readPositiveFloat(xmlCtx, section, 'delay') self.modelName = _xml.readString(xmlCtx, section, 'modelName') if IS_CLIENT: self.soundEvent = _xml.readString(xmlCtx, section, 'wwsoundEvent') 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 _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 __readItemFilterNodeFromXml(itemType, xmlCtx, section): fn = cc.ItemsFilter.FilterNode() if section.has_key('id'): fn.ids = ix.readTupleOfPositiveInts(xmlCtx, section, 'id') if section.has_key('itemGroupName'): fn.itemGroupNames = ix.readTupleOfStrings(xmlCtx, section, 'itemGroupName', separator=';') if section.has_key('tags'): fn.tags = iv._readTags(xmlCtx, section, 'tags', 'customizationItem') if section.has_key('type'): if itemType is not CustomizationType.DECAL: ix.raiseWrongXml(xmlCtx, 'type', 'type can be used only with decals') types = set( (getattr(DecalType, typeName) for typeName in ix.readTupleOfStrings(xmlCtx, section, 'type') )) if not types.issubset(DecalType.ALL): ix.raiseWrongXml(xmlCtx, 'type', 'unsupported type is used') fn.types = types if section.has_key('historical'): fn.historical = section.readBool('historical', None) return fn
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 _readFromXml(self, target, xmlCtx, section, cache=None): super(StyleXmlReader, self)._readFromXml(target, xmlCtx, section) prototype = True if section.has_key('modelsSet'): target.modelsSet = section.readString('modelsSet') if section.has_key('itemFilters'): target.isEditable = True target.itemsFilters = {} for sectionName, oSection in section['itemFilters'].items(): c11nType = CustomizationNamesToTypes[upper(sectionName)] target.itemsFilters[c11nType] = self._readItemsFilterFromXml( c11nType, xmlCtx, oSection) if section.has_key('alternateItems'): target.isEditable = True target.alternateItems = {} for sectionName, oSection in section['alternateItems'].items(): c11nType = CustomizationNamesToTypes[upper(sectionName)] if oSection.has_key('id'): target.alternateItems[ c11nType] = ix.readTupleOfPositiveInts( xmlCtx, oSection, 'id') if section.has_key('outfits'): prototype = False outfits = {} for i, (_, oSection) in enumerate(section['outfits'].items()): oCtx = ((xmlCtx, 'outfits'), 'outfit {}'.format(i)) season = readEnum(oCtx, oSection, 'season', SeasonType) outfit = self.__outfitDeserializer.decode( c11n.CustomizationOutfit.customType, oCtx, oSection) for s in SeasonType.SEASONS: if s & season: outfits[s] = outfit outfit.styleId = target.id target.outfits = outfits if section.has_key('isRent'): target.isRent = section.readBool('isRent') if target.isRent: target.rentCount = section.readInt('rentCount', RENT_DEFAULT_BATTLES) target.tags = target.tags.union( frozenset((ItemTags.VEHICLE_BOUND, ))) totalSeason = sum(target.outfits) if totalSeason != target.season and not prototype: ix.raiseWrongXml( xmlCtx, 'outfits', 'style season must correspond to declared outfits')
def __readFilterNodeFromXml(xmlCtx, section): fn = cc.VehicleFilter.FilterNode() strNations = ix.readStringOrNone(xmlCtx, section, 'nations') if strNations: r = [] for nation in strNations.split(): nationId = nations.INDICES.get(nation) if nationId is None: ix.raiseWrongXml(xmlCtx, 'nations', "unknown nation '%s'" % nation) r.append(nationId) fn.nations = r if section.has_key('levels'): fn.levels = ix.readTupleOfPositiveInts(xmlCtx, section, 'levels') if section.has_key('vehicles'): fn.vehicles = iv._readNationVehiclesByNames( xmlCtx, section, 'vehicles', None) if section.has_key('tags'): fn.tags = iv._readTags(xmlCtx, section, 'tags', 'vehicle') return fn
def _readFromXml(self, target, xmlCtx, section, cache=None): super(StyleXmlReader, self)._readFromXml(target, xmlCtx, section) prototype = True if section.has_key('modelsSet'): target.modelsSet = section.readString('modelsSet') if IS_EDITOR: target.editorData.modelsSet = target.modelsSet if section.has_key('itemFilters'): target.isEditable = True itemsFilters = {} for sectionName, oSection in section['itemFilters'].items(): c11nType = CustomizationNamesToTypes[upper(sectionName)] itemsFilters[c11nType] = self._readItemsFilterFromXml( c11nType, xmlCtx, oSection) target.itemsFilters = itemsFilters if section.has_key('alternateItems'): target.isEditable = True alternateItems = {} for sectionName, oSection in section['alternateItems'].items(): c11nType = CustomizationNamesToTypes[upper(sectionName)] if oSection.has_key('id'): alternateItems[c11nType] = ix.readTupleOfPositiveInts( xmlCtx, oSection, 'id') target.alternateItems = alternateItems if section.has_key('dependencies'): target.isEditable = True dependencies = {} dependenciesAncestors = {} for _, camouflageSection in section['dependencies'].items(): camouflageDependencies = {} for sectionName in camouflageSection.keys(): if sectionName == 'id': camouflageIDs = ix.readTupleOfPositiveInts( xmlCtx, camouflageSection, 'id') c11nType = CustomizationNamesToTypes[upper(sectionName)] camouflageDependencies[ c11nType] = ix.readTupleOfPositiveInts( xmlCtx, camouflageSection, sectionName) for camouflageID in camouflageIDs: dependencies[camouflageID] = camouflageDependencies for itemType, itemIDs in camouflageDependencies.iteritems( ): itemTypeAncestors = dependenciesAncestors.setdefault( itemType, {}) for customizationItemID in itemIDs: itemTypeAncestors.setdefault( customizationItemID, []).append(camouflageID) target.dependencies = dependencies target.dependenciesAncestors = dependenciesAncestors if section.has_key('outfits'): prototype = False outfits = self.__readOutfitSection(target.id, section, xmlCtx) target.outfits = outfits if section.has_key('isRent'): target.isRent = section.readBool('isRent') if target.isRent: target.rentCount = section.readInt('rentCount', RENT_DEFAULT_BATTLES) target.tags = target.tags.union( frozenset((ItemTags.VEHICLE_BOUND, ))) totalSeason = sum(target.outfits) if totalSeason != target.season and not prototype: ix.raiseWrongXml( xmlCtx, 'outfits', 'style season must correspond to declared outfits')