pub fn get_match_details(match_info: &Value, puuid: &str) -> Option<Value>Expand description
⚙️ Function: Extracts relevant match details for a given summoner from the match information.
This function retrieves detailed information about a match, focusing on the summoner specified by their summoner_id.
It validates the game mode, identifies the summoner’s performance, and compares their stats with the enemy team in each role (TOP, JUNGLE, MIDDLE, BOTTOM, UTILITY).
§Parameters:
match_info: A reference to aValue(from theserde_jsoncrate) containing the entire match data fetched from the Riot API.summoner_id: A string slice representing the summoner’s ID, used to locate their stats in the match data.
§Returns:
Option<Value>: Returns a JSON object containing the match result (Victory or Defeat) and detailed role-based stats comparisons, orNoneif the game mode is invalid or the data is not available.
§Example:
This function is typically used to extract and format match details for reporting to a Discord channel:
let match_details = get_match_details(&match_info, summoner_id);
if let Some(details) = match_details {
// Process match details for further use
}§Notes:
- The function first checks if the game mode is valid using
is_valid_game_mode. If the game mode is invalid, the function returnsNone. - It then searches for the summoner in the participants list and identifies their team and match result (Victory or Defeat).
- The function separates the participants into two teams (the summoner’s team and the enemy team) and compares stats for each role.
- It generates JSON-formatted role matchups comparing stats between the summoner’s team and their opponents for each role.