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, 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, conflictedEqs=None, skipConfirm=False): super(TurretInstaller, self).__init__(vehicle, item, (GUI_ITEM_TYPE.TURRET,), True, conflictedEqs, skipConfirm=skipConfirm) self.gunCD = 0 mayInstallCurrent = item.mayInstall(vehicle, gunCD=self.gunCD) if not mayInstallCurrent[0]: self._findAvailableGun(vehicle, item) self.addPlugin(plugins.TurretCompatibilityInstallValidator(vehicle, item, self.gunCD))
def __init__(self, vehicle, item, conflictedEqs=None): """ Ctor. @param vehicle: vehicle @param item: equipment to install @param conflictedEqs: conflicted items """ super(TurretInstaller, self).__init__(vehicle, item, (GUI_ITEM_TYPE.TURRET, ), True, conflictedEqs) self.gunCD = 0 mayInstallCurrent = item.mayInstall(vehicle, slotIdx=0, gunCD=self.gunCD) if not mayInstallCurrent[0]: iGuns = sorted(g_itemsCache.items.getItems( REQ_CRITERIA.VEHICLE.SUITABLE([vehicle], [GUI_ITEM_TYPE.GUN]) | REQ_CRITERIA.INVENTORY).keys(), reverse=True) for gun in itertools.ifilter(lambda x: x['compactDescr'] in iGuns, item.descriptor['guns']): mayInstall = item.mayInstall(vehicle, slotIdx=0, gunCD=gun['compactDescr']) if mayInstall[0]: self.gunCD = gun['compactDescr'] break self.addPlugin( plugins.TurretCompatibilityInstallValidator( vehicle, item, self.gunCD))
def __init__(self, vehicle, item, conflictedEqs=None): """ Ctor. @param vehicle: vehicle @param item: equipment to install @param conflictedEqs: conflicted items """ super(TurretInstaller, self).__init__(vehicle, item, (GUI_ITEM_TYPE.TURRET, ), True, conflictedEqs) self.gunCD = 0 mayInstallCurrent = item.mayInstall(vehicle, gunCD=self.gunCD) if not mayInstallCurrent[0]: for gun in item.descriptor['guns']: gunItem = g_itemsCache.items.getItemByCD(gun['compactDescr']) if gunItem.isInInventory: mayInstall = item.mayInstall(vehicle, slotIdx=0, gunCD=gun['compactDescr']) if mayInstall[0]: self.gunCD = gun['compactDescr'] break self.addPlugin( plugins.TurretCompatibilityInstallValidator( vehicle, item, self.gunCD))
def __init__(self, vehicle, item, conflictedEqs=None): """ Ctor. @param vehicle: vehicle @param item: equipment to install @param conflictedEqs: conflicted items """ super(TurretInstaller, self).__init__(vehicle, item, (GUI_ITEM_TYPE.TURRET, ), True, conflictedEqs) self.gunCD = 0 mayInstallCurrent = item.mayInstall(vehicle, gunCD=self.gunCD) if not mayInstallCurrent[0]: self._findAvailableGun(vehicle, item) self.addPlugin( plugins.TurretCompatibilityInstallValidator( vehicle, item, self.gunCD))
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) ])