Skip to content

Commit ad8618c

Browse files
author
babelshift
committed
Added wrappers for DOTA 2 GetMatchDetails method.
1 parent e336f43 commit ad8618c

8 files changed

Lines changed: 190 additions & 0 deletions

File tree

Lines changed: 69 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,69 @@
1+
using Newtonsoft.Json;
2+
using System;
3+
using System.Collections.Generic;
4+
using System.Linq;
5+
using System.Text;
6+
using System.Threading.Tasks;
7+
8+
namespace SteamWebAPI2.Models.DOTA2
9+
{
10+
public class MatchDetailResult
11+
{
12+
public IList<MatchPlayer> Players { get; set; }
13+
[JsonProperty(PropertyName = "radiant_win")]
14+
public bool RadiantWin { get; set; }
15+
public int Duration { get; set; }
16+
[JsonProperty(PropertyName = "start_time")]
17+
public int StartTime { get; set; }
18+
[JsonProperty(PropertyName = "match_id")]
19+
public int MatchId { get; set; }
20+
[JsonProperty(PropertyName = "match_seq_num")]
21+
public int MatchSequenceNumber { get; set; }
22+
[JsonProperty(PropertyName = "tower_status_radiant")]
23+
public int TowerStatusRadiant { get; set; }
24+
[JsonProperty(PropertyName = "tower_status_dire")]
25+
public int TowerStatusDire { get; set; }
26+
[JsonProperty(PropertyName = "barracks_status_radiant")]
27+
public int BarracksStatusRadiant { get; set; }
28+
[JsonProperty(PropertyName = "barracks_status_dire")]
29+
public int BarracksStatusDire { get; set; }
30+
public int Cluster { get; set; }
31+
[JsonProperty(PropertyName = "first_blood_time")]
32+
public int FirstBloodTime { get; set; }
33+
[JsonProperty(PropertyName = "lobby_type")]
34+
public int LobbyType { get; set; }
35+
[JsonProperty(PropertyName = "human_players")]
36+
public int HumanPlayers { get; set; }
37+
[JsonProperty(PropertyName = "league_id")]
38+
public int LeagueId { get; set; }
39+
[JsonProperty(PropertyName = "positive_votes")]
40+
public int PositiveVotes { get; set; }
41+
[JsonProperty(PropertyName = "negative_votes")]
42+
public int NegativeVotes { get; set; }
43+
[JsonProperty(PropertyName = "game_mode")]
44+
public int GameMode { get; set; }
45+
public int Engine { get; set; }
46+
[JsonProperty(PropertyName = "radiant_team_id")]
47+
public int RadiantTeamId { get; set; }
48+
[JsonProperty(PropertyName = "radiant_name")]
49+
public string RadiantName { get; set; }
50+
[JsonProperty(PropertyName = "radiant_logo")]
51+
public long RadiantLogo { get; set; }
52+
[JsonProperty(PropertyName = "radiant_team_complete")]
53+
public int RadiantTeamComplete { get; set; }
54+
[JsonProperty(PropertyName = "dire_team_id")]
55+
public int DireTeamId { get; set; }
56+
[JsonProperty(PropertyName = "dire_name")]
57+
public string DireName { get; set; }
58+
[JsonProperty(PropertyName = "dire_logo")]
59+
public long DireLogo { get; set; }
60+
[JsonProperty(PropertyName = "dire_team_complete")]
61+
public int DireTeamComplete { get; set; }
62+
[JsonProperty(PropertyName = "radiant_captain")]
63+
public int RadiantCaptain { get; set; }
64+
[JsonProperty(PropertyName = "dire_captain")]
65+
public int DireCaptain { get; set; }
66+
[JsonProperty(PropertyName = "picks_bans")]
67+
public IList<MatchPickBan> PicksAndBans { get; set; }
68+
}
69+
}
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 MatchDetailResultContainer
10+
{
11+
public MatchDetailResult Result { get; set; }
12+
}
13+
}
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
using Newtonsoft.Json;
2+
using System;
3+
using System.Collections.Generic;
4+
using System.Linq;
5+
using System.Text;
6+
using System.Threading.Tasks;
7+
8+
namespace SteamWebAPI2.Models.DOTA2
9+
{
10+
public class MatchPickBan
11+
{
12+
[JsonProperty(PropertyName = "is_pick")]
13+
public bool IsPick { get; set; }
14+
[JsonProperty(PropertyName = "hero_id")]
15+
public int HeroId { get; set; }
16+
public int Team { get; set; }
17+
public int Order { get; set; }
18+
}
19+
}
Lines changed: 55 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,55 @@
1+
using Newtonsoft.Json;
2+
using System;
3+
using System.Collections.Generic;
4+
using System.Linq;
5+
using System.Text;
6+
using System.Threading.Tasks;
7+
8+
namespace SteamWebAPI2.Models.DOTA2
9+
{
10+
public class MatchPlayer
11+
{
12+
[JsonProperty(PropertyName = "account_id")]
13+
public int AccountId { get; set; }
14+
[JsonProperty(PropertyName = "player_slot")]
15+
public int PlayerSlot { get; set; }
16+
[JsonProperty(PropertyName = "hero_id")]
17+
public int HeroId { get; set; }
18+
[JsonProperty(PropertyName = "item_0")]
19+
public int Item0 { get; set; }
20+
[JsonProperty(PropertyName = "item_1")]
21+
public int Item1 { get; set; }
22+
[JsonProperty(PropertyName = "item_2")]
23+
public int Item2 { get; set; }
24+
[JsonProperty(PropertyName = "item_3")]
25+
public int Item3 { get; set; }
26+
[JsonProperty(PropertyName = "item_4")]
27+
public int Item4 { get; set; }
28+
[JsonProperty(PropertyName = "item_5")]
29+
public int Item5 { get; set; }
30+
public int Kills { get; set; }
31+
public int Deaths { get; set; }
32+
public int Assists { get; set; }
33+
[JsonProperty(PropertyName = "leaver_status")]
34+
public int LeaverStatus { get; set; }
35+
public int Gold { get; set; }
36+
[JsonProperty(PropertyName = "last_hits")]
37+
public int LastHits { get; set; }
38+
public int Denies { get; set; }
39+
[JsonProperty(PropertyName = "gold_per_min")]
40+
public int GoldPerMinute { get; set; }
41+
[JsonProperty(PropertyName = "xp_per_min")]
42+
public int ExperiencePerMinute { get; set; }
43+
[JsonProperty(PropertyName = "gold_spent")]
44+
public int GoldSpent { get; set; }
45+
[JsonProperty(PropertyName = "hero_damage")]
46+
public int HeroDamage { get; set; }
47+
[JsonProperty(PropertyName = "tower_damage")]
48+
public int TowerDamage { get; set; }
49+
[JsonProperty(PropertyName = "hero_healing")]
50+
public int HeroHealing { get; set; }
51+
public int Level { get; set; }
52+
[JsonProperty(PropertyName = "ability_upgrades")]
53+
public IList<MatchPlayerAbilityUpgrade> AbilityUpgrades { get; set; }
54+
}
55+
}
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
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 MatchPlayerAbilityUpgrade
10+
{
11+
public int Ability { get; set; }
12+
public int Time { get; set; }
13+
public int Level { get; set; }
14+
}
15+
}

SteamWebAPI2.Models/SteamWebAPI2.Models.csproj

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -72,6 +72,11 @@
7272
<Compile Include="DOTA2\LiveLeagueGameTeamDireInfo.cs" />
7373
<Compile Include="DOTA2\LiveLeagueGameTeamRadiantDetail.cs" />
7474
<Compile Include="DOTA2\LiveLeagueGameTeamRadiantInfo.cs" />
75+
<Compile Include="DOTA2\MatchPlayerAbilityUpgrade.cs" />
76+
<Compile Include="DOTA2\MatchDetailResult.cs" />
77+
<Compile Include="DOTA2\MatchDetailResultContainer.cs" />
78+
<Compile Include="DOTA2\MatchPickBan.cs" />
79+
<Compile Include="DOTA2\MatchPlayer.cs" />
7580
<Compile Include="DOTA2\ProPlayerListResult.cs" />
7681
<Compile Include="DOTA2\ProPlayerListResultContainer.cs" />
7782
<Compile Include="DOTA2\PlayerOfficialInfoResult.cs" />

SteamWebAPI2/DOTA2Match.cs

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,5 +22,13 @@ public async Task<IReadOnlyCollection<LiveLeagueGame>> GetLiveLeagueGames()
2222
var liveLeagueGames = await GetJsonAsync<LiveLeagueGameResultContainer>(interfaceName, "GetLiveLeagueGames", 1);
2323
return new ReadOnlyCollection<LiveLeagueGame>(liveLeagueGames.Result.Games);
2424
}
25+
26+
public async Task<MatchDetailResult> GetMatchDetails(int matchId)
27+
{
28+
List<SteamWebRequestParameter> parameters = new List<SteamWebRequestParameter>();
29+
parameters.Add(new SteamWebRequestParameter("match_id", matchId.ToString()));
30+
var matchDetail = await GetJsonAsync<MatchDetailResultContainer>(interfaceName, "GetMatchDetails", 1, parameters);
31+
return matchDetail.Result;
32+
}
2533
}
2634
}

SteamWebAPI2/SteamWebSession.cs

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -68,5 +68,11 @@ public async Task<IReadOnlyCollection<LiveLeagueGame>> GetDOTA2LiveLeagueGames()
6868
DOTA2Match dota2Match = new DOTA2Match(steamWebApiKey);
6969
return await dota2Match.GetLiveLeagueGames();
7070
}
71+
72+
public async Task<MatchDetailResult> GetDOTA2MatchDetails(int matchId)
73+
{
74+
DOTA2Match dota2Match = new DOTA2Match(steamWebApiKey);
75+
return await dota2Match.GetMatchDetails(matchId);
76+
}
7177
}
7278
}

0 commit comments

Comments
 (0)