def _applyItems(self, purchaseItems, isModeChanged, callback): results = [] style = self.__modifiedStyle vehicleCD = g_currentVehicle.item.descriptor.makeCompactDescr() originalOutfits = self._ctx.startMode.getOriginalOutfits() if style is not None: baseStyleOutfits = {} modifiedStyleOutfits = {} for season in SeasonType.COMMON_SEASONS: diff = self._ctx.stylesDiffsCache.getDiffs(style).get(season) baseStyleOutfits[season] = style.getOutfit(season, vehicleCD=vehicleCD) modifiedStyleOutfits[season] = style.getOutfit(season, vehicleCD=vehicleCD, diff=diff) removeUnselectedItemsFromEditableStyle(modifiedStyleOutfits, baseStyleOutfits, purchaseItems) result = yield OutfitApplier(g_currentVehicle.item, [ (outfit, season) for season, outfit in modifiedStyleOutfits.iteritems() ]).request() results.append(result) else: outfit = self._modifiedOutfits[self.season] result = yield OutfitApplier(g_currentVehicle.item, ((outfit, SeasonType.ALL),)).request() results.append(result) if style is not None and style.isRentable and self.__prolongRent: self._service.buyItems(style, count=1, vehicle=g_currentVehicle.item) self.__prolongRent = False if self.__autoRentEnabled != g_currentVehicle.item.isAutoRentStyle: yield VehicleAutoStyleEquipProcessor(g_currentVehicle.item, self.__autoRentEnabled, self.__autoRentChangeSource).request() self.__autoRentChangeSource = CLIENT_COMMAND_SOURCES.UNDEFINED if self.isInited: self._events.onItemsBought(originalOutfits, purchaseItems, results) callback(self) return
def applyItems(self, purchaseItems): self.itemsCache.onSyncCompleted -= self.__onCacheResync groupHasItems = { AdditionalPurchaseGroups.STYLES_GROUP_ID: False, SeasonType.WINTER: False, SeasonType.SUMMER: False, SeasonType.DESERT: False } modifiedOutfits = { season: outfit.copy() for season, outfit in self._modifiedOutfits.iteritems() } for pItem in purchaseItems: if not pItem.selected: if pItem.slot: slot = modifiedOutfits[pItem.group].getContainer( pItem.areaID).slotFor(pItem.slot) slot.remove(pItem.regionID) groupHasItems[pItem.group] = True if self._mode == C11nMode.CUSTOM: groupHasItems[self._currentSeason] = True empty = self.service.getEmptyOutfit() for season in SeasonType.COMMON_SEASONS: if groupHasItems[season]: yield OutfitApplier(g_currentVehicle.item, empty, season).request() results = [] for season in SeasonType.COMMON_SEASONS: if groupHasItems[season]: outfit = modifiedOutfits[season] result = yield OutfitApplier(g_currentVehicle.item, outfit, season).request() results.append(result) if groupHasItems[AdditionalPurchaseGroups.STYLES_GROUP_ID]: result = yield StyleApplier(g_currentVehicle.item, self._modifiedStyle).request() results.append(result) if self._autoRentEnabled != g_currentVehicle.item.isAutoRentStyle: yield VehicleAutoStyleEquipProcessor( g_currentVehicle.item, self._autoRentEnabled).request() self.onCustomizationItemsBought(purchaseItems, results) self.__onCacheResync() self.itemsCache.onSyncCompleted += self.__onCacheResync
def __setAutoRent(self, autoRent): yield VehicleAutoStyleEquipProcessor(g_currentVehicle.item, autoRent).request()