示例#1
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
示例#2
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
示例#3
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
示例#4
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