Exemple #1
0
    def create_from_actor_data(self, actor_data: dict, teams: List['Team']):
        self.name = actor_data['name']
        if 'Engine.PlayerReplicationInfo:bBot' in actor_data and actor_data['Engine.PlayerReplicationInfo:bBot']:
            self.is_bot = True
            self.online_id = get_online_id_for_bot(bot_map, self)

        else:
            actor_type = list(actor_data["Engine.PlayerReplicationInfo:UniqueId"]['unique_id']['remote_id'].keys())[0]
            self.online_id = actor_data["Engine.PlayerReplicationInfo:UniqueId"]['unique_id']['remote_id'][actor_type]
        try:
            self.score = actor_data["TAGame.PRI_TA:MatchScore"]
        except KeyError:
            logger.warning('Score is not found for player')
        team_actor_id = actor_data["Engine.PlayerReplicationInfo:Team"]
        if team_actor_id == -1:
            # if they leave at the end
            team_actor_id = actor_data['team']
        for team in teams:
            if team.actor_id == team_actor_id:
                self.is_orange = team.is_orange
        assert self.is_orange is not None, 'Cannot find team for player: %s' % self.name
        self.score = actor_data.get("TAGame.PRI_TA:MatchScore", None)
        self.goals = actor_data.get("TAGame.PRI_TA:MatchGoals", None)
        self.assists = actor_data.get("TAGame.PRI_TA:MatchAssists", None)
        self.saves = actor_data.get("TAGame.PRI_TA:MatchSaves", None)
        self.shots = actor_data.get("TAGame.PRI_TA:MatchShots", None)
        self.parse_actor_data(actor_data)

        logger.debug('Created Player from actor_data: %s', self)
        return self
Exemple #2
0
    def parse_player_stats(self, player_stats: dict):
        self.name = player_stats["Name"]["value"]["str"]
        self.online_id = str(player_stats["OnlineID"]["value"]["q_word"])
        self.is_orange = bool(player_stats["Team"]["value"]["int"])
        self.score = player_stats["Score"]["value"]["int"]
        self.goals = player_stats["Goals"]["value"]["int"]
        self.assists = player_stats["Assists"]["value"]["int"]
        self.saves = player_stats["Saves"]["value"]["int"]
        self.shots = player_stats["Shots"]["value"]["int"]
        self.is_bot = bool(player_stats["bBot"]["value"]["bool"])

        logger.info('Created Player from stats: %s' % self)
        if self.is_bot or self.online_id == '0' or self.online_id == 0:
            self.online_id = get_online_id_for_bot(bot_map, self)

        return self
Exemple #3
0
    def parse_player_stats(self, player_stats: dict):
        self.name = player_stats["Name"]
        self.online_id = player_stats["OnlineID"]
        self.is_orange = bool(player_stats["Team"])
        self.score = player_stats["Score"]
        self.goals = player_stats["Goals"]
        self.assists = player_stats["Assists"]
        self.saves = player_stats["Saves"]
        self.shots = player_stats["Shots"]
        self.is_bot = player_stats["bBot"]

        logger.debug('Created Player from stats: %s', self)
        if self.is_bot or self.online_id == '0' or self.online_id == 0:
            self.online_id = get_online_id_for_bot(bot_map, self)

        return self
Exemple #4
0
    def decode_online_id(self, actor_data: dict):
        if 'Engine.PlayerReplicationInfo:bBot' in actor_data and actor_data[
                'Engine.PlayerReplicationInfo:bBot']:
            self.is_bot = True
            self.online_id = get_online_id_for_bot(bot_map, self)
            return

        actor_type = list(actor_data["Engine.PlayerReplicationInfo:UniqueId"]
                          ['unique_id']['remote_id'].keys())[0]
        id_data = actor_data["Engine.PlayerReplicationInfo:UniqueId"][
            'unique_id']['remote_id'][actor_type]
        self.id_network = actor_type
        if actor_type == "steam":
            self.online_id = id_data
        elif actor_type == "play_station":
            id_ = int.from_bytes(bytes(
                [play_station_bit_swap(byte_) for byte_ in id_data[1][-8:]]),
                                 byteorder='little')
            self.online_id = str(id_)
        elif actor_type == 'xbox':
            self.online_id = id_data
        else:
            raise RuntimeError(f"Unknown actor type: {actor_type}")
            pass