コード例 #1
0
 def _removeItem(self, slotId, season=None):
     if self.__modifiedStyle is None:
         return
     elif slotId == self.STYLE_SLOT:
         self.__modifiedStyle = None
         self._modifiedOutfits = {
             s: self._service.getEmptyOutfit()
             for s in SeasonType.COMMON_SEASONS
         }
         return
     elif not self.__modifiedStyle.isEditable:
         return _logger.error(
             'Failed to remove item from slotId: %s for style: %s. Style is not Editable',
             slotId, self.__modifiedStyle)
     else:
         season = season or self.season
         outfit = self._modifiedOutfits[season]
         vehicleCD = g_currentVehicle.item.descriptor.makeCompactDescr()
         baseOutfit = self.__modifiedStyle.getOutfit(season,
                                                     vehicleCD=vehicleCD)
         fitOutfit(baseOutfit, getCurrentVehicleAvailableRegionsMap())
         removeItemFromEditableStyle(outfit, baseOutfit, slotId)
         diff = getEditableStyleOutfitDiff(outfit, baseOutfit)
         self._ctx.stylesDiffsCache.saveDiff(self.__modifiedStyle, season,
                                             diff)
         return
コード例 #2
0
    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)
コード例 #3
0
    def _applyItems(self, purchaseItems, isModeChanged, callback):
        results = []
        vehicleCD = g_currentVehicle.item.descriptor.makeCompactDescr()
        modifiedOutfits = {
            season: outfit.copy()
            for season, outfit in self._modifiedOutfits.iteritems()
        }
        removeUnselectedItemsFromEditableStyle(modifiedOutfits,
                                               self.__baseOutfits,
                                               purchaseItems)
        self._soundEventChacker.lockPlayingSounds()
        outfit = self._modifiedOutfits[self.season]
        result = yield OutfitApplier(g_currentVehicle.item, outfit,
                                     SeasonType.ALL).request()
        results.append(result)
        for season in SeasonType.COMMON_SEASONS:
            outfit = modifiedOutfits[season]
            baseOutfit = self.__baseOutfits[season]
            if not outfit.isEqual(baseOutfit):
                diff = getEditableStyleOutfitDiff(outfit, baseOutfit)
                outfit = self.__style.getOutfit(season,
                                                vehicleCD=vehicleCD,
                                                diff=diff)
                result = yield OutfitApplier(g_currentVehicle.item, outfit,
                                             season).request()
                results.append(result)

        self._soundEventChacker.unlockPlayingSounds()
        if self.isInited:
            self._events.onItemsBought(purchaseItems, results)
        callback(self)
コード例 #4
0
 def _iterOutfitsWithoutItem(self, item, count):
     season = g_currentVehicle.item.getAnyOutfitSeason()
     isMountedStyleSelected = g_currentVehicle.item.getOutfit(
         season).id == self.__style.id
     if isMountedStyleSelected:
         iterOutfitsWithoutItem = partial(getOutfitWithoutItems,
                                          self.getOutfitsInfo(), item.intCD,
                                          count)
     else:
         outfits = {
             season: outfit
             for season, outfit in
             g_currentVehicle.item.outfits.iteritems()
         }
         iterOutfitsWithoutItem = partial(getOutfitWithoutItemsNoDiff,
                                          outfits, item.intCD, count)
     vehicleCD = g_currentVehicle.item.descriptor.makeCompactDescr()
     for season, outfit in iterOutfitsWithoutItem():
         if isMountedStyleSelected:
             baseOutfit = self.__baseOutfits[season]
             diff = getEditableStyleOutfitDiff(outfit, baseOutfit)
             outfit = self.__style.getOutfit(season,
                                             vehicleCD=vehicleCD,
                                             diff=diff)
         yield (season, outfit)
コード例 #5
0
    def _onStop(self):
        diffs = {}
        for season in SeasonType.COMMON_SEASONS:
            outfit = self._modifiedOutfits[season]
            baseOutfit = self.__baseOutfits[season]
            diffs[season] = getEditableStyleOutfitDiff(outfit, baseOutfit)

        self._ctx.stylesDiffsCache.saveDiffs(self.__style, diffs)
        super(EditableStyleMode, self)._onStop()
コード例 #6
0
    def changeStyleProgressionLevel(self, toLevel):
        vehicleCD = g_currentVehicle.item.descriptor.makeCompactDescr()
        baseOutfit = self.__modifiedStyle.getOutfit(self.season, vehicleCD=vehicleCD)
        for seasonID in SeasonType.COMMON_SEASONS:
            self._modifiedOutfits[seasonID] = getStyleProgressionOutfit(self._modifiedOutfits[seasonID], toLevel, seasonID)
            addOutfit = self.__modifiedStyle.getAdditionalOutfit(toLevel, seasonID, vehicleCD)
            if addOutfit is not None:
                baseOutfit = baseOutfit.patch(addOutfit)
            diff = getEditableStyleOutfitDiff(self._modifiedOutfits[seasonID], baseOutfit)
            self._ctx.stylesDiffsCache.saveDiff(self.__modifiedStyle, seasonID, diff)

        self._fitOutfits(modifiedOnly=True)
        self._ctx.refreshOutfit()
        self._events.onComponentChanged(self.STYLE_SLOT, True)
        return
コード例 #7
0
    def _sellItem(self, item, count):
        if item.fullInventoryCount(g_currentVehicle.item.intCD) < count:
            vehicleCD = g_currentVehicle.item.descriptor.makeCompactDescr()
            for season, outfit in getOutfitWithoutItems(
                    self.getOutfitsInfo(), item.intCD, count):
                baseOutfit = self.__baseOutfits[season]
                diff = getEditableStyleOutfitDiff(outfit, baseOutfit)
                outfit = self.__style.getOutfit(season,
                                                vehicleCD=vehicleCD,
                                                diff=diff)
                yield OutfitApplier(g_currentVehicle.item, outfit,
                                    season).request()

        yield CustomizationsSeller(g_currentVehicle.item, item,
                                   count).request()