Esempio n. 1
0
    def construct(self):
        block = []
        shell = self.shell
        configuration = self.configuration
        buyPrice = configuration.buyPrice
        sellPrice = configuration.sellPrice
        if buyPrice and sellPrice:
            LOG_ERROR('You are not allowed to use buyPrice and sellPrice at the same time')
            return
        else:
            notEnoughMoney = False
            showDelimiter = False
            shop = self.itemsCache.items.shop
            money = self.itemsCache.items.stats.money
            if buyPrice and shell.buyPrices:
                for itemPrice in shell.buyPrices.iteritems(directOrder=False):
                    if not isItemBuyPriceAvailable(shell, itemPrice, shop) or not itemPrice.price:
                        continue
                    currency = itemPrice.getCurrency()
                    value = itemPrice.price.getSignValue(currency)
                    defValue = itemPrice.defPrice.getSignValue(currency)
                    actionPercent = itemPrice.getActionPrc()
                    needValue = value - money.getSignValue(currency)
                    if needValue > 0:
                        notEnoughMoney = True
                    else:
                        needValue = None
                    if showDelimiter:
                        block.append(formatters.packTextBlockData(text=text_styles.standard(TOOLTIPS.VEHICLE_TEXTDELIMITER_OR), padding=formatters.packPadding(left=81 + self.leftPadding)))
                    block.append(makePriceBlock(value, CURRENCY_SETTINGS.getBuySetting(currency), needValue, defValue if defValue > 0 else None, actionPercent, valueWidth=self._valueWidth))
                    showDelimiter = True

            if sellPrice and shell.sellPrices:
                block.append(makePriceBlock(shell.sellPrices.itemPrice.price.credits, CURRENCY_SETTINGS.SELL_PRICE, oldPrice=shell.sellPrices.itemPrice.defPrice.credits, percent=shell.sellPrices.itemPrice.getActionPrc(), valueWidth=self._valueWidth))
            inventoryCount = shell.inventoryCount
            if inventoryCount:
                block.append(formatters.packTextParameterBlockData(name=text_styles.main(TOOLTIPS.VEHICLE_INVENTORYCOUNT), value=text_styles.stats(inventoryCount), valueWidth=self._valueWidth, padding=formatters.packPadding(left=-5)))
            hasAction = shell.buyPrices.itemPrice.isActionPrice() or shell.sellPrices.itemPrice.isActionPrice()
            return (block, notEnoughMoney or hasAction)
Esempio n. 2
0
    def construct(self):
        block = []
        module = self.module
        slotIdx = self.configuration.slotIdx
        vehicle = self.configuration.vehicle
        sellPrice = self.configuration.sellPrice
        buyPrice = self.configuration.buyPrice
        unlockPrice = self.configuration.unlockPrice
        inventoryCount = self.configuration.inventoryCount
        vehiclesCount = self.configuration.vehiclesCount
        researchNode = self.configuration.node
        if buyPrice and sellPrice:
            LOG_ERROR('You are not allowed to use buyPrice and sellPrice at the same time')
            return
        else:

            def checkState(state):
                if researchNode is not None:
                    return bool(int(researchNode.state) & state)
                else:
                    return False

            isEqOrDev = module.itemTypeID in GUI_ITEM_TYPE.ARTEFACTS
            isNextToUnlock = checkState(NODE_STATE_FLAGS.NEXT_2_UNLOCK)
            isInstalled = checkState(NODE_STATE_FLAGS.INSTALLED)
            isInInventory = checkState(NODE_STATE_FLAGS.IN_INVENTORY)
            isUnlocked = checkState(NODE_STATE_FLAGS.UNLOCKED)
            isAutoUnlock = checkState(NODE_STATE_FLAGS.AUTO_UNLOCKED)
            items = self.itemsCache.items
            money = items.stats.money
            itemPrice = MONEY_UNDEFINED
            if module is not None:
                itemPrice = module.buyPrices.itemPrice.price
            isMoneyEnough = money >= itemPrice
            leftPadding = 92
            if unlockPrice and not isEqOrDev:
                parentCD = vehicle.intCD if vehicle is not None else None
                isAvailable, cost, need = getUnlockPrice(module.intCD, parentCD)
                neededValue = None
                if not isUnlocked and isNextToUnlock and need > 0:
                    neededValue = need
                if cost > 0:
                    block.append(makePriceBlock(cost, CURRENCY_SETTINGS.UNLOCK_PRICE, neededValue, leftPadding=leftPadding, valueWidth=self._valueWidth))
            notEnoughMoney = False
            hasAction = False
            if buyPrice and not isAutoUnlock:
                shop = self.itemsCache.items.shop
                money = self.itemsCache.items.stats.money
                rootInInv = vehicle is not None and vehicle.isInInventory
                if researchNode:
                    showNeeded = rootInInv and not isMoneyEnough and (isNextToUnlock or isUnlocked) and not (isInstalled or isInInventory)
                else:
                    isModuleUnlocked = module.isUnlocked
                    isModuleInInventory = module.isInInventory
                    showNeeded = not isModuleInInventory and isModuleUnlocked
                showDelimiter = False
                leftPadding = 92
                for itemPrice in module.buyPrices.iteritems(directOrder=False):
                    if not isItemBuyPriceAvailable(module, itemPrice, shop):
                        continue
                    currency = itemPrice.getCurrency()
                    value = itemPrice.price.getSignValue(currency)
                    defValue = itemPrice.defPrice.getSignValue(currency)
                    actionPercent = itemPrice.getActionPrc()
                    if isEqOrDev or showNeeded:
                        needValue = value - money.getSignValue(currency)
                        if needValue > 0:
                            notEnoughMoney = True
                        else:
                            needValue = None
                    else:
                        needValue = None
                    if currency == Currency.GOLD and actionPercent > 0:
                        leftActionPadding = 101 + self.leftPadding
                    else:
                        leftActionPadding = 81 + self.leftPadding
                    if actionPercent > 0:
                        hasAction = True
                    if showDelimiter:
                        block.append(formatters.packTextBlockData(text=text_styles.standard(TOOLTIPS.VEHICLE_TEXTDELIMITER_OR), padding=formatters.packPadding(left=leftActionPadding)))
                    block.append(makePriceBlock(value, CURRENCY_SETTINGS.getBuySetting(currency), needValue, defValue if defValue > 0 else None, actionPercent, valueWidth=self._valueWidth, leftPadding=leftPadding))
                    showDelimiter = True

            if sellPrice and module.sellPrices:
                block.append(makePriceBlock(module.sellPrices.itemPrice.price.credits, CURRENCY_SETTINGS.SELL_PRICE, oldPrice=module.sellPrices.itemPrice.defPrice.credits, percent=module.sellPrices.itemPrice.getActionPrc(), valueWidth=self._valueWidth, leftPadding=leftPadding))
            if inventoryCount:
                count = module.inventoryCount
                if count > 0:
                    block.append(self._getInventoryBlock(count))
            if vehiclesCount:
                inventoryVehicles = items.getVehicles(REQ_CRITERIA.INVENTORY)
                count = len(module.getInstalledVehicles(inventoryVehicles.itervalues()))
                if count > 0:
                    block.append(formatters.packTextParameterBlockData(name=text_styles.main(TOOLTIPS.VEHICLE_VEHICLECOUNT), value=text_styles.stats(count), valueWidth=self._valueWidth, padding=formatters.packPadding(left=-5)))
            isOptionalDevice = module.itemTypeID == GUI_ITEM_TYPE.OPTIONALDEVICE
            if isOptionalDevice and not module.isRemovable and not self.configuration.isAwardWindow:
                removalPrice = module.getRemovalPrice(self.itemsCache.items)
                removalPriceCurrency = removalPrice.getCurrency()
                currencyTextFormatter = getattr(text_styles, removalPriceCurrency, text_styles.gold)
                block.append(formatters.packTextParameterWithIconBlockData(name=text_styles.main(TOOLTIPS.MODULEFITS_NOT_REMOVABLE_DISMANTLING_PRICE), value=currencyTextFormatter(removalPrice.price.get(removalPriceCurrency)), icon=removalPriceCurrency, valueWidth=self._valueWidth, padding=formatters.packPadding(left=-5)))
            hasAction |= module.sellPrices.itemPrice.isActionPrice()
            return (block, notEnoughMoney or hasAction)