Function extract_champions_info

Source
async fn extract_champions_info(
    champions: Vec<HashMap<String, Value>>,
    champions_data: &Map<String, Value>,
    collection_emoji: Collection<EmojiId>,
) -> String
Expand description

⚙️ Function: Extracts and formats champion information for display.

This function processes a list of champion details and matches each champion ID to the corresponding champion name from the provided champion data (typically fetched from Data Dragon). It then formats and returns a string that includes each champion’s name, level, and mastery points.

§Parameters:

  • champions: A vector of HashMaps, where each HashMap contains information about a player’s champion (e.g., champion ID, level, mastery points). This is typically fetched from the Riot API.
  • champions_data: A HashMap containing the full list of champion data from Data Dragon, which is used to map champion IDs to their names.

§Returns:

  • String: A formatted string containing information about each champion:
    • Champion name
    • Champion level
    • Champion mastery points

The returned string will display each champion on a new line, formatted like this:

Yasuo - Level: 7 - Points: 123456
Zed - Level: 6 - Points: 98765
Lee Sin - Level: 5 - Points: 54321

§⚠️ Notes:

  • If a champion’s ID cannot be matched to a name in champions_data, the champion will be listed as “Unknown Champion”.
  • This function assumes that every champion in the champions list has valid data for level and mastery points.

§Example:

let champions = some_function_fetching_champions();
let champions_data = some_function_fetching_champion_data();
let formatted_champions = extract_champions_info(champions, champions_data);

The resulting formatted_champions string will be:

Yasuo - Level: 7 - Points: 123456
Zed - Level: 6 - Points: 98765
Lee Sin - Level: 5 - Points: 54321