def pack(self): component = CustomizationOutfit() for container in self._containers.itervalues(): container.pack(component) component.styleId = self._id return component
def _applyItems(self, purchaseItems, isModeChanged, callback): results = [] vehicleCD = g_currentVehicle.item.descriptor.makeCompactDescr() modifiedOutfits = {season:outfit.copy() for season, outfit in self._modifiedOutfits.iteritems()} originalOutfits = self._ctx.startMode.getOriginalOutfits() removeUnselectedItemsFromEditableStyle(modifiedOutfits, self.__baseOutfits, purchaseItems) requestData = [] for season in SeasonType.COMMON_SEASONS: outfit = modifiedOutfits[season] baseOutfit = self.__baseOutfits[season] if outfit.vehicleCD != baseOutfit.vehicleCD or not outfit.isEqual(baseOutfit): diff = getEditableStyleOutfitDiff(outfit, baseOutfit) outfit = self.__style.getOutfit(season, vehicleCD=vehicleCD, diff=diff) requestData.append((outfit, season)) if not requestData: emptyComponent = CustomizationOutfit() outfit = self._modifiedOutfits[self.season] emptyComponent.styleId = outfit.id outfit = Outfit(component=emptyComponent) requestData.append((outfit, SeasonType.ALL)) result = yield OutfitApplier(g_currentVehicle.item, requestData).request() results.append(result) if self.isInited: self._events.onItemsBought(originalOutfits, purchaseItems, results) callback(self)
def pack(self): """ Pack the current outfit into a component. """ component = CustomizationOutfit() for container in self._containers.itervalues(): container.pack(component) component.styleId = self._id return component
def pack(self): component = CustomizationOutfit() for container in self._containers.itervalues(): container.pack(component) component.styleId = self._id component.styleProgressionLevel = self.__styleProgressionLevel component.serial_number = self.__styleSerialNumber return component
def __init__(self, strCompactDescr=None, isEnabled=False, isInstalled=False, proxy=None): super(Outfit, self).__init__(strCompactDescr) self._containers = {} if strCompactDescr: component = parseCompDescr(strCompactDescr) else: component = CustomizationOutfit() self._id = component.styleId if self._id: intCD = makeIntCompactDescrByID('customizationItem', CustomizationType.STYLE, self._id) self._styleDescr = getItemByCompactDescr(intCD) else: self._styleDescr = None self._isEnabled = isEnabled self._isInstalled = isInstalled for container in scaffold(): container.unpack(component, proxy) self._containers[container.getAreaID()] = container self.invalidate() return
def __init__(self, strCompactDescr=None, component=None, vehicleCD='', vehicleType=None): super(Outfit, self).__init__(strCompactDescr) self._containers = {} self._vehicleCD = vehicleCD if strCompactDescr is not None and component is not None: raise SoftException("'strCompactDescr' and 'component' arguments are mutually exclusive!") if strCompactDescr: component = parseOutfitDescr(strCompactDescr) elif component is None: component = CustomizationOutfit() self._id = component.styleId self.__styleProgressionLevel = component.styleProgressionLevel self.__styleSerialNumber = component.serial_number self._styleDescr = None if self._id: intCD = makeIntCompactDescrByID('customizationItem', CustomizationType.STYLE, self._id) if not IS_EDITOR: self._styleDescr = getItemByCompactDescr(intCD) else: from items.vehicles import g_cache if g_cache.customization20(createNew=False): self._styleDescr = getItemByCompactDescr(intCD) self._construct(vehicleType=vehicleType) for container in self._containers.itervalues(): container.unpack(component) self.__itemsCounter = None self.invalidate() return
def __init__(self, strCompactDescr=None, component=None, vehicleCD='', vehicleType=None): super(Outfit, self).__init__(strCompactDescr) self._containers = {} self._vehicleCD = vehicleCD if strCompactDescr is not None and component is not None: raise SoftException( "'strCompactDescr' and 'component' arguments are mutually exclusive!" ) if strCompactDescr: component = parseOutfitDescr(strCompactDescr) elif component is None: component = CustomizationOutfit() self._id = component.styleId if self._id: intCD = makeIntCompactDescrByID('customizationItem', CustomizationType.STYLE, self._id) self._styleDescr = getItemByCompactDescr(intCD) else: self._styleDescr = None self._construct(vehicleType=vehicleType) for container in self._containers.itervalues(): container.unpack(component) self.__itemsCounter = None self.invalidate() return
def _sellItem(self, item, count, callback): if item.fullInventoryCount(g_currentVehicle.item.intCD) < count: emptyComponent = CustomizationOutfit() vehicleCD = g_currentVehicle.item.descriptor.makeCompactDescr() outfit = Outfit(component=emptyComponent, vehicleCD=vehicleCD) yield OutfitApplier(g_currentVehicle.item, ((outfit, SeasonType.ALL),)).request() result = yield CustomizationsSeller(g_currentVehicle.item, item, count).request() callback(result)
def _request(self, callback): _logger.debug( 'Make server request to put on outfit on vehicle %s, season %s', self.vehicle.invID, self.season) component = self.outfit.pack() if self.season == SeasonType.ALL: component = CustomizationOutfit() component.styleId = self.outfit.id elif component.styleId and isEditedStyle(component): intCD = makeIntCompactDescrByID('customizationItem', CustomizationType.STYLE, component.styleId) style = self.itemsCache.items.getItemByCD(intCD) baseComponent = style.getOutfit( self.season, self.vehicle.descriptor.makeCompactDescr()) component = component.getDiff(baseComponent.pack()) BigWorld.player().shop.buyAndEquipOutfit( self.vehicle.invID, self.season, component.makeCompDescr(), lambda code: self._response(code, callback))
def __init__(self, strCompactDescr=None, isEnabled=False, proxy=None): super(Outfit, self).__init__(strCompactDescr) self._containers = {} if strCompactDescr: component = parseCompDescr(strCompactDescr) else: component = CustomizationOutfit() self._id = component.styleId self._isEnabled = isEnabled for container in scaffold(): container.unpack(component, proxy) self._containers[container.getAreaID()] = container self.invalidate()
def getOutfitComponent(outfitCD, vehicleDescriptor=None): if outfitCD: outfitComponent = parseOutfitDescr(outfitCD) season = _currentMapSeason() if outfitComponent.styleId != 0 and season is not None: intCD = makeIntCompactDescrByID('customizationItem', CustomizationType.STYLE, outfitComponent.styleId) styleDescr = getItemByCompactDescr(intCD) if IS_EDITOR: if hasattr(outfitComponent, 'edSeasonsMask'): enyOutfit = styleDescr.outfits[season] season = enyOutfit.edSeasonsMask baseOutfitComponent = deepcopy(styleDescr.outfits[season]) if vehicleDescriptor and ItemTags.ADD_NATIONAL_EMBLEM in styleDescr.tags: emblems = createNationalEmblemComponents(vehicleDescriptor) baseOutfitComponent.decals.extend(emblems) if isEditedStyle(outfitComponent): outfitComponent = baseOutfitComponent.applyDiff(outfitComponent) else: outfitComponent = baseOutfitComponent return outfitComponent else: return CustomizationOutfit()
def getOutfitComponent(outfitCD, vehicleDescriptor=None, seasonType=None): if outfitCD: outfitComponent = parseOutfitDescr(outfitCD) if seasonType is None: seasonType = _currentMapSeason() if outfitComponent.styleId != 0 and outfitComponent.styleId != EMPTY_ITEM_ID and seasonType is not None: intCD = makeIntCompactDescrByID('customizationItem', CustomizationType.STYLE, outfitComponent.styleId) styleDescr = getItemByCompactDescr(intCD) if IS_EDITOR: if hasattr(outfitComponent, 'edSeasonsMask'): if styleDescr.outfits is not None and bool( styleDescr.outfits): anyOutfit = styleDescr.outfits[ styleDescr.outfits.keys()[0]] seasonType = anyOutfit.edSeasonsMask else: return outfitComponent baseOutfitComponent = deepcopy(styleDescr.outfits[seasonType]) if styleDescr.isProgression or IS_EDITOR: if IS_EDITOR: baseOutfitComponent.styleId = styleDescr.id outfit = Outfit(component=baseOutfitComponent, vehicleCD=vehicleDescriptor.makeCompactDescr()) if outfit and outfit.style and outfit.style.styleProgressions: outfit = getStyleProgressionOutfit( outfit, outfitComponent.styleProgressionLevel, seasonType) baseOutfitComponent = outfit.pack() baseOutfitComponent.styleProgressionLevel = outfitComponent.styleProgressionLevel if styleDescr.isWithSerialNumber: baseOutfitComponent.serial_number = outfitComponent.serial_number if vehicleDescriptor and ItemTags.ADD_NATIONAL_EMBLEM in styleDescr.tags: emblems = createNationalEmblemComponents(vehicleDescriptor) baseOutfitComponent.decals.extend(emblems) if isEditedStyle(outfitComponent): outfitComponent = baseOutfitComponent.applyDiff( outfitComponent) else: outfitComponent = baseOutfitComponent if IS_EDITOR: def setupAlternateItem(itemType, outfit, sourceOutfit, collectionName): alternateItem = outfit.editorData.alternateItems[itemType] if alternateItem != 0: sourceComponents = getattr(sourceOutfit, collectionName) if sourceComponents is not None: if itemType != CustomizationType.MODIFICATION: for componentItem in sourceComponents: componentItem.id = alternateItem else: for index, _ in enumerate(sourceComponents): sourceComponents[index] = alternateItem setattr(sourceOutfit, collectionName, sourceComponents) return anyOutfit = styleDescr.outfits[seasonType] setupAlternateItem(CustomizationType.DECAL, anyOutfit, outfitComponent, 'decals') setupAlternateItem(CustomizationType.PROJECTION_DECAL, anyOutfit, outfitComponent, 'projection_decals') setupAlternateItem(CustomizationType.PAINT, anyOutfit, outfitComponent, 'paints') setupAlternateItem(CustomizationType.CAMOUFLAGE, anyOutfit, outfitComponent, 'camouflages') setupAlternateItem(CustomizationType.MODIFICATION, anyOutfit, outfitComponent, 'modifications') setupAlternateItem(CustomizationType.PERSONAL_NUMBER, anyOutfit, outfitComponent, 'personal_numbers') return outfitComponent else: return CustomizationOutfit()
def getEmptyOutfitWithNationalEmblems(self, vehicleCD): vehDesc = VehicleDescr(vehicleCD) decals = createNationalEmblemComponents(vehDesc) component = CustomizationOutfit(decals=decals) return self.itemsFactory.createOutfit(component=component, vehicleCD=vehicleCD)