Skip to content

Commit

Permalink
use Get-Team function
Browse files Browse the repository at this point in the history
  • Loading branch information
nephest committed Mar 6, 2024
1 parent 6461c91 commit 30e2ab2
Showing 1 changed file with 7 additions and 18 deletions.
25 changes: 7 additions & 18 deletions Reveal-Sc2Opponent.ps1
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@

<#PSScriptInfo
.VERSION 0.2.0
.VERSION 0.2.1
.GUID db8ffc68-4388-4119-b437-1f56c999611e
Expand Down Expand Up @@ -241,6 +241,7 @@ function Get-Game {
return $Game
}


function Get-Team {
param(
[int32] $Season,
Expand Down Expand Up @@ -318,27 +319,15 @@ function Get-UnmaskedPlayer {
Write-Progress -Activity $SearchActivity -Status "Failed" -Completed
return
}
$OpponentTeams = @()
Write-Progress `
-Activity $SearchActivity `
-Status "Pulling opponent teams" `
-PercentComplete 40
for(($i = 0); $i -lt $OpponentIds.Length;)
{
$EndIx = [Math]::Min($i + $Script:TeamBatchSize - 1, $OpponentIds.Length - 1);
$OpponendIdBatch = $OpponentIds[$i..$EndIx]
$OpponentTeamBatch = Invoke-EnhancedRestMethod -Uri ("${Sc2PulseApiRoot}/group/team" +
"?season=${Season}" +
"&queue=${Queue}" +
"&race=$($Races[$GameOpponent.Race])" +
"&characterId=$([String]::Join(',', $OpponendIdBatch))")
$OpponentTeams += $OpponentTeamBatch
$i += $Script:TeamBatchSize
Write-Progress `
-Activity "Opponent search" `
-Status "Pulling opponent teams" `
-PercentComplete (40 + (($EndIx / $OpponentIds.Length) * 60))
}
$OpponentTeams = Get-Team `
-Season $Season `
-Queue $Queue `
-Race $Script:Races[$GameOpponent.Race] `
-CharacterId $OpponentIds
$Now = [DateTimeOffset]::Now
foreach($Team in $OpponentTeams) {
$LastPlayedParsed = [DateTimeOffset]::Parse(
Expand Down

0 comments on commit 30e2ab2

Please sign in to comment.