Example #1
0
    def invalidateVehiclesInfo(self, arenaDP):
        regionGetter = player_format.getRegionCode
        isSpeaking = self.bwProto.voipController.isPlayerSpeaking
        userGetter = self.usersStorage.getUser
        actionGetter = VehicleActions.getBitMask
        playerTeam = arenaDP.getNumberOfTeam()
        if self._arenaVisitor.hasRespawns():
            sortKey = vos_collections.RespawnSortKey
        else:
            sortKey = vos_collections.VehicleInfoSortKey
        isFallout = self._arenaVisitor.gui.isFalloutClassic()
        for isEnemy, collection in ((False,
                                     vos_collections.AllyItemsCollection(
                                         sortKey=sortKey)),
                                    (True,
                                     vos_collections.EnemyItemsCollection(
                                         sortKey=sortKey))):
            result = []
            for vInfoVO, vStatsVO in collection.iterator(arenaDP):
                result.append(
                    self._makeItem(vInfoVO, vStatsVO, userGetter, isSpeaking,
                                   actionGetter, regionGetter,
                                   playerTeam, isEnemy,
                                   self._getSquadIdx(arenaDP,
                                                     vInfoVO), isFallout))

            self.as_setVehiclesDataS({
                'vehiclesInfo': result,
                'isEnemy': isEnemy
            })
 def __checkHasAlive(self, arenaDP):
     """ Check if there are alive vehicle in either team, play finish sound if there is none.
     """
     allies = set(vos_collections.AllyItemsCollection().ids(arenaDP))
     enemies = set(vos_collections.EnemyItemsCollection().ids(arenaDP))
     if allies and self.__deadAllies == allies or enemies and self.__deadEnemies == enemies:
         self.__onRoundFinished(_SOUND_EVENTS.LAST_KILL)
Example #3
0
 def _getInfoCollection(self, isEnemy):
     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)
     return collection
 def __readyToShow(self, vo):
     if self.__isShown:
         return False
     arenaDP = self.sessionProvider.getArenaDP()
     vInfoVO = arenaDP.getVehicleInfo()
     pos = arenaDP.getVehicleStats(
         vInfoVO.vehicleID).gameModeSpecific.getValue(
             BattleRoyaleKeys.RANK.value)
     if self.__isSolo():
         if vo.vehicleID == self.__playerVehicleID() and not vo.isAlive():
             return pos > self._SKIP_SCREEN_FOR_TOP_POSITIONS
     elif all((not infoVo.isAlive() for infoVo, statsVo in
               vos_collections.AllyItemsCollection().iterator(arenaDP))):
         return pos > self._SKIP_SCREEN_FOR_TOP_POSITIONS
     return False
    def __initSquadPlayers(self):
        self.__vehicleIDs = []
        arenaDP = self.__sessionProvider.getArenaDP()
        collection = vos_collections.AllyItemsCollection().ids(arenaDP)
        names = []
        clans = []
        for vId in collection:
            vInfoVO = arenaDP.getVehicleInfo(vId)
            playerVehId = BigWorld.player().observedVehicleID or arenaDP.getPlayerVehicleID()
            if not vInfoVO.isObserver() and playerVehId != vId and not isSpawnedBot(vInfoVO.vehicleType.tags):
                self.__vehicleIDs.append(vId)
                names.append(vInfoVO.player.name)
                clanAbbrev = getClanAbbrevString(vInfoVO.player.clanAbbrev) if vInfoVO.player.clanAbbrev else None
                clans.append(clanAbbrev)

        self.as_setInitDataS(backport.text(R.strings.battle_royale.playersPanel.title()), names, clans)
        return
Example #6
0
    def __initSquadPlayers(self):
        self.__vehicleIDs = []
        arenaDP = self.sessionProvider.getArenaDP()
        collection = vos_collections.AllyItemsCollection().ids(arenaDP)
        names = []
        clans = []
        for vId in collection:
            vInfoVO = arenaDP.getVehicleInfo(vId)
            if not vInfoVO.isObserver() and arenaDP.isSquadMan(
                    vId) and arenaDP.getPlayerVehicleID() != vId:
                self.__vehicleIDs.append(vId)
                names.append(vInfoVO.player.name)
                clanAbbrev = getClanAbbrevString(
                    vInfoVO.player.clanAbbrev
                ) if vInfoVO.player.clanAbbrev else None
                clans.append(clanAbbrev)

        if self.__vehicleIDs:
            self.as_setInitDataS(
                backport.text(R.strings.battle_royale.playersPanel.title()),
                names, clans)
        return
Example #7
0
 def getAlliesVehiclesNumber(self):
     """Gets number of vehicles that are allies
     :return: number of vehicles that are allies.
     :rtype: int.
     """
     return vos_collections.AllyItemsCollection().count(self)
Example #8
0
 def getAlliesVehiclesNumber(self):
     return vos_collections.AllyItemsCollection().count(self)
Example #9
0
    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))
Example #10
0
 def addSortIDs(self, isEnemy, arenaDP):
     raise not isEnemy or AssertionError
     self._items = vos_collections.AllyItemsCollection(sortKey=self._sortKey).ids(arenaDP)
     self.removeObserverIDs(arenaDP)
 def addSortIDs(self, isEnemy, arenaDP):
     self._items = vos_collections.AllyItemsCollection(
         sortKey=self._sortKey).ids(arenaDP)
     self.removeObserverIDs(arenaDP)
Example #12
0
 def __getSquadKills(self):
     allies = vos_collections.AllyItemsCollection()
     frags = sum([ vStatsVO.frags for vInfoVO, vStatsVO in allies.iterator(self.__arenaDP) if not vInfoVO.isObserver() and vInfoVO.isSquadMan() ])
     return _StatsItemValues(frags, _NO_MAX_VALUE)