Skip to content

Commit

Permalink
use new more precise duration calculation
Browse files Browse the repository at this point in the history
Use the new duration attribute from simpleArcParse, in order to extract
duration in milliseconds. Display the time with precision up to 2 decimal
places.

Stop storing the old server_end.json file, as we will rely only on the new
duration value. However, for formatting encounters, allow using the old
method if we haven't yet extracted the precise_duration.

Signed-off-by: Jacob Keller <[email protected]>
  • Loading branch information
jacob-keller committed Dec 13, 2018
1 parent fd3f5eb commit 2d4271c
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 19 deletions.
25 changes: 18 additions & 7 deletions l0g-101086.psm1
Original file line number Diff line number Diff line change
Expand Up @@ -1208,14 +1208,25 @@ Function Load-From-EVTC {
$boss["servertime"] = [int]$servertime
$boss["time"] = ConvertFrom-UnixDate $servertime

# Get the encounter duration (in difference of unix timestamps)
$duration_json = [io.path]::combine($extras_path, "duration.json")
if (X-Test-Path $duration_json) {
$duration = (Get-Content -Raw -Path $duration_json | ConvertFrom-Json)
$boss["duration"] = [int]$duration
$span = New-TimeSpan -Seconds $duration
$duration_string = "$([math]::floor($span.TotalMinutes))m $($span.Seconds.ToString("00"))s"
$precise_duration_json = [io.path]::combine($extras_path, "precise_duration.json")
if (X-Test-Path $precise_duration_json) {
$precise_duration = (Get-Content -Raw -Path $precise_duration_json | ConvertFrom-Json)
$boss["duration"] = [int]($precise_duration / 1000)
$span = [TimeSpan]::FromMilliseconds($precise_duration)
$minutes = New-TimeSpan -Minutes ([math]::floor($span.TotalMinutes))
$millis = $span - $minutes
$duration_string = "$($minutes.Minutes)m $(($millis.TotalMilliseconds / 1000).ToString("00.00"))s"
$boss["duration_string"] = $duration_string
} else {
# Get the encounter duration (in difference of unix timestamps)
$duration_json = [io.path]::combine($extras_path, "duration.json")
if (X-Test-Path $duration_json) {
$duration = (Get-Content -Raw -Path $duration_json | ConvertFrom-Json)
$boss["duration"] = [int]$duration
$span = New-TimeSpan -Seconds $duration
$duration_string = "$([math]::floor($span.TotalMinutes))m $($span.Seconds.ToString("00"))s"
$boss["duration_string"] = $duration_string
}
}

# Get the encounter name
Expand Down
16 changes: 4 additions & 12 deletions upload-logs.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -237,24 +237,16 @@ ForEach($f in $files) {

Log-Output "Outcome: ${evtc_success}"

# Extract the precise duration in milliseconds
$precise_duration = (& $simple_arc_parse duration "${evtc}")
$precise_duration | ConvertTo-Json | Out-File -FilePath (Join-Path $dir -ChildPath "precise_duration.json")

# Parse the evtc combat events to determine the server start time
$start_time = (& $simple_arc_parse start_time "${evtc}")
$start_time | ConvertTo-Json | Out-File -FilePath (Join-Path $dir -ChildPath "servertime.json")

Log-Output "Start Time: ${start_time}"

# Parse the evtc combat events to determine the server end time, then calculate a duration in seconds
$end_time = (& $simple_arc_parse end_time "${evtc}")
if ($end_time -le $start_time) {
Log-Output "End Time: ${end_time}"
Log-Output "The end time in the log file is less than the start time. Skipping duration calculation."
} else {
$duration = $end_time - $start_time
$duration | ConvertTo-Json | Out-File -FilePath (Join-Path $dir -ChildPath "duration.json")

Log-Output "Encounter duration: ${duration}"
}

# Parse the evtc to determine if the encounter was a challenge mote
$is_cm = (& $simple_arc_parse is_cm "${evtc}")
$is_cm | ConvertTo-Json | Out-File -FilePath (Join-Path $dir -ChildPath "is_cm.json")
Expand Down

0 comments on commit 2d4271c

Please sign in to comment.