From 1ed4515cfaa8ce5575241b5f1d0d63ba50dd15c4 Mon Sep 17 00:00:00 2001 From: Lanta Date: Thu, 18 Jul 2024 11:16:43 +0200 Subject: [PATCH 1/3] clan4 casual --- last_stats.php | 6 +++++ update/matchparser.ps1 | 55 ++++++++++++++++++++++++++---------------- 2 files changed, 40 insertions(+), 21 deletions(-) diff --git a/last_stats.php b/last_stats.php index edc2d7e..066d455 100644 --- a/last_stats.php +++ b/last_stats.php @@ -33,6 +33,9 @@ $ogDescription = "Explore detailed player statistics over the past month includi // if ($key == 'all') { // echo "Stats for $key (minimal 20 matches)"; // } + if ($key == 'clan_4_casual') { + echo "Stats for $key (minimal 4 matches)"; + } if ($key == 'Intense') { echo "Stats for $key (minimal 8 matches)"; } @@ -71,6 +74,9 @@ $ogDescription = "Explore detailed player statistics over the past month includi if ($key == 'all' && $player_data['matches'] < 20) { continue; } + if ($key == 'clan_4_casual' && $player_data['matches'] < 4) { + continue; + } if ($key == 'Intense' && $player_data['matches'] < 8) { continue; } diff --git a/update/matchparser.ps1 b/update/matchparser.ps1 index 33c0647..d41af56 100644 --- a/update/matchparser.ps1 +++ b/update/matchparser.ps1 @@ -149,26 +149,36 @@ foreach ($player in $all_player_matches) { $killstats = @() $matchfiles = Get-ChildItem "$scriptroot/../data/killstats/" -File -Filter *.json + +$killstats_only_full_clan_matches = @() +$guids = $matchfiles.Name | ForEach-Object { $_.Split("_")[0] } +$groupedGuids_full_clan_matches = $guids | Group-Object | Where-Object { $_.Count -eq 4 } + $last_month = (get-date).AddMonths($monthsback) foreach ($file in $matchfiles) { $json = get-content $file | ConvertFrom-Json if ($json.created -gt $last_month) { $killstats += $json + if ($groupedGuids_full_clan_matches.Name -contains $json.matchid) { + $killstats_only_full_clan_matches += $json + } } else { write-output "Archiving $($file.name)" - Move-Item -Path $file.FullName -Destination "$scriptroot/../data/killstats/archive" -Force + Move-Item -Path $file.FullName -Destination "$scriptroot/../data/killstats/archive/" -Force } } - function Get-MatchStatsPlayer { param ( [switch] $GameMode, [switch] $MatchType, [string] $typemodevalue, [array] $playernames, - [string] $friendlyname + [string] $friendlyname, + [array] $killstats, + [string] $sortstat + ) $MatchStatsPlayer = @() foreach ($player in $playernames) { @@ -181,8 +191,8 @@ function Get-MatchStatsPlayer { if ($MatchType) { $filterProperty = 'matchType' } - $alives = (($killstats | where-object { $_.stats.playername -eq $player -and $_.stats.$filterProperty -like $typemodevalue }).deathType | where-object {$_ -eq 'alive'}).count - $deaths = (($killstats | where-object { $_.stats.playername -eq $player -and $_.stats.$filterProperty -like $typemodevalue }).deathType | where-object {$_ -ne 'alive'}).count + $alives = (($killstats | where-object { $_.stats.playername -eq $player -and $_.stats.$filterProperty -like $typemodevalue }).deathType | where-object { $_ -eq 'alive' }).count + $deaths = (($killstats | where-object { $_.stats.playername -eq $player -and $_.stats.$filterProperty -like $typemodevalue }).deathType | where-object { $_ -ne 'alive' }).count $kills = (($killstats.stats | where-object { $_.playername -eq $player -and $_.$filterProperty -like $typemodevalue }).kills | Measure-Object -sum).sum $dbno = (($killstats.stats | where-object { $_.playername -eq $player -and $_.$filterProperty -like $typemodevalue }).dbno | Measure-Object -sum).sum $humankills = (($killstats.stats | where-object { $_.playername -eq $player -and $_.$filterProperty -like $typemodevalue }).humankills | Measure-Object -sum).sum @@ -214,22 +224,24 @@ function Get-MatchStatsPlayer { change = $change } } - return $MatchStatsPlayer | ForEach-Object { - $_ | Add-Member -NotePropertyName RandomKey -NotePropertyValue (Get-Random) -PassThru - } | Sort-Object -Property RandomKey | Select-Object -Property * -ExcludeProperty RandomKey #randomize the order + $MatchStatsPlayer_sorted = $MatchStatsPlayer | ForEach-Object { + $_ | Add-Member -NotePropertyName RandomKey -NotePropertyValue (Get-Random) -PassThru + } | Sort-Object -Property $sortstat -Descending | Select-Object -Property * -ExcludeProperty RandomKey #randomize the order + return $MatchStatsPlayer_sorted } -$playerstats_event_ibr = Get-MatchStatsPlayer -GameMode -typemodevalue 'ibr' -playernames $all_player_matches.playername -friendlyname 'Intense' -$playerstats_airoyale = Get-MatchStatsPlayer -MatchType -typemodevalue 'airoyale' -playernames $all_player_matches.playername -friendlyname 'Casual' -$playerstats_official = Get-MatchStatsPlayer -MatchType -typemodevalue 'official' -playernames $all_player_matches.playername -friendlyname 'official' -$playerstats_custom = Get-MatchStatsPlayer -MatchType -typemodevalue 'custom' -playernames $all_player_matches.playername -friendlyname 'custom' -$playerstats_all = Get-MatchStatsPlayer -MatchType -typemodevalue '*' -playernames $all_player_matches.playername -friendlyname 'all' -$playerstats_ranked = Get-MatchStatsPlayer -MatchType -typemodevalue 'competitive' -playernames $all_player_matches.playername -friendlyname 'Ranked' +$playerstats_event_ibr = Get-MatchStatsPlayer -GameMode -typemodevalue 'ibr' -playernames $all_player_matches.playername -friendlyname 'Intense' -killstats $killstats -sortstat 'randomkey' +$playerstats_airoyale = Get-MatchStatsPlayer -MatchType -typemodevalue 'airoyale' -playernames $all_player_matches.playername -friendlyname 'Casual' -killstats $killstats -sortstat 'randomkey' +$playerstats_official = Get-MatchStatsPlayer -MatchType -typemodevalue 'official' -playernames $all_player_matches.playername -friendlyname 'official' -killstats $killstats -sortstat 'randomkey' +$playerstats_custom = Get-MatchStatsPlayer -MatchType -typemodevalue 'custom' -playernames $all_player_matches.playername -friendlyname 'custom' -killstats $killstats -sortstat 'randomkey' +$playerstats_all = Get-MatchStatsPlayer -MatchType -typemodevalue '*' -playernames $all_player_matches.playername -friendlyname 'all' -killstats $killstats -sortstat 'randomkey' +$playerstats_ranked = Get-MatchStatsPlayer -MatchType -typemodevalue 'competitive' -playernames $all_player_matches.playername -friendlyname 'Ranked' -killstats $killstats -sortstat 'randomkey' +$playerstats_airoyale_clan = Get-MatchStatsPlayer -MatchType -typemodevalue 'airoyale' -playernames $all_player_matches.playername -friendlyname 'Casual' -killstats $killstats_only_full_clan_matches -sortstat 'winratio' $playerstats_custom = $playerstats_custom | Sort-Object winratio -Descending @@ -244,13 +256,14 @@ $formattedString = "$currentDateTime - Time Zone: $currentTimezone" # Output the formatted string $playerstats = [PSCustomObject]@{ - all = $playerstats_all - Intense = $playerstats_event_ibr - Casual = $playerstats_airoyale - official = $playerstats_official - custom = $playerstats_custom - updated = $formattedString - Ranked = $playerstats_ranked + all = $playerstats_all + Intense = $playerstats_event_ibr + Casual = $playerstats_airoyale + official = $playerstats_official + custom = $playerstats_custom + updated = $formattedString + Ranked = $playerstats_ranked + clan_4_casual = $playerstats_airoyale_clan } write-output "Writing file" -- 2.49.1 From 6def52e449e95d5e0a584377da023b91926e668c Mon Sep 17 00:00:00 2001 From: Lanta Date: Thu, 18 Jul 2024 11:19:34 +0200 Subject: [PATCH 2/3] order --- update/matchparser.ps1 | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/update/matchparser.ps1 b/update/matchparser.ps1 index d41af56..c3caf62 100644 --- a/update/matchparser.ps1 +++ b/update/matchparser.ps1 @@ -257,13 +257,14 @@ $formattedString = "$currentDateTime - Time Zone: $currentTimezone" $playerstats = [PSCustomObject]@{ all = $playerstats_all + clan_4_casual = $playerstats_airoyale_clan Intense = $playerstats_event_ibr Casual = $playerstats_airoyale official = $playerstats_official custom = $playerstats_custom updated = $formattedString Ranked = $playerstats_ranked - clan_4_casual = $playerstats_airoyale_clan + } write-output "Writing file" -- 2.49.1 From 16265f138d62840d07c6a456d6cf4627274865d5 Mon Sep 17 00:00:00 2001 From: Lanta Date: Thu, 18 Jul 2024 11:25:50 +0200 Subject: [PATCH 3/3] new table (clan) and accumulate stats quarter --- last_stats.php | 2 +- update/matchparser.ps1 | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/last_stats.php b/last_stats.php index 066d455..b5d7389 100644 --- a/last_stats.php +++ b/last_stats.php @@ -15,7 +15,7 @@ $ogDescription = "Explore detailed player statistics over the past month includi
-

Player Stats past month

+

Player Stats past Quarter