-
Notifications
You must be signed in to change notification settings - Fork 0
/
Champion.psm1
48 lines (47 loc) · 1.38 KB
/
Champion.psm1
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
42
43
44
45
46
47
48
Function Get-Champions
{
[CmdletBinding()]
Param
(
[ValidateSet('br', 'eune', 'euw', 'kr', 'lan', 'las', 'na', 'oce', 'ru', 'tr')]
[string]$Region = 'na'
)
$champions = Invoke-RiotRestMethod -BaseUri "https://$Region.api.pvp.net/api/lol/$Region/v1.2/champion"
$championData = Get-StaticChampionData -Region $Region
Foreach($champion in $champions.champions)
{
$championName = $championData | Where-Object {$_.id -eq $champion.id} | Select-Object -ExpandProperty name
$champion | Add-Member -MemberType NoteProperty -Name 'Name' -Value $championName
$champion
}
}
Function Get-Champion
{
[CmdletBinding()]
Param
(
[Parameter(Mandatory=$true,
ParameterSetName='ID')]
[string[]]$ID,
[Parameter(Mandatory=$true,
ParameterSetName='Name')]
[string[]]$Name,
[ValidateSet('br', 'eune', 'euw', 'kr', 'lan', 'las', 'na', 'oce', 'ru', 'tr')]
[string]$Region = 'na'
)
$champions = Get-Champions
If($PSCmdlet.ParameterSetName -eq 'Name')
{
Foreach($championName in $Name)
{
$champions | Where-Object {$_.name -eq $championName}
}
}
ElseIf($PSCmdlet.ParameterSetName -eq 'ID')
{
Foreach($championID in $ID)
{
$champions | Where-Object {$_.id -eq $championID}
}
}
}