diff --git a/matchinfo.php b/matchinfo.php index 02b4497..4a6b9a9 100644 --- a/matchinfo.php +++ b/matchinfo.php @@ -98,10 +98,25 @@ $lastMatches = array_slice($allMatches, 0, 8); foreach ($files as $file) { $jsonData_individual_player = json_decode(file_get_contents($file), true); + $individualPlayerName = $jsonData_individual_player['stats']['playername']; + + // Search for the player in $jsonData['included'] to find damageDealt + $damageDealt = 0; + foreach ($jsonData['included'] as $includedItem) { + if ($includedItem['type'] == "participant") { + $playerStats = $includedItem['attributes']['stats']; + if ($individualPlayerName == $playerStats['name']) { + $damageDealt = $playerStats['damageDealt']; + break; // Stop searching once the player is found + } + } + } + echo ""; - echo "" . htmlspecialchars($jsonData_individual_player['stats']['playername']) . ""; + echo "" . htmlspecialchars($individualPlayerName) . ""; echo "" . htmlspecialchars($jsonData_individual_player['stats']['humankills']) . ""; echo "" . htmlspecialchars($jsonData_individual_player['stats']['kills']) . ""; + echo "" . htmlspecialchars($damageDealt) . ""; // Display damageDealt here echo ""; } echo "";