def __parseClanData(self, clanData, serviceLeaguesEnabled, callback):
     updateData = {}
     myClanName = getClanTag(clanData.get('tag'), clanData.get('color') or '')
     if myClanName:
         updateData['myClanName'] = myClanName
     myClanIcon = yield self.__imagesFetchCoordinator.fetchImageByUrl(clanData.get('emblem'), oneUse=False)
     if myClanIcon:
         updateData['myClanIcon'] = myClanIcon
     leagueIcon = yield self.__imagesFetchCoordinator.fetchImageByUrl(clanData.get('back_emblem'), oneUse=False)
     if leagueIcon:
         updateData['leagueIcon'] = leagueIcon
     if serviceLeaguesEnabled:
         myClanRating = clanData.get('position')
         if isinstance(myClanRating, int):
             textStyle = text_styles.highTitle
             updateData['myClanRating'] = textStyle(backport.getNiceNumberFormat(myClanRating))
         else:
             textStyle = text_styles.highTitleDisabled
             updateData['myClanRating'] = textStyle('--')
     else:
         textStyle = text_styles.highTitleDisabled
     myClanElo = clanData.get('elo')
     if isinstance(myClanElo, int):
         updateData['myClanElo'] = textStyle(backport.getNiceNumberFormat(myClanElo))
     callback(updateData)
예제 #2
0
def __makeShellTooltip(self, descriptor, piercingPower):
    kind = descriptor.kind
    player = BigWorld.player()
    gunID = player.getVehicleDescriptor().gun.id[-1]
    shellNation = descriptor.id[0]
    shellName = descriptor.name
    shellSpeed = 'error'
    shotsObject = g_cache.guns(shellNation).get(gunID).shots
    for i, shot in enumerate(shotsObject):
        if shotsObject[i].shell.name == shellName:
            shellSpeed = shotsObject[i].speed * 1.25
            break
    header = i18n.makeString('#ingame_gui:shells_kinds/{0:>s}'.format(kind),
                             caliber=backport.getNiceNumberFormat(descriptor.caliber), userString=descriptor.userString)
    if GUI_SETTINGS.technicalInfo:
        tooltipStr = INGAME_GUI.SHELLS_KINDS_PARAMS
        paramsDict = {'damage': str(int(descriptor.damage[0])),
                      'piercingPower': str(piercingPower)}
        if descriptor.hasStun and self.lobbyContext.getServerSettings().spgRedesignFeatures.isStunEnabled():
            stun = descriptor.stun
            tooltipStr = INGAME_GUI.SHELLS_KINDS_STUNPARAMS
            paramsDict['stunMinDuration'] = backport.getNiceNumberFormat(
                stun.guaranteedStunDuration * stun.stunDuration)
            paramsDict['stunMaxDuration'] = backport.getNiceNumberFormat(stun.stunDuration)
        body = i18n.makeString(tooltipStr, **paramsDict)
        fmt = TOOLTIP_FORMAT
    else:
        body = ''
        fmt = TOOLTIP_NO_BODY_FORMAT
    tmp = '\nСкорость снаряда: {} м/с\nМаксимальный/минимальный урон: {}/{}\nМаксимльное/минимальное пробитие: {}/{} мм'
    body += tmp.format(int(shellSpeed), int(descriptor.damage[0] * 1.25), int(descriptor.damage[0] * 0.75),
                       int(piercingPower * 1.25), int(piercingPower * 0.75))
    return fmt.format(header, body)
    def __parseGroupsData(self, groupsData, callback):
        groups = []
        for group in groupsData:
            clans = []
            for clan in group.get('clans', []):
                clanVO = {'title': makeString(FORTIFICATIONS.BATTLEQUEUE_CLANPOSITION, position='--'),
                 'clanName': getClanTag(clan.get('tag'), clan.get('color') or ''),
                 'clanElo': '--',
                 'tooltip': ''}
                leagueIconUrl = clan.get('back_emblem')
                if leagueIconUrl:
                    clanVO['leagueIcon'] = yield self.__imagesFetchCoordinator.fetchImageByUrl(clan.get('back_emblem'), oneUse=False)
                    if not clanVO['leagueIcon']:
                        callback([])
                        return
                clanVO['clanIcon'] = yield self.__imagesFetchCoordinator.fetchImageByUrl(clan.get('emblem'), oneUse=False)
                if not clanVO['clanIcon']:
                    callback([])
                    return
                elo = clan.get('elo')
                if isinstance(elo, int):
                    clanVO['clanElo'] = backport.getNiceNumberFormat(elo)
                position = clan.get('position')
                if isinstance(position, int):
                    position = backport.getNiceNumberFormat(position)
                    clanVO['title'] = makeString(FORTIFICATIONS.BATTLEQUEUE_CLANPOSITION, position=position)
                clans.append(clanVO)

            groups.append({'title': group.get('title'),
             'leagues': clans})

        callback(groups)
def kpiFormatValueRange(kpiName, valueRange):
    ending = R.strings.tank_setup.kpi.bonus.valueTypes.dyn(
        kpiName, R.strings.tank_setup.kpi.bonus.valueTypes.default)()
    minValue, maxValue = valueRange
    return '{}-{}{}'.format(getNiceNumberFormat(minValue),
                            getNiceNumberFormat(maxValue),
                            backport.text(ending))
예제 #5
0
def minimizedTitleCumulativeFormat(current, total):
    if current == total:
        current = text_styles.bonusAppliedText(
            backport.getNiceNumberFormat(int(current)))
    else:
        current = text_styles.stats(backport.getNiceNumberFormat(int(current)))
    total = text_styles.standard(int(total))
    return text_styles.disabled('%s / %s' % (current, total))
예제 #6
0
 def __packKpiValue(kpi):
     if kpi.type == KPI.Type.AGGREGATE_MUL:
         value = ((kpi.value[0] - 1.0) * 100, (kpi.value[1] - 1.0) * 100)
         valueStr = '{}-{}'.format(getNiceNumberFormat(value[0]),
                                   getNiceNumberFormat(value[1]))
         valueStr = '+' + valueStr if value[0] > 0 else valueStr
     else:
         value = (kpi.value -
                  1.0) * 100 if kpi.type == KPI.Type.MUL else kpi.value
         valueStr = '+' + getNiceNumberFormat(
             value) if value > 0 else getNiceNumberFormat(value)
     return valueStr
예제 #7
0
 def __init__(self, targetData, accountDossier, isCurrentUser):
     self._isCurrentUser = isCurrentUser
     self._formattedWinsEfficiency = PUtils.getFormattedWinsEfficiency(targetData)
     self._dmgDealt = targetData.getDamageDealt()
     self._dmgReceived = targetData.getDamageReceived()
     self._damageEfficiency = backport.getNiceNumberFormat(PUtils.getValueOrUnavailable(targetData.getDamageEfficiency()))
     self._armorUsingEfficiency = PUtils.getValueOrUnavailable(targetData.getArmorUsingEfficiency())
     self._avgXP = PUtils.getValueOrUnavailable(targetData.getAvgXP())
     self._avgDmg = PUtils.getValueOrUnavailable(targetData.getAvgDamage())
     maxXP = targetData.getMaxXp()
     self._maxXP_formattedStr = backport.getIntegralFormat(maxXP)
     self._armorUsingToolTipData = PUtils.createToolTipData([PUtils.getAvgDamageBlockedValue(targetData)])
     self._avgAssistDmg = backport.getNiceNumberFormat(PUtils.getValueOrUnavailable(targetData.getDamageAssistedEfficiency()))
     super(ProfileDictStatisticsVO, self).__init__((targetData, accountDossier))
예제 #8
0
 def __getPosition(self):
     webSeasonInfo = self.__rankedController.getWebSeasonProvider(
     ).seasonInfo
     if webSeasonInfo.league == UNDEFINED_LEAGUE_ID:
         webSeasonInfo = self.__rankedController.getClientSeasonInfo()
     return backport.getNiceNumberFormat(
         webSeasonInfo.position) if webSeasonInfo.position else '0'
예제 #9
0
 def __packKDR(self, kdr, kills, consumablesKills, deaths):
     return PUtils.packLditItemData(
         backport.getNiceNumberFormat(kdr)
         if kdr is not None else PUtils.UNAVAILABLE_VALUE,
         PROFILE.SECTION_STATISTICS_SCORES_KILLDEATHRATIO,
         PROFILE.PROFILE_PARAMS_TOOLTIP_KDR, 'kdr40x32.png',
         PUtils.createToolTipData([kills, consumablesKills, deaths]))
 def formatFloatPercent(value):
     if value != ProfileUtils.UNAVAILABLE_VALUE:
         value = value * 100
         value = text_styles.concatStylesWithSpace(
             backport.getNiceNumberFormat(value),
             ProfileUtils.PERCENT_SYMBOL)
     return str(value)
 def getCoolDownMessage(self, rqTypeID, coolDown=None):
     requestName = self.lookupName(rqTypeID)
     if coolDown is None:
         coolDown = self.getDefaultCoolDown()
     return i18n.makeString(I18N_SYSTEM_MESSAGES.REQUEST_ISINCOOLDOWN,
                            request=requestName,
                            coolDown=backport.getNiceNumberFormat(coolDown))
예제 #12
0
    def __makeLeaguesBlock(self, leagues):
        leaguesVO = []
        for league in leagues[:len(_DIVISIONS)]:
            division = league.get('max_vehicle_level')
            level = division if division in _DIVISIONS else _DIVISIONS[0]
            imgSource = league.get(
                'emblemImage') or RES_ICONS.getDefaultLeagueIcon(level)
            elo = league.get('elo')
            if elo:
                elo = backport.getNiceNumberFormat(elo)
                label = text_styles.stats(elo) if league.get(
                    'position') else text_styles.main(elo)
            else:
                label = text_styles.main(DUMMY_UNAVAILABLE_DATA)
            tooltip = league.get('tooltip')
            if tooltip:
                tooltip = makeTooltip(tooltip.get('header'),
                                      tooltip.get('body'))
            leaguesVO.append({
                'imgSource': imgSource,
                'label': label,
                'tooltip': tooltip
            })

        return leaguesVO
예제 #13
0
 def _getHeaderData(self, data):
     return (PUtils.getTotalBattlesHeaderParam(data[0], PROFILE.SECTION_STATISTICS_SCORES_TOTALBATTLES, PROFILE.PROFILE_PARAMS_TOOLTIP_BATTLESCOUNT),
      PUtils.packLditItemData(self._damageEfficiency, PROFILE.SECTION_STATISTICS_DETAILED_DAMAGECOEFFICIENT, PROFILE.PROFILE_PARAMS_TOOLTIP_DAMAGECOEFF, 'dmgRatio40x32.png', PUtils.createToolTipData((backport.getIntegralFormat(self._dmgDealt), backport.getIntegralFormat(self._dmgReceived)))),
      _packAvgDmgLditItemData(self._avgDmg),
      _packAvgXPLditItemData(self._avgXP),
      PUtils.packLditItemData(self._avgAssistDmg, PROFILE.SECTION_STATISTICS_SCORES_AVGASSISTEDDAMAGE, PROFILE.PROFILE_PARAMS_TOOLTIP_AVGASSISTEDDAMAGE, 'assist40x32.png'),
      PUtils.packLditItemData(backport.getNiceNumberFormat(self._armorUsingEfficiency), PROFILE.SECTION_STATISTICS_SCORES_ARMORUSING, PROFILE.PROFILE_PARAMS_TOOLTIP_ARMORUSING, 'armorUsing40x32.png', self._armorUsingToolTipData))
예제 #14
0
 def __packAvgPosition(self):
     res = PUtils.getValueOrUnavailable(
         self.__targetData.getAveragePosition())
     return PUtils.packLditItemData(
         backport.getNiceNumberFormat(res),
         PROFILE.SECTION_SUMMARY_SCORES_AVERAGERANK,
         PROFILE.PROFILE_PARAMS_TOOLTIP_BRAVERAGERANK,
         'avgPosition40x32.png')
예제 #15
0
def processRatioValue(value):
    if value.ratio is not None:
        return backport.getNiceNumberFormat(float(value.ratio))
    elif value.dealt is not None and value.received is not None:
        ctx = {'numerator': backport.getIntegralFormat(value.dealt),
         'denominator': backport.getIntegralFormat(value.received)}
        sourceKey = 'inverse' if value.dealt == 0 else 'normal'
        return makeHtmlString('html_templates:lobby/session_stats/', 'ratio', ctx, sourceKey=sourceKey)
    else:
        return '-'
예제 #16
0
def relate(relation, value, label):
    if not isinstance(value, types.StringTypes):
        value = backport.getNiceNumberFormat(value)
    else:
        value = value
    relation = backport.text(
        R.strings.quests.details.requirementsRelation.dyn(relation)())
    rlabel = backport.text(R.strings.quests.details.requirements.relation(),
                           relation=relation,
                           value=value)
    return '{}{}'.format(label, rlabel)
예제 #17
0
def formatRelation(value, relation, relationI18nType=RELATIONS_SCHEME.DEFAULT):
    relation = relation or 'equal'
    if not isinstance(value, types.StringTypes):
        value = backport.getNiceNumberFormat(value)
    return makeHtmlString(
        'html_templates:lobby/quests', 'relation', {
            'relation':
            i18n.makeString('#quests:details/relations%d/%s' %
                            (relationI18nType, relation)),
            'value':
            value
        })
 def _makeVO(self, item, extraData):
     isChecked = extraData['checked']
     status = item.getStatus()
     outcome = {
         'dbID':
         item.getDbID(),
         'checked':
         isChecked,
         'clanVO': {
             'fullName': formatField(getter=item.getClanFullName),
             'clanName': formatField(getter=item.getClanName),
             'clanAbbrev': formatField(getter=item.getClanAbbrev),
             'dbID': item.getClanDbID(),
             'isActive': item.isClanActive()
         },
         'personalRating':
         formatField(getter=item.getPersonalRating,
                     formatter=backport.getIntegralFormat),
         'battlesCount':
         formatField(getter=item.getBattlesCount,
                     formatter=backport.getIntegralFormat),
         'wins':
         formatField(getter=item.getBattleXpAvg,
                     formatter=lambda value: backport.getNiceNumberFormat(
                         value) + '%'),
         'awgExp':
         formatField(getter=item.getBattlesPerformanceAvg,
                     formatter=backport.getIntegralFormat),
         'status': {
             'text':
             self._makeInviteStateString(item),
             'tooltip':
             self._makeTooltip(body=self._makeRequestTooltip(
                 status=item.getStatus(),
                 user=formatField(getter=item.getSenderName),
                 date=formatField(
                     getter=item.getUpdatedAt,
                     formatter=formatters.formatShortDateShortTimeString)))
         },
         'enabled':
         status == CLAN_INVITE_STATES.ACTIVE
         or status == CLAN_INVITE_STATES.ERROR,
         'canShowContextMenu':
         True,
         'messageTooltip':
         self._makeTooltip(
             body=escape(item.getComment()) if isValueAvailable(
                 getter=item.getComment) else str()),
         'actions':
         self.__buildActionsSection(item.getStatus())
     }
     return outcome
예제 #19
0
def _titleRelationFormat(value,
                         relation,
                         relationI18nType=RELATIONS_SCHEME.DEFAULT,
                         titleKey=None):
    if value is not None:
        relation = relation or 'equal'
        if not isinstance(value, types.StringTypes):
            value = backport.getNiceNumberFormat(value)
        relation = i18n.makeString('#quests:details/relations%s/%s' %
                                   (relationI18nType, relation))
        return '%s %s' % (relation, value)
    elif titleKey:
        return i18n.makeString(titleKey)
    else:
        return i18n.makeString(QUESTS.DETAILS_CONDITIONS_TARGET_TITLE)
        return
예제 #20
0
 def __getStatusText(self, isMain):
     statusConditionValues = self.__getStatusConditionValues(isMain)
     if statusConditionValues:
         current, goal, state = statusConditionValues
         currentStr = backport.getNiceNumberFormat(current)
         goalStr = backport.getIntegralFormat(goal)
         if state == QUEST_PROGRESS_STATE.COMPLETED:
             return ''.join([
                 text_styles.bonusAppliedText(currentStr),
                 text_styles.success(' / %s' % goalStr)
             ])
         if state == QUEST_PROGRESS_STATE.FAILED:
             return ''.join([
                 text_styles.error(currentStr),
                 text_styles.failedStatusText(' / %s' % goalStr)
             ])
         return ''.join([
             text_styles.stats(currentStr),
             text_styles.main(' / %s' % goalStr)
         ])
 def _getFormatLongUserName(self, kind):
     if self.nationID == nations.INDICES['germany']:
         caliber = float(self.descriptor.caliber) / 10
         dimension = backport.text(
             R.strings.item_types.shell.dimension.sm())
     elif self.nationID == nations.INDICES['usa']:
         caliber = float(self.descriptor.caliber) / 25.4
         dimension = backport.text(
             R.strings.item_types.shell.dimension.inch())
     else:
         caliber = self.descriptor.caliber
         dimension = backport.text(
             R.strings.item_types.shell.dimension.mm())
     return backport.text(R.strings.item_types.shell.name(),
                          kind=backport.text(
                              R.strings.item_types.shell.dyn(kind).dyn(
                                  self.descriptor.kind)()),
                          name=self.userName,
                          caliber=backport.getNiceNumberFormat(caliber),
                          dimension=dimension)
 def _makeVO(self, item, extra):
     return {
         'dbID':
         item.getDbID(),
         'userInfo': {
             'userName': formatField(getter=item.getAccountName),
             'dbID': item.getAccountDbID()
         },
         'personalRating':
         formatField(getter=item.getPersonalRating,
                     formatter=backport.getIntegralFormat),
         'battlesCount':
         formatField(getter=item.getBattlesCount,
                     formatter=backport.getIntegralFormat),
         'wins':
         formatField(getter=item.getBattlesPerformanceAvg,
                     formatter=lambda value: backport.getNiceNumberFormat(
                         value) + '%'),
         'awgExp':
         formatField(getter=item.getBattleXpAvg,
                     formatter=backport.getIntegralFormat),
         'status': {
             'text':
             self._makeInviteStateString(item),
             'tooltip':
             self._makeTooltip(body=self._makeRequestTooltip(
                 status=item.getStatus(),
                 user=formatField(getter=item.getSenderName),
                 date=formatField(
                     getter=item.getUpdatedAt,
                     formatter=formatters.formatShortDateShortTimeString)))
         },
         'canShowContextMenu':
         True,
         'messageTooltip':
         self._makeTooltip(body=item.getComment() if isValueAvailable(
             getter=item.getComment) else str()),
         'sent':
         formatField(getter=item.getCreatedAt,
                     formatter=formatters.formatShortDateShortTimeString)
     }
예제 #23
0
 def __makeShellTooltip(self, descriptor, piercingPower, shotSpeed):
     kind = descriptor.kind
     projSpeedFactor = vehicles.g_cache.commonConfig['miscParams'][
         'projectileSpeedFactor']
     header = backport.text(R.strings.ingame_gui.shells_kinds.dyn(kind)(),
                            caliber=backport.getNiceNumberFormat(
                                descriptor.caliber),
                            userString=descriptor.userString)
     if GUI_SETTINGS.technicalInfo:
         params = [
             backport.text(
                 R.strings.ingame_gui.shells_kinds.params.damage(),
                 value=backport.getNiceNumberFormat(descriptor.damage[0]))
         ]
         if piercingPower != 0:
             params.append(
                 backport.text(
                     R.strings.ingame_gui.shells_kinds.params.piercingPower(
                     ),
                     value=backport.getNiceNumberFormat(piercingPower)))
         params.append(
             backport.text(
                 R.strings.ingame_gui.shells_kinds.params.shotSpeed(),
                 value=backport.getIntegralFormat(shotSpeed /
                                                  projSpeedFactor)))
         if kind == SHELL_TYPES.HIGH_EXPLOSIVE and descriptor.type.explosionRadius > 0.0:
             params.append(
                 backport.text(R.strings.ingame_gui.shells_kinds.params.
                               explosionRadius(),
                               value=backport.getNiceNumberFormat(
                                   descriptor.type.explosionRadius)))
         if descriptor.hasStun and self.lobbyContext.getServerSettings(
         ).spgRedesignFeatures.isStunEnabled():
             stun = descriptor.stun
             params.append(
                 backport.text(
                     R.strings.ingame_gui.shells_kinds.params.stunDuration(
                     ),
                     minValue=backport.getNiceNumberFormat(
                         stun.guaranteedStunDuration * stun.stunDuration),
                     maxValue=backport.getNiceNumberFormat(
                         stun.stunDuration)))
         body = text_styles.concatStylesToMultiLine(*params)
         fmt = TOOLTIP_FORMAT
     else:
         body = ''
         fmt = TOOLTIP_NO_BODY_FORMAT
     return fmt.format(header, body)
 def _updateDetailedInfo(self):
     clanID = self.__selectedClan.getClanDbID()
     clanName = formatField(self.__selectedClan.getClanFullName)
     rating = formatField(getter=self.__selectedClan.getPersonalRating,
                          formatter=backport.getIntegralFormat)
     battlesCount = formatField(getter=self.__selectedClan.getBattlesCount,
                                formatter=backport.getIntegralFormat)
     wins = formatField(
         getter=self.__selectedClan.getBattleXpAvg,
         formatter=lambda value: backport.getNiceNumberFormat(value) + '%')
     avgExp = formatField(
         getter=self.__selectedClan.getBattlesPerformanceAvg,
         formatter=backport.getIntegralFormat)
     stats = [
         _packItemData(battlesCount, CLANS.SEARCH_INFO_STATS_BATTLES,
                       CLANS.SEARCH_INFO_STATS_BATTLES_TOOLTIP,
                       'avgBattlesCount40x32.png'),
         _packItemData(wins, CLANS.SEARCH_INFO_STATS_WINS,
                       CLANS.SEARCH_INFO_STATS_WINS_TOOLTIP,
                       'avgWins40x32.png'),
         _packItemData(avgExp, CLANS.SEARCH_INFO_STATS_AVGEXP,
                       CLANS.SEARCH_INFO_STATS_AVGEXP_TOOLTIP,
                       'avgExp40x32.png')
     ]
     self.as_setDataS({
         'clanId':
         clanID,
         'clanName':
         clanName,
         'ratingTitle':
         text_styles.main(CLANS.SEARCH_INFO_RATINGTITLE),
         'rating':
         text_styles.promoTitle(rating),
         'stats':
         stats
     })
def kpiFormatValue(kpiName, value):
    ending = R.strings.tank_setup.kpi.bonus.valueTypes.dyn(
        kpiName, R.strings.tank_setup.kpi.bonus.valueTypes.default)()
    return ('+' if value > 0 else
            '') + getNiceNumberFormat(value) + backport.text(ending)
예제 #26
0
 def getEfficiencyPercent(dividend, delimiter, unavailableValue=UNAVAILABLE_VALUE):
     return backport.getNiceNumberFormat(float(dividend) / delimiter * 100) + ProfileUtils.PERCENT_SYMBOL if delimiter != 0 else unavailableValue
예제 #27
0
 def formatEfficiency(coeff2, valueReceiveFunction):
     return backport.getNiceNumberFormat(valueReceiveFunction()) if coeff2 > 0 else ProfileUtils.UNAVAILABLE_VALUE
예제 #28
0
 def _buildData(self, targetData, isCurrentUser):
     return backport.getNiceNumberFormat(ProfileUtils.getValueOrUnavailable(targetData.getAverageLevel()))
예제 #29
0
def _avgDetectedField(targetData, isCurrentUser):
    formatedDetected = backport.getNiceNumberFormat(ProfileUtils.getValueOrUnavailable(targetData.getAvgEnemiesSpotted()))
    return DetailedStatisticsUtils.getDetailedDataObject(PROFILE.SECTION_STATISTICS_DETAILED_AVGDETECTEDENEMIES, formatedDetected, PROFILE.PROFILE_PARAMS_TOOLTIP_AVGDETECTEDENEMIES)
예제 #30
0
 def getNiceNumberFormat(cls, value):
     return backport.getNiceNumberFormat(value)