<th>humankills</th> #117

Merged
OpzekerIT merged 2 commits from dev into main 2023-11-15 15:06:45 +00:00
Showing only changes of commit 0907f12d98 - Show all commits

View file

@ -80,11 +80,19 @@ $lastMatches = array_slice($allMatches, 0, 8);
echo "</tr>"; echo "</tr>";
echo "</table>"; 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>Player Name</th>
<th>Kills</th> <th>Kills</th>
<th>humankills</th> <th>humankills</th>
@ -93,40 +101,35 @@ $lastMatches = array_slice($allMatches, 0, 8);
<th>DBNOs</th> <th>DBNOs</th>
</tr>"; </tr>";
$directory = 'data/killstats/'; foreach ($files as $file) {
$prefix = $matchdata['id']; $jsonData_individual_player = json_decode(file_get_contents($file), true);
$files = glob($directory . $prefix . '*'); $individualPlayerName = $jsonData_individual_player['stats']['playername'];
// Search for the player in $jsonData['included'] to find damageDealt
foreach ($files as $file) { $damageDealt = 0;
$jsonData_individual_player = json_decode(file_get_contents($file), true); foreach ($jsonData['included'] as $includedItem) {
$individualPlayerName = $jsonData_individual_player['stats']['playername']; if ($includedItem['type'] == "participant") {
$playerStats = $includedItem['attributes']['stats'];
// Search for the player in $jsonData['included'] to find damageDealt if ($individualPlayerName == $playerStats['name']) {
$damageDealt = 0; $damageDealt = $playerStats['damageDealt'];
foreach ($jsonData['included'] as $includedItem) { $rank = $playerStats['winPlace'];
if ($includedItem['type'] == "participant") { $DBNOs = $playerStats['DBNOs'];
$playerStats = $includedItem['attributes']['stats']; break;
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 "<table class='sortable'>";
echo "<tr> echo "<tr>
<th>Player Name</th> <th>Player Name</th>