Пример #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)])
Пример #2
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)])
Пример #3
0
 def __init__(self, item, opType, plugs=tuple()):
     """
     Ctor.
     
     @param item: module to install
     @param opType: operation type
     @param plugs: plugins list
     """
     ItemProcessor.__init__(self, item,
                            plugs + (plugins.ModuleValidator(item), ))
     self.opType = opType
Пример #4
0
 def __init__(self, vehicle, module, allowableTypes):
     super(VehicleItemProcessor, self).__init__(module, [
         proc_plugs.VehicleValidator(
             vehicle, False, prop={
                 'isBroken': True,
                 'isLocked': True
             }),
         proc_plugs.ModuleValidator(module),
         proc_plugs.ModuleTypeValidator(module, allowableTypes)
     ])
     self.vehicle = vehicle
     self.allowableTypes = allowableTypes
Пример #5
0
 def __init__(self, vehicle, module, allowableTypes):
     """
     Ctor.
     
     @param vehicle: vehicle
     @param module: module to be installed
     @param allowableTypes: module allowable types
     """
     super(VehicleItemProcessor, self).__init__(module, [plugins.VehicleValidator(vehicle, False, prop={'isBroken': True,
       'isLocked': True}), plugins.ModuleValidator(module), plugins.ModuleTypeValidator(module, allowableTypes)])
     self.vehicle = vehicle
     self.allowableTypes = allowableTypes
Пример #6
0
 def __init__(self, tankman, vehicle, slot):
     super(TankmanEquip, self).__init__()
     self.tankman = tankman
     self.vehicle = vehicle
     self.slot = slot
     self.isReequip = False
     anotherTankman = dict(vehicle.crew).get(slot)
     if tankman is not None and anotherTankman is not None and anotherTankman.invID != tankman.invID:
         self.isReequip = True
     self.addPlugins([
         plugins.VehicleValidator(vehicle, False, prop={'isLocked': True}),
         plugins.ModuleValidator(tankman),
         plugins.ModuleTypeValidator(tankman, (GUI_ITEM_TYPE.TANKMAN, ))
     ])
Пример #7
0
 def __init__(self, item, opType, plugs=tuple()):
     ItemProcessor.__init__(self, item,
                            plugs + (plugins.ModuleValidator(item), ))
     self.opType = opType
Пример #8
0
 def __init__(self,
              vehicle,
              item,
              slotIdx,
              gunCompDescr,
              conflictedEqs=None):
     self.__vehInvID = vehicle.inventoryID
     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, True)
     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,
                     'credits':
                     BigWorld.wg_getIntegralFormat(
                         self._getOpPrice().credits)
                 })
         ])
         if item.itemTypeID == GUI_ITEM_TYPE.TURRET:
             self.addPlugin(
                 plugins.TurretCompatibilityInstallValidator(
                     vehicle, item, self.__gunCompDescr))
         elif item.itemTypeID == GUI_ITEM_TYPE.OPTIONALDEVICE:
             self.addPlugin(
                 plugins.MessageConfirmator(
                     'installConfirmationNotRemovable',
                     ctx={'name': item.userName},
                     isEnabled=not item.isRemovable))
         self.addPlugin(
             plugins.MessageConfirmator(
                 'removeIncompatibleEqs',
                 ctx={
                     'name':
                     "', '".join([eq.userName for eq in conflictedEqs])
                 },
                 isEnabled=bool(conflictedEqs)))
     else:
         self.addPlugins([
             plugins.ModuleBuyerConfirmator(
                 'confirmBuyNotInstall',
                 ctx={
                     'userString':
                     item.userName,
                     'typeString':
                     self.item.userType,
                     'credits':
                     BigWorld.wg_getIntegralFormat(
                         self._getOpPrice().credits),
                     'reason':
                     self.__makeInstallReasonMsg(installReason)
                 })
         ])
Пример #9
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
     self._installedModuleCD = vehicle.descriptor.getComponentsByType(
         item.itemTypeName)[0].compactDescr
     conflictedEqs = conflictedEqs or tuple()
     conflictMsg = ''
     if conflictedEqs:
         self.__makeConflictMsg("', '".join(
             [eq.userName for eq in conflictedEqs]))
     self.__mayInstall, self._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._installConfirmatorPluginCls(
                 '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([
             self._storeConfirmatorPluginCls(
                 'confirmBuyNotInstall',
                 ctx=self._getItemConfirmationData(conflictMsg),
                 isEnabled=not skipConfirm,
                 item=item)
         ])