Skip to content

Commit e587a85

Browse files
author
babelshift
committed
Added wrapper for DOTA 2 GetHeroes method.
1 parent d8b96de commit e587a85

5 files changed

Lines changed: 56 additions & 0 deletions

File tree

SteamWebAPI2.Models/DOTA2/Hero.cs

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
using System;
2+
using System.Collections.Generic;
3+
using System.Linq;
4+
using System.Text;
5+
using System.Threading.Tasks;
6+
7+
namespace SteamWebAPI2.Models.DOTA2
8+
{
9+
public class Hero
10+
{
11+
public string Name { get; set; }
12+
public int Id { get; set; }
13+
}
14+
}
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
using System;
2+
using System.Collections.Generic;
3+
using System.Linq;
4+
using System.Text;
5+
using System.Threading.Tasks;
6+
7+
namespace SteamWebAPI2.Models.DOTA2
8+
{
9+
public class HeroResult
10+
{
11+
public IList<Hero> Heroes { get; set; }
12+
}
13+
}
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
using System;
2+
using System.Collections.Generic;
3+
using System.Linq;
4+
using System.Text;
5+
using System.Threading.Tasks;
6+
7+
namespace SteamWebAPI2.Models.DOTA2
8+
{
9+
public class HeroResultContainer
10+
{
11+
public HeroResult Result { get; set; }
12+
}
13+
}

SteamWebAPI2.Models/SteamWebAPI2.Models.csproj

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,9 @@
5959
<Compile Include="DOTA2\GameItem.cs" />
6060
<Compile Include="DOTA2\GameItemResult.cs" />
6161
<Compile Include="DOTA2\GameItemResultContainer.cs" />
62+
<Compile Include="DOTA2\Hero.cs" />
63+
<Compile Include="DOTA2\HeroResult.cs" />
64+
<Compile Include="DOTA2\HeroResultContainer.cs" />
6265
<Compile Include="DOTA2\League.cs" />
6366
<Compile Include="DOTA2\LeagueResult.cs" />
6467
<Compile Include="DOTA2\LeagueResultContainer.cs" />

SteamWebAPI2/DOTA2Econ.cs

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,5 +36,18 @@ public async Task<IReadOnlyCollection<GameItem>> GetGameItemsAsync(string langua
3636
var teamInfos = await CallMethodAsync<GameItemResultContainer>("GetGameItems", 1);
3737
return new ReadOnlyCollection<GameItem>(teamInfos.Result.Items);
3838
}
39+
40+
public async Task<IReadOnlyCollection<Hero>> GetHeroesAsync(string language = "", bool itemizedOnly = false)
41+
{
42+
List<SteamWebRequestParameter> parameters = new List<SteamWebRequestParameter>();
43+
44+
int itemizedOnlyValue = itemizedOnly ? 1 : 0;
45+
46+
AddToParametersIfHasValue("language", language, parameters);
47+
AddToParametersIfHasValue("itemizedonly", itemizedOnlyValue, parameters);
48+
49+
var teamInfos = await CallMethodAsync<HeroResultContainer>("GetHeroes", 1);
50+
return new ReadOnlyCollection<Hero>(teamInfos.Result.Heroes);
51+
}
3952
}
4053
}

0 commit comments

Comments
 (0)