def __init__(self, vehicle, item, itemType, slotIdx, 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) addPlugins = [] if install: addPlugins += (plugins.CompatibilityInstallValidator( vehicle, item, slotIdx), plugins.MessageConfirmator( 'removeIncompatibleEqs', ctx={ 'name': "', '".join( [eq.userName for eq in conflictedEqs]) }, isEnabled=bool(conflictedEqs) and not skipConfirm)) else: addPlugins += (plugins.CompatibilityRemoveValidator(vehicle, item), ) self.install = install self.slotIdx = slotIdx self.addPlugins(addPlugins)
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)])
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)])
def __init__(self, vehicle, item, conflictedEqs=None, skipConfirm=False): super(OtherModuleInstaller, self).__init__(vehicle, item, (GUI_ITEM_TYPE.CHASSIS, GUI_ITEM_TYPE.GUN, GUI_ITEM_TYPE.ENGINE, GUI_ITEM_TYPE.FUEL_TANK, GUI_ITEM_TYPE.RADIO, GUI_ITEM_TYPE.SHELL), True, conflictedEqs, skipConfirm=skipConfirm) self.addPlugin(plugins.CompatibilityInstallValidator(vehicle, item, 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)
def __init__(self, vehicle, item, conflictedEqs=None): """ Ctor. @param vehicle: vehicle @param item: equipment to install @param conflictedEqs: conflicted items """ super(OtherModuleInstaller, self).__init__(vehicle, item, (GUI_ITEM_TYPE.CHASSIS, GUI_ITEM_TYPE.GUN, GUI_ITEM_TYPE.ENGINE, GUI_ITEM_TYPE.FUEL_TANK, GUI_ITEM_TYPE.RADIO, GUI_ITEM_TYPE.SHELL), True, conflictedEqs) self.addPlugin(plugins.CompatibilityInstallValidator(vehicle, item, 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) }) ])
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) ])