Exemplo n.º 1
0
    def _request(self, callback):
        _logger.debug('Make server request to put on outfit on vehicle %s, outfitData %s', self.vehicle.invID, self.outfitData)
        requestData = []
        c11nService = dependency.instance(ICustomizationService)
        for outfit, season in self.outfitData:
            component = None
            if outfit.style:
                intCD = makeIntCompactDescrByID('customizationItem', CustomizationType.STYLE, outfit.style.id)
                style = self.itemsCache.items.getItemByCD(intCD)
                if style and style.isProgressive:
                    outfit = c11nService.removeAdditionalProgressionData(outfit=outfit, style=style, vehCD=self.vehicle.descriptor.makeCompactDescr(), season=season)
                    component = outfit.pack()
            if component is None:
                component = outfit.pack()
            if component.styleId and isEditedStyle(component):
                intCD = makeIntCompactDescrByID('customizationItem', CustomizationType.STYLE, component.styleId)
                style = self.itemsCache.items.getItemByCD(intCD)
                baseOutfit = style.getOutfit(season, self.vehicle.descriptor.makeCompactDescr())
                baseComponent = baseOutfit.pack()
                component = component.getDiff(baseComponent)
            self.__validateOutfitComponent(component)
            requestData.append((component.makeCompDescr(), season))

        BigWorld.player().shop.buyAndEquipOutfit(self.vehicle.invID, requestData, lambda code: self._response(code, callback))
        return
    def isEditedForVehicle(self, vehicleIntCD):
        c11nCtx = self._service.getCtx()
        if c11nCtx is not None and vehicleIntCD == g_currentVehicle.item.intCD:
            diffs = c11nCtx.stylesDiffsCache.getDiffs(self)
            for diff in diffs.itervalues():
                if diff is not None and isEditedStyle(parseCompDescr(diff)):
                    return True

        else:
            outfitsPool = self._itemsCache.items.inventory.getC11nOutfitsFromPool(
                vehicleIntCD)
            for styleId, _ in outfitsPool:
                if styleId == self.id:
                    return True

        return False
Exemplo n.º 3
0
 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 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()