Beispiel #1
0
 def setPlayerVehicle(self, vID, vDesc):
     ctrl = self.shared.prebattleSetups
     isSetupsSelectionStarted = ctrl.isSelectionStarted(
     ) if ctrl is not None else False
     ctrl = self.__sharedRepo.ammo
     if ctrl is not None:
         if not isSetupsSelectionStarted:
             ctrl.clearAmmo()
             ctrl.setGunSettings(vDesc.gun)
     ctrl = self.__sharedRepo.equipments
     if ctrl is not None:
         ctrl.notifyPlayerVehicleSet(vID)
     ctrl = self.__sharedRepo.vehicleState
     if ctrl is not None:
         ctrl.setPlayerVehicle(vID)
     ctrl = self.shared.prebattleSetups
     if ctrl is not None:
         ctrl.setPlayerVehicle(vID, vDesc)
     ctrl = self.__dynamicRepo.respawn
     if ctrl is not None:
         ctrl.spawnVehicle(vID)
     mapKind = self.__arenaVisitor.type.getVehicleCamouflageKind()
     g_tankActiveCamouflage[
         vDesc.type.compactDescr] = SeasonType.fromArenaKind(mapKind)
     return
def _currentMapSeason():
    if IS_EDITOR:
        return SeasonType.SUMMER
    else:
        arena = BigWorld.player().arena
        if arena is not None:
            mapKind = arena.arenaType.vehicleCamouflageKind
            return SeasonType.fromArenaKind(mapKind)
        return
Beispiel #3
0
 def setPlayerVehicle(self, vID, vDesc):
     ctrl = self.__sharedRepo.ammo
     if ctrl is not None:
         ctrl.setGunSettings(vDesc.gun)
     ctrl = self.__sharedRepo.vehicleState
     if ctrl is not None:
         ctrl.setPlayerVehicle(vID)
     ctrl = self.__dynamicRepo.respawn
     if ctrl is not None:
         ctrl.spawnVehicle(vID)
     mapKind = self.__arenaVisitor.type.getVehicleCamouflageKind()
     g_tankActiveCamouflage[vDesc.type.compactDescr] = SeasonType.fromArenaKind(mapKind)
     return
Beispiel #4
0
def new_prepareOutfit(base, self, *a, **kw):
    outfit = base(self, *a, **kw).copy()
    vDesc = self.typeDescriptor
    if not vDesc:
        return
    if g_config.data['enabled'] and vDesc.name not in g_config.disable and not (
            vDesc.type.hasCustomDefaultCamouflage
            and g_config.data['disableWithDefault']):
        if not g_config.data['useBought']:
            outfit = Outfit()
        seasonName = SEASON_TYPE_TO_NAME[SeasonType.fromArenaKind(
            BigWorld.player().arena.arenaType.vehicleCamouflageKind)]
        outfit = applyOutfitInfo(
            outfit, seasonName, vDesc,
            g_config.arenaCamoCache.setdefault(self.id, {}), self.id,
            self.id == BigWorld.player().playerVehicleID)
    return outfit
Beispiel #5
0
def new_reload(base, self, vDesc, vState, outfit):
    if vState != 'undamaged':
        return base(self, vDesc, vState, outfit)
    manager = ServicesLocator.appLoader.getDefLobbyApp().containerManager
    if manager is not None:
        container = manager.getContainer(ViewTypes.LOBBY_SUB)
        if container is not None:
            c11nView = container.getView()
            if c11nView is not None and hasattr(c11nView, 'service'):
                outfit = c11nView.service.getCtx().currentOutfit
                return base(self, vDesc, vState, outfit)
    if (not g_config.data['enabled'] or vDesc.name in g_config.disable
            or (vDesc.type.hasCustomDefaultCamouflage
                and g_config.data['disableWithDefault'])):
        return base(self, vDesc, vState, outfit)
    for descr in g_currentPreviewVehicle, g_currentVehicle:
        if descr.isPresent() and descr.item.descriptor.name == vDesc.name:
            vehicle = descr.item
            break
    else:
        vehicle = None
    nation, vehicleName = vDesc.name.split(':')
    intCD = vDesc.type.compactDescr
    season = g_tankActiveCamouflage.get(intCD, SeasonType.EVENT)
    if g_config.data['hangarCamoKind'] < 3:
        g_tankActiveCamouflage[intCD] = SeasonType.fromArenaKind(
            g_config.data['hangarCamoKind'])
    elif season in (SeasonType.UNDEFINED, SeasonType.EVENT):
        active = [
            s for s in SeasonType.SEASONS
            if vehicle and vehicle.hasOutfitWithItems(s)
        ]
        g_tankActiveCamouflage[intCD] = random.choice(
            active) if active else SeasonType.SUMMER
    if season not in (g_tankActiveCamouflage[intCD], SeasonType.UNDEFINED,
                      SeasonType.EVENT):
        season = g_tankActiveCamouflage[intCD]
        if vehicle:
            outfit = vehicle.getOutfit(season)
    outfit = outfit.copy() if outfit else Outfit()
    seasonName = SEASON_TYPE_TO_NAME[g_tankActiveCamouflage[intCD]]
    seasonCache = g_config.hangarCamoCache.setdefault(nation, {}).setdefault(
        vehicleName, {}).setdefault(seasonName, {})
    outfit = applyOutfitInfo(outfit, seasonName, vDesc, seasonCache)
    return base(self, vDesc, vState, outfit)
Beispiel #6
0
def new_applyVehicleOutfit(base, self, *a, **kw):
    result = self._CompoundAppearance__outfit.copy()
    vID = self._CompoundAppearance__vID
    vDesc = self._CompoundAppearance__typeDesc
    if not vDesc:
        return base(self, *a, **kw)
    if g_config.data['enabled'] and vDesc.name not in g_config.disable and not (
            vDesc.type.hasCustomDefaultCamouflage
            and g_config.data['disableWithDefault']):
        if not g_config.data['useBought']:
            result = Outfit()
        seasonName = SEASON_TYPE_TO_NAME[SeasonType.fromArenaKind(
            BigWorld.player().arena.arenaType.vehicleCamouflageKind)]
        nationName, vehicleName = vDesc.name.split(':')
        applied = False
        cleaned = False
        if self._CompoundAppearance__vID == BigWorld.player().playerVehicleID:
            vehCache = g_config.outfitCache.get(nationName,
                                                {}).get(vehicleName, {})
            applyPlayerCache(result, vehicleName, vehCache.get(seasonName, {}))
            applied, cleaned = applyCamoCache(
                result, vehicleName,
                vehCache.get(seasonName, {}).get('camo', {}))
            if cleaned:
                vehCache.get(seasonName, {}).pop('camo', None)
            if not vehCache.get(seasonName, None):
                vehCache.pop(seasonName, None)
        if g_config.data['doRandom'] and (not applied or cleaned
                                          or g_config.data['fillEmptySlots']):
            seasonCache = g_config.arenaCamoCache.setdefault(vID, {})
            processRandomCamouflages(result,
                                     seasonName,
                                     seasonCache,
                                     vID,
                                     isGunCarriage=vDesc.turret.isGunCarriage)
            applyCamoCache(result, vehicleName, seasonCache)
    self._CompoundAppearance__outfit = result
    base(self, *a, **kw)
def onBattleLoaded(statistic):
    if LOG_BATTLES:
        player = BigWorld.player()
        araneInfo = None
        g_replayCtrl = BattleReplay.g_replayCtrl
        if g_replayCtrl.isPlaying or g_replayCtrl.isRecording:
            arenaInfo = g_replayCtrl._BattleReplay__replayCtrl.getArenaInfoStr()
            if arenaInfo and isinstance(arenaInfo, str):
                try:
                    arenaInfo = json.loads(arenaInfo)
                except:
                    pass
        if arenaInfo:
            dateTime = arenaInfo.get('dateTime','')
            serverName = arenaInfo.get('serverName','')
        else:
            now = datetime.now()
            dateTime = '%02d.%02d.%04d %02d:%02d:%02d' % (now.day, now.month, now.year, now.hour, now.minute, now.second)
            serverName = g_replayCtrl.connectionMgr.serverUserName
        vType = statistic.base[player.playerVehicleID]
        battleInfo = ('%s' % player.arenaUniqueID,
                      dateTime,
                      '"%s"' % serverName,
                      '%s' % vType['accountDBID'],
                      '"%s"' % vType['userName'],
                      '"%s"' % tankTypeAbb(vType['type']['tag']),
                      '"%s"' % vType['name'],
                      '%d' % vType['level'],
                      '"%d(%s)"' % (player.arenaGuiType, ARENA_GUI_TYPE_LABEL.LABELS.get(player.arenaGuiType)),
                      '"%d(%s)"' % (player.arenaTypeID, getArenaGeomentryName(player.arenaTypeID)),
                      '"%d(%s)"' % (player.arenaBonusType, BONUS_TYPE_NAMES.get(player.arenaBonusType)),
                      '"%d(%s)"' % (player.arenaExtraData['arenaKind'], SeasonTypeNames[SeasonType.fromArenaKind(player.arenaExtraData['arenaKind'])]),
                      '%d' % player.arenaExtraData['battleLevel'],
                      #--------------
                      '%d' % statistic.allyTanksCount,
                      '%d' % statistic.enemyTanksCount,
                      '%d' % statistic.allyTeamHP,
                      '%d' % statistic.enemyTeamHP,
                      ('%.3f' % (sum([value['level'] for value in statistic.base.itervalues() if not value['isEnemy']]) / float(statistic.allyTanksCount))).replace('.',','),
                      ('%.3f' % (sum([value['level'] for value in statistic.base.itervalues() if value['isEnemy']]) / float(statistic.enemyTanksCount))).replace('.',','))
        printStrings(LOG_BATTLES_FILENAME, battleInfo)
Beispiel #8
0
def getOutfitType(arenaKind, bonusType):
    return SeasonType.fromArenaKind(arenaKind)
Beispiel #9
0
def parseBattleOutfit(outfit, cache, arenaKind, bonusType):
    if not outfit.styleId:
        return outfit
    style = cache.styles[outfit.styleId]
    return style.outfits[SeasonType.fromArenaKind(arenaKind)]
Beispiel #10
0
def new_assembleModel(base, self, *a, **kw):
    result = base(self, *a, **kw)
    if not self._HangarVehicleAppearance__isVehicleDestroyed:
        manager = g_appLoader.getDefLobbyApp().containerManager
        if manager is not None:
            container = manager.getContainer(ViewTypes.LOBBY_SUB)
            if container is not None:
                c11nView = container.getView()
                if c11nView is not None and hasattr(c11nView,
                                                    'getCurrentOutfit'):
                    outfit = c11nView.getCurrentOutfit(
                    )  # fix for HangarFreeCam
                    self.updateCustomization(outfit)
                    return result
        if g_currentPreviewVehicle.isPresent():
            vehicle = g_currentPreviewVehicle.item
        elif g_currentVehicle.isPresent():
            vehicle = g_currentVehicle.item
        else:
            vehicle = None
        vDesc = self._HangarVehicleAppearance__vDesc
        if g_config.data[
                'enabled'] and vDesc.name not in g_config.disable and not (
                    vDesc.type.hasCustomDefaultCamouflage
                    and g_config.data['disableWithDefault']):
            nationName, vehicleName = vDesc.name.split(':')
            intCD = vDesc.type.compactDescr
            if g_config.data['hangarCamoKind'] < 3:
                idx = g_config.data['hangarCamoKind']
                season = SeasonType.fromArenaKind(idx)
                outfit = vehicle.getOutfit(season).copy(
                ) if vehicle else self.itemsFactory.createOutfit()
                g_tankActiveCamouflage[intCD] = season
            else:
                outfit = self._getActiveOutfit().copy()
                if g_tankActiveCamouflage.get(
                        intCD, SeasonType.EVENT) == SeasonType.EVENT:
                    active = []
                    for season in SeasonType.SEASONS:
                        if vehicle and vehicle.hasOutfitWithItems(season):
                            active.append(season)
                    g_tankActiveCamouflage[intCD] = random.choice(
                        active) if active else SeasonType.SUMMER
            if not g_config.data['useBought']:
                outfit = self.itemsFactory.createOutfit()
            seasonName = SEASON_TYPE_TO_NAME[g_tankActiveCamouflage[intCD]]
            vehCache = g_config.outfitCache.get(nationName,
                                                {}).get(vehicleName, {})
            applyPlayerCache(outfit, vehicleName, vehCache.get(seasonName, {}))
            applied, cleaned = applyCamoCache(
                outfit, vehicleName,
                vehCache.get(seasonName, {}).get('camo', {}))
            if cleaned:
                vehCache.get(seasonName, {}).pop('camo', None)
            if not vehCache.get(seasonName, None):
                vehCache.pop(seasonName, None)
            if g_config.data['doRandom'] and (not applied or cleaned or
                                              g_config.data['fillEmptySlots']):
                seasonCache = g_config.hangarCamoCache.setdefault(
                    nationName, {}).setdefault(vehicleName,
                                               {}).setdefault(seasonName, {})
                processRandomCamouflages(
                    outfit,
                    seasonName,
                    seasonCache,
                    isGunCarriage=vDesc.turret.isGunCarriage)
                applyCamoCache(outfit, vehicleName, seasonCache)
            self._HangarVehicleAppearance__outfit = outfit
            self.updateCustomization(outfit)
    return result
Beispiel #11
0
def getOutfitType(arenaKind, bonusType):
    """Calculate SeasonType from arena parameters.
    Support of event season could be here."""
    return SeasonType.fromArenaKind(arenaKind)
Beispiel #12
0
 def parseBattleOutfit(outfit, cache, arenaKind, bonusType):
     """Parse outfit and substitute predefined style with items"""
     if not outfit.styleId:
         return outfit
     style = cache.styles[outfit.styleId]
     return style.outfits[SeasonType.fromArenaKind(arenaKind)]
def onBattleLoaded(statistic):
    global LOG_BATTLES_FILENAME, LOG_PLAYERS_FILENAME, LOG_EVENTS_FILENAME
    if UNIQUE_SUBDIR:
        logName = 'temp'
        replayFileName = g_replayCtrl.getAutoStartFileName()
        if replayFileName is not None and replayFileName != '':
            logName, _ = os.path.splitext(os.path.basename(replayFileName))
        logPath = getLogPath(LOG_DIR + '/' + logName + '_' +
                             datetime.now().strftime('%d%m%y%H%M%S%f')[:15])
    else:
        logPath = getLogPath(LOG_DIR)
    LOG_BATTLES_FILENAME = logPath + 'sl_battles_ver_%s.csv' % CSV_VERSION
    LOG_PLAYERS_FILENAME = logPath + 'sl_players_ver_%s.csv' % CSV_VERSION
    LOG_EVENTS_FILENAME = logPath + 'sl_events_ver_%s.csv' % CSV_VERSION
    if LOG_BATTLES and not os.path.exists(LOG_BATTLES_FILENAME):
        printStrings(LOG_BATTLES_FILENAME, BATTLES_HEADER)
    if LOG_PLAYERS and not os.path.exists(LOG_PLAYERS_FILENAME):
        printStrings(LOG_PLAYERS_FILENAME, PLAYERS_HEADER)
    if LOG_EVENTS and not os.path.exists(LOG_EVENTS_FILENAME):
        printStrings(LOG_EVENTS_FILENAME, EVENTS_HEADER)
    #--------------
    if LOG_BATTLES:
        player = BigWorld.player()
        araneInfo = None
        if g_replayCtrl.isPlaying or g_replayCtrl.isRecording:
            arenaInfo = g_replayCtrl._BattleReplay__replayCtrl.getArenaInfoStr(
            )
            if arenaInfo and isinstance(arenaInfo, str):
                try:
                    arenaInfo = json.loads(arenaInfo)
                except:
                    pass
        if arenaInfo:
            dateTime = arenaInfo.get('dateTime', '')
            serverName = arenaInfo.get('serverName', '')
        else:
            now = datetime.now()
            dateTime = '%02d.%02d.%04d %02d:%02d:%02d' % (
                now.day, now.month, now.year, now.hour, now.minute, now.second)
            serverName = g_replayCtrl.connectionMgr.serverUserName
        vType = statistic.base[player.playerVehicleID]
        battleInfo = (
            '%s' % player.arenaUniqueID,
            dateTime,
            '"%s"' % serverName,
            '%s' % vType.get('accountDBID', '-'),
            '"%s"' % vType['userName'],
            '"%s"' % tankTypeAbb(vType['type']['tag']),
            '"%s"' % vType['name'],
            '%d' % vType['level'],
            '"%s(%d)"' % (ARENA_GUI_TYPE_LABEL.LABELS.get(
                player.arenaGuiType), player.arenaGuiType),
            '"%s(%d)"' %
            (getArenaGeomentryName(player.arenaTypeID), player.arenaTypeID),
            '"%s(%d)"' % (BONUS_TYPE_NAMES.get(
                player.arenaBonusType), player.arenaBonusType),
            '"%s(%d)"' % (SeasonTypeNames[SeasonType.fromArenaKind(
                player.arenaExtraData['arenaKind'])],
                          player.arenaExtraData['arenaKind']),
            ('%d' % player.arenaExtraData['battleLevel'])
            if 'battleLevel' in player.arenaExtraData else '-',
            #--------------
            '%d' % statistic.allyTanksCount,
            '%d' % statistic.enemyTanksCount,
            '%d' % statistic.allyTeamHP,
            '%d' % statistic.enemyTeamHP,
            ('%.3f' % (sum([
                value['level'] for value in statistic.base.itervalues()
                if not value['isEnemy']
            ]) / float(statistic.allyTanksCount))).replace('.', ','),
            ('%.3f' % (sum([
                value['level']
                for value in statistic.base.itervalues() if value['isEnemy']
            ]) / float(statistic.enemyTanksCount))).replace('.', ','))
        printStrings(LOG_BATTLES_FILENAME, battleInfo)