Ejemplo n.º 1
0
 def _inventorySyncHandler(self, *_):
     dk, _ = getDemountKitForOptDevice(self.__item)
     if not dk.enabled:
         self._closeClickHandler()
         return
     if self.__moneyOption:
         self.__moneyOption.updatePrice(self.removalPrice)
     self.removalPrice = self.__item.getRemovalPrice(self._itemsCache.items)
     gold = self._itemsCache.items.stats.gold
     goldEnough = self._isGoldEnough(gold)
     dkCount = dk.inventoryCount
     if self._isSelected(GOLD) and not goldEnough:
         if dkCount > 0:
             self._select(DEMOUNT_KIT)
         else:
             self._select(NOTHING)
     elif self._isSelected(DEMOUNT_KIT) and dkCount <= 0:
         if goldEnough:
             self._select(GOLD)
         else:
             self._select(NOTHING)
     elif self._isSelected(NOTHING):
         if dkCount > 0:
             self._select(DEMOUNT_KIT)
         elif goldEnough:
             self._select(GOLD)
Ejemplo n.º 2
0
 def _onLoading(self, *args, **kwargs):
     self.setSubView(Placeholder.TOP_RIGHT, MoneyBalance())
     self.setSubView(
         Placeholder.TITLE,
         SimpleTextTitle(
             getDemountDialogTitle(self.__item, self.__forFitting)))
     self.__selector = content = SelectOptionContent()
     content.addOption(DemountKitOption(self.__item.intCD))
     self.__moneyOption = MoneyOption(self.removalPrice)
     content.addOption(self.__moneyOption)
     content.setMessage(
         backport.text(R.strings.demount_kit.equipmentDemount.confirmation.
                       description()))
     dk, _ = getDemountKitForOptDevice(self.__item)
     goldEnough = self._isGoldEnough()
     if dk.inventoryCount > 0:
         self._select(DEMOUNT_KIT)
     elif goldEnough:
         self._select(GOLD)
     else:
         self._select(NOTHING)
     self.setSubView(Placeholder.CONTENT, self.__selector)
     self.addButton(ConfirmButton(R.strings.menu.moduleFits.removeName()))
     self.addButton(CancelButton())
     self._itemsCache.onSyncCompleted += self._inventorySyncHandler
     super(DemountOptionalDeviceDialog, self)._onLoading(*args, **kwargs)
Ejemplo n.º 3
0
 def _setResult(self, result):
     goldEnough = self._isGoldEnough()
     dk, _ = getDemountKitForOptDevice(self.__item)
     dkEnough = dk.inventoryCount > 0
     if result == DialogButtons.SUBMIT:
         if not goldEnough and not dkEnough:
             showBuyGoldForEquipment(self.removalPrice.price.gold)
             result = DialogButtons.CANCEL
     super(DemountOptionalDeviceDialog, self)._setResult(result)
Ejemplo n.º 4
0
    def _populate(self):
        super(VehicleSellDialog, self)._populate()
        self.__subscribe()
        vehInvID = self.__vehInvID
        self.__items = list()
        self.__vehicle = self.__itemsCache.items.getVehicle(vehInvID)
        self.__nationGroupVehicles = self.__getNationGroupVehicles(
            self.__vehicle.intCD)
        self.__otherVehicleShells = self.__getOtherVehiclesShells(vehInvID)
        self.__vehicleSellPrice = self.__vehicle.sellPrices.itemPrice.price
        self.__accountMoney = _VSDMoney(self.__itemsCache.items.stats.money)
        if self.__getIsDemountKitEnabled():
            for optDevice in self.__vehicle.optDevices.setupLayouts.getUniqueItems(
            ):
                if optDevice is not None and not optDevice.isRemovable:
                    demountKit, currency = getDemountKitForOptDevice(optDevice)
                    if demountKit is not None and currency == Currency.GOLD:
                        self.__accountMoney[
                            _DK_CURRENCY] = demountKit.inventoryCount

            self.__isDemountKitEnabled = True
        optionalDevicesOnVehicle = []
        shellsOnVehicle = []
        equipmentsOnVehicle = []
        battleBoostersOnVehicle = []
        customizationOnVehicle = []
        currentBalance = _VSDMoney(self.__accountMoney)
        for vehicle in self.__nationGroupVehicles:
            onVehicleOptionalDevices, currentBalance = self.__prepareVehicleOptionalDevices(
                vehicle, currentBalance)
            optionalDevicesOnVehicle.extend(onVehicleOptionalDevices)
            shellsOnVehicle.extend(self.__prepareOnVehicleShells(vehicle))
            equipmentsOnVehicle.extend(
                self.__prepareVehicleEquipments(vehicle))
            battleBoostersOnVehicle.extend(
                self.__prepareVehicleBoosters(vehicle))
            customizationOnVehicle.extend(
                self.__prepareVehicleCustomizations(vehicle))

        data = {
            'accountMoney': self.__accountMoney.toDict(),
            'sellVehicleVO': self.__getSellVehicleData(),
            'modulesInInventory': self.__prepareInventoryModules(),
            'shellsInInventory': self.__prepareInventoryShells(),
            'isSlidingComponentOpened': _getSlidingComponentOpened(),
            'optionalDevicesOnVehicle': optionalDevicesOnVehicle,
            'shellsOnVehicle': shellsOnVehicle,
            'equipmentsOnVehicle': equipmentsOnVehicle,
            'battleBoostersOnVehicle': battleBoostersOnVehicle,
            'customizationOnVehicle': customizationOnVehicle
        }
        self.as_setDataS(data)
        self.__updateTotalCost()
        self.setCrewDismissal(self.__isCrewDismissal)
        return
 def __init__(self, itemCD):
     super(DemountKitOption, self).__init__()
     item = self._itemsCache.items.getItemByCD(itemCD)
     self.__demountKit, _ = getDemountKitForOptDevice(item)
     self.viewModel.setIcon(
         R.images.gui.maps.icons.demountKit.common_150x150())
     self.viewModel.setText(
         backport.text(R.strings.demount_kit.equipmentDemount.optionFree()))
     self.viewModel.setComponentType(ComponentType.DEMOUNT_KIT)
     self.viewModel.tooltip.setType(TooltipType.BACKPORT)
     self.tooltipFactory = self._tooltipFactory
Ejemplo n.º 6
0
 def _inventorySyncHandler(self, *_):
     dk, _ = getDemountKitForOptDevice(self.__item)
     if dk is not None and dk.enabled:
         self.__dkAppeared = True
         self._closeClickHandler()
         return
     else:
         singlePriceFooter = self.getSubView(Placeholder.FOOTER)
         singlePriceFooter.updatePrice(self.itemPrice)
         checkMoneyButton = self.getButton(DialogButtons.SUBMIT)
         checkMoneyButton.money = self.itemPrice.price
         return
Ejemplo n.º 7
0
 def _getAdditionalData(self):
     dk, _ = getDemountKitForOptDevice(self.__item)
     return {
         'useDemountKit': self._isSelected(DEMOUNT_KIT),
         'openSingleDemountWindow': dk and not dk.enabled
     }