forked from Philipp15b/go-steamapi
/
match.go
101 lines (91 loc) · 3.29 KB
/
match.go
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
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
package dota
import (
"github.com/fasmat/go-steamapi"
"net/url"
"strconv"
)
type matchResultJson struct {
Result MatchResult
}
type MatchResult struct {
Players []Player
Season uint `json:"item_0,omitempty"`
RadiantWin bool `json:"radiant_win"`
Duration uint
MatchStart uint `json:"start_time"`
MatchId uint64 `json:"match_id"`
MatchSequenceNo uint `json:"match_seq_num"`
TowerStatusRadiant DotaTowerStatus `json:"tower_status_radiant"`
TowerStatusDire DotaTowerStatus `json:"tower_status_dire"`
BarracksStatusRadiant DotaBarracksStatus `json:"barracks_status_radiant"`
BarracksStatusDire DotaBarracksStatus `json:"barracks_status_dire"`
Cluster uint
FirstBloodTime int `json:"first_blood_time"`
LobbyType DotaLobbyType `json:"lobby_type"`
HumanPlayers uint `json:"human_players"`
LeagueId uint
PositiveVotes uint `json:"positive_votes"`
NegativeVotes uint `json:"negative_votes"`
GameMode DotaGameMode `json:"game_mode"`
PicksBans []PickBan `json:"picks_bans,omitempty"`
}
type Player struct {
AccountId uint32 `json:"account_id"`
PlayerSlot DotaPlayerSlot `json:"player_slot"`
HeroId uint `json:"hero_id"`
Item0 uint `json:"item_0"`
Item1 uint `json:"item_1"`
Item2 uint `json:"item_2"`
Item3 uint `json:"item_3"`
Item4 uint `json:"item_4"`
Item5 uint `json:"item_5"`
Kills uint
Deaths uint
Assists uint
LeaverStatus DotaLeaverStatus `json:"leaver_status"`
GoldRemaining uint `json:"gold"`
LastHits uint `json:"last_hits"`
Denies uint `json:"denies"`
GPM uint `json:"gold_per_min"`
XPM uint `json:"xp_per_min"`
GoldSpent uint `json:"gold_spent"`
HeroDamage uint `json:"hero_damage"`
TowerDamage uint `json:"tower_damage"`
HeroHealing uint `json:"hero_healing"`
Level uint
Abilities []Ability `json:"ability_upgrades"`
Units []Unit `json:"additional_units,omitempty"`
}
type Ability struct {
Id uint `json:"ability"`
TimeUpgraded int `json:"time"`
Level uint
}
type Unit struct {
Name string `json:"unitname"`
Item0 uint `json:"item_0"`
Item1 uint `json:"item_1"`
Item2 uint `json:"item_2"`
Item3 uint `json:"item_3"`
Item4 uint `json:"item_4"`
Item5 uint `json:"item_5"`
}
type PickBan struct {
IsPick bool `json:"is_pick"`
HeroId uint `json:"hero_id"`
Team DotaTeam
Order uint
}
// Fetches statistics of a specific Match.
func GetMatchDetails(matchid uint64, app int, apiKey string) (*MatchResult, error) {
getMatchDetails := steamapi.NewSteamMethod("IDOTA2Match_"+strconv.Itoa(app), "GetMatchDetails", 1)
vals := url.Values{}
vals.Add("key", apiKey)
vals.Add("match_id", strconv.FormatUint(matchid, 10))
var resp matchResultJson
err := getMatchDetails.Request(vals, &resp)
if err != nil {
return nil, err
}
return &resp.Result, nil
}