def create_exp_status(vehicles):
        if not g_currentVehicle.isPresent(): return
        parent = g_currentVehicle.item.intCD if g_currentVehicle.item else None
        vehicles_id = vehicles.keys()
        modules_exp_needed = 0
        elite_exp_need = 0
        research_vehicles = {}
        e_research = False
        m_research = False
        for unlocks in g_currentVehicle.item.descriptor.type.unlocksDescrs:
            if unlocks[1] in vehicles_id:
                temp_vehicle = vehicles[unlocks[1]]
                if temp_vehicle and not temp_vehicle.isUnlocked:
                    is_available, cost, _ = getUnlockPrice(unlocks[1], parent)
                    research_vehicles[unlocks[1]] = {'exp': cost, 'battles': 1, 'vehicle': temp_vehicle}
                    elite_exp_need += cost
                    e_research = True
                    for research in unlocks:
                        if research in (unlocks[0], unlocks[1]): continue
                        is_available, cost, _ = getUnlockPrice(research, parent)
                        if not is_available:
                            research_vehicles[unlocks[1]]['exp'] += cost

            else:
                is_available, cost, _ = getUnlockPrice(unlocks[1], parent)
                if not is_available:
                    modules_exp_needed += cost
                    elite_exp_need += cost
                    e_research = True
                    m_research = True

        return modules_exp_needed, elite_exp_need, research_vehicles, e_research, m_research
Exemplo n.º 2
0
 def __getTechTreeVehicleStatus(self, config, vehicle):
     nodeState = int(config.node.state)
     tooltip, level = None, InventoryVehicle.STATE_LEVEL.WARNING
     parentCD = None
     if config.node is not None:
         parentCD = config.node.unlockProps.parentID
     _, _, need2Unlock = getUnlockPrice(vehicle.intCD, parentCD)
     if not nodeState & NODE_STATE.UNLOCKED:
         if not nodeState & NODE_STATE.NEXT_2_UNLOCK:
             tooltip = '#tooltips:researchPage/vehicle/status/parentModuleIsLocked'
         elif need2Unlock > 0:
             tooltip = '#tooltips:researchPage/module/status/notEnoughXP'
             level = InventoryVehicle.STATE_LEVEL.CRITICAL
     else:
         if nodeState & NODE_STATE.IN_INVENTORY:
             return self.__getVehicleStatus(False, vehicle)
         canRentOrBuy, reason = vehicle.mayRentOrBuy(
             g_itemsCache.items.stats.money)
         if not canRentOrBuy:
             level = InventoryVehicle.STATE_LEVEL.CRITICAL
             if reason == 'gold_error':
                 tooltip = '#tooltips:moduleFits/gold_error'
             elif reason == 'credit_error':
                 tooltip = '#tooltips:moduleFits/credit_error'
             else:
                 tooltip = '#tooltips:moduleFits/operation_error'
     header, text = getComplexStatus(tooltip)
     if header is None and text is None:
         return
     return {'header': header, 'text': text, 'level': level}
Exemplo n.º 3
0
 def __getTechTreeVehicleStatus(self, config, vehicle):
     nodeState = int(config.node.state)
     tooltip, level = None, InventoryVehicle.STATE_LEVEL.WARNING
     parentCD = None
     if config.node is not None:
         parentCD = config.node.unlockProps.parentID
     _, _, need2Unlock = getUnlockPrice(vehicle.intCD, parentCD)
     if not nodeState & NODE_STATE.UNLOCKED:
         if not nodeState & NODE_STATE.NEXT_2_UNLOCK:
             tooltip = '#tooltips:researchPage/vehicle/status/parentModuleIsLocked'
         elif need2Unlock > 0:
             tooltip = '#tooltips:researchPage/module/status/notEnoughXP'
             level = InventoryVehicle.STATE_LEVEL.CRITICAL
     else:
         if nodeState & NODE_STATE.IN_INVENTORY:
             return self.__getVehicleStatus(False, vehicle)
         canRentOrBuy, reason = vehicle.mayRentOrBuy(g_itemsCache.items.stats.money)
         if not canRentOrBuy:
             level = InventoryVehicle.STATE_LEVEL.CRITICAL
             if reason == 'gold_error':
                 tooltip = '#tooltips:moduleFits/gold_error'
             elif reason == 'credit_error':
                 tooltip = '#tooltips:moduleFits/credit_error'
             else:
                 tooltip = '#tooltips:moduleFits/operation_error'
     header, text = getComplexStatus(tooltip)
     if header is None and text is None:
         return
     else:
         return {'header': header,
          'text': text,
          'level': level}
Exemplo n.º 4
0
 def __getTechTreeVehicleStatus(self, config, vehicle):
     nodeState = int(config.node.state)
     tooltip, level = None, Vehicle.VEHICLE_STATE_LEVEL.WARNING
     parentCD = None
     if config.node is not None:
         parentCD = config.node.unlockProps.parentID
     _, _, need2Unlock = getUnlockPrice(vehicle.intCD, parentCD)
     if not nodeState & NODE_STATE.UNLOCKED:
         if not nodeState & NODE_STATE.NEXT_2_UNLOCK:
             tooltip = TOOLTIPS.RESEARCHPAGE_VEHICLE_STATUS_PARENTMODULEISLOCKED
         elif need2Unlock > 0:
             tooltip = TOOLTIPS.RESEARCHPAGE_MODULE_STATUS_NOTENOUGHXP
             level = Vehicle.VEHICLE_STATE_LEVEL.CRITICAL
     else:
         if nodeState & NODE_STATE.IN_INVENTORY:
             return self.__getVehicleStatus(False, vehicle)
         canRentOrBuy, reason = vehicle.mayRentOrBuy(g_itemsCache.items.stats.money)
         if not canRentOrBuy:
             level = Vehicle.VEHICLE_STATE_LEVEL.CRITICAL
             if reason == 'gold_error':
                 tooltip = TOOLTIPS.MODULEFITS_GOLD_ERROR
             elif reason == 'credits_error':
                 tooltip = TOOLTIPS.MODULEFITS_CREDITS_ERROR
             else:
                 tooltip = TOOLTIPS.MODULEFITS_OPERATION_ERROR
     header, text = getComplexStatus(tooltip)
     if header is None and text is None:
         return
     else:
         return {'header': header,
          'text': text,
          'level': level}
Exemplo n.º 5
0
def StatusBlockConstructor_construct(base, self):
    block, result = base(self)
    if block and config.get('tooltips/showXpToUnlockVeh'):
        try:
            techTreeNode = self.configuration.node
            vehicle = self.vehicle
            isUnlocked = vehicle.isUnlocked
            parentCD = techTreeNode.unlockProps.parentID if techTreeNode is not None else None
            if parentCD is not None:
                isAvailable, cost, need, defCost, discount = getUnlockPrice(
                    vehicle.intCD, parentCD, vehicle.level)
                if isAvailable and not isUnlocked and need > 0 and techTreeNode is not None:
                    icon = "<img src='{}' vspace='{}'".format(
                        RES_ICONS.MAPS_ICONS_LIBRARY_XPCOSTICON_1.replace(
                            '..', 'img://gui'), -3)
                    template = "<font face='$TitleFont' size='14'><font color='#ff2717'>{}</font> {}</font> {}"
                    block[0]['data']['text'] = template.format(
                        i18n.makeString(
                            STORAGE.BLUEPRINTS_CARD_CONVERTREQUIRED), need,
                        icon)
            return block, result
        except Exception as ex:
            err(traceback.format_exc())
            return block, result
    else:
        return block, result
Exemplo n.º 6
0
 def __getTechTreeVehicleStatus(self, config, vehicle):
     nodeState = int(config.node.state)
     tooltip, level = None, Vehicle.VEHICLE_STATE_LEVEL.WARNING
     parentCD = None
     if config.node is not None:
         parentCD = config.node.unlockProps.parentID
     _, _, need2Unlock = getUnlockPrice(vehicle.intCD, parentCD)
     if not nodeState & NODE_STATE_FLAGS.UNLOCKED:
         if not nodeState & NODE_STATE_FLAGS.NEXT_2_UNLOCK:
             tooltip = TOOLTIPS.RESEARCHPAGE_VEHICLE_STATUS_PARENTMODULEISLOCKED
         elif need2Unlock > 0:
             tooltip = TOOLTIPS.RESEARCHPAGE_MODULE_STATUS_NOTENOUGHXP
             level = Vehicle.VEHICLE_STATE_LEVEL.CRITICAL
     else:
         if nodeState & NODE_STATE_FLAGS.IN_INVENTORY:
             return self.__getVehicleStatus(False, vehicle)
         mayObtain, reason = vehicle.mayObtainForMoney(
             g_itemsCache.items.stats.money)
         if not mayObtain:
             level = Vehicle.VEHICLE_STATE_LEVEL.CRITICAL
             if reason == 'gold_error':
                 tooltip = TOOLTIPS.MODULEFITS_GOLD_ERROR
             elif reason == 'credits_error':
                 tooltip = TOOLTIPS.MODULEFITS_CREDITS_ERROR
             else:
                 tooltip = TOOLTIPS.MODULEFITS_OPERATION_ERROR
     header, text = getComplexStatus(tooltip)
     if header is None and text is None:
         return
     else:
         return {'header': header, 'text': text, 'level': level}
Exemplo n.º 7
0
    def _getResearchPageStatus(self):
        module = self.module
        configuration = self.configuration
        vehicle = configuration.vehicle
        node = configuration.node
        block = []

        def status(title=None, desc=None):
            if title is not None or desc is not None:
                block.append(
                    formatters.packTitleDescBlock(
                        title=text_styles.middleTitle(title)
                        if title is not None else '',
                        desc=text_styles.main(desc)
                        if desc is not None else ''))
            return block

        header, text = (None, None)
        nodeState = int(node.state)
        statusTemplate = '#tooltips:researchPage/module/status/%s'
        parentCD = vehicle.intCD if vehicle is not None else None
        _, _, need = getUnlockPrice(module.intCD, parentCD)
        if not nodeState & NODE_STATE_FLAGS.UNLOCKED:
            if not vehicle.isUnlocked:
                header, text = getComplexStatus(statusTemplate %
                                                'rootVehicleIsLocked')
            elif not nodeState & NODE_STATE_FLAGS.NEXT_2_UNLOCK:
                header, text = getComplexStatus(statusTemplate %
                                                'parentModuleIsLocked')
            elif need > 0:
                header, text = getComplexStatus(statusTemplate % 'notEnoughXP')
                header = text_styles.critical(header)
            return status(header, text)
        elif not vehicle.isInInventory:
            header, text = getComplexStatus(statusTemplate % 'needToBuyTank')
            text %= {'vehiclename': vehicle.userName}
            return status(header, text)
        elif nodeState & NODE_STATE_FLAGS.INSTALLED:
            return status()
        else:
            if vehicle is not None:
                if vehicle.isInInventory:
                    vState = vehicle.getState()
                    if vState == 'battle':
                        header, text = getComplexStatus(statusTemplate %
                                                        'vehicleIsInBattle')
                    elif vState == 'locked':
                        header, text = getComplexStatus(
                            statusTemplate % 'vehicleIsReadyToFight')
                    elif vState == 'damaged' or vState == 'exploded' or vState == 'destroyed':
                        header, text = getComplexStatus(statusTemplate %
                                                        'vehicleIsBroken')
                if header is not None or text is not None:
                    return status(header, text)
            return self._getStatus()
Exemplo n.º 8
0
    def _getResearchPageStatus(self, module, configuration):
        vehicle = configuration.vehicle
        node = configuration.node

        def status(header=None,
                   text=None,
                   level=InventoryVehicle.STATE_LEVEL.WARNING):
            if header is not None or text is not None:
                return {'header': header, 'text': text, 'level': level}
            else:
                return

        header, text = (None, None)
        level = InventoryVehicle.STATE_LEVEL.WARNING
        nodeState = int(node.state)
        statusTemplate = '#tooltips:researchPage/module/status/%s'
        parentCD = vehicle.intCD if vehicle is not None else None
        _, _, need = getUnlockPrice(module.intCD, parentCD)
        if not nodeState & NODE_STATE.UNLOCKED:
            if not vehicle.isUnlocked:
                header, text = getComplexStatus(statusTemplate %
                                                'rootVehicleIsLocked')
            elif not nodeState & NODE_STATE.NEXT_2_UNLOCK:
                header, text = getComplexStatus(statusTemplate %
                                                'parentModuleIsLocked')
            elif need > 0:
                header, text = getComplexStatus(statusTemplate % 'notEnoughXP')
                level = InventoryVehicle.STATE_LEVEL.CRITICAL
            return status(header, text, level)
        if not vehicle.isInInventory:
            header, text = getComplexStatus(statusTemplate % 'needToBuyTank')
            text %= {'vehiclename': vehicle.userName}
            return status(header, text, InventoryVehicle.STATE_LEVEL.WARNING)
        if nodeState & NODE_STATE.INSTALLED:
            return status()
        if vehicle is not None:
            if vehicle.isInInventory:
                vState = vehicle.getState()
                if vState == 'battle':
                    header, text = getComplexStatus(statusTemplate %
                                                    'vehicleIsInBattle')
                elif vState == 'locked':
                    header, text = getComplexStatus(statusTemplate %
                                                    'vehicleIsReadyToFight')
                elif vState == 'damaged' or vState == 'exploded' or vState == 'destroyed':
                    header, text = getComplexStatus(statusTemplate %
                                                    'vehicleIsBroken')
            if header is not None or text is not None:
                return status(header, text, level)
        return self._getStatus(module, configuration)
Exemplo n.º 9
0
    def _getResearchPageStatus(self, module, configuration):
        vehicle = configuration.vehicle
        node = configuration.node

        def status(header = None, text = None, level = InventoryVehicle.STATE_LEVEL.WARNING):
            if header is not None or text is not None:
                return {'header': header,
                 'text': text,
                 'level': level}
            else:
                return
                return

        header, text = (None, None)
        level = InventoryVehicle.STATE_LEVEL.WARNING
        nodeState = int(node.state)
        statusTemplate = '#tooltips:researchPage/module/status/%s'
        parentCD = vehicle.intCD if vehicle is not None else None
        _, _, need = getUnlockPrice(module.intCD, parentCD)
        if not nodeState & NODE_STATE.UNLOCKED:
            if not vehicle.isUnlocked:
                header, text = getComplexStatus(statusTemplate % 'rootVehicleIsLocked')
            elif not nodeState & NODE_STATE.NEXT_2_UNLOCK:
                header, text = getComplexStatus(statusTemplate % 'parentModuleIsLocked')
            elif need > 0:
                header, text = getComplexStatus(statusTemplate % 'notEnoughXP')
                level = InventoryVehicle.STATE_LEVEL.CRITICAL
            return status(header, text, level)
        elif not vehicle.isInInventory:
            header, text = getComplexStatus(statusTemplate % 'needToBuyTank')
            text %= {'vehiclename': vehicle.userName}
            return status(header, text, InventoryVehicle.STATE_LEVEL.WARNING)
        elif nodeState & NODE_STATE.INSTALLED:
            return status()
        else:
            if vehicle is not None:
                if vehicle.isInInventory:
                    vState = vehicle.getState()
                    if vState == 'battle':
                        header, text = getComplexStatus(statusTemplate % 'vehicleIsInBattle')
                    elif vState == 'locked':
                        header, text = getComplexStatus(statusTemplate % 'vehicleIsReadyToFight')
                    elif vState == 'damaged' or vState == 'exploded' or vState == 'destroyed':
                        header, text = getComplexStatus(statusTemplate % 'vehicleIsBroken')
                if header is not None or text is not None:
                    return status(header, text, level)
            return self._getStatus(module, configuration)
Exemplo n.º 10
0
    def _getResearchPageStatus(self, module, configuration):
        vehicle = configuration.vehicle
        node = configuration.node

        def status(header=None, text=None, level=Vehicle.VEHICLE_STATE_LEVEL.WARNING):
            if header is not None or text is not None:
                return {"header": header, "text": text, "level": level}
            else:
                return
                return

        header, text = (None, None)
        level = Vehicle.VEHICLE_STATE_LEVEL.WARNING
        nodeState = int(node.state)
        statusTemplate = "#tooltips:researchPage/module/status/%s"
        parentCD = vehicle.intCD if vehicle is not None else None
        _, _, need = getUnlockPrice(module.intCD, parentCD)
        if not nodeState & NODE_STATE.UNLOCKED:
            if not vehicle.isUnlocked:
                header, text = getComplexStatus(statusTemplate % "rootVehicleIsLocked")
            elif not nodeState & NODE_STATE.NEXT_2_UNLOCK:
                header, text = getComplexStatus(statusTemplate % "parentModuleIsLocked")
            elif need > 0:
                header, text = getComplexStatus(statusTemplate % "notEnoughXP")
                level = Vehicle.VEHICLE_STATE_LEVEL.CRITICAL
            return status(header, text, level)
        elif not vehicle.isInInventory:
            header, text = getComplexStatus(statusTemplate % "needToBuyTank")
            text %= {"vehiclename": vehicle.userName}
            return status(header, text, Vehicle.VEHICLE_STATE_LEVEL.WARNING)
        elif nodeState & NODE_STATE.INSTALLED:
            return status()
        else:
            if vehicle is not None:
                if vehicle.isInInventory:
                    vState = vehicle.getState()
                    if vState == "battle":
                        header, text = getComplexStatus(statusTemplate % "vehicleIsInBattle")
                    elif vState == "locked":
                        header, text = getComplexStatus(statusTemplate % "vehicleIsReadyToFight")
                    elif vState == "damaged" or vState == "exploded" or vState == "destroyed":
                        header, text = getComplexStatus(statusTemplate % "vehicleIsBroken")
                if header is not None or text is not None:
                    return status(header, text, level)
            return self._getStatus(module, configuration)
Exemplo n.º 11
0
    def _getResearchPageStatus(self):
        module = self.module
        configuration = self.configuration
        vehicle = configuration.vehicle
        node = configuration.node
        block = []

        def status(title = None, desc = None):
            if title is not None or desc is not None:
                block.append(formatters.packTitleDescBlock(title=text_styles.middleTitle(title) if title is not None else '', desc=text_styles.main(desc) if desc is not None else ''))
            return block

        header, text = (None, None)
        nodeState = int(node.state)
        statusTemplate = '#tooltips:researchPage/module/status/%s'
        parentCD = vehicle.intCD if vehicle is not None else None
        _, _, need = getUnlockPrice(module.intCD, parentCD)
        if not nodeState & NODE_STATE.UNLOCKED:
            if not vehicle.isUnlocked:
                header, text = getComplexStatus(statusTemplate % 'rootVehicleIsLocked')
            elif not nodeState & NODE_STATE.NEXT_2_UNLOCK:
                header, text = getComplexStatus(statusTemplate % 'parentModuleIsLocked')
            elif need > 0:
                header, text = getComplexStatus(statusTemplate % 'notEnoughXP')
            return status(header, text)
        elif not vehicle.isInInventory:
            header, text = getComplexStatus(statusTemplate % 'needToBuyTank')
            text %= {'vehiclename': vehicle.userName}
            return status(header, text)
        elif nodeState & NODE_STATE.INSTALLED:
            return status()
        else:
            if vehicle is not None:
                if vehicle.isInInventory:
                    vState = vehicle.getState()
                    if vState == 'battle':
                        header, text = getComplexStatus(statusTemplate % 'vehicleIsInBattle')
                    elif vState == 'locked':
                        header, text = getComplexStatus(statusTemplate % 'vehicleIsReadyToFight')
                    elif vState == 'damaged' or vState == 'exploded' or vState == 'destroyed':
                        header, text = getComplexStatus(statusTemplate % 'vehicleIsBroken')
                if header is not None or text is not None:
                    return status(header, text)
            return self._getStatus()
Exemplo n.º 12
0
 def construct(self):
     xp = self.configuration.xp
     dailyXP = self.configuration.dailyXP
     buyPrice = self.configuration.buyPrice
     sellPrice = self.configuration.sellPrice
     unlockPrice = self.configuration.unlockPrice
     techTreeNode = self.configuration.node
     minRentPrice = self.configuration.minRentPrice
     rentals = self.configuration.rentals
     futureRentals = self.configuration.futureRentals
     paddings = formatters.packPadding(left=-4)
     neededValue = 0
     actionPrc = 0
     if buyPrice and sellPrice:
         LOG_ERROR("You are not allowed to use buyPrice and sellPrice at the same time")
         return
     else:
         block = []
         isUnlocked = self.vehicle.isUnlocked
         isInInventory = self.vehicle.isInInventory
         isNextToUnlock = False
         parentCD = None
         if techTreeNode is not None:
             isNextToUnlock = bool(int(techTreeNode.state) & NODE_STATE_FLAGS.NEXT_2_UNLOCK)
             parentCD = techTreeNode.unlockProps.parentID
         if xp:
             xpValue = self.vehicle.xp
             if xpValue:
                 xPText = text_styles.expText(_int(xpValue))
                 icon = ICON_TEXT_FRAMES.FREE_XP if self.vehicle.isPremium else ICON_TEXT_FRAMES.XP
                 block.append(
                     formatters.packTextParameterWithIconBlockData(
                         name=text_styles.main(TOOLTIPS.VEHICLE_XP),
                         value=xPText,
                         icon=icon,
                         valueWidth=self._valueWidth,
                         padding=paddings,
                     )
                 )
         if dailyXP:
             attrs = g_itemsCache.items.stats.attributes
             if attrs & constants.ACCOUNT_ATTR.DAILY_MULTIPLIED_XP and self.vehicle.dailyXPFactor > 0:
                 dailyXPText = text_styles.main(text_styles.expText("x" + _int(self.vehicle.dailyXPFactor)))
                 block.append(
                     formatters.packTextParameterWithIconBlockData(
                         name=text_styles.main(TOOLTIPS.VEHICLE_DAILYXPFACTOR),
                         value=dailyXPText,
                         icon=ICON_TEXT_FRAMES.DOUBLE_XP_FACTOR,
                         valueWidth=self._valueWidth,
                         padding=paddings,
                     )
                 )
         if unlockPrice:
             isAvailable, cost, need = getUnlockPrice(self.vehicle.intCD, parentCD)
             if cost > 0:
                 neededValue = None
                 if isAvailable and not isUnlocked and need > 0 and techTreeNode is not None:
                     neededValue = need
                 block.append(
                     makePriceBlock(cost, CURRENCY_SETTINGS.UNLOCK_PRICE, neededValue, valueWidth=self._valueWidth)
                 )
         if buyPrice:
             if self.vehicle.isRestorePossible():
                 price = self.vehicle.restorePrice
                 defaultPrice = price
                 currency = price.getCurrency()
                 buyPriceText = price.get(currency)
                 oldPrice = defaultPrice.get(currency)
                 neededValue = _getNeedValue(price, currency)
                 if isInInventory or not isInInventory and not isUnlocked and not isNextToUnlock:
                     neededValue = None
                 block.append(
                     makePriceBlock(
                         buyPriceText,
                         CURRENCY_SETTINGS.RESTORE_PRICE,
                         neededValue,
                         oldPrice,
                         actionPrc,
                         valueWidth=self._valueWidth,
                     )
                 )
                 if self.vehicle.hasLimitedRestore():
                     timeKey, formattedTime = getTimeLeftInfo(self.vehicle.restoreInfo.getRestoreTimeLeft(), None)
                     block.append(
                         formatters.packTextParameterWithIconBlockData(
                             name=text_styles.main("#tooltips:vehicle/restoreLeft/%s" % timeKey),
                             value=text_styles.main(formattedTime),
                             icon=ICON_TEXT_FRAMES.ALERT if timeKey == "hours" else ICON_TEXT_FRAMES.EMPTY,
                             valueWidth=self._valueWidth,
                             padding=formatters.packPadding(left=-4),
                         )
                     )
             elif not (self.vehicle.isDisabledForBuy or self.vehicle.isPremiumIGR or self.vehicle.isTelecom):
                 price = self.vehicle.buyPrice
                 actionPrc = self.vehicle.actionPrc
                 defaultPrice = self.vehicle.defaultPrice
                 currency = price.getCurrency()
                 buyPriceText = price.get(currency)
                 oldPrice = defaultPrice.get(currency)
                 neededValue = _getNeedValue(price, currency)
                 if isInInventory or not isInInventory and not isUnlocked and not isNextToUnlock:
                     neededValue = None
                 block.append(
                     makePriceBlock(
                         buyPriceText,
                         CURRENCY_SETTINGS.getBuySetting(currency),
                         neededValue,
                         oldPrice,
                         0,
                         valueWidth=self._valueWidth,
                     )
                 )
         if sellPrice and not self.vehicle.isTelecom:
             sellPrice = self.vehicle.sellPrice
             if sellPrice.isSet(Currency.GOLD):
                 sellPriceText = text_styles.gold(_int(sellPrice.gold))
                 sellPriceIcon = ICON_TEXT_FRAMES.GOLD
             else:
                 sellPriceText = text_styles.credits(_int(sellPrice.credits))
                 sellPriceIcon = ICON_TEXT_FRAMES.CREDITS
             block.append(
                 formatters.packTextParameterWithIconBlockData(
                     name=text_styles.main(TOOLTIPS.VEHICLE_SELL_PRICE),
                     value=sellPriceText,
                     icon=sellPriceIcon,
                     valueWidth=self._valueWidth,
                     padding=paddings,
                 )
             )
         if minRentPrice and not self.vehicle.isPremiumIGR:
             minRentPricePackage = self.vehicle.getRentPackage()
             if minRentPricePackage:
                 minRentPriceValue = Money(*minRentPricePackage["rentPrice"])
                 minDefaultRentPriceValue = Money(*minRentPricePackage["defaultRentPrice"])
                 actionPrc = self.vehicle.getRentPackageActionPrc(minRentPricePackage["days"])
                 currency = minRentPriceValue.getCurrency()
                 price = minRentPriceValue.get(currency)
                 oldPrice = minDefaultRentPriceValue.get(currency)
                 neededValue = _getNeedValue(minRentPriceValue, currency)
                 block.append(
                     makePriceBlock(
                         price,
                         CURRENCY_SETTINGS.getRentSetting(currency),
                         neededValue,
                         oldPrice,
                         actionPrc,
                         valueWidth=self._valueWidth,
                     )
                 )
                 if not self.vehicle.isRented or self.vehicle.rentalIsOver:
                     block.append(
                         formatters.packTextParameterWithIconBlockData(
                             name=text_styles.main("#tooltips:vehicle/rentAvailable"),
                             value="",
                             icon=ICON_TEXT_FRAMES.RENTALS,
                             valueWidth=self._valueWidth,
                             padding=paddings,
                         )
                     )
         if rentals and not self.vehicle.isPremiumIGR:
             if futureRentals:
                 rentLeftKey = "#tooltips:vehicle/rentLeftFuture/%s"
                 rentInfo = RentalInfoProvider(time=self._rentExpiryTime, isRented=True)
             else:
                 rentLeftKey = "#tooltips:vehicle/rentLeft/%s"
                 rentInfo = self.vehicle.rentInfo
             rentFormatter = RentLeftFormatter(rentInfo)
             rentLeftInfo = rentFormatter.getRentLeftStr(
                 rentLeftKey,
                 formatter=lambda key, countType, count, _=None: {
                     "left": count,
                     "descr": i18n.makeString(key % countType),
                 },
             )
             if rentLeftInfo:
                 block.append(
                     formatters.packTextParameterWithIconBlockData(
                         name=text_styles.main(rentLeftInfo["descr"]),
                         value=text_styles.main(rentLeftInfo["left"]),
                         icon=ICON_TEXT_FRAMES.RENTALS,
                         valueWidth=self._valueWidth,
                         padding=formatters.packPadding(left=-4, bottom=-16),
                     )
                 )
         notEnoughMoney = neededValue > 0
         hasAction = actionPrc > 0
         return (block, notEnoughMoney or hasAction)
Exemplo n.º 13
0
 def construct(self):
     xp = self.configuration.xp
     dailyXP = self.configuration.dailyXP
     buyPrice = self.configuration.buyPrice
     sellPrice = self.configuration.sellPrice
     unlockPrice = self.configuration.unlockPrice
     techTreeNode = self.configuration.node
     minRentPrice = self.configuration.minRentPrice
     rentals = self.configuration.rentals
     paddings = formatters.packPadding(left=-4)
     neededValue = 0
     actionPrc = 0
     if buyPrice and sellPrice:
         LOG_ERROR('You are not allowed to use buyPrice and sellPrice at the same time')
         return
     else:
         block = []
         isUnlocked = self.vehicle.isUnlocked
         isInInventory = self.vehicle.isInInventory
         isNextToUnlock = False
         parentCD = None
         if techTreeNode is not None:
             isNextToUnlock = bool(int(techTreeNode.state) & NODE_STATE.NEXT_2_UNLOCK)
             parentCD = techTreeNode.unlockProps.parentID
         if xp:
             xpValue = self.vehicle.xp
             if xpValue:
                 xPText = text_styles.expText(_int(xpValue))
                 icon = ICON_TEXT_FRAMES.FREE_XP if self.vehicle.isPremium else ICON_TEXT_FRAMES.XP
                 block.append(formatters.packTextParameterWithIconBlockData(name=text_styles.main(TOOLTIPS.VEHICLE_XP), value=xPText, icon=icon, valueWidth=self._valueWidth, padding=paddings))
         if dailyXP:
             attrs = g_itemsCache.items.stats.attributes
             if attrs & constants.ACCOUNT_ATTR.DAILY_MULTIPLIED_XP and self.vehicle.dailyXPFactor > 0:
                 dailyXPText = text_styles.main(text_styles.expText('x' + _int(self.vehicle.dailyXPFactor)))
                 block.append(formatters.packTextParameterWithIconBlockData(name=text_styles.main(TOOLTIPS.VEHICLE_DAILYXPFACTOR), value=dailyXPText, icon=ICON_TEXT_FRAMES.DOUBLE_XP_FACTOR, valueWidth=self._valueWidth, padding=paddings))
         if unlockPrice:
             isAvailable, cost, need = getUnlockPrice(self.vehicle.intCD, parentCD)
             if cost > 0:
                 neededValue = None
                 if isAvailable and not isUnlocked and need > 0 and techTreeNode is not None:
                     neededValue = need
                 block.append(makePriceBlock(cost, CURRENCY_SETTINGS.UNLOCK_PRICE, neededValue, valueWidth=self._valueWidth))
         if buyPrice and not (self.vehicle.isDisabledForBuy or self.vehicle.isPremiumIGR or self.vehicle.isTelecom):
             price = self.vehicle.buyPrice
             money = g_itemsCache.items.stats.money
             actionPrc = self.vehicle.actionPrc
             defaultPrice = self.vehicle.defaultPrice
             currency = price.getCurrency()
             buyPriceText = price.get(currency)
             oldPrice = defaultPrice.get(currency)
             neededValue = price.get(currency) - money.get(currency)
             neededValue = neededValue if neededValue > 0 else None
             if isInInventory or not isInInventory and not isUnlocked and not isNextToUnlock:
                 neededValue = None
             block.append(makePriceBlock(buyPriceText, CURRENCY_SETTINGS.getBuySetting(currency), neededValue, oldPrice, actionPrc, valueWidth=self._valueWidth))
         if sellPrice and not self.vehicle.isTelecom:
             sellPrice = self.vehicle.sellPrice
             if sellPrice.isSet(Currency.GOLD):
                 sellPriceText = text_styles.gold(_int(sellPrice.gold))
                 sellPriceIcon = ICON_TEXT_FRAMES.GOLD
             else:
                 sellPriceText = text_styles.credits(_int(sellPrice.credits))
                 sellPriceIcon = ICON_TEXT_FRAMES.CREDITS
             block.append(formatters.packTextParameterWithIconBlockData(name=text_styles.main(TOOLTIPS.VEHICLE_SELL_PRICE), value=sellPriceText, icon=sellPriceIcon, valueWidth=self._valueWidth, padding=paddings))
         if minRentPrice and not self.vehicle.isPremiumIGR:
             minRentPricePackage = self.vehicle.getRentPackage()
             if minRentPricePackage:
                 minRentPriceValue = Money(*minRentPricePackage['rentPrice'])
                 minDefaultRentPriceValue = Money(*minRentPricePackage['defaultRentPrice'])
                 actionPrc = self.vehicle.getRentPackageActionPrc(minRentPricePackage['days'])
                 money = g_itemsCache.items.stats.money
                 currency = minRentPriceValue.getCurrency()
                 price = minRentPriceValue.get(currency)
                 oldPrice = minDefaultRentPriceValue.get(currency)
                 neededValue = minRentPriceValue.get(currency) - money.get(currency)
                 neededValue = neededValue if neededValue > 0 else None
                 block.append(makePriceBlock(price, CURRENCY_SETTINGS.getRentSetting(currency), neededValue, oldPrice, actionPrc, valueWidth=self._valueWidth))
         if rentals and not self.vehicle.isPremiumIGR:
             rentFormatter = RentLeftFormatter(self.vehicle.rentInfo)
             rentLeftInfo = rentFormatter.getRentLeftStr('#tooltips:vehicle/rentLeft/%s', formatter=lambda key, countType, count, _ = None: {'left': count,
              'descr': i18n.makeString(key % countType)})
             if rentLeftInfo:
                 block.append(formatters.packTextParameterWithIconBlockData(name=text_styles.main(rentLeftInfo['descr']), value=text_styles.main(rentLeftInfo['left']), icon=ICON_TEXT_FRAMES.RENTALS, valueWidth=self._valueWidth, padding=formatters.packPadding(left=-4, bottom=-16)))
         notEnoughMoney = neededValue > 0
         hasAction = actionPrc > 0
         return (block, notEnoughMoney or hasAction)
Exemplo n.º 14
0
    def _getValue(self):
        result = []
        module = self._tooltip.item
        configuration = self._tooltip.context.getStatsConfiguration(module)
        vehicle = configuration.vehicle
        sellPrice = configuration.sellPrice
        buyPrice = configuration.buyPrice
        unlockPrice = configuration.unlockPrice
        inventoryCount = configuration.inventoryCount
        vehiclesCount = configuration.vehiclesCount
        researchNode = configuration.node
        if buyPrice and sellPrice:
            LOG_ERROR(
                'You are not allowed to use buyPrice and sellPrice at the same time'
            )
            return

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

        isEqOrDev = module.itemTypeID in GUI_ITEM_TYPE.ARTEFACTS
        isNextToUnlock = checkState(NODE_STATE.NEXT_2_UNLOCK)
        isInstalled = checkState(NODE_STATE.INSTALLED)
        isInInventory = checkState(NODE_STATE.IN_INVENTORY)
        isUnlocked = checkState(NODE_STATE.UNLOCKED)
        isAutoUnlock = checkState(NODE_STATE.AUTO_UNLOCKED)
        items = g_itemsCache.items
        credits, gold = items.stats.money
        itemPrice = (0, 0)
        if module is not None:
            itemPrice = module.buyPrice
        isMoneyEnough = credits >= itemPrice[0] and gold >= itemPrice[1]
        if unlockPrice and not isEqOrDev:
            parentCD = vehicle.intCD if vehicle is not None else None
            isAvailable, cost, need = getUnlockPrice(module.intCD, parentCD)
            unlockPriceStat = [cost]
            if not isUnlocked and isNextToUnlock and need > 0:
                unlockPriceStat.append(need)
            if cost > 0:
                result.append(('unlock_price', unlockPriceStat))
        if buyPrice and not isAutoUnlock:
            price = module.altPrice or module.buyPrice
            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
            need = (0, 0)
            if isEqOrDev or showNeeded:
                creditsNeeded = price[0] - credits if price[0] else 0
                goldNeeded = price[1] - gold if price[1] else 0
                need = (max(0, creditsNeeded), max(0, goldNeeded))
            result.append(('buy_price', (price, need)))
            result.append(('def_buy_price', module.defaultAltPrice
                           or module.defaultPrice))
            result.append(('action_prc', module.actionPrc))
        if sellPrice:
            result.append(('sell_price', module.sellPrice))
            result.append(('def_sell_price', module.defaultSellPrice))
            result.append(('action_prc', module.sellActionPrc))
        if inventoryCount:
            count = module.inventoryCount
            if count:
                result.append(('inventoryCount', count))
        if vehiclesCount:
            inventoryVehicles = items.getVehicles(REQ_CRITERIA.INVENTORY)
            count = len(
                module.getInstalledVehicles(inventoryVehicles.itervalues()))
            if count:
                result.append(('vehicleCount', count))
                if count > self._tooltip.MAX_INSTALLED_LIST_LEN:
                    hiddenVehicleCount = count - self._tooltip.MAX_INSTALLED_LIST_LEN
                    result.append(('hiddenVehicleCount', hiddenVehicleCount))
        return result
Exemplo n.º 15
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)
Exemplo n.º 16
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 = g_itemsCache.items
            money = items.stats.money
            itemPrice = ZERO_MONEY
            if module is not None:
                itemPrice = module.buyPrice
            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))
            creditsActionPercent, goldActionPercent = (0, 0)
            need = ZERO_MONEY
            if buyPrice and not isAutoUnlock:
                price = module.altPrice or module.buyPrice
                defPrice = module.defaultAltPrice or module.defaultPrice
                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
                if isEqOrDev or showNeeded:
                    need = price - money
                    need = need.toNonNegative()
                if price.credits > 0:
                    creditsActionPercent = getActionPrc(price.credits, defPrice.credits)
                    block.append(makePriceBlock(price.credits, CURRENCY_SETTINGS.BUY_CREDITS_PRICE, need.credits if need.credits > 0 else None, defPrice.credits if defPrice.credits > 0 else None, creditsActionPercent, self._valueWidth, leftPadding))
                if price.gold > 0:
                    goldActionPercent = getActionPrc(price.gold, defPrice.gold)
                    block.append(formatters.packTextBlockData(text=text_styles.standard(TOOLTIPS.VEHICLE_TEXTDELIMITER_OR), padding=formatters.packPadding(left=(101 if goldActionPercent > 0 else 81) + self.leftPadding)))
                    block.append(makePriceBlock(price.gold, CURRENCY_SETTINGS.BUY_GOLD_PRICE, need.gold if need.gold > 0 else None, defPrice.gold if defPrice.gold > 0 else None, goldActionPercent, self._valueWidth, leftPadding))
            if sellPrice:
                block.append(makePriceBlock(module.sellPrice.credits, CURRENCY_SETTINGS.SELL_PRICE, oldPrice=module.defaultSellPrice.credits, percent=module.sellActionPrc, valueWidth=self._valueWidth, leftPadding=leftPadding))
            if inventoryCount:
                count = module.inventoryCount
                if count > 0:
                    block.append(formatters.packTextParameterBlockData(name=text_styles.main(TOOLTIPS.VEHICLE_INVENTORYCOUNT), value=text_styles.stats(count), valueWidth=self._valueWidth, padding=formatters.packPadding(left=-5)))
            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)))
            notEnoughMoney = need > ZERO_MONEY
            hasAction = creditsActionPercent > 0 or goldActionPercent > 0 or module.sellActionPrc > 0
            return (block, notEnoughMoney or hasAction)
Exemplo n.º 17
0
 def construct(self):
     xp = self.configuration.xp
     dailyXP = self.configuration.dailyXP
     buyPrice = self.configuration.buyPrice
     sellPrice = self.configuration.sellPrice
     unlockPrice = self.configuration.unlockPrice
     techTreeNode = self.configuration.node
     minRentPrice = self.configuration.minRentPrice
     rentals = self.configuration.rentals
     futureRentals = self.configuration.futureRentals
     paddings = formatters.packPadding(left=-4)
     neededValue = 0
     actionPrc = 0
     if buyPrice and sellPrice:
         LOG_ERROR(
             'You are not allowed to use buyPrice and sellPrice at the same time'
         )
         return
     else:
         block = []
         isUnlocked = self.vehicle.isUnlocked
         isInInventory = self.vehicle.isInInventory
         isNextToUnlock = False
         parentCD = None
         if techTreeNode is not None:
             isNextToUnlock = bool(
                 int(techTreeNode.state) & NODE_STATE_FLAGS.NEXT_2_UNLOCK)
             parentCD = techTreeNode.unlockProps.parentID
         if xp:
             xpValue = self.vehicle.xp
             if xpValue:
                 xPText = text_styles.expText(_int(xpValue))
                 icon = ICON_TEXT_FRAMES.FREE_XP if self.vehicle.isPremium else ICON_TEXT_FRAMES.XP
                 block.append(
                     formatters.packTextParameterWithIconBlockData(
                         name=text_styles.main(TOOLTIPS.VEHICLE_XP),
                         value=xPText,
                         icon=icon,
                         valueWidth=self._valueWidth,
                         padding=paddings))
         if dailyXP:
             attrs = g_itemsCache.items.stats.attributes
             if attrs & constants.ACCOUNT_ATTR.DAILY_MULTIPLIED_XP and self.vehicle.dailyXPFactor > 0:
                 dailyXPText = text_styles.main(
                     text_styles.expText('x' +
                                         _int(self.vehicle.dailyXPFactor)))
                 block.append(
                     formatters.packTextParameterWithIconBlockData(
                         name=text_styles.main(
                             TOOLTIPS.VEHICLE_DAILYXPFACTOR),
                         value=dailyXPText,
                         icon=ICON_TEXT_FRAMES.DOUBLE_XP_FACTOR,
                         valueWidth=self._valueWidth,
                         padding=paddings))
         if unlockPrice:
             isAvailable, cost, need = getUnlockPrice(
                 self.vehicle.intCD, parentCD)
             if cost > 0:
                 neededValue = None
                 if isAvailable and not isUnlocked and need > 0 and techTreeNode is not None:
                     neededValue = need
                 block.append(
                     makePriceBlock(cost,
                                    CURRENCY_SETTINGS.UNLOCK_PRICE,
                                    neededValue,
                                    valueWidth=self._valueWidth))
         if buyPrice:
             if self.vehicle.isRestorePossible():
                 price = self.vehicle.restorePrice
                 defaultPrice = price
                 currency = price.getCurrency()
                 buyPriceText = price.get(currency)
                 oldPrice = defaultPrice.get(currency)
                 neededValue = _getNeedValue(price, currency)
                 if isInInventory or not isInInventory and not isUnlocked and not isNextToUnlock:
                     neededValue = None
                 block.append(
                     makePriceBlock(buyPriceText,
                                    CURRENCY_SETTINGS.RESTORE_PRICE,
                                    neededValue,
                                    oldPrice,
                                    actionPrc,
                                    valueWidth=self._valueWidth))
                 if self.vehicle.hasLimitedRestore():
                     timeKey, formattedTime = getTimeLeftInfo(
                         self.vehicle.restoreInfo.getRestoreTimeLeft(),
                         None)
                     block.append(
                         formatters.packTextParameterWithIconBlockData(
                             name=text_styles.main(
                                 '#tooltips:vehicle/restoreLeft/%s' %
                                 timeKey),
                             value=text_styles.main(formattedTime),
                             icon=ICON_TEXT_FRAMES.ALERT if timeKey
                             == 'hours' else ICON_TEXT_FRAMES.EMPTY,
                             valueWidth=self._valueWidth,
                             padding=formatters.packPadding(left=-4)))
             elif not (self.vehicle.isDisabledForBuy or
                       self.vehicle.isPremiumIGR or self.vehicle.isTelecom):
                 price = self.vehicle.buyPrice
                 actionPrc = self.vehicle.actionPrc
                 defaultPrice = self.vehicle.defaultPrice
                 currency = price.getCurrency()
                 buyPriceText = price.get(currency)
                 oldPrice = defaultPrice.get(currency)
                 neededValue = _getNeedValue(price, currency)
                 if isInInventory or not isInInventory and not isUnlocked and not isNextToUnlock:
                     neededValue = None
                 block.append(
                     makePriceBlock(
                         buyPriceText,
                         CURRENCY_SETTINGS.getBuySetting(currency),
                         neededValue,
                         oldPrice,
                         0,
                         valueWidth=self._valueWidth))
         if sellPrice and not self.vehicle.isTelecom:
             sellPrice = self.vehicle.sellPrice
             if sellPrice.isSet(Currency.GOLD):
                 sellPriceText = text_styles.gold(_int(sellPrice.gold))
                 sellPriceIcon = ICON_TEXT_FRAMES.GOLD
             else:
                 sellPriceText = text_styles.credits(_int(
                     sellPrice.credits))
                 sellPriceIcon = ICON_TEXT_FRAMES.CREDITS
             block.append(
                 formatters.packTextParameterWithIconBlockData(
                     name=text_styles.main(TOOLTIPS.VEHICLE_SELL_PRICE),
                     value=sellPriceText,
                     icon=sellPriceIcon,
                     valueWidth=self._valueWidth,
                     padding=paddings))
         if minRentPrice and not self.vehicle.isPremiumIGR:
             minRentPricePackage = self.vehicle.getRentPackage()
             if minRentPricePackage:
                 minRentPriceValue = Money(
                     *minRentPricePackage['rentPrice'])
                 minDefaultRentPriceValue = Money(
                     *minRentPricePackage['defaultRentPrice'])
                 actionPrc = self.vehicle.getRentPackageActionPrc(
                     minRentPricePackage['days'])
                 currency = minRentPriceValue.getCurrency()
                 price = minRentPriceValue.get(currency)
                 oldPrice = minDefaultRentPriceValue.get(currency)
                 neededValue = _getNeedValue(minRentPriceValue, currency)
                 block.append(
                     makePriceBlock(
                         price,
                         CURRENCY_SETTINGS.getRentSetting(currency),
                         neededValue,
                         oldPrice,
                         actionPrc,
                         valueWidth=self._valueWidth))
                 if not self.vehicle.isRented or self.vehicle.rentalIsOver:
                     block.append(
                         formatters.packTextParameterWithIconBlockData(
                             name=text_styles.main(
                                 '#tooltips:vehicle/rentAvailable'),
                             value='',
                             icon=ICON_TEXT_FRAMES.RENTALS,
                             valueWidth=self._valueWidth,
                             padding=paddings))
         if rentals and not self.vehicle.isPremiumIGR:
             if futureRentals:
                 rentLeftKey = '#tooltips:vehicle/rentLeftFuture/%s'
                 rentInfo = RentalInfoProvider(time=self._rentExpiryTime,
                                               isRented=True)
             else:
                 rentLeftKey = '#tooltips:vehicle/rentLeft/%s'
                 rentInfo = self.vehicle.rentInfo
             rentFormatter = RentLeftFormatter(rentInfo)
             rentLeftInfo = rentFormatter.getRentLeftStr(
                 rentLeftKey,
                 formatter=lambda key, countType, count, _=None: {
                     'left': count,
                     'descr': i18n.makeString(key % countType)
                 })
             if rentLeftInfo:
                 block.append(
                     formatters.packTextParameterWithIconBlockData(
                         name=text_styles.main(rentLeftInfo['descr']),
                         value=text_styles.main(rentLeftInfo['left']),
                         icon=ICON_TEXT_FRAMES.RENTALS,
                         valueWidth=self._valueWidth,
                         padding=formatters.packPadding(left=-4,
                                                        bottom=-16)))
         notEnoughMoney = neededValue > 0
         hasAction = actionPrc > 0
         return (block, notEnoughMoney or hasAction)
Exemplo n.º 18
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.NEXT_2_UNLOCK)
            isInstalled = checkState(NODE_STATE.INSTALLED)
            isInInventory = checkState(NODE_STATE.IN_INVENTORY)
            isUnlocked = checkState(NODE_STATE.UNLOCKED)
            isAutoUnlock = checkState(NODE_STATE.AUTO_UNLOCKED)
            items = g_itemsCache.items
            credits, gold = items.stats.money
            itemPrice = (0, 0)
            if module is not None:
                itemPrice = module.buyPrice
            isMoneyEnough = credits >= itemPrice[0] and gold >= itemPrice[1]
            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(self._makePriceBlock(cost, 'unlockPrice', neededValue))
            creditsActionPercent, goldActionPercent = (0, 0)
            needCredits, needGold = (0, 0)
            if buyPrice and not isAutoUnlock:
                creditsPrice, goldPrice = module.altPrice or module.buyPrice
                defCreditsPrice, defGoldPrice = module.defaultAltPrice or module.defaultPrice
                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
                if isEqOrDev or showNeeded:
                    creditsNeeded = creditsPrice - credits if creditsPrice else 0
                    goldNeeded = goldPrice - gold if goldPrice else 0
                    needCredits, needGold = max(0, creditsNeeded), max(0, goldNeeded)
                if creditsPrice > 0:
                    creditsActionPercent = getActionPrc(creditsPrice, defCreditsPrice)
                    block.append(self._makePriceBlock(creditsPrice, 'buyCreditsPrice', needCredits if needCredits > 0 else None, defCreditsPrice if defCreditsPrice > 0 else None, creditsActionPercent))
                if goldPrice > 0:
                    goldActionPercent = getActionPrc(goldPrice, defGoldPrice)
                    block.append(formatters.packTextBlockData(text=text_styles.standard(TOOLTIPS.VEHICLE_TEXTDELIMITER_OR), padding=formatters.packPadding(left=(101 if goldActionPercent > 0 else 81) + self.leftPadding)))
                    block.append(self._makePriceBlock(goldPrice, 'buyGoldPrice', needGold if needGold > 0 else None, defGoldPrice if defGoldPrice > 0 else None, goldActionPercent))
            if sellPrice:
                block.append(self._makePriceBlock(module.sellPrice[0], 'sellPrice', oldPrice=module.defaultSellPrice[0], percent=module.sellActionPrc))
            if inventoryCount:
                count = module.inventoryCount
                if count > 0:
                    block.append(formatters.packTextParameterBlockData(name=text_styles.main(TOOLTIPS.VEHICLE_INVENTORYCOUNT), value=text_styles.stats(count), valueWidth=self._valueWidth, padding=formatters.packPadding(left=-5)))
            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)))
                    isInstalled = False
                    if vehicle is not None:
                        isFit, reason = module.mayInstall(vehicle, slotIdx)
                        if not isFit:
                            reason = reason.replace(' ', '_')
                        isInstalled = reason == 'already_installed'
                    if count > self.MAX_INSTALLED_LIST_LEN and (isInstalled or isMoneyEnough):
                        hiddenVehicleCount = count - self.MAX_INSTALLED_LIST_LEN
                        block.append(formatters.packTextParameterBlockData(name=text_styles.main(TOOLTIPS.SUITABLEVEHICLE_HIDDENVEHICLECOUNT), value=text_styles.stats(hiddenVehicleCount), valueWidth=self._valueWidth, padding=formatters.packPadding(left=-5)))
            notEnoughMoney = needCredits > 0 or needGold > 0
            hasAction = creditsActionPercent > 0 or goldActionPercent > 0 or module.sellActionPrc > 0
            return (block, notEnoughMoney or hasAction)
Exemplo n.º 19
0
    def _getValue(self):
        result = []
        module = self._tooltip.item
        configuration = self._tooltip.context.getStatsConfiguration(module)
        vehicle = configuration.vehicle
        sellPrice = configuration.sellPrice
        buyPrice = configuration.buyPrice
        unlockPrice = configuration.unlockPrice
        inventoryCount = configuration.inventoryCount
        vehiclesCount = configuration.vehiclesCount
        researchNode = 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.NEXT_2_UNLOCK)
            isInstalled = checkState(NODE_STATE.INSTALLED)
            isInInventory = checkState(NODE_STATE.IN_INVENTORY)
            isUnlocked = checkState(NODE_STATE.UNLOCKED)
            isAutoUnlock = checkState(NODE_STATE.AUTO_UNLOCKED)
            items = g_itemsCache.items
            credits, gold = items.stats.money
            itemPrice = (0, 0)
            if module is not None:
                itemPrice = module.buyPrice
            isMoneyEnough = credits >= itemPrice[0] and gold >= itemPrice[1]
            if unlockPrice and not isEqOrDev:
                parentCD = vehicle.intCD if vehicle is not None else None
                isAvailable, cost, need = getUnlockPrice(module.intCD, parentCD)
                unlockPriceStat = [cost]
                if not isUnlocked and isNextToUnlock and need > 0:
                    unlockPriceStat.append(need)
                if cost > 0:
                    result.append(("unlock_price", unlockPriceStat))
            if buyPrice and not isAutoUnlock:
                price = module.altPrice or module.buyPrice
                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
                need = (0, 0)
                if isEqOrDev or showNeeded:
                    creditsNeeded = price[0] - credits if price[0] else 0
                    goldNeeded = price[1] - gold if price[1] else 0
                    need = (max(0, creditsNeeded), max(0, goldNeeded))
                result.append(("buy_price", (price, need)))
                result.append(("def_buy_price", module.defaultAltPrice or module.defaultPrice))
                result.append(("action_prc", module.actionPrc))
            if sellPrice:
                result.append(("sell_price", module.sellPrice))
                result.append(("def_sell_price", module.defaultSellPrice))
                result.append(("action_prc", module.sellActionPrc))
            if inventoryCount:
                count = module.inventoryCount
                if count:
                    result.append(("inventoryCount", count))
            if vehiclesCount:
                inventoryVehicles = items.getVehicles(REQ_CRITERIA.INVENTORY)
                count = len(module.getInstalledVehicles(inventoryVehicles.itervalues()))
                if count:
                    result.append(("vehicleCount", count))
                    if count > self._tooltip.MAX_INSTALLED_LIST_LEN:
                        hiddenVehicleCount = count - self._tooltip.MAX_INSTALLED_LIST_LEN
                        result.append(("hiddenVehicleCount", hiddenVehicleCount))
            return result
Exemplo n.º 20
0
 def construct(self):
     xp = self.configuration.xp
     dailyXP = self.configuration.dailyXP
     buyPrice = self.configuration.buyPrice
     sellPrice = self.configuration.sellPrice
     unlockPrice = self.configuration.unlockPrice
     techTreeNode = self.configuration.node
     minRentPrice = self.configuration.minRentPrice
     rentals = self.configuration.rentals
     if buyPrice and sellPrice:
         LOG_ERROR('You are not allowed to use buyPrice and sellPrice at the same time')
         return
     else:
         priceBlock = []
         isUnlocked = self.vehicle.isUnlocked
         isInInventory = self.vehicle.isInInventory
         isRented = self.vehicle.isRented
         isNextToUnlock = False
         parentCD = None
         if techTreeNode is not None:
             isNextToUnlock = bool(int(techTreeNode.state) & NODE_STATE.NEXT_2_UNLOCK)
             parentCD = techTreeNode.unlockProps.parentID
         if xp:
             xpValue = self.vehicle.xp
             if xpValue:
                 xPText = text_styles.expText(_int(xpValue))
                 icon = ICON_TEXT_FRAMES.FREE_XP if self.vehicle.isPremium else ICON_TEXT_FRAMES.XP
                 priceBlock.append(formatters.packTextParameterWithIconBlockData(name=text_styles.main(_ms(TOOLTIPS.VEHICLE_XP)), value=xPText, icon=icon, valueWidth=self._valueWidth, padding=formatters.packPadding(left=self.leftPadding, right=self.rightPadding)))
         if dailyXP:
             attrs = g_itemsCache.items.stats.attributes
             if attrs & constants.ACCOUNT_ATTR.DAILY_MULTIPLIED_XP and self.vehicle.dailyXPFactor > 0:
                 dailyXPText = text_styles.main(text_styles.expText('x' + _int(self.vehicle.dailyXPFactor)))
                 priceBlock.append(formatters.packTextParameterWithIconBlockData(name=text_styles.main(_ms(TOOLTIPS.VEHICLE_DAILYXPFACTOR)), value=dailyXPText, icon=ICON_TEXT_FRAMES.DOUBLE_XP_FACTOR, valueWidth=self._valueWidth, padding=formatters.packPadding(left=self.leftPadding, right=self.rightPadding)))
         if unlockPrice:
             isAvailable, cost, need = getUnlockPrice(self.vehicle.intCD, parentCD)
             if cost > 0:
                 neededValue = None
                 if isAvailable and not isUnlocked and need > 0 and techTreeNode is not None:
                     neededValue = need
                 block = self._makePriceBlock(cost, _ms(TOOLTIPS.VEHICLE_UNLOCK_PRICE), ICON_TEXT_FRAMES.XP, neededValue)
                 priceBlock.append(block)
         if buyPrice and not (self.vehicle.isDisabledForBuy or self.vehicle.isPremiumIGR or self.vehicle.isTelecom):
             price = self.vehicle.buyPrice
             credits, gold = g_itemsCache.items.stats.money
             creditsBuyPrice = price[0]
             goldBuyPrice = price[1]
             creditsNeeded = creditsBuyPrice - credits if creditsBuyPrice else 0
             goldNeeded = goldBuyPrice - gold if goldBuyPrice else 0
             neededValue = None
             actionPrc = self.vehicle.actionPrc
             defaultPrice = self.vehicle.defaultPrice
             if goldBuyPrice == 0:
                 currencyType = ICON_TEXT_FRAMES.CREDITS
                 buyPriceText = creditsBuyPrice
                 oldPrice = defaultPrice[0]
                 if creditsNeeded > 0:
                     neededValue = creditsNeeded
             else:
                 currencyType = ICON_TEXT_FRAMES.GOLD
                 buyPriceText = goldBuyPrice
                 oldPrice = defaultPrice[1]
                 if goldNeeded > 0:
                     neededValue = goldNeeded
             text = _ms(TOOLTIPS.VEHICLE_BUY_PRICE)
             if isInInventory or not isInInventory and not isUnlocked and not isNextToUnlock:
                 neededValue = None
             block = self._makePriceBlock(buyPriceText, text, currencyType, neededValue, oldPrice, actionPrc)
             priceBlock.append(block)
         if sellPrice and not self.vehicle.isTelecom:
             creditsPrice = self.vehicle.sellPrice[0]
             goldPrice = self.vehicle.sellPrice[1]
             if goldPrice == 0:
                 sellPriceText = text_styles.credits(_int(creditsPrice))
                 sellPriceIcon = ICON_TEXT_FRAMES.CREDITS
             else:
                 sellPriceText = text_styles.gold(_int(goldPrice))
                 sellPriceIcon = ICON_TEXT_FRAMES.GOLD
             priceBlock.append(formatters.packTextParameterWithIconBlockData(name=text_styles.main(_ms(TOOLTIPS.VEHICLE_SELL_PRICE)), value=sellPriceText, icon=sellPriceIcon, valueWidth=self._valueWidth, padding=formatters.packPadding(left=self.leftPadding, right=self.rightPadding)))
         if minRentPrice and not self.vehicle.isPremiumIGR:
             minRentPricePackage = self.vehicle.getRentPackage()
             if minRentPricePackage:
                 minRentPriceValue = minRentPricePackage['rentPrice']
                 minDefaultRentPriceValue = minRentPricePackage['defaultRentPrice']
                 rentActionPrc = self.vehicle.getRentPackageActionPrc(minRentPricePackage['days'])
                 credits, gold = g_itemsCache.items.stats.money
                 creditsPrice = minRentPriceValue[0]
                 goldPrice = minRentPriceValue[1]
                 enoughCreditsForRent = credits - creditsPrice >= 0
                 enoughGoldForRent = gold - goldPrice >= 0
                 neededValue = None
                 if goldPrice == 0:
                     price = creditsPrice
                     oldPrice = minDefaultRentPriceValue[0]
                     currencyType = ICON_TEXT_FRAMES.CREDITS
                     if not enoughCreditsForRent:
                         neededValue = credits - creditsPrice
                 else:
                     price = goldPrice
                     oldPrice = minDefaultRentPriceValue[1]
                     currencyType = ICON_TEXT_FRAMES.GOLD
                     if not enoughGoldForRent:
                         neededValue = gold - goldPrice
                 text = _ms(TOOLTIPS.VEHICLE_MINRENTALSPRICE)
                 block = self._makePriceBlock(price, text, currencyType, neededValue, oldPrice, rentActionPrc)
                 priceBlock.append(block)
         if rentals and not self.vehicle.isPremiumIGR:
             rentFormatter = RentLeftFormatter(self.vehicle.rentInfo)
             rentLeftInfo = rentFormatter.getRentLeftStr('#tooltips:vehicle/rentLeft/%s', formatter=lambda key, countType, count, _ = None: {'left': count,
              'descr': i18n.makeString(key % countType)})
             if rentLeftInfo:
                 priceBlock.append(formatters.packTextParameterWithIconBlockData(name=text_styles.main(rentLeftInfo['descr']), value=text_styles.main(rentLeftInfo['left']), icon=ICON_TEXT_FRAMES.RENTALS, valueWidth=self._valueWidth, padding=formatters.packPadding(left=self.leftPadding, right=self.rightPadding)))
         return priceBlock
Exemplo n.º 21
0
 def _getValue(self):
     result = []
     vehicle = self._tooltip.item
     configuration = self._tooltip.context.getStatsConfiguration(vehicle)
     xp = configuration.xp
     dailyXP = configuration.dailyXP
     unlockPrice = configuration.unlockPrice
     buyPrice = configuration.buyPrice
     sellPrice = configuration.sellPrice
     techTreeNode = configuration.node
     minRentPrice = configuration.minRentPrice
     rentals = configuration.rentals
     if buyPrice and sellPrice:
         LOG_ERROR(
             'You are not allowed to use buyPrice and sellPrice at the same time'
         )
         return
     isUnlocked = vehicle.isUnlocked
     isInInventory = vehicle.isInInventory
     isRented = vehicle.isRented
     isNextToUnlock = False
     parentCD = None
     if techTreeNode is not None:
         isNextToUnlock = bool(
             int(techTreeNode.state) & NODE_STATE.NEXT_2_UNLOCK)
         parentCD = techTreeNode.unlockProps.parentID
     if xp:
         xpValue = vehicle.xp
         if xpValue:
             result.append(('xp', xpValue))
     if dailyXP:
         attrs = g_itemsCache.items.stats.attributes
         if attrs & constants.ACCOUNT_ATTR.DAILY_MULTIPLIED_XP and vehicle.dailyXPFactor:
             result.append(('dailyXPFactor', vehicle.dailyXPFactor))
     if unlockPrice:
         isAvailable, cost, need = getUnlockPrice(vehicle.intCD, parentCD)
         unlockPriceStat = [cost]
         if isAvailable and not isUnlocked and need > 0 and techTreeNode is not None:
             unlockPriceStat.append(need)
         if cost > 0:
             result.append(('unlock_price', unlockPriceStat))
     if buyPrice and not (vehicle.isDisabledForBuy or vehicle.isPremiumIGR):
         price = vehicle.buyPrice
         needed = (0, 0)
         if not isInInventory and (isNextToUnlock
                                   or isUnlocked) or isRented:
             credits, gold = g_itemsCache.items.stats.money
             creditsNeeded = price[0] - credits if price[0] else 0
             goldNeeded = price[1] - gold if price[1] else 0
             needed = (max(0, creditsNeeded), max(0, goldNeeded))
         result.append(('buy_price', (price, needed)))
         result.append(('def_buy_price', vehicle.defaultPrice))
         result.append(('action_prc', vehicle.actionPrc))
     if sellPrice:
         result.append(('sell_price', vehicle.sellPrice))
         result.append(('def_sell_price', vehicle.defaultSellPrice))
         result.append(('action_prc', vehicle.sellActionPrc))
     if minRentPrice and not vehicle.isPremiumIGR:
         minRentPricePackage = vehicle.getRentPackage()
         if minRentPricePackage:
             minRentPriceValue = minRentPricePackage['rentPrice']
             minDefaultRentPriceValue = minRentPricePackage[
                 'defaultRentPrice']
             rentActionPrc = vehicle.getRentPackageActionPrc(
                 minRentPricePackage['days'])
             credits, gold = g_itemsCache.items.stats.money
             enoughGoldForRent = gold - minRentPriceValue[1] >= 0
             enoughCreditsForRent = credits - minRentPriceValue[0] >= 0
             result.append(('minRentalsPrice', (minRentPriceValue,
                                                (enoughCreditsForRent,
                                                 enoughGoldForRent))))
             result.append(('defRentPrice', minDefaultRentPriceValue))
             result.append(('rentActionPrc', rentActionPrc))
     if rentals and not vehicle.isPremiumIGR:
         rentFormatter = RentLeftFormatter(vehicle.rentInfo)
         rentLeftInfo = rentFormatter.getRentLeftStr(
             '#tooltips:vehicle/rentLeft/%s',
             formatter=lambda key, countType, count, _=None: {
                 'left': count,
                 'descr': i18n.makeString(key % countType)
             })
         if rentLeftInfo:
             result.append(('rentals', rentLeftInfo))
     return result
Exemplo n.º 22
0
 def _getValue(self):
     result = []
     vehicle = self._tooltip.item
     configuration = self._tooltip.context.getStatsConfiguration(vehicle)
     xp = configuration.xp
     dailyXP = configuration.dailyXP
     unlockPrice = configuration.unlockPrice
     buyPrice = configuration.buyPrice
     sellPrice = configuration.sellPrice
     techTreeNode = configuration.node
     minRentPrice = configuration.minRentPrice
     rentals = configuration.rentals
     if buyPrice and sellPrice:
         LOG_ERROR('You are not allowed to use buyPrice and sellPrice at the same time')
         return
     else:
         isUnlocked = vehicle.isUnlocked
         isInInventory = vehicle.isInInventory
         isRented = vehicle.isRented
         isNextToUnlock = False
         parentCD = None
         if techTreeNode is not None:
             isNextToUnlock = bool(int(techTreeNode.state) & NODE_STATE.NEXT_2_UNLOCK)
             parentCD = techTreeNode.unlockProps.parentID
         if xp:
             xpValue = vehicle.xp
             if xpValue:
                 result.append(('xp', xpValue))
         if dailyXP:
             attrs = g_itemsCache.items.stats.attributes
             if attrs & constants.ACCOUNT_ATTR.DAILY_MULTIPLIED_XP and vehicle.dailyXPFactor:
                 result.append(('dailyXPFactor', vehicle.dailyXPFactor))
         if unlockPrice:
             isAvailable, cost, need = getUnlockPrice(vehicle.intCD, parentCD)
             unlockPriceStat = [cost]
             if isAvailable and not isUnlocked and need > 0 and techTreeNode is not None:
                 unlockPriceStat.append(need)
             if cost > 0:
                 result.append(('unlock_price', unlockPriceStat))
         if buyPrice and not (vehicle.isDisabledForBuy or vehicle.isPremiumIGR):
             price = vehicle.buyPrice
             needed = (0, 0)
             if not isInInventory and (isNextToUnlock or isUnlocked) or isRented:
                 credits, gold = g_itemsCache.items.stats.money
                 creditsNeeded = price[0] - credits if price[0] else 0
                 goldNeeded = price[1] - gold if price[1] else 0
                 needed = (max(0, creditsNeeded), max(0, goldNeeded))
             result.append(('buy_price', (price, needed)))
             result.append(('def_buy_price', vehicle.defaultPrice))
             result.append(('action_prc', vehicle.actionPrc))
         if sellPrice:
             result.append(('sell_price', vehicle.sellPrice))
             result.append(('def_sell_price', vehicle.defaultSellPrice))
             result.append(('action_prc', vehicle.sellActionPrc))
         if minRentPrice and not vehicle.isPremiumIGR:
             minRentPricePackage = vehicle.getRentPackage()
             if minRentPricePackage:
                 minRentPriceValue = minRentPricePackage['rentPrice']
                 minDefaultRentPriceValue = minRentPricePackage['defaultRentPrice']
                 rentActionPrc = vehicle.getRentPackageActionPrc(minRentPricePackage['days'])
                 credits, gold = g_itemsCache.items.stats.money
                 enoughGoldForRent = gold - minRentPriceValue[1] >= 0
                 enoughCreditsForRent = credits - minRentPriceValue[0] >= 0
                 result.append(('minRentalsPrice', (minRentPriceValue, (enoughCreditsForRent, enoughGoldForRent))))
                 result.append(('defRentPrice', minDefaultRentPriceValue))
                 result.append(('rentActionPrc', rentActionPrc))
         if rentals and not vehicle.isPremiumIGR:
             rentLeftTime = vehicle.rentLeftTime
             if rentLeftTime > 0:
                 if rentLeftTime > time_utils.ONE_DAY:
                     timeLeft = math.ceil(vehicle.rentLeftTime / time_utils.ONE_DAY)
                     description = i18n.makeString(TOOLTIPS.VEHICLE_RENTLEFT_DAYS)
                 else:
                     timeLeft = math.ceil(vehicle.rentLeftTime / time_utils.ONE_HOUR)
                     description = i18n.makeString(TOOLTIPS.VEHICLE_RENTLEFT_HOURS)
                 result.append(('rentals', {'left': timeLeft,
                   'descr': description}))
         return result
Exemplo n.º 23
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 = g_itemsCache.items
            money = items.stats.money
            itemPrice = ZERO_MONEY
            if module is not None:
                itemPrice = module.buyPrice
            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))
            creditsActionPercent, goldActionPercent = (0, 0)
            need = ZERO_MONEY
            if buyPrice and not isAutoUnlock:
                price = module.altPrice or module.buyPrice
                defPrice = module.defaultAltPrice or module.defaultPrice
                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
                if isEqOrDev or showNeeded:
                    need = price - money
                    need = need.toNonNegative()
                if price.credits > 0:
                    creditsActionPercent = getActionPrc(
                        price.credits, defPrice.credits)
                    block.append(
                        makePriceBlock(
                            price.credits, CURRENCY_SETTINGS.BUY_CREDITS_PRICE,
                            need.credits if need.credits > 0 else None,
                            defPrice.credits if defPrice.credits > 0 else None,
                            creditsActionPercent, self._valueWidth,
                            leftPadding))
                if price.gold > 0:
                    goldActionPercent = getActionPrc(price.gold, defPrice.gold)
                    block.append(
                        formatters.packTextBlockData(
                            text=text_styles.standard(
                                TOOLTIPS.VEHICLE_TEXTDELIMITER_OR),
                            padding=formatters.packPadding(
                                left=(101 if goldActionPercent > 0 else 81) +
                                self.leftPadding)))
                    block.append(
                        makePriceBlock(
                            price.gold, CURRENCY_SETTINGS.BUY_GOLD_PRICE,
                            need.gold if need.gold > 0 else None,
                            defPrice.gold if defPrice.gold > 0 else None,
                            goldActionPercent, self._valueWidth, leftPadding))
            if sellPrice:
                block.append(
                    makePriceBlock(module.sellPrice.credits,
                                   CURRENCY_SETTINGS.SELL_PRICE,
                                   oldPrice=module.defaultSellPrice.credits,
                                   percent=module.sellActionPrc,
                                   valueWidth=self._valueWidth,
                                   leftPadding=leftPadding))
            if inventoryCount:
                count = module.inventoryCount
                if count > 0:
                    block.append(
                        formatters.packTextParameterBlockData(
                            name=text_styles.main(
                                TOOLTIPS.VEHICLE_INVENTORYCOUNT),
                            value=text_styles.stats(count),
                            valueWidth=self._valueWidth,
                            padding=formatters.packPadding(left=-5)))
            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)))
            notEnoughMoney = need > ZERO_MONEY
            hasAction = creditsActionPercent > 0 or goldActionPercent > 0 or module.sellActionPrc > 0
            return (block, notEnoughMoney or hasAction)