예제 #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):
     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)
                 })
         ])