Example #1
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))
Example #2
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
Example #3
0
 def __init__(self, tankman):
     self.__tankman = tankman
     restorePrice, _ = getTankmenRestoreInfo(tankman)
     super(TankmanRestore, self).__init__(tankman, (plugins.TankmanLockedValidator(tankman),
      plugins.TankmanOperationConfirmator('restoreTankman', tankman),
      plugins.BarracksSlotsValidator(berthsNeeded=1),
      plugins.MoneyValidator(restorePrice),
      plugins.IsLongDisconnectedFromCenter()))
Example #4
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))
Example #5
0
 def __init__(self, nationID, vehTypeID, role, tmanCostTypeIdx):
     super(TankmanRecruit, self).__init__([plugins.MoneyValidator(self.__getRecruitPrice(tmanCostTypeIdx)),
      plugins.FreeTankmanValidator(isEnabled=tmanCostTypeIdx == 0),
      plugins.BarracksSlotsValidator(),
      plugins.IsLongDisconnectedFromCenter()])
     self.nationID = nationID
     self.vehTypeID = vehTypeID
     self.role = role
     self.tmanCostTypeIdx = tmanCostTypeIdx
Example #6
0
 def __init__(self, tankman):
     raise tankman is not None or AssertionError('tankman must be given')
     self.__tankman = tankman
     restorePrice, _ = getTankmenRestoreInfo(tankman)
     super(TankmanRestore, self).__init__(tankman, [plugins.TankmanOperationConfirmator('restoreTankman', tankman),
      plugins.BarracksSlotsValidator(berthsNeeded=1),
      plugins.MoneyValidator(restorePrice),
      plugins.IsLongDisconnectedFromCenter()])
     return
Example #7
0
 def __init__(self, nationID, vehTypeID, role, tmanCostTypeIdx):
     super(TankmanRecruit, self).__init__([plugins.VehicleCrewLockedValidator(self.itemsCache.items.getItemByCD(makeIntCompactDescrByID('vehicle', nationID, vehTypeID))),
      plugins.MoneyValidator(self.__getRecruitPrice(tmanCostTypeIdx)),
      plugins.FreeTankmanValidator(isEnabled=tmanCostTypeIdx == 0),
      plugins.BarracksSlotsValidator(),
      plugins.IsLongDisconnectedFromCenter()])
     self.nationID = nationID
     self.vehTypeID = vehTypeID
     self.role = role
     self.tmanCostTypeIdx = tmanCostTypeIdx
Example #8
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),
      plugins.BarracksSlotsValidator(isEnabled=self.isReplace)])
     return
Example #9
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
Example #10
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))
 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
Example #12
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
Example #13
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)
     ])
Example #14
0
    def __init__(self, vehicle, shells=None, eqs=None, optDevs=None, inventory=None, customizationItems=None, boosters=None, isCrewDismiss=False, itemsForDemountKit=None):
        shells = shells or []
        eqs = eqs or []
        boosters = boosters or []
        optDevs = optDevs or []
        inventory = inventory or []
        customizationItems = customizationItems or []
        itemsForDemountKit = itemsForDemountKit or []
        nationGroupVehs = vehicle.getAllNationGroupVehs(self.itemsCache.items)
        self.vehicle = vehicle
        self.nationGroupVehs = nationGroupVehs
        self.shells = shells
        self.eqs = eqs
        self.optDevs = optDevs
        self.gainMoney, self.spendMoney = self.__getGainSpendMoney(vehicle, nationGroupVehs, shells, eqs, boosters, optDevs, inventory, customizationItems, itemsForDemountKit)
        self.inventory = set((m.intCD for m in inventory))
        self.customizationItems = set(customizationItems)
        self.boosters = boosters
        self.itemsForDemountKit = itemsForDemountKit
        barracksBerthsNeeded = getCrewCount(nationGroupVehs)
        bufferOverflowCtx = {}
        isBufferOverflowed = False
        crewSkinsNeedDeletion = []
        self.__compensationAmount = ItemPrice(Money(), Money())
        if isCrewDismiss:
            tankmenGoingToBuffer, deletedTankmen = self.__restore.getTankmenDeletedBySelling(*nationGroupVehs)
            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
            if self.__lobbyContext.getServerSettings().isCrewSkinsEnabled():
                freeCountByItem = {}
                for veh in nationGroupVehs:
                    for _, tankman in veh.crew:
                        if tankman is not None and tankman.skinID != NO_CREW_SKIN_ID:
                            crewSkinItem = self.itemsCache.items.getCrewSkin(tankman.skinID)
                            if freeCountByItem.setdefault(crewSkinItem.getID(), crewSkinItem.getFreeCount()) < crewSkinItem.getMaxCount():
                                freeCountByItem[crewSkinItem.getID()] += 1
                            else:
                                crewSkinsNeedDeletion.append(crewSkinItem)
                                self.__compensationAmount += crewSkinItem.getBuyPrice()

        self.__compensationRequired = bool(crewSkinsNeedDeletion)
        plugins = [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),
         proc_plugs.BattleBoosterValidator(boosters),
         proc_plugs.DismountForDemountKitValidator(vehicle, itemsForDemountKit),
         _getUniqueVehicleSellConfirmator(vehicle)]
        if self.__lobbyContext.getServerSettings().isCrewSkinsEnabled():
            ctx = {'price': self.__compensationAmount,
             'action': None,
             'items': crewSkinsNeedDeletion}
            skinsPlugin = proc_plugs.CrewSkinsCompensationDialogConfirmator('crewSkins/skinWillBeDeleted', proc_plugs.CrewSkinsRemovalCompensationDialogMeta.OUT_OF_STORAGE_SUFFIX, ctx=ctx, isEnabled=bool(crewSkinsNeedDeletion))
            plugins.append(skinsPlugin)
        super(VehicleSeller, self).__init__(vehicle, plugins)
        self.isCrewDismiss = isCrewDismiss
        self.isDismantlingForMoney = bool(self.spendMoney)
        self.isRemovedAfterRent = vehicle.isRented
        self.usedDemountKitsCount = len(itemsForDemountKit)
        self.__hasPairModification = any((step.action.getPurchasedID() is not None for step in vehicle.postProgression.iterUnorderedSteps() if step.action.isMultiAction()))
        return