def _getSysMsgType(self): """ :return: <str> system message type """ return CURRENCY_TO_SM_TYPE.get( self.item.buyPrices.itemPrice.getCurrency(byWeight=False), SM_TYPE.Information)
def __onItemsBought(self, purchaseItems, results): errorCount = 0 for result in results: if not result.success: errorCount += 1 if result.userMsg: SystemMessages.pushI18nMessage(result.userMsg, type=result.sysMsgType) if not errorCount: cart = getTotalPurchaseInfo(purchaseItems) if cart.totalPrice != ITEM_PRICE_EMPTY: msgCtx = { 'money': formatPrice(cart.totalPrice.price), 'count': cart.numSelected } SystemMessages.pushI18nMessage( MESSENGER. SERVICECHANNELMESSAGES_SYSMSG_CONVERTER_CUSTOMIZATIONSBUY, type=CURRENCY_TO_SM_TYPE.get( cart.totalPrice.getCurrency(byWeight=True), SM_TYPE.PurchaseForGold), **msgCtx) else: SystemMessages.pushI18nMessage( MESSENGER. SERVICECHANNELMESSAGES_SYSMSG_CONVERTER_CUSTOMIZATIONS, type=SM_TYPE.Information) self.__onCloseWindow(proceed=True)
def _successHandler(self, code, ctx=None): currency = self.item.buyPrices.itemPrice.price.getCurrency( byWeight=True) messageType = MESSENGER.SERVICECHANNELMESSAGES_SYSMSG_CUSTOMIZATIONS_BUY sysMsgType = CURRENCY_TO_SM_TYPE.get(currency, SM_TYPE.PurchaseForGold) SystemMessages.pushI18nMessage(messageType, type=sysMsgType, **self._getMsgCtx()) return makeSuccess(auxData=ctx)
def _successHandler(self, code, ctx=None): currency = self.item.buyPrices.itemPrice.price.getCurrency(byWeight=True) sysMsgType = CURRENCY_TO_SM_TYPE.get(currency, SM_TYPE.PurchaseForGold) msgCtx = self._getMsgCtx() if self.count == 1: msg = backport.text(R.strings.messenger.serviceChannelMessages.sysMsg.customization.buyOne(), **msgCtx) else: msgCtx = {'items': backport.text(R.strings.messenger.serviceChannelMessages.sysMsg.customization.item(), **msgCtx) + '.', 'money': msgCtx['money']} msg = backport.text(R.strings.messenger.serviceChannelMessages.sysMsg.customization.buyMany(), **msgCtx) SystemMessages.pushMessage(msg, type=sysMsgType) return makeSuccess(auxData=ctx)
def _getSysMsgType(self): return CURRENCY_TO_SM_TYPE.get(self.item.buyPrices.itemPrice.getCurrency(byWeight=False), SM_TYPE.Information)
def _getSysMsgType(self): return CURRENCY_TO_SM_TYPE.get(self._currency, SM_TYPE.PurchaseForCredits)
def buyAndExit(self, purchaseItems): self._currentSettings = self._cleanSettings(self._currentSettings) for itemsKey in self._currentSettings: for camoName in self._currentSettings[itemsKey]: g_config.camouflages[itemsKey].setdefault(camoName, {}).update(self._currentSettings[itemsKey][camoName]) if self._currentSettings['remap']: newSettings = {'disable': g_config.disable, 'remap': g_config.camouflages['remap']} loadJson(g_config.ID, 'settings', newSettings, g_config.configPath, True) if self._currentSettings['custom']: for confFolderName in g_config.configFolders: configFolder = g_config.configFolders[confFolderName] loadJson(g_config.ID, 'settings', {key: g_config.camouflages['custom'][key] for key in configFolder}, g_config.configPath + 'camouflages/' + confFolderName + '/', True, False) if any(self._currentSettings.itervalues()): from ..processors import collectCamouflageData collectCamouflageData() self.itemsCache.onSyncCompleted -= self.__onCacheResync boughtOutfits = {season: self.service.getCustomOutfit(season) for season in SeasonType.COMMON_SEASONS} cart = getTotalPurchaseInfo(purchaseItems) nationName, vehicleName = g_currentVehicle.item.descriptor.name.split(':') vehConfig = g_config.outfitCache.get(nationName, {}).get(vehicleName, {}) for pItem in (x for x in purchaseItems if x.selected): seasonName = SEASON_TYPE_TO_NAME[pItem.group] if pItem.slot == GUI_ITEM_TYPE.CAMOUFLAGE: bItem, bComp = boughtOutfits[pItem.group].getContainer(pItem.areaID).slotFor(pItem.slot)._items.get( pItem.regionID, (None, None)) component = self._modifiedOutfits[pItem.group].getContainer(pItem.areaID).slotFor(pItem.slot).getComponent( pItem.regionID) if pItem.isDismantling and (not bItem or not bComp) or not pItem.isDismantling and pItem.item == bItem and \ component.palette == bComp.palette and component.patternSize == bComp.patternSize: vehConfig.get(seasonName, {}).get('camo', {}).pop(TankPartIndexes.getName(pItem.areaID), []) else: g_config.outfitCache.setdefault(nationName, {}).setdefault(vehicleName, {}).setdefault( seasonName, {}).setdefault('camo', {})[TankPartIndexes.getName(pItem.areaID)] = ( [pItem.item.id, component.palette, component.patternSize] if not pItem.isDismantling else []) g_config.hangarCamoCache.get(nationName, {}).get(vehicleName, {}).get(seasonName, {}).pop( TankPartIndexes.getName(pItem.areaID), {}) else: typeName = GUI_ITEM_TYPE_NAMES[pItem.slot] bItem = boughtOutfits[pItem.group].getContainer(pItem.areaID).slotFor(pItem.slot).getItem(pItem.regionID) if pItem.isDismantling and not bItem or not pItem.isDismantling and pItem.item == bItem: vehConfig.get(seasonName, {}).get(typeName, {}).get( TankPartIndexes.getName(pItem.areaID) if pItem.areaID < 4 else 'misc', {}).pop(str(pItem.regionID), None) else: g_config.outfitCache.setdefault(nationName, {}).setdefault(vehicleName, {}).setdefault( seasonName, {}).setdefault(typeName, {}).setdefault( TankPartIndexes.getName(pItem.areaID) if pItem.areaID < 4 else 'misc', {})[ str(pItem.regionID)] = (pItem.item.id if not pItem.isDismantling else None) for nationName in g_config.outfitCache.keys(): for vehicleName in g_config.outfitCache[nationName].keys(): for season in g_config.outfitCache[nationName][vehicleName].keys(): for itemType in g_config.outfitCache[nationName][vehicleName][season].keys(): if itemType == 'camo': if g_currentVehicle.item.turret.isGunCarriage: g_config.outfitCache[nationName][vehicleName][season][itemType].pop('turret', None) else: for areaName in g_config.outfitCache[nationName][vehicleName][season][itemType].keys(): if not g_config.outfitCache[nationName][vehicleName][season][itemType][areaName]: del g_config.outfitCache[nationName][vehicleName][season][itemType][areaName] if not g_config.outfitCache[nationName][vehicleName][season][itemType]: del g_config.outfitCache[nationName][vehicleName][season][itemType] if not g_config.outfitCache[nationName][vehicleName][season]: del g_config.outfitCache[nationName][vehicleName][season] if not g_config.outfitCache[nationName][vehicleName]: del g_config.outfitCache[nationName][vehicleName] if not g_config.outfitCache[nationName]: del g_config.outfitCache[nationName] loadJson(g_config.ID, 'outfitCache', g_config.outfitCache, g_config.configPath, True) if cart.totalPrice != ITEM_PRICE_EMPTY: msgCtx = {'money': formatPrice(cart.totalPrice.price), 'count': cart.numSelected} SystemMessages.pushMessage(g_config.i18n['UI_flashCol_applied_money'] % msgCtx, type=CURRENCY_TO_SM_TYPE.get(cart.totalPrice.getCurrency(byWeight=True), SM_TYPE.PurchaseForGold)) else: SystemMessages.pushI18nMessage(MESSENGER.SERVICECHANNELMESSAGES_SYSMSG_CONVERTER_CUSTOMIZATIONS, type=SM_TYPE.Information) self.__onCacheResync() self.itemsCache.onSyncCompleted += self.__onCacheResync
def _getSysMsgType(self): return CURRENCY_TO_SM_TYPE.get(self.item.buyPrice.getCurrency(byWeight=False), SM_TYPE.Information)
def __getSysMsgType(self, price): return CURRENCY_TO_SM_TYPE.get(price.getCurrency(byWeight=False), SM_TYPE.Information)
def _getSuccessMsgType(self): return CURRENCY_TO_SM_TYPE.get( self.__getPrice().getCurrency(byWeight=False), SM_TYPE.Information)
def __getSysMsgType(self): tmanCost = self.__getRecruitPrice(self.tmanCostTypeIdx) return CURRENCY_TO_SM_TYPE.get(tmanCost.getCurrency(byWeight=False), SM_TYPE.Information)
def buyAndExit(self, purchaseItems): self.itemsCache.onSyncCompleted -= self.__onCacheResync cart = getTotalPurchaseInfo(purchaseItems) 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()} results = [] 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() 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) errorCount = 0 for result in results: if not result.success: errorCount += 1 if result.userMsg: SystemMessages.pushI18nMessage(result.userMsg, type=result.sysMsgType) if not errorCount: if cart.totalPrice != ITEM_PRICE_EMPTY: msgCtx = {'money': formatPrice(cart.totalPrice.price), 'count': cart.numSelected} SystemMessages.pushI18nMessage(MESSENGER.SERVICECHANNELMESSAGES_SYSMSG_CONVERTER_CUSTOMIZATIONSBUY, type=CURRENCY_TO_SM_TYPE.get(cart.totalPrice.getCurrency(byWeight=True), SM_TYPE.PurchaseForGold), **msgCtx) else: SystemMessages.pushI18nMessage(MESSENGER.SERVICECHANNELMESSAGES_SYSMSG_CONVERTER_CUSTOMIZATIONS, type=SM_TYPE.Information) self.__onConfirmCloseWindow(proceed=True) else: self.__onCacheResync() self.itemsCache.onSyncCompleted += self.__onCacheResync
def _successHandler(self, code, ctx=None): sysMsgType = CURRENCY_TO_SM_TYPE.get(self.buyCurrency, SM_TYPE.PurchaseForCredits) return makeI18nSuccess(self._formMessage('success'), type=sysMsgType, **self._getMsgCtx())
def _getSuccessMsgType(self): return CURRENCY_TO_SM_TYPE.get(self.__getPrice().getCurrency(), SM_TYPE.PurchaseForCredits)
def _getSysMsgType(price): return CURRENCY_TO_SM_TYPE.get(price.getCurrency(byWeight=False), SM_TYPE.Information)
def _getSysMsgType(self): """ :return: <str> system message type """ return CURRENCY_TO_SM_TYPE.get(self.rentPrice.getCurrency(byWeight=False), SM_TYPE.Information)