Exemplo n.º 1
0
def FragsCollectableStats_addVehicleStatusUpdate(self, vInfoVO):
    LOG_DEBUG('FragsCollectableStats.addVehicleStatusUpdate(%s) [vehCD=%s]' %
              (vInfoVO, vInfoVO.vehicleType.compactDescr))

    global enemies_wn8, allies_wn8

    if len(vehicles) == 0:
        config.reload()
        enemies_wn8 = allies_wn8 = 0

    vid = vInfoVO.vehicleID
    vehCD = vInfoVO.vehicleType.compactDescr

    is_ally = BigWorld.player().team == vInfoVO.team
    if vInfoVO.isAlive():
        if vid not in vehicles:
            info = xvm_vehinfo.getVehicleInfoData(vehCD)
            vehicle = dict(vehCD=vehCD, info=info, team=vInfoVO.team)
            vehicles[vid] = vehicle
            setVehicleStats(vid, vehicle)
    else:
        if vid in vehicles:
            vehicle = vehicles.pop(vid)

            if vehicle.get('wn8', None) is not None:
                if is_ally:
                    allies_wn8 -= vehicle['wn8']
                else:
                    enemies_wn8 -= vehicle['wn8']

                LOG_DEBUG('ALLIES=%d ENEMIES=%d RATIO=%s' %
                          (allies_wn8, enemies_wn8,
                           (allies_wn8 * 100 /
                            enemies_wn8) if enemies_wn8 != 0 else -1))
                xfw.as_event('ON_UPDATE_TEAM_RATING')
Exemplo n.º 2
0
def _applyXvmFilter(item, filters, total_stats, vehicles_stats):
    premium = filters[PREFS.PREMIUM]
    special = filters[PREFS.SPECIAL]
    normal = filters[PREFS.NORMAL]
    elite = filters[PREFS.ELITE]
    non_elite = filters[PREFS.NON_ELITE]

    if elite and not premium:
        normal = True

    vdata = vehinfo.getVehicleInfoData(item.intCD)
    if vdata is None:
        warn('Cannot find VehicleInfoData for vehCD={}'.format(item.intCD))
        return True

    remove = False

    # isPremium include 'premium' and 'special' vehicles
    if premium and special and normal:
        pass
    elif premium and special:
        remove |= not item.isPremium
    elif premium and normal:
        remove |= vdata['special']
    elif special and normal:
        remove |= vdata['premium']
    else:
        remove |= premium and not vdata['premium']
        remove |= special and not vdata['special']
        remove |= normal and item.isPremium

    if elite != non_elite:
        remove |= elite and not item.isElite
        remove |= non_elite and item.isElite

    stat = vehicles_stats.get(item.intCD)
    if stat:
        mark_of_mastery = total_stats.getMarkOfMasteryForVehicle(item.intCD)
        remove |= filters[PREFS.NO_MASTER] and mark_of_mastery == MarkOfMasteryAchievement.MARK_OF_MASTERY.MASTER

    remove |= filters[PREFS.FULL_CREW] and not item.isCrewFull

    if filters[PREFS.TRAINING_CREW]:
        isCrewTraining = False
        for slotIdx, crewman in item.crew:
            if crewman is None:
                isCrewTraining = True
                break
            if not crewman.isMaxRoleLevel:
                isCrewTraining = True
                break
        remove |= not isCrewTraining

    remove |= not filters[PREFS.RESERVE] and vdata['isReserved']
    # next line will make xor filter: non_reserve <--> reserve,
    # instead of non_reserve <--> non_reserve + reserve
    remove |= filters[PREFS.RESERVE] and not vdata['isReserved']

    return not remove
Exemplo n.º 3
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
 def registerVInfoData(self, vehCD):
     self.vehCD = vehCD
     vInfoData = vehinfo.getVehicleInfoData(vehCD)
     
     for item in ('wn8expDamage', 'wn8expSpot', 'wn8expFrag', 'wn8expDef', 'wn8expWinRate'):
         self.tankExpd[item] = vInfoData.get(item, None)
     
     self.vInfoOK = None not in self.tankExpd.values()
     if self.vInfoOK:
         self.setAvgTier()
Exemplo n.º 5
0
def vehicle_onEnterWorld(self, vehicle):
    if vehicle.id == self.playerVehicleID:
        battleEff.vehCD = vehicle.typeDescriptor.type.compactDescr
        vehicleInfoData = vehinfo.getVehicleInfoData(battleEff.vehCD)
        battleEff.tankExpd['wn8expDamage'] = vehicleInfoData.get(
            'wn8expDamage', None)
        battleEff.tankExpd['wn8expSpot'] = vehicleInfoData.get(
            'wn8expSpot', None)
        battleEff.tankExpd['wn8expDef'] = vehicleInfoData.get(
            'wn8expDef', None)
        battleEff.tankExpd['wn8expFrag'] = vehicleInfoData.get(
            'wn8expFrag', None)
        battleEff.tankExists = None not in battleEff.tankExpd.values()
def _applyXvmFilter(item, filters, total_stats, vehicles_stats):
    premium = filters[PREFS.PREMIUM]
    normal = filters[PREFS.NORMAL]
    elite = filters[PREFS.ELITE]
    non_elite = filters[PREFS.NON_ELITE]

    if elite and not premium:
        normal = True

    vdata = vehinfo.getVehicleInfoData(item.intCD)
    if vdata is None:
        warn('Cannot find VehicleInfoData for vehCD={}'.format(item.intCD))
        return True

    remove = False

    if premium != normal:
        remove |= premium and not item.isPremium
        remove |= normal and item.isPremium

    if elite != non_elite:
        remove |= elite and not item.isElite
        remove |= non_elite and item.isElite

    stat = vehicles_stats.get(item.intCD)
    if stat:
        mark_of_mastery = total_stats.getMarkOfMasteryForVehicle(item.intCD)
        remove |= filters[
            PREFS.
            NO_MASTER] and mark_of_mastery == MarkOfMasteryAchievement.MARK_OF_MASTERY.MASTER

    remove |= filters[PREFS.FULL_CREW] and not item.isCrewFull

    remove |= not filters[PREFS.RESERVE] and vdata['isReserved']
    # next line will make xor filter: non_reserve <--> reserve,
    # instead of non_reserve <--> non_reserve + reserve
    remove |= filters[PREFS.RESERVE] and not vdata['isReserved']

    return not remove
Exemplo n.º 7
0
def _applyXvmFilter(item, filters, total_stats, vehicles_stats):
    premium = filters[PREFS.PREMIUM]
    normal = filters[PREFS.NORMAL]
    elite = filters[PREFS.ELITE]
    non_elite = filters[PREFS.NON_ELITE]

    if elite and not premium:
        normal = True

    vdata = vehinfo.getVehicleInfoData(item.intCD)
    if vdata is None:
        warn('Cannot find VehicleInfoData for vehCD={}'.format(item.intCD))
        return True

    remove = False

    if premium != normal:
        remove |= premium and not item.isPremium
        remove |= normal and item.isPremium

    if elite != non_elite:
        remove |= elite and not item.isElite
        remove |= non_elite and item.isElite

    stat = vehicles_stats.get(item.intCD)
    if stat:
        mark_of_mastery = total_stats.getMarkOfMasteryForVehicle(item.intCD)
        remove |= filters[PREFS.NO_MASTER] and mark_of_mastery == MarkOfMasteryAchievement.MARK_OF_MASTERY.MASTER

    remove |= filters[PREFS.FULL_CREW] and not item.isCrewFull

    remove |= not filters[PREFS.RESERVE] and vdata['isReserved']
    # next line will make xor filter: non_reserve <--> reserve,
    # instead of non_reserve <--> non_reserve + reserve
    remove |= filters[PREFS.RESERVE] and not vdata['isReserved']

    return not remove