def getVehicleDataVO(vehicle):
    rentInfoText = RentLeftFormatter(vehicle.rentInfo, vehicle.isPremiumIGR).getRentLeftStr()
    vState, vStateLvl = vehicle.getState()
    if vehicle.isRotationApplied():
        if vState in (Vehicle.VEHICLE_STATE.AMMO_NOT_FULL, Vehicle.VEHICLE_STATE.LOCKED):
            vState = Vehicle.VEHICLE_STATE.ROTATION_GROUP_UNLOCKED
    smallStatus, largeStatus = getStatusStrings(vState, vStateLvl, substitute=rentInfoText, ctx={'icon': icons.premiumIgrSmall(),
     'battlesLeft': getBattlesLeft(vehicle)})
    if vehicle.dailyXPFactor > 1:
        bonusImage = getButtonsAssetPath('bonus_x{}'.format(vehicle.dailyXPFactor))
    else:
        bonusImage = ''
    label = vehicle.shortUserName if vehicle.isPremiumIGR else vehicle.userName
    labelStyle = text_styles.premiumVehicleName if vehicle.isPremium else text_styles.vehicleName
    return {'id': vehicle.invID,
     'intCD': vehicle.intCD,
     'infoText': largeStatus,
     'smallInfoText': smallStatus,
     'clanLock': vehicle.clanLock,
     'lockBackground': _isLockedBackground(vState, vStateLvl),
     'icon': vehicle.icon,
     'iconAlt': getIconPath('noImage'),
     'iconSmall': vehicle.iconSmall,
     'iconSmallAlt': getSmallIconPath('noImage'),
     'label': labelStyle(label),
     'level': vehicle.level,
     'premium': vehicle.isPremium,
     'favorite': vehicle.isFavorite,
     'nation': vehicle.nationID,
     'xpImgSource': bonusImage,
     'tankType': '{}_elite'.format(vehicle.type) if vehicle.isElite else vehicle.type,
     'rentLeft': rentInfoText,
     'clickEnabled': vehicle.isInInventory,
     'alpha': 1,
     'infoImgSrc': getVehicleStateIcon(vState),
     'isCritInfo': vStateLvl == Vehicle.VEHICLE_STATE_LEVEL.CRITICAL}
def getVehicleDataVO(vehicle):
    lowTierMMController = dependency.instance(ILowTierMMController)
    rentInfoText = RentLeftFormatter(vehicle.rentInfo,
                                     vehicle.isPremiumIGR).getRentLeftStr()
    vState, vStateLvl = vehicle.getState()
    if vehicle.isRotationApplied():
        if vState in (Vehicle.VEHICLE_STATE.AMMO_NOT_FULL,
                      Vehicle.VEHICLE_STATE.LOCKED):
            vState = Vehicle.VEHICLE_STATE.ROTATION_GROUP_UNLOCKED
    if not vehicle.activeInNationGroup:
        vState = Vehicle.VEHICLE_STATE.NOT_PRESENT
    customStateExt = ''
    if vState in (Vehicle.VEHICLE_STATE.RENTABLE,
                  Vehicle.VEHICLE_STATE.RENTABLE_AGAIN):
        rentPackagesInfo = vehicle.getRentPackagesInfo
        if rentPackagesInfo.seasonType:
            customStateExt = '/' + SEASON_NAME_BY_TYPE.get(
                rentPackagesInfo.seasonType)
    smallStatus, largeStatus = getStatusStrings(vState + customStateExt,
                                                vStateLvl,
                                                substitute=rentInfoText,
                                                ctx={
                                                    'icon':
                                                    icons.premiumIgrSmall(),
                                                    'battlesLeft':
                                                    getBattlesLeft(vehicle)
                                                })
    smallHoverStatus, largeHoverStatus = smallStatus, largeStatus
    if vState == Vehicle.VEHICLE_STATE.RENTABLE:
        smallHoverStatus, largeHoverStatus = getStatusStrings(
            vState + '/hover',
            vStateLvl,
            substitute=rentInfoText,
            ctx={
                'icon': icons.premiumIgrSmall(),
                'battlesLeft': getBattlesLeft(vehicle)
            })
    if vehicle.dailyXPFactor > 1:
        bonusImage = getButtonsAssetPath('bonus_x{}'.format(
            vehicle.dailyXPFactor))
    else:
        bonusImage = ''
    label = vehicle.shortUserName if vehicle.isPremiumIGR else vehicle.userName
    labelStyle = text_styles.premiumVehicleName if vehicle.isPremium else text_styles.vehicleName
    tankType = '{}_elite'.format(
        vehicle.type) if vehicle.isElite else vehicle.type
    current, maximum = vehicle.getCrystalsEarnedInfo()
    isCrystalsLimitReached = current == maximum
    return {
        'id':
        vehicle.invID,
        'intCD':
        vehicle.intCD,
        'infoText':
        largeStatus,
        'infoHoverText':
        largeHoverStatus,
        'smallInfoText':
        smallStatus,
        'smallInfoHoverText':
        smallHoverStatus,
        'clanLock':
        vehicle.clanLock,
        'lockBackground':
        _isLockedBackground(vState, vStateLvl),
        'icon':
        vehicle.icon,
        'iconAlt':
        getIconPath('noImage'),
        'iconSmall':
        vehicle.iconSmall,
        'iconSmallAlt':
        getSmallIconPath('noImage'),
        'label':
        labelStyle(label),
        'level':
        vehicle.level,
        'premium':
        vehicle.isPremium,
        'favorite':
        vehicle.isFavorite,
        'giveaway':
        vehicle.isLowTierEvent and lowTierMMController.isEnabled(),
        'nation':
        vehicle.nationID,
        'xpImgSource':
        bonusImage,
        'tankType':
        tankType,
        'rentLeft':
        rentInfoText,
        'clickEnabled':
        vehicle.isInInventory and vehicle.activeInNationGroup
        or vehicle.isRentPromotion,
        'alpha':
        1,
        'infoImgSrc':
        getVehicleStateIcon(vState),
        'additionalImgSrc':
        getVehicleStateAddIcon(vState),
        'isCritInfo':
        vStateLvl == Vehicle.VEHICLE_STATE_LEVEL.CRITICAL,
        'isRentPromotion':
        vehicle.isRentPromotion and not vehicle.isRented,
        'isNationChangeAvailable':
        vehicle.hasNationGroup,
        'isEarnCrystals':
        vehicle.isEarnCrystals,
        'isCrystalsLimitReached':
        isCrystalsLimitReached,
        'isUseRightBtn':
        True,
        'tooltip':
        TOOLTIPS_CONSTANTS.CAROUSEL_VEHICLE
    }
Example #3
0
 def __getVehicleStatus(self, showCustomStates, vehicle):
     if showCustomStates:
         isInInventory = vehicle.isInInventory
         level = Vehicle.VEHICLE_STATE_LEVEL.WARNING
         if not isInInventory and vehicle.hasRestoreCooldown() and vehicle.isHidden:
             timeKey, formattedTime = getTimeLeftInfo(self.vehicle.restoreInfo.getRestoreCooldownTimeLeft())
             return {'header': _ms('#tooltips:vehicleStatus/restoreCooldown/%s' % timeKey, time=formattedTime),
              'text': '',
              'level': level}
         isUnlocked = vehicle.isUnlocked
         mayObtain, reason = vehicle.mayObtainForMoney(self.itemsCache.items.stats.money)
         msg = None
         if not isUnlocked:
             msg = 'notUnlocked'
         elif isInInventory:
             msg = 'inHangar'
         elif not mayObtain:
             level = Vehicle.VEHICLE_STATE_LEVEL.CRITICAL
             if reason == GUI_ITEM_ECONOMY_CODE.NOT_ENOUGH_GOLD:
                 msg = 'notEnoughGold'
             elif reason == GUI_ITEM_ECONOMY_CODE.NOT_ENOUGH_CREDITS:
                 msg = 'notEnoughCredits'
             else:
                 msg = 'operationError'
         if msg is not None:
             header, text = getComplexStatus('#tooltips:vehicleStatus/%s' % msg)
             return {'header': header,
              'text': text,
              'level': level}
         return
     else:
         state, level = vehicle.getState()
         if state == Vehicle.VEHICLE_STATE.SERVER_RESTRICTION:
             return
         if state == Vehicle.VEHICLE_STATE.ROTATION_GROUP_UNLOCKED:
             header, text = getComplexStatus('#tooltips:vehicleStatus/%s' % state, groupNum=vehicle.rotationGroupNum, battlesLeft=getBattlesLeft(vehicle))
         else:
             header, text = getComplexStatus('#tooltips:vehicleStatus/%s' % state)
             if header is None and text is None:
                 return
         return {'header': header,
          'text': text,
          'level': level}