fn extract_participant_stats(p: &Value) -> ValueExpand description
⚙️ Function: Extracts key participant statistics from a match for a given player.
This function retrieves important statistics for a participant in a League of Legends match, such as their summoner name,
champion name, kills, deaths, assists, total farm, gold earned, and vision score. The extracted stats are returned as a JSON object (serde_json::Value).
§Parameters:
p: A reference to aserde_json::Valueobject representing a participant in the match. This object contains all of the participant’s stats and data.
§Returns:
Value: Returns a JSON object containing the player’s stats, including their summoner name, champion name, K/D/A (kills, deaths, assists), total farm (minions and neutral monsters killed), gold earned, gold per minute, and vision score.
§Example:
This function is used to format and extract individual player stats from the match data:
let player_stats = extract_participant_stats(&participant);
println!("{}", player_stats["summonerName"]);§Notes:
- The summoner’s name is prioritized over their Riot ID game name, but if the summoner name is missing, the Riot ID is used as a fallback.
- Total farm is calculated as the sum of minions killed and neutral monsters killed.
- The stats returned include the summoner’s name, champion, K/D/A, farm, gold, gold per minute, and vision score, which are useful for comparing performance across teams.