This commit is contained in:
Thijs Stobbelaar 2023-11-15 16:04:24 +01:00
parent 30c25bcc48
commit 0907f12d98

View file

@ -80,11 +80,19 @@ $lastMatches = array_slice($allMatches, 0, 8);
echo "</tr>";
echo "</table>";
$directory = 'data/killstats/';
$prefix = $matchdata['id'];
$files = glob($directory . $prefix . '*');
if (count($files) == 0) {
echo "No individual player data available (yet) check back in half hour.";
} else {
echo "<table class='sortable'>";
echo "<tr>
echo "<table class='sortable'>";
echo "<tr>
<th>Player Name</th>
<th>Kills</th>
<th>humankills</th>
@ -93,40 +101,35 @@ $lastMatches = array_slice($allMatches, 0, 8);
<th>DBNOs</th>
</tr>";
$directory = 'data/killstats/';
$prefix = $matchdata['id'];
$files = glob($directory . $prefix . '*');
foreach ($files as $file) {
$jsonData_individual_player = json_decode(file_get_contents($file), true);
$individualPlayerName = $jsonData_individual_player['stats']['playername'];
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'];
$rank = $playerStats['winPlace'];
$DBNOs = $playerStats['DBNOs'];
break;
// 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'];
$rank = $playerStats['winPlace'];
$DBNOs = $playerStats['DBNOs'];
break;
}
}
}
}
echo "<tr>";
echo "<td>" . htmlspecialchars($individualPlayerName) . "</td>";
echo "<td>" . htmlspecialchars($jsonData_individual_player['stats']['humankills']) . "</td>";
echo "<td>" . htmlspecialchars($jsonData_individual_player['stats']['kills']) . "</td>";
echo "<td>" . htmlspecialchars($damageDealt) . "</td>";
echo "<td>" . htmlspecialchars($rank) . "</td>";
echo "<td>" . htmlspecialchars($DBNOs) . "</td>";
echo "</tr>";
}
echo "</table>";
echo "<tr>";
echo "<td>" . htmlspecialchars($individualPlayerName) . "</td>";
echo "<td>" . htmlspecialchars($jsonData_individual_player['stats']['humankills']) . "</td>";
echo "<td>" . htmlspecialchars($jsonData_individual_player['stats']['kills']) . "</td>";
echo "<td>" . htmlspecialchars($damageDealt) . "</td>";
echo "<td>" . htmlspecialchars($rank) . "</td>";
echo "<td>" . htmlspecialchars($DBNOs) . "</td>";
echo "</tr>";
}
echo "</table>";
}
echo "<table class='sortable'>";
echo "<tr>
<th>Player Name</th>