コード例 #1
0
    def get_match_result(self, match_id, side):
        """
        Returns list of games results / sides. (radiant or dire)
        """
        steam_xml_file = download_xml(4, match_id)
        radiant_xml_result = str(steam_xml_file.find("radiant_win").text).upper()
        player_side = ""

        for players in steam_xml_file:
            for player in players:
                xml_account_id = player.find("account_id").text
                if xml_account_id == self.account_id:
                    player_slot = player.find("player_slot").text
                    if int(player_slot) < 5:
                        player_side = "Radiant"
                    else:
                        player_side = "Dire"

                if player_side == "Radiant" and radiant_xml_result == "TRUE":
                    player_result = 1
                elif player_side == "Dire" and radiant_xml_result == "FALSE":
                    player_result = 1
                else:
                    player_result = 0

        if side == 0:
            return player_result
        elif side == 1:
            return player_side
        else:
            return None
コード例 #2
0
    def list_dota2_news(self):
        """
        This function downloads the xml file and adds the chosen items into a list.
        It then returns this list with current dota2 news.
        """
        self.pass_static()
        steam_xml_file = download_xml(3, "")
        news_list = []

        for news_items in steam_xml_file:
            for news_item in news_items:
                news_list.append(news_item.find("title").text)
                news_list.append(news_item.find("url").text)
                news_list.append(news_item.find("contents").text)
        return news_list
コード例 #3
0
    def get_match_data(self):
        """
        This function returns the match_id and time in timestamp.
        Converting of timestamp happens when outputting.
        """
        steam_xml_file = download_xml(2, str(self.account_id))

        steam_xml_root = steam_xml_file
        steam_xml_matches = steam_xml_root.find('matches')
        match_data_list = []

        for match in steam_xml_matches:
            for m_id in match.findall('match_id'):
                match_data_list.append(m_id.text)
                match_data_list.append(match.find('start_time').text)
        return match_data_list
コード例 #4
0
 def get_user_hero_id(self, amount):
     """
     This functions returns a list containing the ID of the hero that the given account_id user, has played.
     It fills up after completing all for loops, otherwise it will only remember the first input hero_id
     """
     # MAGIC
     steam_xml_file = download_xml(2, "")
     steam_xml_root = steam_xml_file
     steam_xml_matches = steam_xml_root.find('matches')
     user_match_data_list = []
     x = 0
     for match in steam_xml_matches:
         for match_info in match:
             for player in match_info:
                 if player.find("account_id").text == self.account_id:
                     user_match_data_list.append(player.find('hero_id').text)
         x += 1
         if x is amount:
             break
     return user_match_data_list
コード例 #5
0
    def get_hero_information(self, hero_id):
        """
        This function returns the hero in text. It is compared to the hero_id given by the list, user_match_data_list.
        From the function get_user_id()
        """
        # MAGIC
        self.pass_static()
        steam_xml_file = download_xml(1, "")
        #   steam_xml_parser = et.parse("herolog.xml")

        steam_hero_root = steam_xml_file
        steam_heroes_root = steam_hero_root.find('heroes')

        hero_list = []

        for all_heroes in steam_heroes_root:
            if hero_id == all_heroes.find("id").text:
                hero_list.append(all_heroes.find("localized_name").text)
                #    print(hero_id)
                #    print(all_heroes.find("localized_name").text)

        for selected_hero in hero_list:
            return selected_hero
コード例 #6
0
 def get_user_match_items(self, amount):
     """"
     This function returns a list of all item_id's per amount games.
     """
     item_ids = []
     amount = (amount*2)
     x = 0
     match_data = self.get_match_data()
     while True:
         steam_xml_file = download_xml(4, match_data[x])
         for players in steam_xml_file:
             for player in players:
                     find_my_id = str(player.find("account_id").text)
                     if find_my_id == str(self.account_id):
                         item_ids.append(player.find("item_0").text)
                         item_ids.append(player.find("item_1").text)
                         item_ids.append(player.find("item_2").text)
                         item_ids.append(player.find("item_3").text)
                         item_ids.append(player.find("item_4").text)
                         item_ids.append(player.find("item_5").text)
         x += 2
         if x is amount:
             break
     return item_ids