IBR CASUAL OFFICIAL SEPERATED #47
2 changed files with 151 additions and 50 deletions
109
last_stats.php
109
last_stats.php
|
|
@ -6,6 +6,7 @@ error_reporting(E_ALL);
|
|||
|
||||
<!DOCTYPE html>
|
||||
<html lang="en">
|
||||
|
||||
<head>
|
||||
<meta charset="UTF-8">
|
||||
<meta http-equiv="X-UA-Compatible" content="IE=edge">
|
||||
|
|
@ -14,42 +15,67 @@ error_reporting(E_ALL);
|
|||
<link rel="stylesheet" href="./includes/styles.css">
|
||||
<script src="./lib/sorttable.js"></script>
|
||||
</head>
|
||||
|
||||
<body>
|
||||
|
||||
<?php include './includes/navigation.php'; ?>
|
||||
<?php include './includes/navigation.php'; ?>
|
||||
|
||||
<main>
|
||||
<section>
|
||||
<h2>Player Stats past 14 days</h2>
|
||||
<?php
|
||||
<main>
|
||||
<section>
|
||||
<h2>Player Stats past 14 days</h2>
|
||||
<?php
|
||||
include './config/config.php';
|
||||
|
||||
$players_matches = json_decode(file_get_contents('./data/player_last_stats.json'), true);
|
||||
|
||||
echo "<table border='1' class='sortable'>";
|
||||
echo "<tr>
|
||||
<th>Playername</th>
|
||||
<th>Deaths</th>
|
||||
<th>Kills</th>
|
||||
<th>Human Kills</th>
|
||||
<th>Matches</th>
|
||||
<th>K/D (Human)</th>
|
||||
<th>K/D (All)</th>
|
||||
</tr>";
|
||||
|
||||
foreach ($players_matches as $player_data) {
|
||||
if (!isset($player_data['playername']) || is_null($player_data['playername'])) {
|
||||
continue; // Skip this iteration and move to the next
|
||||
foreach ($players_matches as $key => $player_datas) {
|
||||
if ($key == 'updated') {
|
||||
continue;
|
||||
}
|
||||
$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 "<br>";
|
||||
echo "Stats for $key";
|
||||
echo "<table border='1' class='sortable'>";
|
||||
echo "<tr>
|
||||
<th>Playername</th>
|
||||
<th>Deaths</th>
|
||||
<th>Kills</th>
|
||||
<th>Human Kills</th>
|
||||
<th>Matches</th>
|
||||
<th>K/D (Human)</th>
|
||||
<th>K/D (All)</th>
|
||||
</tr>";
|
||||
foreach ($player_datas as $player_data) {
|
||||
if (!isset($player_data['playername']) || is_null($player_data['playername'])) {
|
||||
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 =
|
||||
!isset($player_data['KD_H']) || $player_data['KD_H'] === null
|
||||
? "null"
|
||||
: ($player_data['KD_H'] == "Infinity"
|
||||
? "∞"
|
||||
: (is_numeric($player_data['KD_H'])
|
||||
? number_format((float) $player_data['KD_H'], 2, ',', '')
|
||||
: "0")); // or any other default string for non-numerical values
|
||||
|
||||
|
||||
$KD_ALL =
|
||||
!isset($player_data['KD_ALL']) || $player_data['KD_ALL'] === null
|
||||
? "null"
|
||||
: ($player_data['KD_ALL'] == "Infinity"
|
||||
? "∞"
|
||||
: (is_numeric($player_data['KD_ALL'])
|
||||
? number_format((float) $player_data['KD_ALL'], 2, ',', '')
|
||||
: "0")); // or any other default string for non-numerical values
|
||||
|
||||
|
||||
|
||||
echo "<tr>
|
||||
<td>$player_name</td>
|
||||
<td>$deaths</td>
|
||||
<td>$kills</td>
|
||||
|
|
@ -58,23 +84,28 @@ error_reporting(E_ALL);
|
|||
<td>$KD_H</td>
|
||||
<td>$KD_ALL</td>
|
||||
</tr>";
|
||||
}
|
||||
|
||||
echo "</table>";
|
||||
}
|
||||
echo "</table>";
|
||||
echo "Last update: ";
|
||||
foreach ($players_matches as $player_data) {
|
||||
if (isset($player_data['updated'])) {
|
||||
echo $player_data['updated'];
|
||||
break; // Once found, exit the loop
|
||||
|
||||
foreach ($players_matches as $key => $update) {
|
||||
if ($key == 'updated'){
|
||||
echo "Last update: $update ";
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
?>
|
||||
</section>
|
||||
</main>
|
||||
|
||||
<?php include './includes/footer.php'; ?>
|
||||
|
||||
|
||||
?>
|
||||
</section>
|
||||
</main>
|
||||
|
||||
<?php include './includes/footer.php'; ?>
|
||||
|
||||
</body>
|
||||
</html>
|
||||
|
||||
</html>
|
||||
|
|
@ -5,11 +5,13 @@ if ($PSScriptRoot.length -eq 0) {
|
|||
else {
|
||||
$scriptroot = $PSScriptRoot
|
||||
}
|
||||
|
||||
$matches = 5
|
||||
function get-killstats {
|
||||
param (
|
||||
$player_name,
|
||||
$telemetry
|
||||
$telemetry,
|
||||
$matchType,
|
||||
$gameMode
|
||||
)
|
||||
$attacks = @()
|
||||
foreach ($action in $telemetry) {
|
||||
|
|
@ -25,17 +27,24 @@ function get-killstats {
|
|||
humankills = ($kills | where-object { $_.victim.accountId -notlike 'ai.*' }).count
|
||||
kills = $kills.count
|
||||
deaths = ($attacks | where-object { $_.victim.name -eq $player_name }).count
|
||||
gameMode = $gameMode
|
||||
matchType = $matchType
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
$all_player_matches = get-content "$scriptroot/../data/player_matches.json" | convertfrom-json -Depth 100
|
||||
$killstats = @()
|
||||
$i = 0
|
||||
|
||||
foreach ($player in $all_player_matches) {
|
||||
$player_name = $player.playername
|
||||
|
||||
foreach ($match in $player.player_matches) {
|
||||
|
||||
$i++
|
||||
$j = 0
|
||||
write-output "$($all_player_matches.count) / $i"
|
||||
foreach ($match in $player.player_matches | select-object -First $matches) {
|
||||
$j++
|
||||
write-output "$($player.player_matches.count)/ $j"
|
||||
|
||||
|
||||
$telemetryfile = "$scriptroot/../data/telemetry_cache/$($match.telemetry_url.split("/")[-1])"
|
||||
|
|
@ -51,20 +60,20 @@ foreach ($player in $all_player_matches) {
|
|||
}
|
||||
|
||||
write-output "Analyzing for player $player_name telemetry: $($match.telemetry_url)"
|
||||
$killstats += get-killstats -player_name $player_name -telemetry ($telemetry | where-object { $_._T -eq 'LOGPLAYERKILLV2' })
|
||||
$killstats += get-killstats -player_name $player_name -telemetry ($telemetry | where-object { $_._T -eq 'LOGPLAYERKILLV2' }) -gameMode $match.gameMode -matchType $match.matchType
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
$playerstats = @()
|
||||
$playerstats_all = @()
|
||||
foreach ($player in $all_player_matches.playername) {
|
||||
|
||||
$deaths = (($killstats | where-object { $_.playername -eq $player }).deaths | Measure-Object -sum).sum
|
||||
$kills = (($killstats | where-object { $_.playername -eq $player }).kills | Measure-Object -sum).sum
|
||||
$humankills = (($killstats | where-object { $_.playername -eq $player }).humankills | Measure-Object -sum).sum
|
||||
|
||||
$playerstats += [PSCustomObject]@{
|
||||
$playerstats_all += [PSCustomObject]@{
|
||||
playername = $player
|
||||
deaths = $deaths
|
||||
kills = $kills
|
||||
|
|
@ -74,6 +83,63 @@ foreach ($player in $all_player_matches.playername) {
|
|||
KD_ALL = $kills / $deaths
|
||||
}
|
||||
}
|
||||
##IBR
|
||||
|
||||
$playerstats_event_ibr = @()
|
||||
foreach ($player in $all_player_matches.playername) {
|
||||
|
||||
$deaths = (($killstats | where-object { $_.playername -eq $player -and $_.gameMode -eq 'ibr' -and $_.matchType -eq 'event' }).deaths | Measure-Object -sum).sum
|
||||
$kills = (($killstats | where-object { $_.playername -eq $player -and $_.gameMode -eq 'ibr' -and $_.matchType -eq 'event' }).kills | Measure-Object -sum).sum
|
||||
$humankills = (($killstats | where-object { $_.playername -eq $player -and $_.gameMode -eq 'ibr' -and $_.matchType -eq 'event' }).humankills | Measure-Object -sum).sum
|
||||
|
||||
$playerstats_event_ibr += [PSCustomObject]@{
|
||||
playername = $player
|
||||
deaths = $deaths
|
||||
kills = $kills
|
||||
humankills = $humankills
|
||||
matches = ((($all_player_matches | where-object { $_.playername -eq $player }).player_matches | Where-Object { $_.matchType -eq 'event' -and $_.gameMode -eq 'ibr' }).count)
|
||||
KD_H = $humankills / $deaths
|
||||
KD_ALL = $kills / $deaths
|
||||
}
|
||||
}
|
||||
|
||||
##airoyale
|
||||
$playerstats_airoyale = @()
|
||||
foreach ($player in $all_player_matches.playername) {
|
||||
|
||||
$deaths = (($killstats | where-object { $_.playername -eq $player -and $_.matchType -eq 'airoyale' }).deaths | Measure-Object -sum).sum
|
||||
$kills = (($killstats | where-object { $_.playername -eq $player -and $_.matchType -eq 'airoyale' }).kills | Measure-Object -sum).sum
|
||||
$humankills = (($killstats | where-object { $_.playername -eq $player -and $_.matchType -eq 'airoyale' }).humankills | Measure-Object -sum).sum
|
||||
|
||||
$playerstats_airoyale += [PSCustomObject]@{
|
||||
playername = $player
|
||||
deaths = $deaths
|
||||
kills = $kills
|
||||
humankills = $humankills
|
||||
matches = ((($all_player_matches | where-object { $_.playername -eq $player }).player_matches | Where-Object { $_.matchType -eq 'airoyale' }).count)
|
||||
KD_H = $humankills / $deaths
|
||||
KD_ALL = $kills / $deaths
|
||||
}
|
||||
}
|
||||
|
||||
$playerstats_official = @()
|
||||
foreach ($player in $all_player_matches.playername) {
|
||||
|
||||
$deaths = (($killstats | where-object { $_.playername -eq $player -and $_.matchType -eq 'official' }).deaths | Measure-Object -sum).sum
|
||||
$kills = (($killstats | where-object { $_.playername -eq $player -and $_.matchType -eq 'official' }).kills | Measure-Object -sum).sum
|
||||
$humankills = (($killstats | where-object { $_.playername -eq $player -and $_.matchType -eq 'official' }).humankills | Measure-Object -sum).sum
|
||||
|
||||
$playerstats_official += [PSCustomObject]@{
|
||||
playername = $player
|
||||
deaths = $deaths
|
||||
kills = $kills
|
||||
humankills = $humankills
|
||||
matches = ((($all_player_matches | where-object { $_.playername -eq $player }).player_matches | Where-Object { $_.matchType -eq 'official' }).count)
|
||||
KD_H = $humankills / $deaths
|
||||
KD_ALL = $kills / $deaths
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
$currentDateTime = Get-Date
|
||||
|
||||
|
|
@ -84,10 +150,14 @@ $currentTimezone = (Get-TimeZone).Id
|
|||
$formattedString = "$currentDateTime - Time Zone: $currentTimezone"
|
||||
|
||||
# Output the formatted string
|
||||
$playerstats += [PSCustomObject]@{
|
||||
updated = $formattedString
|
||||
}
|
||||
|
||||
$playerstats = [PSCustomObject]@{
|
||||
all = $playerstats_all
|
||||
Intense = $playerstats_event_ibr
|
||||
Casual = $playerstats_airoyale
|
||||
official = $playerstats_official
|
||||
updated = $formattedString
|
||||
}
|
||||
|
||||
write-output "Writing file"
|
||||
($playerstats | convertto-json) | out-file "$scriptroot/../data/player_last_stats.json"
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue