From 527f6667b3288bd530910ba50a994fa7fa8e9c28 Mon Sep 17 00:00:00 2001 From: Thijs Stobbelaar Date: Mon, 25 Sep 2023 13:59:18 +0200 Subject: [PATCH] last stats --- data/player_last_stats.json | 77 ++++++++++++++++++++++++++++++++++++ last_stats.php | 79 +++++++++++++++++++++++++++++++++++++ latestmatches.php | 3 +- topstatsavg.php | 2 +- update/matchparser.ps1 | 26 ++++++++++++ 5 files changed, 185 insertions(+), 2 deletions(-) create mode 100644 data/player_last_stats.json create mode 100644 last_stats.php diff --git a/data/player_last_stats.json b/data/player_last_stats.json new file mode 100644 index 0000000..f38be71 --- /dev/null +++ b/data/player_last_stats.json @@ -0,0 +1,77 @@ +[ + { + "playername": "Lanta01", + "deaths": 56.0, + "kills": 215.0, + "humankills": 66.0, + "matches": 68, + "KD_H": 1.1785714285714286, + "KD_ALL": 3.8392857142857144 + }, + { + "playername": "Petje1972", + "deaths": 42.0, + "kills": 251.0, + "humankills": 54.0, + "matches": 48, + "KD_H": 1.2857142857142858, + "KD_ALL": 5.976190476190476 + }, + { + "playername": "TaGMoM", + "deaths": 13.0, + "kills": 42.0, + "humankills": 1.0, + "matches": 14, + "KD_H": 0.07692307692307693, + "KD_ALL": 3.230769230769231 + }, + { + "playername": "r00tger", + "deaths": 0.0, + "kills": 6.0, + "humankills": 2.0, + "matches": 4, + "KD_H": "Infinity", + "KD_ALL": "Infinity" + }, + { + "playername": "Masistuta", + "deaths": 31.0, + "kills": 139.0, + "humankills": 17.0, + "matches": 42, + "KD_H": 0.5483870967741935, + "KD_ALL": 4.483870967741935 + }, + { + "playername": "RalphNorris", + "deaths": 42.0, + "kills": 80.0, + "humankills": 10.0, + "matches": 47, + "KD_H": 0.23809523809523808, + "KD_ALL": 1.9047619047619047 + }, + { + "playername": "Jimbo_The_One", + "deaths": 34.0, + "kills": 38.0, + "humankills": 20.0, + "matches": 43, + "KD_H": 0.5882352941176471, + "KD_ALL": 1.1176470588235294 + }, + { + "playername": "Shepherders", + "deaths": 3.0, + "kills": 4.0, + "humankills": 0.0, + "matches": 3, + "KD_H": 0.0, + "KD_ALL": 1.3333333333333333 + }, + { + "updated": "09/25/2023 13:52:33 - Time Zone: W. Europe Standard Time" + } +] diff --git a/last_stats.php b/last_stats.php new file mode 100644 index 0000000..8b56425 --- /dev/null +++ b/last_stats.php @@ -0,0 +1,79 @@ + + + + + + + + + DTCH - PUBG Clan - Match Stats + + + + + + +
+
+

Player Stats

+ "; + echo " + Playername + Deaths + Kills + Human Kills + Matches + K/D (Human) + K/D (All) + "; + + foreach ($players_matches as $player_data) { + if (isset($player_data['updated'])) { + continue; // Skip this iteration and move to the next + } + $player_name = $player_data['playername']; + $deaths = number_format($player_data['deaths'], 2, ',', ''); + $kills = number_format($player_data['kills'], 2, ',', ''); + $humankills = number_format($player_data['humankills'], 2, ',', ''); + $matches = $player_data['matches']; + $KD_H = ($player_data['KD_H'] == "Infinity") ? "∞" : number_format($player_data['KD_H'], 2, ',', ''); + $KD_ALL = ($player_data['KD_ALL'] == "Infinity") ? "∞" : number_format($player_data['KD_ALL'], 2, ',', ''); + + echo " + $player_name + $deaths + $kills + $humankills + $matches + $KD_H + $KD_ALL + "; + } + echo ""; + echo "Last update: "; + foreach ($players_matches as $player_data) { + if (isset($player_data['updated'])) { + echo $player_data['updated']; + break; // Once found, exit the loop + } + } + + + + ?> +
+
+ + + + + diff --git a/latestmatches.php b/latestmatches.php index 63e2bd1..f4d2bf5 100644 --- a/latestmatches.php +++ b/latestmatches.php @@ -12,6 +12,7 @@ error_reporting(E_ALL); DTCH - PUBG Clan - Match Stats + @@ -39,7 +40,7 @@ error_reporting(E_ALL); foreach ($players_matches as $player_data) { if ($player_data['playername'] === $selected_player) { echo "

Recent Matches for $selected_player

"; - echo ""; + echo "
"; echo ""; foreach ($player_data['player_matches'] as $match) { $date = new DateTime($match['createdAt']); diff --git a/topstatsavg.php b/topstatsavg.php index b7d4d70..f65f77c 100644 --- a/topstatsavg.php +++ b/topstatsavg.php @@ -28,7 +28,7 @@ error_reporting(E_ALL); $selected_mode = isset($_POST['game_mode']) ? $_POST['game_mode'] : 'squad'; // Form to select game mode - echo " + echo " diff --git a/update/matchparser.ps1 b/update/matchparser.ps1 index 5cd6e29..8948f8b 100644 --- a/update/matchparser.ps1 +++ b/update/matchparser.ps1 @@ -1,3 +1,10 @@ + +if($PSScriptRoot.length -eq 0){ + $scriptroot = Get-Location +}else{ + $scriptroot = $PSScriptRoot +} + function get-killstats { param ( $player_name, @@ -69,3 +76,22 @@ foreach ($player in $all_player_matches.playername) { } } + +$currentDateTime = Get-Date + +# Get current timezone +$currentTimezone = (Get-TimeZone).Id + +# Format and parse the information into a string +$formattedString = "$currentDateTime - Time Zone: $currentTimezone" + +# Output the formatted string +$playerstats += [PSCustomObject]@{ + updated = $formattedString + } + + + +($playerstats | convertto-json) | out-file "$scriptroot/../data/player_last_stats.json" + +
Match DateGame ModeMatchTypeMapKillsDamage DealtTime SurvivedwinPlace