Ejemplo n.º 1
0
 def __init__(self, vehicle, item, slotIdx, gunCompDescr, conflictedEqs=None, skipConfirm=False):
     self.__vehInvID = vehicle.invID
     self.__slotIdx = int(slotIdx)
     self.__gunCompDescr = gunCompDescr
     self.__vehicle = vehicle
     conflictedEqs = conflictedEqs or tuple()
     conflictMsg = ''
     if conflictedEqs:
         self.__makeConflictMsg("', '".join([ eq.userName for eq in conflictedEqs ]))
     self.__mayInstall, installReason = item.mayInstall(vehicle, slotIdx)
     super(BuyAndInstallItemProcessor, self).__init__(item, 1, Currency.CREDITS)
     self.addPlugins([plugins.ModuleValidator(item)])
     if self.__mayInstall:
         self.addPlugins([plugins.VehicleValidator(vehicle, True, prop={'isBroken': True,
           'isLocked': True}), plugins.CompatibilityInstallValidator(vehicle, item, slotIdx), plugins.ModuleBuyerConfirmator('confirmBuyAndInstall', ctx={'userString': item.userName,
           'typeString': self.item.userType,
           'conflictedEqs': conflictMsg,
           'currencyIcon': _getIconHtmlTagForCurrency(self._currency),
           'value': _formatCurrencyValue(self._currency, self._getOpPrice().price.get(self._currency))}, isEnabled=not skipConfirm)])
         if item.itemTypeID == GUI_ITEM_TYPE.TURRET:
             self.addPlugin(plugins.TurretCompatibilityInstallValidator(vehicle, item, self.__gunCompDescr))
         elif item.itemTypeID == GUI_ITEM_TYPE.OPTIONALDEVICE:
             removalPrice = item.getRemovalPrice(self.itemsCache.items)
             self.addPlugin(plugins.MessageConfirmator('installConfirmationNotRemovable_%s' % removalPrice.price.getCurrency(), ctx={'name': item.userName}, isEnabled=not item.isRemovable and not skipConfirm))
         self.addPlugin(plugins.MessageConfirmator('removeIncompatibleEqs', ctx={'name': "', '".join([ eq.userName for eq in conflictedEqs ])}, isEnabled=bool(conflictedEqs) and not skipConfirm))
     else:
         self.addPlugins([plugins.ModuleBuyerConfirmator('confirmBuyNotInstall', ctx={'userString': item.userName,
           'typeString': self.item.userType,
           'currencyIcon': _getIconHtmlTagForCurrency(self._currency),
           'value': _formatCurrencyValue(self._currency, self._getOpPrice().price.get(self._currency)),
           'reason': self.__makeInstallReasonMsg(installReason)}, isEnabled=not skipConfirm)])
Ejemplo n.º 2
0
def _getUniqueVehicleSellConfirmator(vehicle, lobbyContext=None):
    """
    return confirmation plugin for unique vehicle
    :param vehicle: <Vehicle>
    :return: <MessageConfirmator>
    """
    sellForGold = vehicle.getSellPrice(preferred=True).getCurrency(
        byWeight=True) == Currency.GOLD
    if lobbyContext is not None and lobbyContext.getServerSettings(
    ).isVehicleRestoreEnabled(
    ) and not sellForGold and not vehicle.isUnrecoverable:
        if vehicle.isRecentlyRestored():
            return plugins.MessageConfirmator(
                'vehicleSell/restoreCooldown',
                ctx={
                    'cooldown':
                    formatTime(
                        vehicle.restoreInfo.getRestoreCooldownTimeLeft(),
                        time_utils.ONE_DAY)
                },
                isEnabled=vehicle.isUnique)
        if vehicle.isPurchased:
            return plugins.MessageConfirmator('vehicleSell/restoreUnlimited',
                                              isEnabled=vehicle.isUnique)
    if vehicle.isCrewLocked:
        dialogI18n = 'vehicleSell/unique/crewLocked'
    else:
        dialogI18n = 'vehicleSell/unique'
    return plugins.MessageConfirmator(dialogI18n, isEnabled=vehicle.isUnique)
Ejemplo n.º 3
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)))
Ejemplo n.º 4
0
def _getUniqueVehicleSellConfirmator(vehicle):
    """
    return confirmation plugin for unique vehicle
    :param vehicle: <Vehicle>
    :return: <MessageConfirmator>
    """
    if g_lobbyContext.getServerSettings().isVehicleRestoreEnabled() and not vehicle.sellForGold and not vehicle.isUnrecoverable:
        if vehicle.isRecentlyRestored():
            return plugins.MessageConfirmator('vehicleSell/restoreCooldown', ctx={'cooldown': formatTime(vehicle.restoreInfo.getRestoreCooldownTimeLeft(), time_utils.ONE_DAY)}, isEnabled=vehicle.isUnique)
        if vehicle.isPurchased:
            return plugins.MessageConfirmator('vehicleSell/restoreUnlimited', isEnabled=vehicle.isUnique)
    return plugins.MessageConfirmator('vehicleSell/unique', isEnabled=vehicle.isUnique)
Ejemplo n.º 5
0
 def __init__(self, tankman, vehicle, tmanCostTypeIdx):
     hasUndistributedExp = False
     if tmanCostTypeIdx != 2:
         canLearnSkills, lastSkillLevel = tankman.newSkillCount
         hasUndistributedExp = lastSkillLevel > 0 or canLearnSkills > 1
     super(TankmanRetraining, self).__init__(tankman, (plugins.VehicleValidator(vehicle, False),
      plugins.TankmanLockedValidator(tankman),
      plugins.VehicleCrewLockedValidator(vehicle),
      plugins.MessageConfirmator('tankmanRetraining/unknownVehicle', ctx={'tankname': vehicle.userName}, isEnabled=not vehicle.isInInventory),
      plugins.MessageConfirmator('tankmanRetraining/undistributedExp', ctx={}, isEnabled=hasUndistributedExp)))
     self.vehicle = vehicle
     self.tmanCostTypeIdx = tmanCostTypeIdx
     self.tmanCost = self._getRecruitPrice(self.tmanCostTypeIdx)
 def __init__(self, tankman, firstNameID, firstNameGroup, lastNameID,
              lastNameGroup, iconID, iconGroup):
     hasUniqueData = self.__hasUniqueData(tankman, firstNameID, lastNameID,
                                          iconID)
     isFemale = tankman.descriptor.isFemale
     if isFemale:
         price = self.itemsCache.items.shop.passportFemaleChangeCost
     else:
         price = self.itemsCache.items.shop.passportChangeCost
     super(TankmanChangePassport, self).__init__(
         tankman,
         (plugins.TankmanChangePassportValidator(tankman),
          plugins.MessageConfirmator(
              'replacePassport/unique'
              if hasUniqueData else 'replacePassportConfirmation',
              ctx={
                  Currency.GOLD:
                  text_styles.concatStylesWithSpace(
                      text_styles.gold(BigWorld.wg_getGoldFormat(price)),
                      icons.makeImageTag(
                          RES_ICONS.MAPS_ICONS_LIBRARY_GOLDICON_2))
              })))
     self.firstNameID = firstNameID
     self.firstNameGroup = firstNameGroup
     self.lastNameID = lastNameID
     self.lastNameGroup = lastNameGroup
     self.iconID = iconID
     self.iconGroup = iconGroup
     self.isFemale = isFemale
     self.isPremium = tankman.descriptor.isPremium
     self.price = price
Ejemplo n.º 7
0
 def __init__(self,
              vehicle,
              item,
              itemType,
              install=True,
              conflictedEqs=None,
              plugs=tuple()):
     """
     Ctor.
     
     @param vehicle: vehicle
     @param item: equipment to install
     @param itemType: vehicle module type
     @param install: flag to designated process
     @param conflictedEqs: conflicted items
     @param plugs: plugins list
     """
     opType = 'apply' if install else 'remove'
     conflictedEqs = conflictedEqs or tuple()
     ModuleProcessor.__init__(self, item=item, opType=opType, plugs=plugs)
     VehicleItemProcessor.__init__(self,
                                   vehicle=vehicle,
                                   module=item,
                                   allowableTypes=itemType)
     if install:
         self.addPlugin(
             plugins.MessageConfirmator(
                 'removeIncompatibleEqs',
                 ctx={
                     'name':
                     "', '".join([eq.userName for eq in conflictedEqs])
                 },
                 isEnabled=bool(conflictedEqs)))
     self.install = install
Ejemplo n.º 8
0
 def __init__(self, vehicle, item, slotIdx, gunCompDescr, conflictedEqs=None, skipConfirm=False):
     self.__vehInvID = vehicle.invID
     self.__slotIdx = int(slotIdx)
     self.__gunCompDescr = gunCompDescr
     self.__vehicle = vehicle
     conflictedEqs = conflictedEqs or tuple()
     conflictMsg = ''
     if conflictedEqs:
         self.__makeConflictMsg("', '".join([ eq.userName for eq in conflictedEqs ]))
     self.__mayInstall, installReason = item.mayInstall(vehicle, slotIdx)
     super(BuyAndInstallItemProcessor, self).__init__(item, 1, Currency.CREDITS)
     self.addPlugins([plugins.ModuleValidator(item)])
     if self.__mayInstall:
         self.addPlugins([plugins.VehicleValidator(vehicle, True, prop={'isBroken': True,
           'isLocked': True}), plugins.CompatibilityInstallValidator(vehicle, item, slotIdx), self._confirmatorPluginCls('confirmBuyAndInstall', ctx=self._getItemConfirmationData(conflictMsg), isEnabled=not skipConfirm, item=self.item)])
         if item.itemTypeID == GUI_ITEM_TYPE.TURRET:
             self.addPlugin(plugins.TurretCompatibilityInstallValidator(vehicle, item, self.__gunCompDescr))
         self.addPlugin(plugins.MessageConfirmator('removeIncompatibleEqs', ctx={'name': "', '".join([ eq.userName for eq in conflictedEqs ]),
          'reason': _wrapHtmlMessage('incompatibleReason', backport.text(R.strings.dialogs.removeIncompatibleEqs.message.reason()))}, isEnabled=bool(conflictedEqs) and not skipConfirm))
     else:
         self.addPlugins([plugins.BuyAndStorageConfirmator('confirmBuyNotInstall', ctx={'userString': item.userName,
           'typeString': item.userType,
           'currencyIcon': _getIconHtmlTagForCurrency(self._currency),
           'value': _formatCurrencyValue(self._currency, self._getOpPrice().price.get(self._currency)),
           'reason': self.__makeInstallReasonMsg(installReason)}, isEnabled=not skipConfirm, item=item)])
Ejemplo n.º 9
0
 def __init__(self, showConfirm=True, showWarning=True):
     self.__hasDiscounts = bool(
         self.itemsCache.items.shop.personalSlotDiscounts)
     self.__frozenSlotPrice = None
     slotCost = self.__getSlotPrice()
     if self.__hasDiscounts and not slotCost:
         confirmationType = 'freeSlotConfirmation'
         ctx = {}
     else:
         confirmationType = 'buySlotConfirmation'
         ctx = {
             'goldCost':
             text_styles.concatStylesWithSpace(
                 text_styles.gold(str(slotCost.gold)),
                 icons.makeImageTag(
                     RES_ICONS.MAPS_ICONS_LIBRARY_GOLDICON_2))
         }
     super(VehicleSlotBuyer, self).__init__(
         (proc_plugs.MessageInformator(
             'buySlotNotEnoughCredits',
             activeHandler=lambda: not proc_plugs.MoneyValidator(
                 slotCost).validate().success,
             isEnabled=showWarning),
          proc_plugs.MessageConfirmator(confirmationType,
                                        isEnabled=showConfirm,
                                        ctx=ctx),
          proc_plugs.MoneyValidator(slotCost)))
     return
Ejemplo n.º 10
0
 def __init__(self,
              vehicle,
              item,
              itemType,
              install=True,
              conflictedEqs=None,
              plugs=tuple(),
              skipConfirm=False):
     opType = 'apply' if install else 'remove'
     conflictedEqs = conflictedEqs or tuple()
     ModuleProcessor.__init__(self, item=item, opType=opType, plugs=plugs)
     VehicleItemProcessor.__init__(self,
                                   vehicle=vehicle,
                                   module=item,
                                   allowableTypes=itemType)
     if install:
         self.addPlugin(
             plugins.MessageConfirmator(
                 'removeIncompatibleEqs',
                 ctx={
                     'name':
                     "', '".join([eq.userName for eq in conflictedEqs])
                 },
                 isEnabled=bool(conflictedEqs) and not skipConfirm))
     self.install = install
Ejemplo n.º 11
0
 def __getConfirmator(self, withoutBenefits, period, price):
     if withoutBenefits:
         return plugins.HtmlMessageConfirmator(
             'buyPremWithoutBenefitsConfirmation',
             'html_templates:lobby/dialogs',
             'confirmBuyPremWithoutBenefeits', {
                 'days':
                 text_styles.stats(period),
                 Currency.GOLD:
                 text_styles.concatStylesWithSpace(
                     text_styles.gold(BigWorld.wg_getGoldFormat(price)),
                     icons.makeImageTag(
                         RES_ICONS.MAPS_ICONS_LIBRARY_GOLDICON_2))
             })
     localKey = 'premiumContinueConfirmation' if self.wasPremium else 'premiumBuyConfirmation'
     return plugins.MessageConfirmator(
         localKey,
         ctx={
             'days':
             text_styles.stats(period),
             Currency.GOLD:
             text_styles.concatStylesWithSpace(
                 text_styles.gold(BigWorld.wg_getGoldFormat(price)),
                 icons.makeImageTag(
                     RES_ICONS.MAPS_ICONS_LIBRARY_GOLDICON_2))
         })
Ejemplo n.º 12
0
    def __init__(self, tmen, vehicle, tmanCostTypeIdx):
        hasUndistributedExp = False
        if tmanCostTypeIdx != 2:
            for tmanInvID in tmen:
                canLearnSkills, lastSkillLevel = self.itemsCache.items.getTankman(tmanInvID).newSkillCount
                hasUndistributedExp = lastSkillLevel > 0 or canLearnSkills > 1
                if hasUndistributedExp:
                    break

        super(TankmanCrewRetraining, self).__init__((plugins.VehicleValidator(vehicle, False),
         plugins.VehicleCrewLockedValidator(vehicle),
         plugins.GroupOperationsValidator(tmen, tmanCostTypeIdx),
         plugins.MessageConfirmator('tankmanRetraining/unknownVehicle', ctx={'tankname': vehicle.userName}, isEnabled=not vehicle.isInInventory),
         plugins.MessageConfirmator('tankmanRetraining/undistributedExp', ctx={}, isEnabled=hasUndistributedExp)))
        self.tankmen = tmen
        self.vehicle = vehicle
        self.tmanCostTypeIdx = tmanCostTypeIdx
Ejemplo n.º 13
0
 def __init__(self,
              vehicle,
              item,
              slotIdx,
              install=True,
              isUseMoney=False,
              conflictedEqs=None,
              skipConfirm=False):
     """
     Ctor.
     
     @param vehicle: vehicle
     @param item: module to install
     @param slotIdx: vehicle equipment slot index to install
     @param install: true if device is being installed, false if being demounted
     @param isUseMoney: if False - it means the user selected 'destroy' device, otherwise - de-install for money
     @param conflictedEqs: conflicted items
     """
     super(OptDeviceInstaller,
           self).__init__(vehicle,
                          item, (GUI_ITEM_TYPE.OPTIONALDEVICE, ),
                          slotIdx,
                          install,
                          conflictedEqs,
                          skipConfirm=skipConfirm)
     self.removalPrice = item.getRemovalPrice(self.itemsCache.items)
     action = None
     if self.removalPrice.isActionPrice():
         action = packActionTooltipData(ACTION_TOOLTIPS_TYPE.ECONOMICS,
                                        'paidRemovalCost', True,
                                        self.removalPrice.price,
                                        self.removalPrice.defPrice)
     addPlugins = []
     if install:
         addPlugins += (plugins.MessageConfirmator(
             'installConfirmationNotRemovable_%s' %
             self.removalPrice.price.getCurrency(),
             ctx={'name': item.userName},
             isEnabled=not item.isRemovable and not skipConfirm), )
     else:
         addPlugins += (plugins.DemountDeviceConfirmator(
             'removeConfirmationNotRemovableMoney',
             ctx={
                 'name': item.userName,
                 'price': self.removalPrice,
                 'action': action,
                 'item': item
             },
             isEnabled=not item.isRemovable and isUseMoney
             and not skipConfirm),
                        plugins.DestroyDeviceConfirmator(
                            'removeConfirmationNotRemovable',
                            itemName=item.userName,
                            isEnabled=not item.isRemovable
                            and not isUseMoney and not skipConfirm))
     self.addPlugins(addPlugins)
     self.useMoney = isUseMoney
     return
Ejemplo n.º 14
0
 def __init__(self, tankman, vehicle, tmanCostTypeIdx):
     super(TankmanRetraining, self).__init__(
         tankman,
         (plugins.VehicleValidator(vehicle, False),
          plugins.MessageConfirmator('tankmanRetraining/unknownVehicle',
                                     ctx={'tankname': vehicle.userName},
                                     isEnabled=not vehicle.isInInventory)))
     self.vehicle = vehicle
     self.tmanCostTypeIdx = tmanCostTypeIdx
Ejemplo n.º 15
0
 def __init__(self, tankman, role, vehTypeCompDescr):
     self.__roleIdx = SKILL_INDICES[role]
     self.__vehTypeCompDescr = vehTypeCompDescr
     self.__changeRoleCost = g_itemsCache.items.shop.changeRoleCost
     vehicle = g_itemsCache.items.getItemByCD(self.__vehTypeCompDescr)
     super(TankmanChangeRole, self).__init__(tankman, [plugins.MessageConfirmator('tankmanChageRole/unknownVehicle', ctx={'tankname': vehicle.userName}, isEnabled=not vehicle.isInInventory),
      plugins.VehicleValidator(vehicle, False),
      plugins.VehicleRoleValidator(vehicle, role),
      plugins.MoneyValidator(Money(gold=self.__changeRoleCost))])
Ejemplo n.º 16
0
 def __init__(self, tankman, firstNameID, firstNameGroup, lastNameID, lastNameGroup, iconID, iconGroup):
     hasUniqueData = self.__hasUniqueData(tankman, firstNameID, lastNameID, iconID)
     super(TankmanChangePassport, self).__init__(tankman, (plugins.MessageConfirmator('replacePassport/unique' if hasUniqueData else 'replacePassportConfirmation'),))
     self.firstNameID = firstNameID
     self.firstNameGroup = firstNameGroup
     self.lastNameID = lastNameID
     self.lastNameGroup = lastNameGroup
     self.iconID = iconID
     self.iconGroup = iconGroup
     self.isFemale = tankman.descriptor.isFemale
     self.isPremium = tankman.descriptor.isPremium
Ejemplo n.º 17
0
def _getUniqueVehicleSellConfirmator(vehicle, lobbyContext=None, itemsCache=None):
    info = vehicle.restoreInfo
    if info is None and itemsCache and hasNationGroup(vehicle.intCD):
        mainVehTypeCD = getMainVehicleInNationGroup(getNationGroupID(vehicle.intCD))
        restoreData = itemsCache.items.recycleBin.vehiclesBuffer.get(mainVehTypeCD)
        if restoreData:
            restoreType, changedAt = restoreData
            restoreCfg = itemsCache.items.shop.vehiclesRestoreConfig
            info = VehicleRestoreInfo(restoreType, changedAt, restoreCfg.restoreDuration, restoreCfg.restoreCooldown)
    sellForGold = vehicle.getSellPrice(preferred=True).getCurrency(byWeight=True) == Currency.GOLD
    if lobbyContext is not None and lobbyContext.getServerSettings().isVehicleRestoreEnabled():
        if not sellForGold and not vehicle.isUnrecoverable:
            if info is not None and vehicle.isPurchased and info.isInCooldown():
                return proc_plugs.MessageConfirmator('vehicleSell/restoreCooldown', ctx={'cooldown': formatTime(info.getRestoreCooldownTimeLeft(), time_utils.ONE_DAY)}, isEnabled=vehicle.isUnique)
            if vehicle.isPurchased:
                return proc_plugs.MessageConfirmator('vehicleSell/restoreUnlimited', isEnabled=vehicle.isUnique)
        dialogI18n = vehicle.isCrewLocked and 'vehicleSell/unique/crewLocked'
    else:
        dialogI18n = 'vehicleSell/unique'
    return proc_plugs.MessageConfirmator(dialogI18n, isEnabled=vehicle.isUnique)
Ejemplo n.º 18
0
 def __init__(self,
              vehicle,
              item,
              slotIdx,
              install=True,
              isUseGold=False,
              conflictedEqs=None):
     """
     Ctor.
     
     @param vehicle: vehicle
     @param item: module to install
     @param slotIdx: vehicle equipment slot index to install
     @param install: flag to designated process
     @param conflictedEqs: conflicted items
     """
     super(OptDeviceInstaller,
           self).__init__(vehicle, item, (GUI_ITEM_TYPE.OPTIONALDEVICE, ),
                          slotIdx, install, conflictedEqs)
     self.cost = g_itemsCache.items.shop.paidRemovalCost
     defaultCost = g_itemsCache.items.shop.defaults.paidRemovalCost
     action = None
     if self.cost != defaultCost:
         action = {
             'type': ACTION_TOOLTIPS_TYPE.ECONOMICS,
             'key': 'paidRemovalCost',
             'isBuying': True,
             'state': (None, ACTION_TOOLTIPS_STATE.DISCOUNT),
             'newPrice': (0, self.cost),
             'oldPrice': (0, defaultCost)
         }
     addPlugins = []
     if install:
         addPlugins += (plugins.MessageConfirmator(
             'installConfirmationNotRemovable',
             ctx={'name': item.userName},
             isEnabled=not item.isRemovable), )
     else:
         addPlugins += (plugins.DemountDeviceConfirmator(
             'removeConfirmationNotRemovableGold',
             ctx={
                 'name': item.userName,
                 'price': self.cost,
                 'action': action
             },
             isEnabled=not item.isRemovable and isUseGold),
                        plugins.DestroyDeviceConfirmator(
                            'removeConfirmationNotRemovable',
                            itemName=item.userName,
                            isEnabled=not item.isRemovable
                            and not isUseGold))
     self.addPlugins(addPlugins)
     self.useGold = isUseGold
Ejemplo n.º 19
0
    def __init__(self, tmen, vehicle, tmanCostTypeIdx):
        hasUndistributedExp = False
        isGoldPrice = tmanCostTypeIdx == 2
        if not isGoldPrice:
            for tmanInvID in tmen:
                canLearnSkills, lastSkillLevel = self.itemsCache.items.getTankman(
                    tmanInvID).newSkillCount
                hasUndistributedExp = lastSkillLevel > 0 or canLearnSkills > 1
                if hasUndistributedExp:
                    break

        self.tankmen = tmen
        self.vehicle = vehicle
        self.tmanCostTypeIdx = tmanCostTypeIdx
        ctx = {'tankname': vehicle.userName}
        if isGoldPrice:
            ctx['price'] = formatPrice(Money(
                gold=self.itemsCache.items.shop.tankmanCost[tmanCostTypeIdx]
                ['gold'] * len(self.tankmen)),
                                       reverse=True,
                                       useIcon=True,
                                       useStyle=True)
        super(TankmanCrewRetraining, self).__init__(
            (plugins.VehicleValidator(vehicle, False),
             plugins.VehicleCrewLockedValidator(vehicle),
             plugins.GroupOperationsValidator(tmen, tmanCostTypeIdx),
             plugins.MessageConfirmator(
                 'tankmanRetraining/knownVehicleByGold/pack',
                 ctx=ctx,
                 isEnabled=isGoldPrice and len(tmen) > 1),
             plugins.MessageConfirmator('tankmanRetraining/knownVehicleByGold',
                                        ctx=ctx,
                                        isEnabled=isGoldPrice
                                        and len(tmen) == 1),
             plugins.MessageConfirmator('tankmanRetraining/unknownVehicle',
                                        ctx=ctx,
                                        isEnabled=not vehicle.isInInventory),
             plugins.MessageConfirmator('tankmanRetraining/undistributedExp',
                                        ctx=ctx,
                                        isEnabled=hasUndistributedExp)))
Ejemplo n.º 20
0
 def __init__(self,
              vehicle,
              item,
              slotIdx,
              install=True,
              allSetups=True,
              financeOperation=False,
              conflictedEqs=None,
              skipConfirm=False):
     super(OptDeviceInstaller,
           self).__init__(vehicle,
                          item, (GUI_ITEM_TYPE.OPTIONALDEVICE, ),
                          slotIdx,
                          install,
                          conflictedEqs,
                          skipConfirm=skipConfirm)
     self.removalPrice = item.getRemovalPrice(self.itemsCache.items)
     addPlugins = []
     if install:
         addPlugins += (plugins.MessageConfirmator(
             'installConfirmationNotRemovable_{}'.format(
                 self.removalPrice.price.getCurrency()),
             ctx={
                 'name':
                 item.userName,
                 'complex':
                 _wrapHtmlMessage(
                     'confirmationNotRemovable',
                     backport.text(
                         R.strings.dialogs.confirmationNotRemovable.message.
                         complex())),
                 'destroy':
                 _wrapHtmlMessage(
                     'confirmationNotRemovable',
                     backport.text(
                         R.strings.dialogs.confirmationNotRemovable.message.
                         destroy()))
             },
             isEnabled=not item.isRemovable and not skipConfirm), )
     else:
         addPlugins += (plugins.DemountDeviceConfirmator(
             isEnabled=not item.isRemovable and financeOperation
             and not skipConfirm,
             item=self.item,
             vehicle=vehicle),
                        plugins.DestroyDeviceConfirmator(
                            isEnabled=not item.isRemovable
                            and not financeOperation and not skipConfirm,
                            item=item))
     self.addPlugins(addPlugins)
     self.financeOperation = financeOperation
     self.allSetups = allSetups
Ejemplo n.º 21
0
 def __init__(self, berthsPrice, berthsCount):
     super(TankmanBerthsBuyer, self).__init__(
         (plugins.MessageInformator(
             'barracksExpandNotEnoughMoney',
             activeHandler=lambda: not plugins.MoneyValidator(
                 berthsPrice).validate().success),
          plugins.MessageConfirmator('barracksExpand',
                                     ctx={
                                         'price': berthsPrice.gold,
                                         'count': berthsCount
                                     }),
          plugins.MoneyValidator(berthsPrice)))
     self.berthsPrice = berthsPrice
Ejemplo n.º 22
0
 def __init__(self,
              vehicle,
              item,
              itemType,
              slotIdx,
              install=True,
              conflictedEqs=None,
              plugs=tuple()):
     """
     Ctor.
     
     @param vehicle: vehicle
     @param item: module to install
     @param slotIdx: vehicle equipment slot index to install
     @param itemType: item type
     @param install: flag to designated process
     @param conflictedEqs: conflicted items
     @param plugs: plugins list
     """
     opType = 'apply' if install else 'remove'
     if not conflictedEqs:
         conflictedEqs = tuple()
         ModuleProcessor.__init__(self,
                                  item=item,
                                  opType=opType,
                                  plugs=plugs)
         VehicleItemProcessor.__init__(self,
                                       vehicle=vehicle,
                                       module=item,
                                       allowableTypes=itemType)
         addPlugins = []
         install and addPlugins += (plugins.CompatibilityInstallValidator(
             vehicle, item, slotIdx),
                                    plugins.MessageConfirmator(
                                        'removeIncompatibleEqs',
                                        ctx={
                                            'name':
                                            "', '".join([
                                                VehicleItem(
                                                    descriptor=eq).name
                                                for eq in conflictedEqs
                                            ])
                                        },
                                        isEnabled=bool(conflictedEqs)))
     else:
         addPlugins += (plugins.CompatibilityRemoveValidator(vehicle,
                                                             item), )
     self.install = install
     self.slotIdx = slotIdx
     self.addPlugins(addPlugins)
Ejemplo n.º 23
0
 def __init__(self, period, price, arenaUniqueID=0):
     self.wasPremium = g_itemsCache.items.stats.isPremium
     localKey = 'premiumContinueConfirmation' if self.wasPremium else 'premiumBuyConfirmation'
     super(PremiumAccountBuyer, self).__init__(
         (plugins.MessageConfirmator(localKey,
                                     ctx={
                                         'days':
                                         int(period),
                                         'gold':
                                         BigWorld.wg_getGoldFormat(price)
                                     }), plugins.MoneyValidator(
                                         (0, price))))
     self.premiumPrice = price
     self.period = period
     self.arenaUniqueID = arenaUniqueID
Ejemplo n.º 24
0
 def __init__(self,
              vehicle,
              item,
              slotIdx,
              install=True,
              isUseMoney=False,
              conflictedEqs=None,
              skipConfirm=False):
     super(OptDeviceInstaller,
           self).__init__(vehicle,
                          item, (GUI_ITEM_TYPE.OPTIONALDEVICE, ),
                          slotIdx,
                          install,
                          conflictedEqs,
                          skipConfirm=skipConfirm)
     self.removalPrice = item.getRemovalPrice(self.itemsCache.items)
     action = None
     if self.removalPrice.isActionPrice():
         action = packActionTooltipData(ACTION_TOOLTIPS_TYPE.ECONOMICS,
                                        'paidRemovalCost', True,
                                        self.removalPrice.price,
                                        self.removalPrice.defPrice)
     addPlugins = []
     if install:
         addPlugins += (plugins.MessageConfirmator(
             'installConfirmationNotRemovable_%s' %
             self.removalPrice.price.getCurrency(),
             ctx={'name': item.userName},
             isEnabled=not item.isRemovable and not skipConfirm), )
     else:
         addPlugins += (plugins.DemountDeviceConfirmator(
             'removeConfirmationNotRemovableMoney',
             ctx={
                 'name': item.userName,
                 'price': self.removalPrice,
                 'action': action,
                 'item': item
             },
             isEnabled=not item.isRemovable and isUseMoney
             and not skipConfirm),
                        plugins.DestroyDeviceConfirmator(
                            'removeConfirmationNotRemovable',
                            itemName=item.userName,
                            isEnabled=not item.isRemovable
                            and not isUseMoney and not skipConfirm))
     self.addPlugins(addPlugins)
     self.useMoney = isUseMoney
     return
Ejemplo n.º 25
0
 def __init__(self, vehicle, dismantlingGoldCost, shells = [], eqs = [], optDevs = [], inventory = [], isCrewDismiss = False):
     self.gainMoney, self.spendMoney = self.__getGainSpendMoney(vehicle, shells, eqs, optDevs, inventory, dismantlingGoldCost)
     barracksBerthsNeeded = len(filter(lambda item: item is not None, vehicle.crew))
     super(VehicleSeller, self).__init__(vehicle, (plugins.VehicleValidator(vehicle, False, prop={'isBroken': True,
       'isLocked': True}),
      plugins.MoneyValidator(self.spendMoney),
      plugins.VehicleSellsLeftValidator(vehicle),
      plugins.BarracksSlotsValidator(barracksBerthsNeeded, isEnabled=not isCrewDismiss),
      plugins.MessageConfirmator('vehicleSell/unique', isEnabled=vehicle.isUnique)))
     self.vehicle = vehicle
     self.shells = shells
     self.eqs = eqs
     self.optDevs = optDevs
     self.inventory = inventory
     self.isCrewDismiss = isCrewDismiss
     self.isDismantlingForGold = self.__dismantlingForGoldDevicesCount(vehicle, optDevs) > 0
Ejemplo n.º 26
0
 def __getConfirmator(self, withoutBenefits, period, price):
     if withoutBenefits:
         return plugins.HtmlMessageConfirmator(
             'buyPremWithoutBenefitsConfirmation',
             'html_templates:lobby/dialogs',
             'confirmBuyPremWithoutBenefeits', {
                 'days': int(period),
                 'gold': BigWorld.wg_getGoldFormat(price)
             })
     else:
         localKey = 'premiumContinueConfirmation' if self.wasPremium else 'premiumBuyConfirmation'
         return plugins.MessageConfirmator(
             localKey,
             ctx={
                 'days': int(period),
                 'gold': BigWorld.wg_getGoldFormat(price)
             })
Ejemplo n.º 27
0
 def __init__(self, berthsPrice, berthsCount):
     super(TankmanBerthsBuyer, self).__init__(
         (plugins.MessageInformator(
             'barracksExpandNotEnoughMoney',
             activeHandler=lambda: not plugins.MoneyValidator(
                 berthsPrice).validate().success),
          plugins.MessageConfirmator(
              'barracksExpand',
              ctx={
                  'price':
                  text_styles.concatStylesWithSpace(
                      text_styles.gold(str(berthsPrice.gold)),
                      icons.makeImageTag(
                          RES_ICONS.MAPS_ICONS_LIBRARY_GOLDICON_2)),
                  'count':
                  text_styles.stats(berthsCount)
              }), plugins.MoneyValidator(berthsPrice)))
     self.berthsPrice = berthsPrice
Ejemplo n.º 28
0
 def __init__(self, tankman, role, vehTypeCompDescr):
     self.__roleIdx = SKILL_INDICES[role]
     self.__vehTypeCompDescr = vehTypeCompDescr
     self.__changeRoleCost = self.itemsCache.items.shop.changeRoleCost
     vehicle = self.itemsCache.items.getItemByCD(self.__vehTypeCompDescr)
     super(TankmanChangeRole, self).__init__(
         tankman,
         (plugins.TankmanLockedValidator(tankman),
          plugins.VehicleCrewLockedValidator(vehicle),
          plugins.MessageConfirmator('tankmanChageRole/unknownVehicle',
                                     ctx={'tankname': vehicle.userName},
                                     isEnabled=not vehicle.isInInventory),
          plugins.VehicleValidator(vehicle, False),
          plugins.VehicleRoleValidator(vehicle, role, tankman),
          plugins.MoneyValidator(Money(gold=self.__changeRoleCost))))
     self.__compensationPriceObject = None
     self.__compensationRequired = False
     lobbyContext = dependency.instance(ILobbyContext)
     equippedSkinID = tankman.skinID
     if equippedSkinID != NO_CREW_SKIN_ID and lobbyContext.getServerSettings(
     ).isCrewSkinsEnabled():
         crewSkinItem = self.itemsCache.items.getCrewSkin(equippedSkinID)
         roleMismatch = crewSkinItem.getRoleID(
         ) is not None and crewSkinItem.getRoleID() != role
         self.__compensationPriceObject = crewSkinItem.getBuyPrice()
         self.__compensationRequired = roleMismatch and not crewSkinItem.isStorageAvailable(
         )
         self.addPlugins(
             (plugins.CrewSkinsRoleChangeRemovalConfirmator(
                 'crewSkins/skinWillBeRemoved',
                 ctx={'items': [crewSkinItem]},
                 isEnabled=roleMismatch
                 and crewSkinItem.isStorageAvailable()),
              plugins.CrewSkinsCompensationDialogConfirmator(
                  'crewSkins/skinWillBeDeleted',
                  plugins.CrewSkinsRemovalCompensationDialogMeta.
                  ROLE_MISMATCH_SUFFIX,
                  ctx={
                      'price': self.__compensationPriceObject,
                      'items': [crewSkinItem]
                  },
                  isEnabled=self.__compensationRequired)))
     return
Ejemplo n.º 29
0
 def __init__(self,
              vehicle,
              item,
              slotIdx,
              install=True,
              isUseGold=False,
              conflictedEqs=None):
     """
     Ctor.
     
     @param vehicle: vehicle
     @param item: module to install
     @param slotIdx: vehicle equipment slot index to install
     @param install: flag to designated process
     @param conflictedEqs: conflicted items
     """
     super(OptDeviceInstaller,
           self).__init__(vehicle, item, (GUI_ITEM_TYPE.OPTIONALDEVICE, ),
                          slotIdx, install, conflictedEqs)
     self.cost = g_itemsCache.items.shop.paidRemovalCost
     addPlugins = []
     if install:
         addPlugins += (plugins.MessageConfirmator(
             'installConfirmationNotRemovable',
             ctx={'name': item.userName},
             isEnabled=not item.isRemovable), )
     else:
         addPlugins += (plugins.DemountDeviceConfirmator(
             'removeConfirmationNotRemovableGold',
             ctx={
                 'name': item.userName,
                 'price': self.cost
             },
             isEnabled=not item.isRemovable and isUseGold),
                        plugins.DestroyDeviceConfirmator(
                            'removeConfirmationNotRemovable',
                            itemName=item.userName,
                            isEnabled=not item.isRemovable
                            and not isUseGold))
     self.addPlugins(addPlugins)
     self.useGold = isUseGold
Ejemplo n.º 30
0
 def __init__(self, showConfirm=True, showWarning=True):
     self.__hasDiscounts = bool(
         g_itemsCache.items.shop.personalSlotDiscounts)
     self.__frozenSlotPrice = None
     slotCost = self.__getSlotPrice()
     if self.__hasDiscounts and not slotCost:
         confirmationType = 'freeSlotConfirmation'
         ctx = {}
     else:
         confirmationType = 'buySlotConfirmation'
         ctx = {'gold': slotCost.gold}
     super(VehicleSlotBuyer, self).__init__(
         (plugins.MessageInformator(
             'buySlotNotEnoughCredits',
             activeHandler=lambda: not plugins.MoneyValidator(
                 slotCost).validate().success,
             isEnabled=showWarning),
          plugins.MessageConfirmator(confirmationType,
                                     isEnabled=showConfirm,
                                     ctx=ctx),
          plugins.MoneyValidator(slotCost)))
     return