-
Notifications
You must be signed in to change notification settings - Fork 0
/
AFK_KillsPerHourByShip.ps1
41 lines (37 loc) · 1.49 KB
/
AFK_KillsPerHourByShip.ps1
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
# This script parses each kill in the journal file by hour and by type, outputting a list of totals for each ship type in hourly intervals.
$folder = "$env:USERPROFILE/Saved Games/Frontier Developments/Elite Dangerous/"
$latestLog = Get-ChildItem -Path $folder -Filter "*.log" | Sort-Object LastWriteTime | Select-Object -Last 1
$logContent = Get-Content -Path $latestLog.FullName
$bountiesPerHour = @{}
foreach($line in $logContent) {
$json = ConvertFrom-Json -InputObject $line
if($json.event -eq "Bounty") {
$timeStamp = $json.timestamp
$time = Get-Date -Date $timeStamp -Format 'yyyy-MM-dd-HH'
if($json.Target -ne $null) {
$target = $json.Target
if($bountiesPerHour.ContainsKey($time)) {
if($bountiesPerHour[$time].ContainsKey($target)) {
$bountiesPerHour[$time][$target] += 1
} else {
$bountiesPerHour[$time][$target] = 1
}
} else {
$bountiesPerHour[$time] = @{$target = 1}
}
}
}
}
$outputTable = @()
foreach ($time in $bountiesPerHour.Keys) {
$total = ($bountiesPerHour[$time].Values | Measure-Object -Sum).Sum
$row = [ordered]@{
'Timestamp' = $time
'Total' = $total
}
foreach($target in $bountiesPerHour[$time].Keys) {
$row[$target] = $bountiesPerHour[$time][$target]
}
$outputTable += New-Object PSObject -Property $row
}
$outputTable | Sort-Object Timestamp | Out-String