-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtopstatsavg.php
More file actions
71 lines (57 loc) · 2.39 KB
/
topstatsavg.php
File metadata and controls
71 lines (57 loc) · 2.39 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
<?php
$ogDescription = "Discover comprehensive average statistics for PUBG players. Dive into player performance across various game modes including solo, duo, and squad, and explore key metrics like Kills, Damage, Headshots, Wins, and Top10s. Stay updated with the latest statistical trends in PUBG gaming.";
?>
<!DOCTYPE html>
<html lang="en">
<?php include './includes/head.php'; ?>
<body>
<?php
include './includes/navigation.php';
include './includes/header.php';
?>
<main>
<section>
<h2>Average User Stats</h2>
<?php
include './config/config.php';
$players_data = json_decode(file_get_contents('./data/player_lifetime_data.json'), true);
$selected_mode = isset($_POST['game_mode']) ? $_POST['game_mode'] : 'squad';
// Form to select game mode
echo "<form method='post' action=''>
<input type='submit' name='game_mode' value='solo' class='btn'>
<input type='submit' name='game_mode' value='duo' class='btn'>
<input type='submit' name='game_mode' value='squad' class='btn'>
</form><br>";
$metrics = [
'Kills' => 'kills',
'Damage' => 'damageDealt',
'Headshots' => 'headshotKills',
'Wins' => 'wins',
'Top10s' => 'top10s'
];
echo "<table border='1' class='sortable'>";
echo "<tr><th>Player</th>";
foreach ($metrics as $display => $metric) {
echo "<th>Average $display</th>";
}
echo "</tr>";
foreach ($players_data[$selected_mode] as $player_name => $player_details) {
$account_id = array_key_first($player_details);
$stats = $player_details[$account_id];
$totalGames = $stats['wins'] + $stats['losses']; // Wins + Losses
echo "<tr><td>$player_name</td>";
foreach ($metrics as $metric) {
$averageValue = ($totalGames > 0) ? round($stats[$metric] / $totalGames, 2) : 0;
echo "<td>$averageValue</td>";
}
echo "</tr>";
}
echo "</table><br>";
echo "Last update " ;
echo $players_data['updated'];
?>
</section>
</main>
<?php include './includes/footer.php'; ?>
</body>
</html>