def _setupPlugins(self):
     self.addPlugins(
         (proc_plugs.VehicleValidator(self.__vehicle),
          proc_plugs.MoneyValidator(getVehicleBattleBoostersLayoutPrice(
              self.__vehicle).price,
                                    byCurrencyError=False),
          proc_plugs.BattleBoostersInstallValidator(self.__vehicle)))
Exemple #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), 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)])
Exemple #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)))
Exemple #4
0
 def __init__(self, tankman, skillName):
     vehicle = None
     if tankman.vehicleInvID > 0:
         vehicle = g_itemsCache.items.getVehicle(tankman.vehicleInvID)
     super(TankmanAddSkill, self).__init__(tankman, (plugins.VehicleValidator(vehicle, isEnabled=tankman.vehicleInvID > 0),))
     self.skillName = skillName
     return
Exemple #5
0
 def _getPluginsList(self):
     nationGroupVehs = self.itemToTradeOff.getAllNationGroupVehs(self.itemsCache.items)
     barracksBerthsNeeded = getCrewCount(nationGroupVehs)
     return (proc_plugs.VehicleValidator(self.itemToTradeOff, setAll=True),
      proc_plugs.VehicleSellValidator(self.itemToTradeOff),
      proc_plugs.MoneyValidator(self.price),
      proc_plugs.BarracksSlotsValidator(barracksBerthsNeeded))
 def _setupPlugins(self):
     self.addPlugins(
         (proc_plugs.VehicleValidator(self._vehicle),
          proc_plugs.MoneyValidator(getVehicleConsumablesLayoutPrice(
              self._vehicle).price,
                                    byCurrencyError=False),
          proc_plugs.ConsumablesInstallValidator(self._vehicle)))
 def _setupPlugins(self):
     price = self.__getPrice()
     self.addPlugins(
         (proc_plugs.VehicleValidator(self.__vehicle),
          proc_plugs.MoneyValidator(price),
          proc_plugs.ShellsInstallValidator(self.__vehicle),
          proc_plugs.ConsumablesInstallValidator(self.__vehicle)))
Exemple #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)])
Exemple #9
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 (idx, item): item is not None, vehicle.crew))
     bufferOverflowCtx = {}
     isBufferOverflowed = False
     if isCrewDismiss:
         tankmenGoingToBuffer, deletedTankmen = getRestoreController().getTankmenDeletedBySelling(vehicle)
         countOfDeleted = len(deletedTankmen)
         if countOfDeleted > 0:
             isBufferOverflowed = True
             bufferOverflowCtx['deleted'] = deletedTankmen[-1]
             bufferOverflowCtx['dismissed'] = tankmenGoingToBuffer[-1]
             if countOfDeleted > 1:
                 bufferOverflowCtx['multiple'] = True
                 bufferOverflowCtx['extraCount'] = countOfDeleted - 1
     super(VehicleSeller, self).__init__(vehicle, (plugins.VehicleValidator(vehicle, False, prop={'isBroken': True,
       'isLocked': True}),
      plugins.VehicleSellValidator(vehicle),
      plugins.MoneyValidator(self.spendMoney),
      plugins.VehicleSellsLeftValidator(vehicle, not (vehicle.isRented and vehicle.rentalIsOver)),
      plugins.BarracksSlotsValidator(barracksBerthsNeeded, isEnabled=not isCrewDismiss),
      plugins.BufferOverflowConfirmator(bufferOverflowCtx, isEnabled=isBufferOverflowed),
      _getUniqueVehicleSellConfirmator(vehicle)))
     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
     self.isRemovedAfterRent = vehicle.isRented
 def __init__(self, vehicle):
     self.__prefix = 'return_crew'
     self.__vehicle = vehicle
     super(TankmanReturn, self).__init__(
         (plugins.VehicleValidator(self.__vehicle,
                                   False,
                                   prop={'isLocked': True}),
          plugins.VehicleCrewLockedValidator(vehicle)))
Exemple #11
0
 def __init__(self, tankman):
     vehicle = None
     if tankman.vehicleInvID > 0:
         vehicle = g_itemsCache.items.getVehicle(tankman.vehicleInvID)
     confirmatorType = plugins.DismissTankmanConfirmator('protectedDismissTankman', tankman)
     raise confirmatorType or AssertionError
     super(TankmanDismiss, self).__init__(tankman, [confirmatorType, plugins.VehicleValidator(vehicle, isEnabled=tankman.vehicleInvID > 0)])
     return
Exemple #12
0
 def __init__(self, vehicle, slot, tmanCostTypeIdx):
     super(TankmanRecruitAndEquip, self).__init__()
     self.vehicle = vehicle
     self.slot = slot
     self.tmanCostTypeIdx = tmanCostTypeIdx
     self.isReplace = dict(vehicle.crew).get(slot) is not None
     self.addPlugins([plugins.VehicleValidator(vehicle, False, prop={'isLocked': True}), plugins.MoneyValidator(self.__getRecruitPrice(tmanCostTypeIdx)), plugins.FreeTankmanValidator(isEnabled=tmanCostTypeIdx == 0)])
     return
Exemple #13
0
 def _getPluginsList(self):
     barracksBerthsNeeded = len(
         [item for item in self.itemToTradeOff.crew if item[1] is not None])
     return (proc_plugs.VehicleValidator(self.itemToTradeOff, setAll=True),
             proc_plugs.VehicleTradeInValidator(self.item,
                                                self.itemToTradeOff),
             proc_plugs.VehicleSellValidator(self.itemToTradeOff),
             proc_plugs.MoneyValidator(self.price),
             proc_plugs.BarracksSlotsValidator(barracksBerthsNeeded))
Exemple #14
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))])
Exemple #15
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
Exemple #16
0
 def __init__(self, vehicle, slot=-1):
     super(TankmanUnload, self).__init__()
     self.vehicle = vehicle
     self.slot = slot
     berthsNeeded = 1
     if slot == -1:
         berthsNeeded = len([ item for item in vehicle.crew if item[1] is not None ])
     self.__sysMsgPrefix = 'unload_tankman' if berthsNeeded == 1 else 'unload_crew'
     self.addPlugins([plugins.VehicleValidator(vehicle, False, prop={'isLocked': True}), plugins.VehicleCrewLockedValidator(vehicle), plugins.BarracksSlotsValidator(berthsNeeded)])
     return
Exemple #17
0
 def __init__(self, tankman, firstNameID, lastNameID, iconID, isFemale = False):
     vehicle = None
     if tankman.vehicleInvID > 0:
         vehicle = g_itemsCache.items.getVehicle(tankman.vehicleInvID)
     super(TankmanChangePassport, self).__init__(tankman, (plugins.VehicleValidator(vehicle, isEnabled=tankman.vehicleInvID > 0), plugins.MessageConfirmator('replacePassportConfirmation')))
     self.firstNameID = firstNameID
     self.lastNameID = lastNameID
     self.iconID = iconID
     self.isFemale = isFemale
     return
Exemple #18
0
 def __init__(self, tankman):
     vehicle = None
     if tankman.vehicleInvID > 0:
         vehicle = g_itemsCache.items.getVehicle(tankman.vehicleInvID)
     confirmator = plugins.TankmanOperationConfirmator('protectedDismissTankman', tankman)
     super(TankmanDismiss, self).__init__(tankman, [confirmator, plugins.VehicleValidator(vehicle, isEnabled=tankman.vehicleInvID > 0)])
     deletedTankmen = getRestoreController().getTankmenBeingDeleted()
     if len(deletedTankmen) > 0 and tankman.isRestorable():
         self.addPlugin(plugins.BufferOverflowConfirmator({'dismissed': tankman,
          'deleted': deletedTankmen[0]}))
     return
Exemple #19
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,))])
     return
Exemple #20
0
 def __init__(self, vehicle, buySlot, buyShell = False, crewType = -1):
     self.price = self.__sumBuyPrice(vehicle, buyShell, crewType)
     super(VehicleBuyer, self).__init__(vehicle, (plugins.VehicleValidator(vehicle, False, prop={'isBroken': True,
       'isLocked': True}),
      plugins.MoneyValidator(self.price),
      plugins.VehicleSlotsConfirmator(not buySlot),
      plugins.VehicleFreeLimitConfirmator(vehicle, crewType)))
     self.buyShell = buyShell
     self.buyCrew = crewType != -1
     self.crewType = crewType
     self.vehicle = vehicle
Exemple #21
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
Exemple #22
0
 def __init__(self,
              vehicle,
              shells=None,
              eqs=None,
              optDevs=None,
              inventory=None,
              isCrewDismiss=False):
     shells = shells or []
     eqs = eqs or []
     optDevs = optDevs or []
     inventory = inventory or []
     self.gainMoney, self.spendMoney = self.__getGainSpendMoney(
         vehicle, shells, eqs, optDevs, inventory)
     barracksBerthsNeeded = len(
         [item for item in vehicle.crew if item[1] is not None])
     bufferOverflowCtx = {}
     isBufferOverflowed = False
     if isCrewDismiss:
         tankmenGoingToBuffer, deletedTankmen = self.restore.getTankmenDeletedBySelling(
             vehicle)
         countOfDeleted = len(deletedTankmen)
         if countOfDeleted > 0:
             isBufferOverflowed = True
             bufferOverflowCtx['deleted'] = deletedTankmen[-1]
             bufferOverflowCtx['dismissed'] = tankmenGoingToBuffer[-1]
             if countOfDeleted > 1:
                 bufferOverflowCtx['multiple'] = True
                 bufferOverflowCtx['extraCount'] = countOfDeleted - 1
     super(VehicleSeller, self).__init__(
         vehicle,
         (proc_plugs.VehicleValidator(
             vehicle, False, prop={
                 'isBroken': True,
                 'isLocked': True
             }), proc_plugs.VehicleSellValidator(vehicle),
          proc_plugs.MoneyValidator(self.spendMoney - self.gainMoney),
          proc_plugs.VehicleSellsLeftValidator(
              vehicle, not (vehicle.isRented and vehicle.rentalIsOver)),
          proc_plugs.BarracksSlotsValidator(barracksBerthsNeeded,
                                            isEnabled=not isCrewDismiss),
          proc_plugs.BufferOverflowConfirmator(
              bufferOverflowCtx, isEnabled=isBufferOverflowed),
          _getUniqueVehicleSellConfirmator(vehicle)))
     self.vehicle = vehicle
     self.shells = shells
     self.eqs = eqs
     self.optDevs = optDevs
     self.inventory = inventory
     self.isCrewDismiss = isCrewDismiss
     self.isDismantlingForMoney = len(
         getDismantlingToInventoryDevices(vehicle, optDevs)) > 0
     self.isRemovedAfterRent = vehicle.isRented
     return
Exemple #23
0
 def __init__(self, item, vehicle, slotIdx, plugs=tuple()):
     super(ModuleUpgradeProcessor, self).__init__(item, 'upgrade', plugs)
     addPlugins = []
     self.__upgradePrice = item.getUpgradePrice(self.itemsCache.items)
     addPlugins += (plugins.MoneyValidator(self.__upgradePrice.price),)
     if vehicle is not None:
         addPlugins += (plugins.VehicleValidator(vehicle, True, prop={'isBroken': True,
           'isLocked': True}),)
     self.vehicle = vehicle
     self.slotIdx = slotIdx
     self.addPlugins(addPlugins)
     return
Exemple #24
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
Exemple #25
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)
Exemple #26
0
 def _getPluginsList(self):
     """
     Gets plugins collection
     :return: <tuple(ProcessorPlugin, ...)>
     """
     barracksBerthsNeeded = len(
         filter(lambda (idx, item): item is not None,
                self.itemToTradeOff.crew))
     return (plugins.VehicleValidator(self.itemToTradeOff, setAll=True),
             plugins.VehicleTradeInValidator(self.item,
                                             self.itemToTradeOff),
             plugins.VehicleSellValidator(self.itemToTradeOff),
             plugins.MoneyValidator(self.price),
             plugins.BarracksSlotsValidator(barracksBerthsNeeded))
Exemple #27
0
 def __init__(self, vehicle, slot = -1):
     """
     Ctor.
     
     @param vehicle: vehicle to unload tankman
     @param slot:    slot in given vehicle to unload. -1 by default,
                                     that means - unload all tankmen from vehicle.
     """
     super(TankmanUnload, self).__init__()
     self.vehicle = vehicle
     self.slot = slot
     berthsNeeded = 1
     if slot == -1:
         berthsNeeded = len(filter(lambda (role, t): t is not None, vehicle.crew))
     self.__sysMsgPrefix = 'unload_tankman' if berthsNeeded == 1 else 'unload_crew'
     self.addPlugins([plugins.VehicleValidator(vehicle, False, prop={'isLocked': True}), plugins.BarracksSlotsValidator(berthsNeeded)])
Exemple #28
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
Exemple #29
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
Exemple #30
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