Esempio n. 1
0
 def _successHandler(self, code, ctx=None):
     restoreInfo = ''
     sellForGold = self.vehicle.getSellPrice(preferred=True).getCurrency(byWeight=True) == Currency.GOLD
     if self.vehicle.isPremium and not self.vehicle.isUnique and not self.vehicle.isUnrecoverable and self.__lobbyContext.getServerSettings().isVehicleRestoreEnabled() and not sellForGold:
         timeKey, formattedTime = getTimeLeftInfo(self.itemsCache.items.shop.vehiclesRestoreConfig.restoreDuration)
         restoreInfo = backport.text(R.strings.system_messages.vehicle.restoreDuration.dyn(timeKey, R.invalid)(), time=formattedTime)
     additionalMsgs = []
     if self.__compensationRequired:
         additionalMsgs.append(makeCrewSkinCompensationMessage(self.__compensationAmount))
     if self.__hasPairModification:
         additionalMsgs.append(makeAllPairsDiscardMsg(self.vehicle.userName))
     g_tankActiveCamouflage[self.vehicle.intCD] = SeasonType.UNDEFINED
     msgCtx = {'vehName': self.vehicle.userName}
     if self.usedDemountKitsCount:
         msgCtx['countDK'] = self.usedDemountKitsCount
     if self.isDismantlingForMoney:
         msgCtx['gainMoney'] = formatPrice(self.gainMoney)
         msgCtx['spendMoney'] = formatPrice(self.spendMoney)
     else:
         msgCtx['money'] = formatPrice(self.gainMoney)
     if not self.isRemovedAfterRent:
         msgCtx['restoreInfo'] = restoreInfo
     sysMsgR = R.strings.system_messages.dyn('vehicle_remove' if self.isRemovedAfterRent else 'vehicle_sell', R.invalid)
     if sysMsgR:
         sysMsgR = sysMsgR.dyn('success_dismantling' if self.isDismantlingForMoney else 'success', R.invalid)
     if sysMsgR and self.usedDemountKitsCount:
         sysMsgR = sysMsgR.dyn('with_demount_kit', R.invalid)
     if self.isRemovedAfterRent:
         smType = SM_TYPE.Remove
     elif sellForGold:
         smType = SM_TYPE.SellingForGold
     else:
         smType = SM_TYPE.Selling
     return makeSuccess(userMsg=backport.text(sysMsgR(), **msgCtx), msgType=smType, auxData=additionalMsgs)
Esempio n. 2
0
    def _successHandler(self, code, ctx=None):
        additionalMessages = []
        if ctx.get('shells', []):
            totalPrice = MONEY_UNDEFINED
            for shellCompDescr, price, count in ctx.get('shells', []):
                price = Money.makeFromMoneyTuple(price)
                shell = self.itemsCache.items.getItemByCD(shellCompDescr)
                additionalMessages.append(
                    makeI18nSuccess('shell_buy/success',
                                    name=shell.userName,
                                    count=count,
                                    money=formatPrice(price),
                                    type=self._getSysMsgType(price)))
                totalPrice += price

            additionalMessages.append(
                makeI18nSuccess('layout_apply/success_money_spent',
                                money=formatPrice(totalPrice),
                                type=self._getSysMsgType(totalPrice)))
        if ctx.get('eqs', []):
            for eqCompDescr, price, count in ctx.get('eqs', []):
                price = Money.makeFromMoneyTuple(price)
                equipment = self.itemsCache.items.getItemByCD(eqCompDescr)
                additionalMessages.append(
                    makeI18nSuccess('artefact_buy/success',
                                    kind=equipment.userType,
                                    name=equipment.userName,
                                    count=count,
                                    money=formatPrice(price),
                                    type=self._getSysMsgType(price)))

        return makeSuccess(auxData=additionalMessages)
Esempio n. 3
0
 def _successHandler(self, code, ctx=None):
     restoreInfo = ''
     sellForGold = self.vehicle.getSellPrice(preferred=True).getCurrency(
         byWeight=True) == Currency.GOLD
     if self.vehicle.isPremium and not self.vehicle.isUnique and not self.vehicle.isUnrecoverable and self.lobbyContext.getServerSettings(
     ).isVehicleRestoreEnabled() and not sellForGold:
         timeKey, formattedTime = getTimeLeftInfo(
             self.itemsCache.items.shop.vehiclesRestoreConfig.
             restoreDuration)
         restoreInfo = makeString(
             '#system_messages:vehicle/restoreDuration/%s' % timeKey,
             time=formattedTime)
     if self.isDismantlingForMoney:
         localKey = 'vehicle_sell/success_dismantling'
         smType = SM_TYPE.Selling
         if self.isRemovedAfterRent:
             localKey = 'vehicle_remove/success_dismantling'
             smType = SM_TYPE.Remove
         return makeI18nSuccess(localKey,
                                vehName=self.vehicle.userName,
                                gainMoney=formatPrice(self.gainMoney),
                                spendMoney=formatPrice(self.spendMoney),
                                restoreInfo=restoreInfo,
                                type=smType)
     else:
         localKey = 'vehicle_sell/success'
         smType = SM_TYPE.Selling
         if self.isRemovedAfterRent:
             localKey = 'vehicle_remove/success'
             smType = SM_TYPE.Remove
         return makeI18nSuccess(localKey,
                                vehName=self.vehicle.userName,
                                money=formatPrice(self.gainMoney),
                                restoreInfo=restoreInfo,
                                type=smType)
Esempio n. 4
0
 def _successHandler(self, code, ctx=None):
     return makeI18nSuccess(
         "exchange/success",
         gold=BigWorld.wg_getGoldFormat(self.gold),
         credits=formatPrice((self.credits, 0)),
         type=SM_TYPE.FinancialTransactionWithGold,
     )
 def _getMsgCtx(self):
     price = self.__getPrice(
     ).price if self.__responsePrice is None else self.__responsePrice
     return {
         'vehName': self._vehicle.userName,
         'money': formatPrice(price, ignoreZeros=True)
     }
 def _successHandler(self, code, ctx=None):
     msgType = self.__getTankmanSysMsgType(self.dropSkillCostIdx)
     price = self.itemsCache.items.shop.dropSkillsCost.get(
         self.dropSkillCostIdx)
     return makeI18nSuccess('drop_tankman_skill/success',
                            money=formatPrice(Money(**price)),
                            type=msgType)
Esempio n. 7
0
 def _successHandler(self, code, ctx=None):
     price = self.__getSlotPrice()
     if price:
         money = formatPrice(price)
     else:
         money = formatGoldPrice(price.gold)
     return makeI18nSuccess(sysMsgKey='vehicle_slot_buy/success', money=money, type=SM_TYPE.FinancialTransactionWithGold)
Esempio n. 8
0
 def _successHandler(self, code, ctx=None):
     msgType = SM_TYPE.FinancialTransactionWithGold
     vehicle = self.itemsCache.items.getItemByCD(self.__vehTypeCompDescr)
     additionalMsgs = []
     if self.__compensationRequired:
         additionalMsgs.append(
             makeCrewSkinCompensationMessage(
                 self.__compensationPriceObject))
     if ctx == EQUIP_TMAN_CODE.OK:
         additionalMsgs.append(
             makeI18nSuccess(sysMsgKey='change_tankman_role/installed',
                             vehicle=vehicle.shortUserName))
     elif ctx == EQUIP_TMAN_CODE.NO_FREE_SLOT:
         roleStr = Tankman.getRoleUserName(SKILL_NAMES[self.__roleIdx])
         additionalMsgs.append(
             makeI18nSuccess(sysMsgKey='change_tankman_role/slot_is_taken',
                             vehicle=vehicle.shortUserName,
                             role=roleStr))
     else:
         additionalMsgs.append(
             makeI18nSuccess(sysMsgKey='change_tankman_role/no_vehicle'))
     return makeI18nSuccess('change_tankman_role/success',
                            money=formatPrice(
                                Money(gold=self.__changeRoleCost)),
                            type=msgType,
                            auxData=additionalMsgs)
Esempio n. 9
0
 def _successHandler(self, code, ctx = None):
     price = self.__getSlotPrice()
     if price == ZERO_MONEY:
         money = formatGoldPrice(price.gold)
     else:
         money = formatPrice(price)
     return makeI18nSuccess('vehicle_slot_buy/success', money=money, type=SM_TYPE.FinancialTransactionWithGold)
Esempio n. 10
0
 def _errorHandler(self, code, errStr='', ctx=None):
     needed = Money(credits=self._repairCost.credits -
                    self.itemsCache.items.stats.credits)
     return makeI18nError('vehicle_repair/%s' % errStr,
                          defaultSysMsgKey='vehicle_repair/server_error',
                          vehName=self.item.userName,
                          needed=formatPrice(needed))
Esempio n. 11
0
 def _successHandler(self, code, ctx = None):
     tmanCost = self.__getRecruitPrice(self.tmanCostTypeIdx)
     prefix = self.__getSysMsgPrefix()
     sysMsgType = _getSysMsgType(tmanCost)
     if tmanCost:
         return makeI18nSuccess('%s/financial_success' % prefix, price=formatPrice(tmanCost), type=sysMsgType, auxData=ctx)
     return makeI18nSuccess('%s/success' % prefix, type=sysMsgType, auxData=ctx)
Esempio n. 12
0
 def _getMsgCtx(self):
     return {
         'itemType': self.item.userType,
         'itemName': self.item.userName,
         'count': BigWorld.wg_getIntegralFormat(int(self.count)),
         'money': formatPrice(self._getTotalPrice())
     }
Esempio n. 13
0
 def _getMsgCtx(self):
     return {
         'name': self.item.userName,
         'kind': self.item.userType,
         'count': BigWorld.wg_getIntegralFormat(int(self.count)),
         'money': formatPrice(self._getOpPrice().price)
     }
Esempio n. 14
0
 def _getMsgCtx(self):
     return {
         "name": self.item.userName,
         "kind": self.item.userType,
         "count": BigWorld.wg_getIntegralFormat(int(self.count)),
         "money": formatPrice(self._getOpPrice()),
     }
Esempio n. 15
0
 def __init__(self, tankman, vehicle, tmanCostTypeIdx):
     hasUndistributedExp = False
     isGoldPrice = tmanCostTypeIdx == 2
     if not isGoldPrice:
         canLearnSkills, lastSkillLevel = tankman.newSkillCount
         hasUndistributedExp = lastSkillLevel > 0 or canLearnSkills > 1
     self.vehicle = vehicle
     self.tmanCostTypeIdx = tmanCostTypeIdx
     self.tmanCost = self._getRecruitPrice(self.tmanCostTypeIdx)
     ctx = {'tankname': vehicle.userName}
     if isGoldPrice:
         ctx['price'] = formatPrice(self.tmanCost,
                                    reverse=True,
                                    useIcon=True,
                                    useStyle=True)
     super(TankmanRetraining, self).__init__(
         tankman,
         (plugins.VehicleValidator(
             vehicle, False), plugins.TankmanLockedValidator(tankman),
          plugins.VehicleCrewLockedValidator(vehicle),
          plugins.MessageConfirmator('tankmanRetraining/knownVehicleByGold',
                                     ctx=ctx,
                                     isEnabled=vehicle.isInInventory
                                     and isGoldPrice),
          plugins.MessageConfirmator(
              'tankmanRetraining/unknownVehicleByGold',
              ctx=ctx,
              isEnabled=not vehicle.isInInventory and isGoldPrice),
          plugins.MessageConfirmator('tankmanRetraining/unknownVehicle',
                                     ctx=ctx,
                                     isEnabled=not vehicle.isInInventory
                                     and not isGoldPrice),
          plugins.MessageConfirmator('tankmanRetraining/undistributedExp',
                                     ctx=ctx,
                                     isEnabled=hasUndistributedExp)))
    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):
     sysMsgType = _getSysMsgType(self.tmanCost)
     return makeI18nSuccess(
         'retraining_tankman/financial_success',
         price=formatPrice(self.tmanCost),
         type=sysMsgType,
         auxData=ctx) if self.tmanCost else makeI18nSuccess(
             'retraining_tankman/success', type=sysMsgType, auxData=ctx)
 def _successHandler(self, code, ctx=None):
     tmanCost = self.__getRecruitPrice(self.tmanCostTypeIdx)
     return makeI18nSuccess('recruit_window/financial_success',
                            price=formatPrice(tmanCost),
                            type=self.__getSysMsgType(),
                            auxData=ctx) if tmanCost else makeI18nSuccess(
                                'recruit_window/success',
                                type=self.__getSysMsgType(),
                                auxData=ctx)
 def _getMsgCtx(self):
     price = self.__getPrice(
     ).price if self.__responsePrice is None else self.__responsePrice
     return {
         'name': self._item.userName,
         'kind': self._item.userType,
         'count': backport.getIntegralFormat(int(self.__count)),
         'money': formatPrice(price, ignoreZeros=True)
     }
 def __requestConfirmation(self):
     return DialogsInterface.showDialog(meta=I18nConfirmDialogMeta(
         key='buyConfirmation',
         messageCtx={
             'product': self.__packTitle or '"This Pack"',
             'price': formatPrice(
                 self.__packPrice, reverse=True, useIcon=True)
         },
         focusedID=DIALOG_BUTTON_ID.SUBMIT))
Esempio n. 21
0
 def _successHandler(self, code, ctx=None):
     """
     :param code: <int> server response code
     :param ctx: <obj> localization context
     :return: <ResultMsg> success message
     """
     return makeI18nSuccess('vehicle_restore/success',
                            vehName=self.item.userName,
                            price=formatPrice(self.price),
                            type=self._getSysMsgType())
 def _successHandler(self, code, ctx=None):
     restoreInfo = ''
     sellForGold = self.vehicle.getSellPrice(preferred=True).getCurrency(
         byWeight=True) == Currency.GOLD
     if self.vehicle.isPremium and not self.vehicle.isUnique and not self.vehicle.isUnrecoverable and self.lobbyContext.getServerSettings(
     ).isVehicleRestoreEnabled() and not sellForGold:
         timeKey, formattedTime = getTimeLeftInfo(
             self.itemsCache.items.shop.vehiclesRestoreConfig.
             restoreDuration)
         restoreInfo = makeString(
             '#system_messages:vehicle/restoreDuration/{}'.format(timeKey),
             time=formattedTime)
     compMsg = None
     if self.__compensationRequired:
         compMsg = makeCrewSkinCompensationMessage(
             self.__compensationAmount)
     g_tankActiveCamouflage[self.vehicle.intCD] = SeasonType.UNDEFINED
     makeMsg = partial(makeI18nSuccess,
                       vehName=self.vehicle.userName,
                       auxData=compMsg)
     if self.usedDemountKitsCount:
         makeMsg = partial(makeMsg, countDK=self.usedDemountKitsCount)
     if self.isDismantlingForMoney:
         makeMsg = partial(makeMsg,
                           gainMoney=formatPrice(self.gainMoney),
                           spendMoney=formatPrice(self.spendMoney))
     else:
         makeMsg = partial(makeMsg, money=formatPrice(self.gainMoney))
     if not self.isRemovedAfterRent:
         makeMsg = partial(makeMsg, restoreInfo=restoreInfo)
     sysMsgKey = '{}{}{}'.format(
         'vehicle_remove' if self.isRemovedAfterRent else 'vehicle_sell',
         '/success_dismantling'
         if self.isDismantlingForMoney else '/success',
         '/with_demount_kit' if self.usedDemountKitsCount else '')
     if self.isRemovedAfterRent:
         smType = SM_TYPE.Remove
     elif sellForGold:
         smType = SM_TYPE.SellingForGold
     else:
         smType = SM_TYPE.Selling
     return makeMsg(sysMsgKey=sysMsgKey, type=smType)
Esempio n. 23
0
 def _successHandler(self, code, ctx = None):
     msgType = SM_TYPE.FinancialTransactionWithGold
     vehicle = g_itemsCache.items.getItemByCD(self.__vehTypeCompDescr)
     if ctx == EQUIP_TMAN_CODE.OK:
         auxData = makeI18nSuccess('change_tankman_role/installed', vehicle=vehicle.shortUserName)
     elif ctx == EQUIP_TMAN_CODE.NO_FREE_SLOT:
         roleStr = Tankman.getRoleUserName(SKILL_NAMES[self.__roleIdx])
         auxData = makeI18nSuccess('change_tankman_role/slot_is_taken', vehicle=vehicle.shortUserName, role=roleStr)
     else:
         auxData = makeI18nSuccess('change_tankman_role/no_vehicle')
     return makeI18nSuccess('change_tankman_role/success', money=formatPrice(Money(gold=self.__changeRoleCost)), type=msgType, auxData=auxData)
 def __buyRequestConfirmation(self, key='buyConfirmation'):
     product = self.__title if self.__couponInfo is None else g_currentPreviewVehicle.item.shortUserName
     return DialogsInterface.showDialog(meta=I18nConfirmDialogMeta(
         key=key,
         messageCtx={
             'product':
             product,
             'price':
             formatPrice(self.__getPackPrice(), reverse=True, useIcon=True)
         },
         focusedID=DIALOG_BUTTON_ID.SUBMIT))
Esempio n. 25
0
 def _successHandler(self, code, ctx=None):
     tmanCost = self._getRecruitPrice(self.tmanCostTypeIdx)
     sysMsgType = _getSysMsgType(tmanCost)
     if tmanCost:
         return makeI18nSuccess('retraining_tankman/financial_success',
                                price=formatPrice(tmanCost),
                                type=sysMsgType,
                                auxData=ctx)
     return makeI18nSuccess('retraining_tankman/success',
                            type=sysMsgType,
                            auxData=ctx)
Esempio n. 26
0
 def _successHandler(self, code, ctx = None):
     msgType = SM_TYPE.FinancialTransactionWithGold
     vehicle = g_itemsCache.items.getItemByCD(self.__vehTypeCompDescr)
     if ctx == EQUIP_TMAN_CODE.OK:
         auxData = makeI18nSuccess('change_tankman_role/installed', vehicle=vehicle.shortUserName)
     elif ctx == EQUIP_TMAN_CODE.NO_FREE_SLOT:
         roleStr = Tankman.getRoleUserName(SKILL_NAMES[self.__roleIdx])
         auxData = makeI18nSuccess('change_tankman_role/slot_is_taken', vehicle=vehicle.shortUserName, role=roleStr)
     else:
         auxData = makeI18nSuccess('change_tankman_role/no_vehicle')
     return makeI18nSuccess('change_tankman_role/success', money=formatPrice((0, self.__changeRoleCost)), type=msgType, auxData=auxData)
Esempio n. 27
0
 def __onBuyForDynamicCurrency(self, productName):
     currency, priceVal = first(
         ((c, v) for c, v in self.__dynPrice.iteritems()))
     priceStr = formatPrice({currency: priceVal},
                            currency=currency,
                            reverse=True,
                            useIcon=True)
     requestConfirmed = yield _buyRequestConfirmation(productName, priceStr)
     if requestConfirmed:
         if _mayObtainForDynCurrency(
                 currency, priceVal) and currency in _BUY_PRODUCT_USING_DYN:
             _BUY_PRODUCT_USING_DYN[currency](self.__buyParams)
Esempio n. 28
0
 def _successHandler(self, code, ctx=None):
     tmanCost = self.__getRecruitPrice(self.tmanCostTypeIdx)
     prefix = self.__getSysMsgPrefix()
     sysMsgType = _getSysMsgType(tmanCost)
     return makeI18nSuccess(
         sysMsgKey='{}/financial_success'.format(prefix),
         auxData=ctx,
         price=formatPrice(tmanCost, useStyle=True),
         type=sysMsgType) if tmanCost else makeI18nSuccess(
             sysMsgKey='{}/success'.format(prefix),
             auxData=ctx,
             type=sysMsgType)
 def _successHandler(self, code, ctx=None):
     crewMembersCount = len(self.tankmen)
     messagePrefix = 'retraining_crew'
     if crewMembersCount == 1:
         messagePrefix = 'retraining_tankman'
     crewRetrainingCost = self._getRecruitPrice(self.tmanCostTypeIdx)
     sysMsgType = _getSysMsgType(crewRetrainingCost)
     return makeI18nSuccess(
         '%s/financial_success' % messagePrefix,
         type=sysMsgType,
         auxData=ctx,
         price=formatPrice(crewRetrainingCost)
     ) if crewRetrainingCost else makeI18nSuccess(
         '%s/success' % messagePrefix, type=sysMsgType, auxData=ctx)
    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
Esempio n. 31
0
 def _getMsgCtx(self):
     styleItemType = backport.text(
         R.strings.item_types.customization.style())
     return {
         'itemType':
         styleItemType if self.item.itemTypeID == GUI_ITEM_TYPE.STYLE else
         self.item.userType,
         'itemName':
         self.item.userName,
         'count':
         backport.getIntegralFormat(int(self.count)),
         'money':
         formatPrice(self._getTotalPrice())
     }
Esempio n. 32
0
 def _successHandler(self, code, ctx = None):
     if self.isDismantlingForGold:
         localKey = 'vehicle_sell/success_dismantling'
         smType = SM_TYPE.Selling
         if self.isRemovedAfterRent:
             localKey = 'vehicle_remove/success_dismantling'
             smType = SM_TYPE.Remove
         return makeI18nSuccess(localKey, vehName=self.vehicle.userName, gainMoney=formatPrice(self.gainMoney), spendMoney=formatPrice(self.spendMoney), type=smType)
     else:
         localKey = 'vehicle_sell/success'
         smType = SM_TYPE.Selling
         if self.isRemovedAfterRent:
             localKey = 'vehicle_remove/success'
             smType = SM_TYPE.Remove
         return makeI18nSuccess(localKey, vehName=self.vehicle.userName, money=formatPrice(self.gainMoney), type=smType)
Esempio n. 33
0
 def _buyResponse(self, code, callback):
     LOG_DEBUG('Server response on buy battle booster', code)
     if code < 0:
         return callback(self._errorHandler(code))
     price = self.battleBooster.getBuyPrice().price
     price *= self.count
     message = makeI18nSuccess('battleBooster_buy/success',
                               kind=self.battleBooster.userType,
                               name=self.battleBooster.userName,
                               count=self.count,
                               money=formatPrice(price),
                               type=self._getSysMsgType(price))
     SystemMessages.pushI18nMessage(message.userMsg,
                                    type=message.sysMsgType)
     super(BuyAndInstallBattleBoosterProcessor, self)._request(callback)
Esempio n. 34
0
 def __init__(self,
              intCD,
              rentType,
              nums=(0, ),
              price=MONEY_UNDEFINED,
              seasonType=0,
              renew=False):
     key = 'rentConfirmationRenew' if renew else 'rentConfirmation'
     super(RentConfirmDialogMeta,
           self).__init__(key,
                          scope=ScopeTemplates.LOBBY_SUB_SCOPE,
                          focusedID=DIALOG_BUTTON_ID.SUBMIT)
     vehicle = self.itemsCache.items.getItemByCD(intCD)
     if rentType == RentType.SEASON_CYCLE_RENT:
         if len(nums) > 1:
             key = 'cycles'
             indexes = [
                 self.epicController.getCycleOrdinalNumber(int(n))
                 for n in nums
             ]
             indexes = '{}-{}'.format(min(indexes), max(indexes))
         else:
             key = 'cycle'
             indexes = str(
                 self.epicController.getCycleOrdinalNumber(int(nums[0])))
     elif RentType.SEASON_RENT:
         key = 'season'
         _, endTimestamp = self.epicController.getSeasonTimeRange()
         indexes = str(getTimeStructInLocal(endTimestamp).tm_year)
     else:
         key = ''
         indexes = str(None)
         _logger.debug(
             'GameSeasonType %s with RentType %s is not supported',
             seasonType, rentType)
     stage = backport.text(
         R.strings.vehicle_preview.buyingPanel.offer.rent.name.dyn(key)(),
         value=indexes)
     event = backport.text(R.strings.arenas.type.epic.name.inQuotes())
     period = backport.text(R.strings.dialogs.rentConfirmation.period(),
                            stage=stage or 'Stage',
                            event=event or 'Event')
     self._messageCtx = {
         'name': vehicle.shortUserName or 'Vehicle',
         'period': text_styles.stats(period),
         'price': formatPrice(price, reverse=True, useIcon=True)
     }
     return
Esempio n. 35
0
 def __onBuyForOrdinaryCurrency(self, productName):
     money = Money(**self.__ordPrice)
     if not mayObtainForMoney(money) and mayObtainWithMoneyExchange(money):
         isOk, _ = yield DialogsInterface.showDialog(
             ExchangeCreditsWebProductMeta(productName, 1, money.credits))
         if isOk:
             self.__onBuyForOrdinaryCurrency(productName)
             return
         return
     priceStr = formatPrice(money, reverse=True, useIcon=True)
     requestConfirmed = yield _buyRequestConfirmation(productName, priceStr)
     if requestConfirmed:
         if mayObtainForMoney(money):
             showBuyProductOverlay(self.__buyParams)
         elif money.gold > self.__itemsCache.items.stats.gold:
             showBuyGoldForBundle(money.gold, self.__buyParams)
Esempio n. 36
0
 def _successHandler(self, code, ctx = None):
     restoreInfo = ''
     if self.vehicle.isPremium and not self.vehicle.isUnique and not self.vehicle.isUnrecoverable and g_lobbyContext.getServerSettings().isVehicleRestoreEnabled() and not self.vehicle.sellForGold:
         timeKey, formattedTime = getTimeLeftInfo(g_itemsCache.items.shop.vehiclesRestoreConfig.restoreDuration)
         restoreInfo = makeString('#system_messages:vehicle/restoreDuration/%s' % timeKey, time=formattedTime)
     if self.isDismantlingForGold:
         localKey = 'vehicle_sell/success_dismantling'
         smType = SM_TYPE.Selling
         if self.isRemovedAfterRent:
             localKey = 'vehicle_remove/success_dismantling'
             smType = SM_TYPE.Remove
         return makeI18nSuccess(localKey, vehName=self.vehicle.userName, gainMoney=formatPrice(self.gainMoney), spendMoney=formatPrice(self.spendMoney), restoreInfo=restoreInfo, type=smType)
     else:
         localKey = 'vehicle_sell/success'
         smType = SM_TYPE.Selling
         if self.isRemovedAfterRent:
             localKey = 'vehicle_remove/success'
             smType = SM_TYPE.Remove
         return makeI18nSuccess(localKey, vehName=self.vehicle.userName, money=formatPrice(self.gainMoney), restoreInfo=restoreInfo, type=smType)
Esempio n. 37
0
 def _successHandler(self, code, ctx = None):
     if self.isFemale:
         goldPrice = g_itemsCache.items.shop.passportFemaleChangeCost
     else:
         goldPrice = g_itemsCache.items.shop.passportChangeCost
     return makeI18nSuccess('replace_tankman/success', money=formatPrice((0, goldPrice)), type=SM_TYPE.PurchaseForGold)
Esempio n. 38
0
 def _successHandler(self, code, ctx = None):
     return makeI18nSuccess('vehicle_slot_buy/success', money=formatPrice(self.__getSlotPrice()), type=SM_TYPE.FinancialTransactionWithGold)
Esempio n. 39
0
 def _successHandler(self, code, ctx = None):
     return makeI18nSuccess('vehicle_buy/success', vehName=self.item.userName, price=formatPrice(self.price), type=self._getSysMsgType())
Esempio n. 40
0
 def _successHandler(self, code, ctx = None):
     """
     :param code: <int> server response code
     :param ctx: <obj> localization context
     :return: <ResultMsg> success message
     """
     return makeI18nSuccess('vehicle_restore/success', vehName=self.item.userName, price=formatPrice(self.price), type=self._getSysMsgType())
Esempio n. 41
0
 def _getMsgCtx(self):
     return {'name': self.item.userName,
      'kind': self.item.userType,
      'count': BigWorld.wg_getIntegralFormat(int(self.count)),
      'money': formatPrice(self._getOpPrice())}
Esempio n. 42
0
 def _successHandler(self, code, ctx = None):
     tmanCost = self._getRecruitPrice(self.tmanCostTypeIdx)
     sysMsgType = _getSysMsgType(tmanCost)
     if tmanCost:
         return makeI18nSuccess('retraining_tankman/financial_success', price=formatPrice(tmanCost), type=sysMsgType, auxData=ctx)
     return makeI18nSuccess('retraining_tankman/success', type=sysMsgType, auxData=ctx)
Esempio n. 43
0
 def _successHandler(self, code, ctx = None):
     return makeI18nSuccess('vehicle_repair/success', vehName=self.item.userName, money=formatPrice(self._repairCost), type=SM_TYPE.Repair)
Esempio n. 44
0
 def _successHandler(self, code, ctx = None):
     msgType = self.__getTankmanSysMsgType(self.dropSkillCostIdx)
     price = g_itemsCache.items.shop.dropSkillsCost.get(self.dropSkillCostIdx)
     return makeI18nSuccess('drop_tankman_skill/success', money=formatPrice((price['credits'], price['gold'])), type=msgType)
Esempio n. 45
0
 def _errorHandler(self, code, errStr = '', ctx = None):
     if len(errStr):
         needed = Money(credits=self._repairCost.credits - g_itemsCache.items.stats.credits)
         return makeI18nError('vehicle_repair/%s' % errStr, vehName=self.item.userName, needed=formatPrice(needed))
     return makeI18nError('vehicle_repair/server_error', vehName=self.item.userName)
Esempio n. 46
0
 def _getMsgCtx(self):
     return {'boosterName': self.booster.userName,
      'count': BigWorld.wg_getIntegralFormat(int(self.count)),
      'money': formatPrice(self._getOpPrice())}
Esempio n. 47
0
 def _successHandler(self, code, ctx = None):
     crewMembersCount = len(self.tankmen)
     messagePrefix = 'retraining_crew'
     if crewMembersCount == 1:
         messagePrefix = 'retraining_tankman'
     crewRetrainingCost = self._getRecruitPrice(self.tmanCostTypeIdx)
     if crewRetrainingCost[0] > 0 or crewRetrainingCost[1] > 0:
         return makeI18nSuccess('%s/financial_success' % messagePrefix, type=self._getSysMsgType(), auxData=ctx, price=formatPrice(crewRetrainingCost))
     return makeI18nSuccess('%s/success' % messagePrefix, type=self._getSysMsgType(), auxData=ctx)
Esempio n. 48
0
 def _successHandler(self, code, ctx = None):
     tmanCost = self.__getRecruitPrice(self.tmanCostTypeIdx)
     if tmanCost[0] > 0 or tmanCost[1] > 0:
         return makeI18nSuccess('recruit_window/financial_success', price=formatPrice(tmanCost), type=self.__getSysMsgType(), auxData=ctx)
     return makeI18nSuccess('recruit_window/success', type=self.__getSysMsgType(), auxData=ctx)
Esempio n. 49
0
 def _successHandler(self, code, ctx = None):
     return makeI18nSuccess('buy_tankmen_berths/success', money=formatPrice(self.berthsPrice), type=SM_TYPE.PurchaseForGold)
Esempio n. 50
0
    def _successHandler(self, code, ctx = None):
        additionalMessages = []
        if len(ctx.get('shells', [])):
            totalPrice = ZERO_MONEY
            for shellCompDescr, price, count in ctx.get('shells', []):
                price = Money(*price)
                shell = g_itemsCache.items.getItemByCD(shellCompDescr)
                additionalMessages.append(makeI18nSuccess('shell_buy/success', name=shell.userName, count=count, money=formatPrice(price), type=self.__getSysMsgType(price)))
                totalPrice += price

            additionalMessages.append(makeI18nSuccess('layout_apply/success_money_spent', money=formatPrice(totalPrice), type=self.__getSysMsgType(totalPrice)))
        if len(ctx.get('eqs', [])):
            for eqCompDescr, price, count in ctx.get('eqs', []):
                price = Money(*price)
                equipment = g_itemsCache.items.getItemByCD(eqCompDescr)
                additionalMessages.append(makeI18nSuccess('artefact_buy/success', kind=equipment.userType, name=equipment.userName, count=count, money=formatPrice(price), type=self.__getSysMsgType(price)))

        return makeSuccess(auxData=additionalMessages)