def _updateTeamData(self, isEnemy, team, arenaDP, isFragsUpdate=True):
        pNamesList, fragsList, vNamesList, additionalDataList = ([], [], [], [])
        valuesHashes = []
        ctx = makeTeamCtx(
            team,
            isEnemy,
            arenaDP,
            int(self._battleUI.getPlayerNameLength(isEnemy)),
            self._battleUI.getCameraVehicleID(),
        )
        if isFragsUpdate:
            fragCorrelation = self._battleUI.fragCorrelation
            fragCorrelation.clear(team)
            for index, (vInfoVO, vStatsVO, viStatsVO) in enumerate(arenaDP.getTeamIterator(team)):
                if not self._battleCtx.isObserver(vInfoVO.vehicleID):
                    fragCorrelation.addVehicle(
                        team, vInfoVO.vehicleID, vInfoVO.vehicleType.getClassName(), vInfoVO.isAlive()
                    )
                    if not vInfoVO.isAlive():
                        fragCorrelation.addKilled(team)

        playerAccountID = getAvatarDatabaseID()
        inviteSendingProhibited = isEnemy or self.prbInvites.getSentInviteCount() >= 100
        if not inviteSendingProhibited:
            inviteSendingProhibited = not self._isSquadAllowToInvite(arenaDP)
        invitesReceivingProhibited = arenaDP.getVehicleInfo(playerAccountID).player.forbidInBattleInvitations
        for index, (vInfoVO, vStatsVO, viStatsVO) in enumerate(arenaDP.getVehiclesIterator(isEnemy)):
            if index >= PLAYERS_PANEL_LENGTH:
                LOG_WARNING("Max players in panel are", PLAYERS_PANEL_LENGTH)
                break
            if self._battleCtx.isObserver(vInfoVO.vehicleID) and self._battleCtx.isPlayerObserver():
                continue
            playerFullName = self._battleCtx.getFullPlayerName(vID=vInfoVO.vehicleID, showVehShortName=False)
            if not playerFullName:
                playerFullName = vInfoVO.player.getPlayerLabel()
            valuesHash = self._makeHash(
                index,
                playerFullName,
                vInfoVO,
                vStatsVO,
                viStatsVO,
                ctx,
                playerAccountID,
                inviteSendingProhibited,
                invitesReceivingProhibited,
                isEnemy,
            )
            pName, frags, vName, additionalData = self._battleUI.statsForm.getFormattedStrings(
                vInfoVO, vStatsVO, viStatsVO, ctx, playerFullName
            )
            pNamesList.append(pName)
            fragsList.append(frags)
            vNamesList.append(vName)
            additionalDataList.append(additionalData)
            valuesHashes.append(valuesHash)

        self._battleUI.setTeamValuesData(
            self._makeTeamValues(isEnemy, ctx, pNamesList, fragsList, vNamesList, additionalDataList, valuesHashes)
        )
def new__startGUI(self):
    g_HomeRegion.setAccountDBID(getAvatarDatabaseID())
    IDs = {}
    for vID, vData in self.arena.vehicles.iteritems():
        vehCD = None
        if 'typeCompDescr' in vData:
            vehCD = vData['typeCompDescr']
        elif 'vehicleType' in vData:
            vtype = vData['vehicleType']
            if hasattr(vtype, 'type'):
                vehCD = vData['vehicleType'].type.compactDescr
        if vehCD is None:
            vehCD = 0
        IDs[vData['accountDBID']] = vehCD
    onStats = g_WGStatisticsEvents._onStats_BattleLoaded
    onStatsFull = g_WGStatisticsEvents._onStats_FullBattleLoaded
    if onStatsFull:
        if IDs:
            appTokens = g_WGStatisticsEvents._appTokens_FullBattleLoaded
            appTokens.mixAppTokens()
            if onStats:
                #Make a request only once
                def onStatsExt(statistic):
                    stats = deepcopy(statistic) if statistic else None
                    player = BigWorld.player()
                    if stats and 'players' in stats:
                        for user in stats['players']:
                            ID = user.get('account_id', 0)
                            if ID in IDs and 'vehicles' in user:
                                user['vehicles'] = user['vehicles'].get(
                                    IDs[ID], {})
                    if onStats:
                        for delegate in onStats[0:-1]:
                            delegate(deepcopy(stats))
                        onStats[-1](stats)
                    if onStatsFull:
                        for delegate in onStatsFull[0:-1]:
                            delegate(deepcopy(statistic))
                        onStatsFull[-1](statistic)

                g_WGConsole.getStatsFull_Async(appTokens.appToken, IDs.keys(),
                                               onStatsExt)
            else:
                g_WGConsole.getStatsFull_Async(appTokens.appToken, IDs.keys(),
                                               onStatsFull)
        else:
            for delegate in onStats:
                delegate(None)
            for delegate in onStatsFull:
                delegate(None)
    elif onStats:
        if IDs:
            appTokens = g_WGStatisticsEvents._appTokens_BattleLoaded
            appTokens.mixAppTokens()
            g_WGConsole.getStats_Async(appTokens.appToken, IDs, onStats)
        else:
            for delegate in onStats:
                delegate(None)
    def _updateTeamData(self, isEnemy, team, arenaDP, isFragsUpdate = True):
        pNamesList, fragsList, vNamesList, additionalDataList, pNamesListPanels = ([],
         [],
         [],
         [],
         [])
        valuesHashes = []
        ctx = makeTeamCtx(team, isEnemy, arenaDP, int(self._battleUI.getPlayerNameLength(isEnemy)), int(self._battleUI.getVehicleNameLength(isEnemy)), self._battleUI.getCameraVehicleID())
        if isFragsUpdate:
            fragCorrelation = self._battleUI.fragCorrelation
            fragCorrelation.clear(team)
            collection = vos_collections.TeamVehiclesInfoCollection(team)
            for vInfoVO in collection.iterator(arenaDP):
                if not vInfoVO.isObserver():
                    fragCorrelation.addVehicle(team, vInfoVO.vehicleID, vInfoVO.vehicleType.getClassName(), vInfoVO.isAlive())
                    if not vInfoVO.isAlive():
                        fragCorrelation.addKilled(team)

        playerAccountID = getAvatarDatabaseID()
        inviteSendingProhibited = isEnemy or self.prbInvites.getSentInviteCount() >= 100
        if not inviteSendingProhibited:
            inviteSendingProhibited = not self._isSquadAllowToInvite(arenaDP)
        invitesReceivingProhibited = arenaDP.getVehicleInfo(playerAccountID).player.forbidInBattleInvitations
        isPlayerObserver = self._battleCtx.isPlayerObserver()
        if self._arenaVisitor.hasRespawns():
            sortKey = vos_collections.RespawnSortKey
        else:
            sortKey = vos_collections.VehicleInfoSortKey
        if isEnemy:
            collection = vos_collections.EnemyItemsCollection(sortKey=sortKey)
        else:
            collection = vos_collections.AllyItemsCollection(sortKey=sortKey)
        for index, (vInfoVO, vStatsVO) in enumerate(collection.iterator(arenaDP)):
            if index >= PLAYERS_PANEL_LENGTH:
                LOG_WARNING('Max players in panel are', PLAYERS_PANEL_LENGTH)
                break
            if vInfoVO.isObserver() and isPlayerObserver:
                continue
            playerFullName = self._battleCtx.getPlayerFullName(vID=vInfoVO.vehicleID, showVehShortName=False)
            if not playerFullName:
                playerFullName = vInfoVO.player.getPlayerLabel()
            valuesHash = self._makeHash(index, playerFullName, vInfoVO, vStatsVO, ctx, playerAccountID, inviteSendingProhibited, invitesReceivingProhibited, isEnemy)
            pName, frags, vName, additionalData, pNamePanels = self._battleUI.statsForm.getFormattedStrings(vInfoVO, vStatsVO, ctx, playerFullName)
            pNamesList.append(pName)
            fragsList.append(frags)
            vNamesList.append(vName)
            additionalDataList.append(additionalData)
            valuesHashes.append(valuesHash)
            pNamesListPanels.append(pNamePanels)

        self._battleUI.setTeamValuesData(self._makeTeamValues(isEnemy, ctx, pNamesList, fragsList, vNamesList, additionalDataList, valuesHashes, pNamesListPanels))
Exemple #4
0
def new__startGUI(self):
    g_HomeRegion.setAccountDBID(getAvatarDatabaseID())
    IDs = {}
    for vID, vData in self.arena.vehicles.iteritems():
        vehCD = None
        if 'typeCompDescr' in vData:
            vehCD = vData['typeCompDescr']
        elif 'vehicleType' in vData:
            vtype = vData['vehicleType']
            if hasattr(vtype, 'type'):
                vehCD = vData['vehicleType'].type.compactDescr
        if vehCD is None:
            vehCD = 0
        IDs[vData['accountDBID']] = vehCD
    if g_XVMStatisticsEvents.OnStatsFullBattleLoaded._delegates:
        if IDs:
            if g_XVMStatisticsEvents.OnStatsBattleLoaded._delegates:

                def OnStats(statistic):
                    stats = deepcopy(statistic) if statistic else None
                    player = BigWorld.player()
                    if stats and 'players' in stats:
                        for user in stats['players']:
                            ID = user.get('_id', 0)
                            if ID in IDs and 'v' in user:
                                user['v'] = user['v'].get(str(IDs[ID]), {})
                    if len(g_XVMStatisticsEvents.OnStatsBattleLoaded._delegates) > 1:
                        for delegate in g_XVMStatisticsEvents.OnStatsBattleLoaded._delegates[0:-1]:
                            delegate(deepcopy(stats))
                        g_XVMStatisticsEvents.OnStatsBattleLoaded._delegates[-1](stats)
                    else:
                        g_XVMStatisticsEvents.OnStatsBattleLoaded(stats)
                    if len(g_XVMStatisticsEvents.OnStatsFullBattleLoaded._delegates) > 1:
                        for delegate in g_XVMStatisticsEvents.OnStatsFullBattleLoaded._delegates[0:-1]:
                            delegate(deepcopy(statistic))
                        g_XVMStatisticsEvents.OnStatsFullBattleLoaded._delegates[-1](statistic)
                    else:
                        g_XVMStatisticsEvents.OnStatsFullBattleLoaded(statistic)

                g_XVMConsole.getStatsByID_Async(IDs.keys(), OnStats)
            else:
                g_XVMConsole.getStatsByID_Async(IDs.keys(), g_XVMStatisticsEvents.OnStatsFullBattleLoaded)
        else:
            if g_XVMStatisticsEvents.OnStatsBattleLoaded._delegates:
                g_XVMStatisticsEvents.OnStatsBattleLoaded(None)
            g_XVMStatisticsEvents.OnStatsFullBattleLoaded(None)
    elif g_XVMStatisticsEvents.OnStatsBattleLoaded._delegates:
        if IDs:
            g_XVMConsole.getStats_Async(IDs, g_XVMStatisticsEvents.OnStatsBattleLoaded)
        else:
            g_XVMStatisticsEvents.OnStatsBattleLoaded(None)
    def pressed_key(self):  # not working in training room coz prebID identical
        prebID = 0
        config0.check_running = True
        arena = getattr(BigWorld.player(), 'arena', None)
        if arena is not None:
            if arena.bonusType in self.schematic.key_mode:
                sessionProvider = dependency.instance(IBattleSessionProvider)
                setup = repositories.BattleSessionSetup(
                    avatar=BigWorld.player(), sessionProvider=sessionProvider)
                adding = anonymizer_fakes_ctrl.AnonymizerFakesController(setup)
                databID = getAvatarDatabaseID()

                vehID = getattr(BigWorld.player(), 'playerVehicleID', None)
                if vehID is not None and vehID in arena.vehicles:
                    prebID = arena.vehicles[vehID]['prebattleID']

                for (vehicleID, vData) in getArena().vehicles.iteritems():
                    databaseID = vData['accountDBID']
                    av_ses_id = vData['avatarSessionID']
                    _prebattleID = vData['prebattleID']
                    tag = vData['vehicleType'].type.tags  # frozenset
                    veh_name = vData['vehicleType'].type.name  # str
                    user = adding.usersStorage.getUser(
                        av_ses_id, scope=UserEntityScope.BATTLE)
                    if user is not None:
                        if self.schematic.tank_cls_key or len(
                                self.schematic.tanklist) > 1:
                            if databaseID != databID and (
                                (self.schematic.tank_cls_key & tag) or
                                (veh_name in self.schematic.tanklist)):
                                if not (user.isFriend() or user.isIgnored()):
                                    if prebID > 0 and prebID != _prebattleID:
                                        adding.addBattleIgnored(av_ses_id)
                                        yield wait(1.1)
                                    elif prebID == 0:
                                        adding.addBattleIgnored(av_ses_id)
                                        yield wait(1.1)
                    else:
                        if self.schematic.tank_cls_key or len(
                                self.schematic.tanklist) > 1:
                            if databaseID != databID and (
                                (self.schematic.tank_cls_key & tag) or
                                (veh_name in self.schematic.tanklist)):
                                if prebID > 0 and prebID != _prebattleID:
                                    adding.addBattleIgnored(av_ses_id)
                                    yield wait(1.1)
                                elif prebID == 0:
                                    adding.addBattleIgnored(av_ses_id)
                                    yield wait(1.1)
                SendGuiMessage('Blacklisting finished!')
        config0.check_running = False
    def __updateTeamData(self, isEnemy, arenaDP, isFragsUpdate = True):
        team = arenaDP.getNumberOfTeam(isEnemy)
        fragCorrelation = self.__battleUI.fragCorrelation
        if isFragsUpdate:
            fragCorrelation.clear(team)
        regionGetter = self.__battleCtx.getRegionCode
        isSpeaking = VoiceChatInterface.g_instance.isPlayerSpeaking
        userGetter = self.usersStorage.getUser
        pNamesList, fragsList, vNamesList = [], [], []
        roamingCtrl = game_control.g_instance.roaming

        def isMenuEnabled(dbID):
            return not roamingCtrl.isInRoaming() and not roamingCtrl.isPlayerInRoaming(dbID)

        valuesHashes = []
        ctx = makeTeamCtx(team, isEnemy, arenaDP, int(self.__battleUI.getPlayerNameLength(isEnemy)), self.__battleUI.getCameraVehicleID())
        playerAccountID = getAvatarDatabaseID()
        inviteSendingProhibited = isEnemy or self.prbInvites.getSentInviteCount() >= 100
        if not inviteSendingProhibited:
            inviteSendingProhibited = not self.__isSquadAllowToInvite(arenaDP)
        invitesReceivingProhibited = arenaDP.getVehicleInfo(playerAccountID).player.forbidInBattleInvitations
        for index, (vInfoVO, vStatsVO, viStatsVO) in enumerate(arenaDP.getTeamIterator(isEnemy)):
            if index >= PLAYERS_PANEL_LENGTH:
                LOG_WARNING('Max players in panel are', PLAYERS_PANEL_LENGTH)
                break
            if self.__battleCtx.isObserver(vInfoVO.vehicleID):
                if self.__battleCtx.isPlayerObserver():
                    continue
            elif isFragsUpdate:
                fragCorrelation.addVehicle(team, vInfoVO.vehicleID, vInfoVO.vehicleType.getClassName(), vInfoVO.isAlive())
                if not vInfoVO.isAlive():
                    fragCorrelation.addKilled(team)
            if not self.__panelsUpdatable:
                continue
            playerFullName = self.__battleCtx.getFullPlayerName(vID=vInfoVO.vehicleID, showVehShortName=False)
            if not playerFullName:
                playerFullName = vInfoVO.player.getPlayerLabel()
            valuesHash = self.__makeHash(index, playerFullName, vInfoVO, vStatsVO, viStatsVO, ctx, userGetter, isSpeaking, isMenuEnabled, regionGetter, playerAccountID, inviteSendingProhibited, invitesReceivingProhibited)
            pName, frags, vName = self.__battleUI.getFormattedStrings(vInfoVO, vStatsVO, ctx, playerFullName)
            pNamesList.append(pName)
            fragsList.append(frags)
            vNamesList.append(vName)
            valuesHashes.append(valuesHash)

        if self.__panelsUpdatable:
            self.__battleUI.setTeamValuesData(self.__makeTeamValues(isEnemy, ctx, pNamesList, fragsList, vNamesList, valuesHashes))
    def _updateTeamData(self, isEnemy, team, arenaDP, isFragsUpdate = True):
        pNamesList, fragsList, vNamesList, additionalDataList = ([],
         [],
         [],
         [])
        valuesHashes = []
        ctx = makeTeamCtx(team, isEnemy, arenaDP, int(self._battleUI.getPlayerNameLength(isEnemy)), self._battleUI.getCameraVehicleID())
        if isFragsUpdate:
            fragCorrelation = self._battleUI.fragCorrelation
            fragCorrelation.clear(team)
            for index, (vInfoVO, vStatsVO, viStatsVO) in enumerate(arenaDP.getTeamIterator(team)):
                if not self._battleCtx.isObserver(vInfoVO.vehicleID):
                    fragCorrelation.addVehicle(team, vInfoVO.vehicleID, vInfoVO.vehicleType.getClassName(), vInfoVO.isAlive())
                    if not vInfoVO.isAlive():
                        fragCorrelation.addKilled(team)

        playerAccountID = getAvatarDatabaseID()
        inviteSendingProhibited = isEnemy or self.prbInvites.getSentInviteCount() >= 100
        if not inviteSendingProhibited:
            inviteSendingProhibited = not self._isSquadAllowToInvite(arenaDP)
        invitesReceivingProhibited = arenaDP.getVehicleInfo(playerAccountID).player.forbidInBattleInvitations
        for index, (vInfoVO, vStatsVO, viStatsVO) in enumerate(arenaDP.getVehiclesIterator(isEnemy)):
            if index >= PLAYERS_PANEL_LENGTH:
                LOG_WARNING('Max players in panel are', PLAYERS_PANEL_LENGTH)
                break
            if self._battleCtx.isObserver(vInfoVO.vehicleID) and self._battleCtx.isPlayerObserver():
                continue
            playerFullName = self._battleCtx.getFullPlayerName(vID=vInfoVO.vehicleID, showVehShortName=False)
            if not playerFullName:
                playerFullName = vInfoVO.player.getPlayerLabel()
            valuesHash = self._makeHash(index, playerFullName, vInfoVO, vStatsVO, viStatsVO, ctx, playerAccountID, inviteSendingProhibited, invitesReceivingProhibited, isEnemy)
            pName, frags, vName, additionalData = self._battleUI.statsForm.getFormattedStrings(vInfoVO, vStatsVO, viStatsVO, ctx, playerFullName)
            pNamesList.append(pName)
            fragsList.append(frags)
            vNamesList.append(vName)
            additionalDataList.append(additionalData)
            valuesHashes.append(valuesHash)

        self._battleUI.setTeamValuesData(self._makeTeamValues(isEnemy, ctx, pNamesList, fragsList, vNamesList, additionalDataList, valuesHashes))
Exemple #8
0
def teambl_key():
    prebID = 0
    arena = getattr(BigWorld.player(), 'arena', None)
    if arena is not None and not BattleReplay.isPlaying():
        if arena.bonusType == 1:
            sessionProvider = dependency.instance(IBattleSessionProvider)
            setup = repositories.BattleSessionSetup(
                avatar=BigWorld.player(), sessionProvider=sessionProvider)
            adding = anonymizer_fakes_ctrl.AnonymizerFakesController(setup)
            databID = getAvatarDatabaseID()

            vehID = getattr(BigWorld.player(), 'playerVehicleID', None)
            if vehID is not None and vehID in arena.vehicles:
                prebID = arena.vehicles[vehID]['prebattleID']

            for (vehicleID, vData) in getArena().vehicles.iteritems():
                databaseID = vData['accountDBID']
                av_ses_id = vData['avatarSessionID']
                _prebattleID = vData['prebattleID']
                user = adding.usersStorage.getUser(
                    av_ses_id, scope=UserEntityScope.BATTLE)
                if user is not None:
                    if databaseID != databID and not (user.isFriend()
                                                      or user.isIgnored()):
                        if prebID > 0 and prebID != _prebattleID:
                            adding.addBattleIgnored(av_ses_id)
                            yield wait(1.1)
                        elif prebID == 0:
                            adding.addBattleIgnored(av_ses_id)
                            yield wait(1.1)
                else:
                    if databaseID != databID:
                        if prebID > 0 and prebID != _prebattleID:
                            adding.addBattleIgnored(av_ses_id)
                            yield wait(1.1)
                        elif prebID == 0:
                            adding.addBattleIgnored(av_ses_id)
                            yield wait(1.1)
def getPlayerDatabaseID():
    return _getAccountDatabaseID() or getAvatarDatabaseID()
Exemple #10
0
 def reportBug(self):
     reportBugOpenConfirm(getAccountDatabaseID() or getAvatarDatabaseID())
Exemple #11
0
def getPlayerDatabaseID():
    return getAccountDatabaseID() or getAvatarDatabaseID()
 def reportBug(self):
     reportBugOpenConfirm(getAccountDatabaseID() or getAvatarDatabaseID())