Exemplo n.º 1
0
    def _makeData(self):
        arenaDP = g_sessionProvider.getArenaDP()
        teamIds = arenaDP.getMultiTeamsIndexes()
        playerVehID = avatar_getter.getPlayerVehicleID()
        allyTeams = arenaDP.getAllyTeams()
        isSquadPlayer = arenaDP.isSquadMan(playerVehID)
        teamScores = {}
        enemyScore = 0
        enemyName = ''
        allyScore = 0
        collection = vos_collections.VehiclesItemsCollection()
        for vInfoVO, vStatsVO in collection.iterator(arenaDP):
            points = vStatsVO.winPoints
            if vInfoVO.team in allyTeams:
                allyScore += points
            else:
                if vInfoVO.team in teamScores:
                    currentScore = teamScores[vInfoVO.team]
                    totalScore = currentScore + points
                else:
                    totalScore = points
                teamScores[vInfoVO.team] = totalScore
                if totalScore > enemyScore:
                    enemyScore = totalScore
                    squadIndex = teamIds[vInfoVO.team]
                    enemyName = i18n.makeString(
                        INGAME_GUI.SCOREPANEL_SQUADLBL, sq_number=squadIndex
                    ) if squadIndex else vInfoVO.player.name

        if isSquadPlayer:
            playerName = i18n.makeString(INGAME_GUI.SCOREPANEL_MYSQUADLBL)
        else:
            playerName = avatar_getter.getPlayerName()
            if arenaDP.isTeamKiller(playerVehID):
                playerName = makeHtmlString('html_templates:battle',
                                            'fallouScorePanelTeamKiller',
                                            playerName)
        self.__allyScore = allyScore
        self.__enemyScore = enemyScore
        self.as_setDataS(self._contextType, self._maxScore, 0, allyScore,
                         enemyScore, playerName, enemyName, _TEAM_PROPS)
        self._score = (allyScore, enemyScore)
        g_eventBus.handleEvent(
            events.ScoreEvent(events.ScoreEvent.FRAGS_UPDATED,
                              ctx={
                                  'ally': allyScore,
                                  'enemy': enemyScore
                              }), EVENT_BUS_SCOPE.BATTLE)
Exemplo n.º 2
0
    def invalidateVehiclesStats(self, arenaDP):
        exchange = self._exchangeBroker.getVehiclesStatsExchange()
        collection = vos_collections.VehiclesItemsCollection()
        for vos in collection.iterator(arenaDP):
            vInfoVO, vStatsVO = vos
            if vInfoVO.isObserver():
                continue
            self._statsCollector.addVehicleStatsUpdate(vInfoVO, vStatsVO)
            isEnemy = self.__isEnemyTeam(arenaDP, vInfoVO.team)
            with exchange.getCollectedComponent(isEnemy) as item:
                item.addStats(vStatsVO)

        exchange.addTotalStats(self._statsCollector.getTotalStats(self._arenaVisitor, self.sessionProvider))
        exchange.addSortIDs(arenaDP, False, True)
        data = exchange.get(forced=True)
        if data:
            self.as_setFragsS(data)
Exemplo n.º 3
0
    def invalidateVehiclesStats(self, arenaDP):
        """New statistics has been received.
        :param arenaDP: instance of ArenaDataProvider.
        """
        exchange = self._exchangeBroker.getVehiclesStatsExchange()
        collection = vos_collections.VehiclesItemsCollection()
        for vos in collection.iterator(arenaDP):
            vInfoVO, vStatsVO = vos
            if vInfoVO.isObserver():
                continue
            self._statsCollector.addVehicleStatsUpdate(vInfoVO, vStatsVO)
            isEnemy = self.__isEnemyTeam(arenaDP, vInfoVO.team)
            with exchange.getCollectedComponent(isEnemy) as item:
                item.addStats(vStatsVO)

        exchange.addTotalStats(self._statsCollector.getTotalStats(arenaDP))
        exchange.addSortIDs(arenaDP, False, True)
        data = exchange.get(forced=True)
        if data:
            self.as_setFragsS(data)
Exemplo n.º 4
0
    def _makeData(self):
        arenaDP = g_sessionProvider.getArenaDP()
        playerVehID = avatar_getter.getPlayerVehicleID()
        allyTeams = arenaDP.getAllyTeams()
        allyScore, enemyScore, playerScore = (0, 0, 0)
        collection = vos_collections.VehiclesItemsCollection()
        for vInfoVO, vStatsVO in collection.iterator(arenaDP):
            points = vStatsVO.winPoints
            if vInfoVO.team in allyTeams:
                allyScore += points
                if vInfoVO.vehicleID == playerVehID:
                    playerScore += points
            else:
                enemyScore += points

        self.as_setDataS(self._contextType, self._maxScore, playerScore,
                         allyScore, enemyScore, '', '', {})
        self._score = (allyScore, enemyScore)
        g_eventBus.handleEvent(
            events.ScoreEvent(events.ScoreEvent.FRAGS_UPDATED,
                              ctx={
                                  'ally': allyScore,
                                  'enemy': enemyScore
                              }), EVENT_BUS_SCOPE.BATTLE)