def _getVehicleStats(self, vehicle):
     if vehicle.isOnlyForBattleRoyaleBattles:
         return {'statsText': '',
          'visibleStats': False}
     else:
         intCD = vehicle.intCD
         vehicleRandomStats = self._randomStats.getVehicles() if self._randomStats is not None else {}
         if intCD in vehicleRandomStats:
             battlesCount, wins, _ = vehicleRandomStats.get(intCD)
             markOfMastery = self._randomStats.getMarkOfMasteryForVehicle(intCD)
             if isMarkOfMasteryAchieved(markOfMastery):
                 markOfMasteryText = makeHtmlString('html_templates:lobby/tank_carousel/statistic', 'markOfMastery', ctx={'markOfMastery': markOfMastery})
             else:
                 markOfMasteryText = ''
             winsEfficiency = 100.0 * wins / battlesCount if battlesCount else 0
             winsEfficiencyStr = backport.getIntegralFormat(round(winsEfficiency)) + '%'
             winsText = makeHtmlString('html_templates:lobby/tank_carousel/statistic', 'wins', ctx={'wins': winsEfficiencyStr})
             vehDossier = self._itemsCache.items.getVehicleDossier(intCD)
             vehStats = vehDossier.getTotalStats()
             marksOnGun = vehStats.getAchievement(MARK_ON_GUN_RECORD)
             marksOnGunText = ''
             if marksOnGun.getValue() > 0:
                 marksOnGunText = makeHtmlString('html_templates:lobby/tank_carousel/statistic', 'marksOnGun', ctx={'count': marksOnGun.getValue()})
             template = '{}    {}  {}' if vehicle.isEarnCrystals else '{}   {}     {}'
             statsText = template.format(markOfMasteryText, winsText, marksOnGunText)
         else:
             statsText = '#menu:tankCarousel/statsStatus/unavailable'
         return {'statsText': text_styles.stats(statsText),
          'visibleStats': self._showVehicleStats}
Example #2
0
    def __getDefaultVehicleList(self, targetData, addVehiclesThatInHangarOnly=False):
        result = []
        if self.lobbyContext.getServerSettings().isEpicRandomMarkOfMasteryEnabled():
            __markOfMasteryBattles = (PROFILE_DROPDOWN_KEYS.ALL, PROFILE_DROPDOWN_KEYS.EPIC_RANDOM)
        else:
            __markOfMasteryBattles = (PROFILE_DROPDOWN_KEYS.ALL,)
        showMarkOfMastery = self._battlesType in __markOfMasteryBattles and targetData.getMarksOfMastery() != UNAVAILABLE_MARKS_OF_MASTERY
        for intCD, (battlesCount, wins, xp) in targetData.getVehicles().iteritems():
            avgXP = xp / battlesCount if battlesCount else 0
            vehicle = self.itemsCache.items.getItemByCD(intCD)
            if vehicle is not None:
                isInHangar = vehicle.invID > 0
                if addVehiclesThatInHangarOnly and not isInHangar:
                    continue
                if self._battlesType == PROFILE_DROPDOWN_KEYS.FALLOUT:
                    winsEfficiency = wins
                    winsEfficiencyStr = backport.getIntegralFormat(winsEfficiency)
                else:
                    winsEfficiency = 100.0 * wins / battlesCount if battlesCount else 0
                    winsEfficiencyStr = backport.getIntegralFormat(round(winsEfficiency)) + '%'
                if showMarkOfMastery:
                    markOfMastery = targetData.getMarkOfMasteryForVehicle(intCD)
                    if not isMarkOfMasteryAchieved(markOfMastery):
                        markOfMastery = ProfileUtils.UNAVAILABLE_VALUE
                else:
                    markOfMastery = ProfileUtils.UNAVAILABLE_VALUE
                result.append({'id': intCD,
                 'inventoryID': vehicle.invID,
                 'shortUserName': vehicle.shortUserName,
                 'battlesCount': battlesCount,
                 'winsEfficiency': winsEfficiency,
                 'winsEfficiencyStr': winsEfficiencyStr,
                 'avgExperience': avgXP,
                 'userName': vehicle.userName,
                 'typeIndex': VEHICLE_TABLE_TYPES_ORDER_INDICES_REVERSED[vehicle.type],
                 'nationIndex': GUI_NATIONS_ORDER_INDEX[NAMES[vehicle.nationID]],
                 'nationID': vehicle.nationID,
                 'level': vehicle.level,
                 'markOfMastery': markOfMastery,
                 'markOfMasteryBlock': ACHIEVEMENT_BLOCK.TOTAL,
                 'tankIconPath': vehicle.iconSmall,
                 'typeIconPath': '../maps/icons/filters/tanks/%s.png' % vehicle.type,
                 'isInHangar': isInHangar,
                 'compareModeAvailable': self.comparisonBasket.isEnabled()})

        return result
Example #3
0
 def _getTankParamsVO(self, smallLayout=False):
     self._headerPadding = 0
     itemOffset = 29
     tankItems = []
     if not smallLayout:
         tankItems.append(self._getTankParamVO(text_styles.stats(self.vehicle.typeUserName), self._getTankIcon()))
         tankItems.append(self._getTankParamVO(text_styles.main(backport.text(R.strings.session_stats.tankInfo.level())), backport.image(R.images.gui.maps.icons.levels.dyn('tank_level_{}'.format(self.vehicle.level))())))
     markOfMastery = self.randomStats.getMarkOfMasteryForVehicle(self.vehicle.intCD)
     if isMarkOfMasteryAchieved(markOfMastery):
         tankItems.append(self._getTankParamVO(text_styles.main(backport.text(R.strings.achievements.markOfMastery(), name=text_styles.stats(_TANK_MASTER_TYPES_TEXT[markOfMastery - 1]))), backport.image(R.images.gui.maps.icons.library.proficiency.dyn('class_icons_{}_small'.format(markOfMastery))())))
     vehDossier = self.itemsCache.items.getVehicleDossier(self.vehicle.intCD)
     vehStats = vehDossier.getTotalStats()
     marksOnGun = vehStats.getAchievement(MARK_ON_GUN_RECORD)
     if marksOnGun.getValue() > 0:
         tankItems.append(self._getTankParamVO(text_styles.main(backport.text(R.strings.session_stats.tankInfo.markOnGun(), progress=text_styles.stats('{}{}'.format(marksOnGun.getDamageRating(), '%')))), _MARK_ON_GUN_ICONS[marksOnGun.getValue() - 1]))
     else:
         tankItems.append(self._getTankParamVO(text_styles.main(backport.text(R.strings.session_stats.tankInfo.markOnGun.warning(), progress=text_styles.stats('{}{}'.format(marksOnGun.getDamageRating(), '%')))), backport.image(R.images.gui.maps.icons.library.mark_on_gun_icon())))
     tankItems.append(self._getTankParamVO(text_styles.main(backport.text(R.strings.session_stats.tankInfo.status.total(), total=text_styles.stats(self.vehicleStats.battleCnt))), backport.image(R.images.gui.maps.icons.statistic.battles24())))
     if smallLayout:
         self._headerPadding = -itemOffset * 2
     return tankItems