def XTE(self, params):
     if isinstance(params, dict):
         typesBAT = {}
         typesUNP = {}
         LEVELS = range(1,11)
         for tag in vehicles.VEHICLE_CLASS_TAGS:
             typesBAT[tag] = {}
             typesUNP[tag] = {}
             for level in LEVELS:
                 typesBAT[tag][level] = typesUNP[tag][level] = 0
         for id, stat in params.items():
             allBAT = stat.get('b', 0) if 'b' in stat else stat.get(LONG_TAGS['b'], 0)
             allDMG = stat.get('dmg', 0) if 'dmg' in stat else stat.get(LONG_TAGS['dmg'], 0)
             allFRG = stat.get('frg', 0) if 'frg' in stat else stat.get(LONG_TAGS['frg'], 0)
             if allBAT >= 10 and allDMG and allFRG:
                 if 'id' not in stat:
                     stat['id'] = int(id)
                 xte = self.xte(stat)
                 vehicle = vehicles.getVehicleType(int(id))
                 if vehicle and xte:
                     tag = getVehicleClassTag(vehicle.tags)
                     typesBAT[tag][vehicle.level] += allBAT
                     typesUNP[tag][vehicle.level] += float(allBAT) / (100 - self.specificRating(xte, 'sup'))
         tags = finalUNP = 0
         for tag in typesBAT:
             levels = levelsUNP = 0
             for level in typesBAT[tag]:
                 if typesBAT[tag][level]:
                     levelsUNP += typesUNP[tag][level] * level / typesBAT[tag][level]
                     levels += level 
             if levels:
                 finalUNP += levelsUNP / levels
                 tags += 1
         return self.globalRating(100 - tags / finalUNP, 'sup', True) if finalUNP else 0.0
Example #2
0
 def __getVehicleInfo(vehicle):
     vehicleType = vehicle.typeDescriptor.type
     vClass = getVehicleClassTag(vehicleType.tags)
     vName = vehicleType.userString
     vMatrix = LobbyVehicleMarkerView.__getCorrectedHPGuiMatrix(vehicle)
     return (vClass, vName, vMatrix)
Example #3
0
def addVehicleInfo(vID, vInfo):
    if vID not in g_TanksStatistic.base:
        #Main info -----------------------------------------------------------
        vType = vInfo['vehicleType']
        g_TanksStatistic.base[vID] = tank = {}
        tank['accountDBID'] = vInfo['accountDBID']
        tank['userName'] = vInfo['name']
        tank['tank_id'] = vType.type.compactDescr
        tank['name'] = vType.type.shortUserString.replace(' ', '')
        tank['type'] = {}
        tank['type']['tag'] = getVehicleClassTag(vType.type.tags)
        tank['isEnemy'] = vInfo['team'] != BigWorld.player().team
        tank['isAlive'] = vInfo['isAlive']
        tank['level'] = vType.level
        tank['hp'] = tank['hpMax'] = vType.maxHealth
        #Gun -----------------------------------------------------------------
        tank['gun'] = {}
        tank['gun']['reload'] = float(vType.gun.reloadTime)
        if vType.gun.clip[0] > 1:
            tank['gun']['ammer'] = {}
            tank['gun']['ammer']['reload'] = tank['gun']['reload']
            tank['gun']['ammer']['capacity'] = vType.gun.clip[0]
            tank['gun']['ammer']['shellReload'] = float(vType.gun.clip[1])
            #Equivalent time: 5 shell x 2 sec, ammer 30 sec -> 2+30/5 = 8 sec
            tank['gun']['reload'] = tank['gun']['ammer']['shellReload'] + tank[
                'gun']['ammer']['reload'] / tank['gun']['ammer']['capacity']
        tank['gun']['shell'] = {
            'AP': {
                'damage': 0,
                'dpm': 0
            },
            'APRC': {
                'damage': 0,
                'dpm': 0
            },
            'HC': {
                'damage': 0,
                'dpm': 0
            },
            'HE': {
                'damage': 0,
                'dpm': 0
            }
        }
        #Shells -------------------------
        for shot in vType.gun.shots:
            tag = 'APRC' if shot.shell.kind == SHELL_TYPES.ARMOR_PIERCING_CR else \
                  'HC'   if shot.shell.kind == SHELL_TYPES.HOLLOW_CHARGE     else \
                  'HE'   if shot.shell.kind == SHELL_TYPES.HIGH_EXPLOSIVE    else 'AP'
            tank['gun']['caliber'] = shot.shell.caliber
            damage = float(shot.shell.damage[0])
            if damage > tank['gun']['shell'][tag]['damage']:
                tank['gun']['shell'][tag]['damage'] = damage * (
                    0.5 if tag == 'HE' else 1.0)
                tank['gun']['shell'][tag][
                    'dpm'] = damage * 60 / tank['gun']['reload']
        #Current -------------------------------------------------------------
        if 'SPG' == tank['type']['tag']:
            shell = 'HE'
        else:
            shell = 'AP'   if tank['gun']['shell']['AP']['damage'] > 0   else \
                    'APRC' if tank['gun']['shell']['APRC']['damage'] > 0 else \
                    'HC'   if tank['gun']['shell']['HC']['damage'] > 0   else 'HE'
        tank['gun']['currentShell'] = shell
        tank['gun']['currentDamage'] = tank['gun']['shell'][shell]['damage']
        tank['gun']['currentDpm'] = tank['gun']['shell'][shell]['dpm']
        #Update -------------------------------------------------------------
        g_TanksStatistic.update(UPDATE_REASONE.VEHICLE_ADDED, vID)
Example #4
0
 def __getVehicleInfo(vehicle):
     vehicleType = vehicle.typeDescriptor.type
     vClass = getVehicleClassTag(vehicleType.tags)
     vName = vehicleType.userString
     vMatrix = vehicle.model.node('HP_gui')
     return (vClass, vName, vMatrix)