Exemplo n.º 1
0
def DetailedStatisticsUtils_getStatistics(base, targetData, isCurrentuser, layout):
    res = base(targetData, isCurrentuser, layout)
    global _lastVehCD
    if _lastVehCD is not None and config.networkServicesSettings.statAwards:
        try:
            battles = targetData.getBattlesCount()
            dmg = targetData.getDamageDealt()
            frg = targetData.getFragsCount()

            # remove empty lines
            if res[0]['data'][4] is None:
                del res[0]['data'][4]
            #if res[1]['data'][1] is None:
            #    del res[1]['data'][1]
            #if res[1]['data'][4] is None:
            #    del res[1]['data'][4]

            # xTE
            data = -1
            vinfo = vehinfo.getVehicleInfoData(_lastVehCD)
            ref = {'avgdmg': vinfo.get('avgdmg', None),
                   'avgfrg': vinfo.get('avgfrg', None),
                   'topdmg': vinfo.get('topdmg', None),
                   'topfrg': vinfo.get('topfrg', None)}
            #log('vehCD: {} b:{} d:{} f:{}'.format(_lastVehCD, battles, dmg, frg))
            if battles > 0 and dmg >= 0 and frg >= 0:
                curdmg = float(dmg) / battles
                curfrg = float(frg) / battles
                ref['curdmg'] = curdmg
                ref['curfrg'] = curfrg
                x = vehinfo.calculateXTE(_lastVehCD, curdmg, curfrg)
                ref['xte'] = x
                ref['xte_sup'] = xvm_scale.XvmScaleToSup(x)
                if x >= 0:
                    color = utils.getDynamicColorValue(consts.DYNAMIC_VALUE_TYPE.X, x)
                    xStr = 'XX' if x == 100 else ('0' if x < 10 else '') + str(x)
                    data = '<font color="#{}" size="12">({} {}%)</font>  <font color="{}">{}</font>'.format(
                        XFW_COLORS.UICOLOR_LABEL, l10n('better than'), ref['xte_sup'], color, xStr)
                    #log("xte={} color={}".format(xStr, color))
            res[0]['data'].insert(0, {
                'label': 'xTE',
                'data': data,
                'tooltip': 'xvm_xte',
                'tooltipData': {'body': ref, 'header': {}, 'note': None}})

            # xTDB
            item = res[1]['data'][2]
            if battles > 0 and dmg >= 0:
                x = vehinfo.calculateXTDB(_lastVehCD, float(dmg) / battles)
                sup = xvm_scale.XvmScaleToSup(x)
                if x >= 0:
                    color = utils.getDynamicColorValue(consts.DYNAMIC_VALUE_TYPE.X, x)
                    item['data'] = '<font color="#{}" size="12">({} {}%)</font>  <font color="{}">{}</font>'.format(
                        XFW_COLORS.UICOLOR_LABEL, l10n('better than'), sup, color, item['data'])

        except:
            err(traceback.format_exc())

    return res
Exemplo n.º 2
0
 def pickColors(self):
     self.WN8Color = utils.getDynamicColorValue(
         consts.DYNAMIC_VALUE_TYPE.WN8, self.WN8)
     self.EFFColor = utils.getDynamicColorValue(
         consts.DYNAMIC_VALUE_TYPE.EFF, self.EFF)
     self.XTEColor = utils.getDynamicColorValue(consts.DYNAMIC_VALUE_TYPE.X,
                                                self.XTE)
     self.DIFFExpDmgColor = self.DIFFColors[
         'bad'] if self.DIFFExpDmg <= 0 else self.DIFFColors['good']
Exemplo n.º 3
0
def DetailedStatisticsUtils_getStatistics(base, targetData, isCurrentuser):
    res = base(targetData, isCurrentuser)
    global _lastVehId
    if _lastVehId is not None and token.networkServicesSettings['statAwards']:
        try:
            battles = targetData.getBattlesCount()
            dmg = targetData.getDamageDealt()
            frg = targetData.getFragsCount()
            ref = vehinfo_xte.getReferenceValues(_lastVehId)
            if ref is None:
                ref = {}
            data = -1
            #log('b:{} d:{} f:{}'.format(battles, dmg, frg))
            if battles > 0 and dmg > 0 and frg > 0:
                ref['currentD'] = float(dmg) / battles
                ref['currentF'] = float(frg) / battles
                xte = vehinfo_xte.calculateXTE(_lastVehId, float(dmg) / battles, float(frg) / battles)
                if xte > 0:
                    color = utils.getDynamicColorValue(constants.DYNAMIC_VALUE_TYPE.X, xte)
                    xteStr = 'XX' if xte == 100 else ('0' if xte < 10 else '') + str(xte)
                    data = '<font color="{0}">{1}</font>'.format(color, xteStr)
                    #log("xte={} color={}".format(xteStr, color))
            del res[0]['data'][4]
            res[0]['data'].insert(0, {
                'label': 'xTE',
                'data': data,
                'tooltip': 'xvm_xte',
                'tooltipData': {'body': ref, 'header': {}, 'note': None}})
        except:
            err(traceback.format_exc())

    return res
Exemplo n.º 4
0
    def getRatingColor(stats):
        if stats is None:
            return None

        rating = config.networkServicesSettings.rating
        v = stats.get(rating, 0)
        if config.get('chat/customColors', False):
            # Use custom colors from chat.xc
            v = stats.get('x' + rating, v)  # normalized rating only
            colors = config.get('chat/colors', None)
            if colors is None:
                color = ''
            else:
                color = next((int(x['color'], 0)
                              for x in colors if v <= float(x['value'])),
                             0xFFFFFF)
                color = "#{0:06x}".format(color)
        else:
            # Use colors from colors.xc
            color = xvm_utils.getDynamicColorValue(
                'x' if rating.startswith('x') else rating,
                v if v is not None else 0)

        LOG_DEBUG('%s/%s => %s' % (rating, v, color))
        return color
def _getScaledDynamicColorValue(rating, value):
    return utils.getDynamicColorValue(DYNAMIC_VALUE_TYPE.X, value)