Example #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')
Example #2
0
def _updateDeviceState(self, value):
    device = value[0]
    state = value[2]
    if device in DEVICES:
        if 'destroyed' != state:
            RepairTimers.stopTimer(device)
        as_event(EVENTS[device])
Example #3
0
 def startTimer(self, device, duration):
     self.TIMERS[device]['duration'] = duration
     if self.TIMERS[device]['timer'] is not None:
         return
     self.TIMERS[device]['timer'] = TimeInterval(0.1, self, '{}OnTimer'.format(device))
     self.TIMERS[device]['timer'].start()
     as_event(EVENTS[device])
Example #4
0
 def startTimer(self, device, duration):
     self.TIMERS[device]['duration'] = duration
     if self.TIMERS[device]['timer'] is not None:
         return
     self.TIMERS[device]['timer'] = TimeInterval(0.1, self, '{}OnTimer'.format(device))
     self.TIMERS[device]['timer'].start()
     as_event(EVENTS[device])
Example #5
0
def _updateDeviceState(self, value):
    device = value[0]
    state = value[2]
    if device in DEVICES:
        if 'destroyed' != state:
            RepairTimers.stopTimer(device)
        as_event(EVENTS[device])
Example #6
0
def setVehicleStats(vid, vehicle):
    global enemies_wn8, allies_wn8

    vehicle['stats'] = stats = getPlayerStats(vid)
    if stats is not None:
        vehicle['wn8'] = stats.get('wn8', None)
        info = vehicle['info']

        if config.get('useTankRating', False):
            if 'wn8expDamage' in info and all(
                    k in stats['v']
                    for k in ('b', 'frg', 'dmg', 'w', 'spo', 'def')):
                if stats['v']['b'] >= 100:
                    # Compute WN8 for that vehicle
                    rDAMAGE = stats['v']['dmg'] / (stats['v']['b'] *
                                                   info['wn8expDamage'])
                    rSPOT = stats['v']['spo'] / (stats['v']['b'] *
                                                 info['wn8expSpot'])
                    rFRAG = stats['v']['frg'] / (stats['v']['b'] *
                                                 info['wn8expFrag'])
                    rDEF = stats['v']['def'] / (stats['v']['b'] *
                                                info['wn8expDef'])
                    rWIN = stats['v']['w'] / (stats['v']['b'] *
                                              info['wn8expWinRate']) * 100.0

                    rWINc = max(0, (rWIN - 0.71) / (1 - 0.71))
                    rDAMAGEc = max(0, (rDAMAGE - 0.22) / (1 - 0.22))
                    rFRAGc = max(
                        0, min(rDAMAGEc + 0.2, (rFRAG - 0.12) / (1 - 0.12)))
                    rSPOTc = max(
                        0, min(rDAMAGEc + 0.1, (rSPOT - 0.38) / (1 - 0.38)))
                    rDEFc = max(
                        0, min(rDAMAGEc + 0.1, (rDEF - 0.10) / (1 - 0.10)))

                    WN8 = 980 * rDAMAGEc + 210 * rDAMAGEc * rFRAGc + 155 * rFRAGc * rSPOTc + 75 * rDEFc * rFRAGc + 145 * min(
                        1.8, rWINc)

                    vehicle['wn8'] = WN8

        if vehicle['wn8'] is not None:
            if BigWorld.player().team == vehicle['team']:
                allies_wn8 += float(vehicle['wn8'])
            else:
                enemies_wn8 += float(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')
Example #7
0
 def update(self, vehicle):
     if hotKeyPressed:
         return
     info_panel_data.init(vehicle)
     self.setTextsFormatted()
     as_event('ON_INFO_PANEL')
Example #8
0
 def hide(self):
     if self.timer is not None and self.timer.isStarted():
         self.timer.stop()
         self.timer = None
     self.textsFormatted = None
     as_event('ON_INFO_PANEL')
Example #9
0
 def onTimer(self, device):
     self.TIMERS[device]['duration'] -= 0.1
     as_event(EVENTS[device])
Example #10
0
def resetAll():
    for device in DEVICES:
        RepairTimers.stopTimer(device)
        as_event(EVENTS[device])
Example #11
0
 def onTimer(self, device):
     self.TIMERS[device]['duration'] -= 0.1
     as_event(EVENTS[device])
Example #12
0
def resetAll():
    for device in DEVICES:
        RepairTimers.stopTimer(device)
        as_event(EVENTS[device])