s
This commit is contained in:
parent
c5ceabff1b
commit
146d98d182
1 changed files with 81 additions and 11 deletions
|
|
@ -5,11 +5,13 @@ if ($PSScriptRoot.length -eq 0) {
|
||||||
else {
|
else {
|
||||||
$scriptroot = $PSScriptRoot
|
$scriptroot = $PSScriptRoot
|
||||||
}
|
}
|
||||||
|
$matches = 5
|
||||||
function get-killstats {
|
function get-killstats {
|
||||||
param (
|
param (
|
||||||
$player_name,
|
$player_name,
|
||||||
$telemetry
|
$telemetry,
|
||||||
|
$matchType,
|
||||||
|
$gameMode
|
||||||
)
|
)
|
||||||
$attacks = @()
|
$attacks = @()
|
||||||
foreach ($action in $telemetry) {
|
foreach ($action in $telemetry) {
|
||||||
|
|
@ -25,17 +27,24 @@ function get-killstats {
|
||||||
humankills = ($kills | where-object { $_.victim.accountId -notlike 'ai.*' }).count
|
humankills = ($kills | where-object { $_.victim.accountId -notlike 'ai.*' }).count
|
||||||
kills = $kills.count
|
kills = $kills.count
|
||||||
deaths = ($attacks | where-object { $_.victim.name -eq $player_name }).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
|
$all_player_matches = get-content "$scriptroot/../data/player_matches.json" | convertfrom-json -Depth 100
|
||||||
$killstats = @()
|
$killstats = @()
|
||||||
|
$i = 0
|
||||||
|
|
||||||
foreach ($player in $all_player_matches) {
|
foreach ($player in $all_player_matches) {
|
||||||
$player_name = $player.playername
|
$player_name = $player.playername
|
||||||
|
$i++
|
||||||
foreach ($match in $player.player_matches) {
|
$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])"
|
$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)"
|
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) {
|
foreach ($player in $all_player_matches.playername) {
|
||||||
|
|
||||||
$deaths = (($killstats | where-object { $_.playername -eq $player }).deaths | Measure-Object -sum).sum
|
$deaths = (($killstats | where-object { $_.playername -eq $player }).deaths | Measure-Object -sum).sum
|
||||||
$kills = (($killstats | where-object { $_.playername -eq $player }).kills | 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
|
$humankills = (($killstats | where-object { $_.playername -eq $player }).humankills | Measure-Object -sum).sum
|
||||||
|
|
||||||
$playerstats += [PSCustomObject]@{
|
$playerstats_all += [PSCustomObject]@{
|
||||||
playername = $player
|
playername = $player
|
||||||
deaths = $deaths
|
deaths = $deaths
|
||||||
kills = $kills
|
kills = $kills
|
||||||
|
|
@ -74,6 +83,63 @@ foreach ($player in $all_player_matches.playername) {
|
||||||
KD_ALL = $kills / $deaths
|
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
|
$currentDateTime = Get-Date
|
||||||
|
|
||||||
|
|
@ -84,10 +150,14 @@ $currentTimezone = (Get-TimeZone).Id
|
||||||
$formattedString = "$currentDateTime - Time Zone: $currentTimezone"
|
$formattedString = "$currentDateTime - Time Zone: $currentTimezone"
|
||||||
|
|
||||||
# Output the formatted string
|
# Output the formatted string
|
||||||
$playerstats += [PSCustomObject]@{
|
|
||||||
updated = $formattedString
|
|
||||||
}
|
|
||||||
|
|
||||||
|
$playerstats = [PSCustomObject]@{
|
||||||
|
event_ibr = $playerstats_event_ibr
|
||||||
|
all = $playerstats_all
|
||||||
|
airoyale = $playerstats_airoyale
|
||||||
|
official = $playerstats_official
|
||||||
|
updated = $formattedString
|
||||||
|
}
|
||||||
|
|
||||||
write-output "Writing file"
|
write-output "Writing file"
|
||||||
($playerstats | convertto-json) | out-file "$scriptroot/../data/player_last_stats.json"
|
($playerstats | convertto-json) | out-file "$scriptroot/../data/player_last_stats.json"
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue