-
Notifications
You must be signed in to change notification settings - Fork 8
/
match.go
340 lines (318 loc) · 15.8 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
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
package opendota
import (
"net/http"
"strconv"
"github.com/dghubble/sling"
)
func newMatchService(sling *sling.Sling) *MatchService {
return &MatchService{
sling: sling.Path("matches/"),
}
}
// MatchService provides a method for accessing information about matches.
type MatchService struct {
sling *sling.Sling
}
// Match represents the data about a match.
type Match struct {
MatchID int64 `json:"match_id"`
BarracksStatusDire int `json:"barracks_status_dire"`
BarracksStatusRadiant int `json:"barracks_status_radiant"`
Chat []Chat `json:"chat"`
Cluster int `json:"cluster"`
Cosmetics map[string]int `json:"cosmetics"`
DireScore int `json:"dire_score"`
Duration int `json:"duration"`
Engine int `json:"engine"`
FirstBloodTime int `json:"first_blood_time"`
GameMode int `json:"game_mode"`
HumanPlayers int `json:"human_players"`
LeagueID int `json:"leagueid"`
LobbyType int `json:"lobby_type"`
MatchSeqNum int64 `json:"match_seq_num"`
NegativeVotes int `json:"negative_votes"`
Objectives []Objective `json:"objectives"`
PicksBans []PickBans `json:"picks_bans"`
PositiveVotes int `json:"positive_votes"`
RadiantGoldAdv []int `json:"radiant_gold_adv"`
RadiantScore int `json:"radiant_score"`
RadiantWin bool `json:"radiant_win"`
RadiantXpAdv []int `json:"radiant_xp_adv"`
Skill int `json:"skill"`
StartTime int `json:"start_time"`
Teamfights []Teamfights `json:"teamfights"`
TowerStatusDire int `json:"tower_status_dire"`
TowerStatusRadiant int `json:"tower_status_radiant"`
Version int `json:"version"`
ReplaySalt int `json:"replay_salt"`
SeriesID int `json:"series_id"`
SeriesType int `json:"series_type"`
League MatchLeague `json:"league"`
RadiantTeam MatchTeam `json:"radiant_team"`
DireTeam MatchTeam `json:"dire_team"`
Players []MatchPlayer `json:"players"`
Patch int `json:"patch"`
Region int `json:"region"`
AllWordCounts map[string]int `json:"all_word_counts"`
MyWordCounts map[string]int `json:"my_word_counts"`
Throw int `json:"throw"`
Loss int `json:"loss"`
ReplayURL string `json:"replay_url"`
}
type Benchmarks struct {
GoldPerMin RawPCT `json:"gold_per_min"`
XpPerMin RawPCT `json:"xp_per_min"`
KillsPerMin RawPCT `json:"kills_per_min"`
LastHitsPerMin RawPCT `json:"last_hits_per_min"`
HeroDamagePerMin RawPCT `json:"hero_damage_per_min"`
HeroHealingPerMin RawPCT `json:"hero_healing_per_min"`
TowerDamage RawPCT `json:"tower_damage"`
}
type BuybackLog struct {
Time int `json:"time"`
Slot int `json:"slot"`
Type string `json:"type"`
PlayerSlot int `json:"player_slot"`
}
type Chat struct {
Time int `json:"time"`
Type string `json:"type"`
Unit string `json:"unit,omitempty"`
Key string `json:"key"`
Slot int `json:"slot"`
PlayerSlot int `json:"player_slot"`
}
type Cosmetics struct {
ItemID int `json:"item_id"`
Name string `json:"name"`
Prefab string `json:"prefab"`
CreationDate string `json:"creation_date"`
ImageInventory string `json:"image_inventory"`
ImagePath string `json:"image_path"`
ItemDescription string `json:"item_description"`
ItemName string `json:"item_name"`
ItemRarity string `json:"item_rarity"`
ItemTypeName string `json:"item_type_name"`
UsedByHeroes string `json:"used_by_heroes"`
}
type MatchLeague struct {
LeagueID int `json:"leagueid"`
Ticket string `json:"ticket"`
Banner string `json:"banner"`
Tier string `json:"tier"`
Name string `json:"name"`
}
type Log struct {
Time int `json:"time"`
Key string `json:"key"`
}
type MatchPlayer struct {
MatchID int64 `json:"match_id"`
PlayerSlot int `json:"player_slot"`
AbilityUpgradesArr []int `json:"ability_upgrades_arr"`
AbilityUses map[string]int `json:"ability_uses"`
AccountID int `json:"account_id"`
Actions map[string]int `json:"actions"`
Assists int `json:"assists"`
Backpack0 int `json:"backpack_0"`
Backpack1 int `json:"backpack_1"`
Backpack2 int `json:"backpack_2"`
BuybackLog []BuybackLog `json:"buyback_log"`
CampsStacked int `json:"camps_stacked"`
CreepsStacked int `json:"creeps_stacked"`
Damage map[string]int `json:"damage"`
DamageInflictor map[string]int `json:"damage_inflictor"`
DamageInflictorReceived map[string]int `json:"damage_inflictor_received"`
DamageTaken map[string]int `json:"damage_taken"`
Deaths int `json:"deaths"`
Denies int `json:"denies"`
DnT []int `json:"dn_t"`
FirstbloodClaimed int `json:"firstblood_claimed"`
Gold int `json:"gold"`
GoldPerMin int `json:"gold_per_min"`
GoldReasons map[string]int `json:"gold_reasons"`
GoldSpent int `json:"gold_spent"`
GoldT []int `json:"gold_t"`
HeroDamage int `json:"hero_damage"`
HeroHealing int `json:"hero_healing"`
HeroHits map[string]int `json:"hero_hits"`
HeroID int `json:"hero_id"`
Item0 int `json:"item_0"`
Item1 int `json:"item_1"`
Item2 int `json:"item_2"`
Item3 int `json:"item_3"`
Item4 int `json:"item_4"`
Item5 int `json:"item_5"`
ItemUses map[string]int `json:"item_uses"`
KillStreaks map[string]int `json:"kill_streaks"`
Killed map[string]int `json:"killed"`
KilledBy map[string]int `json:"killed_by"`
Kills int `json:"kills"`
KillsLog []Log `json:"kills_log"`
LanePos map[string]map[string]int `json:"lane_pos"`
LastHits int `json:"last_hits"`
LeaverStatus int `json:"leaver_status"`
Level int `json:"level"`
LhT []int `json:"lh_t"`
LifeState map[string]int `json:"life_state"`
MaxHeroHit MaxHeroHit `json:"max_hero_hit"`
MultiKills map[string]int `json:"multi_kills"`
Obs map[string]map[string]int `json:"obs"`
ObsLeftLog []ObsLog `json:"obs_left_log"`
ObsLog []ObsLog `json:"obs_log"`
ObsPlaced int `json:"obs_placed"`
PartyID int `json:"party_id"`
PartySize int `json:"party_size"`
Pings int `json:"pings"`
PredVict bool `json:"pred_vict"`
Purchase map[string]int `json:"purchase"`
PurchaseLog []Log `json:"purchase_log"`
Randomed bool `json:"randomed"`
RoshansKilled int `json:"roshans_killed"`
RunePickups int `json:"rune_pickups"`
Runes map[string]int `json:"runes"`
RunesLog []RunesLog `json:"runes_log"`
Sen map[string]map[string]int `json:"sen"`
SenLeftLog []ObsLog `json:"sen_left_log"`
SenLog []ObsLog `json:"sen_log"`
SenPlaced int `json:"sen_placed"`
Stuns float64 `json:"stuns"`
TeamfightParticipation float64 `json:"teamfight_participation"`
Times []int `json:"times"`
TowerDamage int `json:"tower_damage"`
TowersKilled int `json:"towers_killed"`
XpPerMin int `json:"xp_per_min"`
XpReasons map[string]int `json:"xp_reasons"`
XpT []int `json:"xp_t"`
Personaname string `json:"personaname"`
Name string `json:"name"`
LastLogin string `json:"last_login"`
RadiantWin bool `json:"radiant_win"`
StartTime int `json:"start_time"`
Duration int `json:"duration"`
Cluster int `json:"cluster"`
LobbyType int `json:"lobby_type"`
GameMode int `json:"game_mode"`
Patch int `json:"patch"`
Region int `json:"region"`
IsRadiant bool `json:"isRadiant"`
Win int `json:"win"`
Lose int `json:"lose"`
TotalGold int `json:"total_gold"`
TotalXp int `json:"total_xp"`
KillsPerMin float64 `json:"kills_per_min"`
Kda int `json:"kda"`
Abandons int `json:"abandons"`
NeutralKills int `json:"neutral_kills"`
TowerKills int `json:"tower_kills"`
CourierKills int `json:"courier_kills"`
LaneKills int `json:"lane_kills"`
HeroKills int `json:"hero_kills"`
ObserverKills int `json:"observer_kills"`
SentryKills int `json:"sentry_kills"`
RoshanKills int `json:"roshan_kills"`
NecronomiconKills int `json:"necronomicon_kills"`
AncientKills int `json:"ancient_kills"`
BuybackCount int `json:"buyback_count"`
ObserverUses int `json:"observer_uses"`
SentryUses int `json:"sentry_uses"`
LaneEfficiency float64 `json:"lane_efficiency"`
LaneEfficiencyPct int `json:"lane_efficiency_pct"`
Lane int `json:"lane"`
LaneRole int `json:"lane_role"`
IsRoaming bool `json:"is_roaming"`
PurchaseTime map[string]int `json:"purchase_time"`
FirstPurchaseTime map[string]int `json:"first_purchase_time"`
ItemWin map[string]int `json:"item_win"`
ItemUsage map[string]int `json:"item_usage"`
PurchaseTpscroll int `json:"purchase_tpscroll"`
ActionsPerMin int `json:"actions_per_min"`
LifeStateDead int `json:"life_state_dead"`
SoloCompetitiveRank int `json:"solo_competitive_rank"`
Cosmetics []Cosmetics `json:"cosmetics"`
Benchmarks Benchmarks `json:"benchmarks"`
PurchaseWardObserver int `json:"purchase_ward_observer,omitempty"`
PurchaseWardSentry int `json:"purchase_ward_sentry,omitempty"`
PurchaseGem int `json:"purchase_gem,omitempty"`
}
type MatchTeam struct {
TeamID int `json:"team_id"`
Name string `json:"name"`
Tag string `json:"tag"`
LogoURL string `json:"logo_url"`
}
type MaxHeroHit struct {
Type string `json:"type"`
Time int `json:"time"`
Max bool `json:"max"`
Inflictor string `json:"inflictor"`
Unit string `json:"unit"`
Key string `json:"key"`
Value int `json:"value"`
Slot int `json:"slot"`
PlayerSlot int `json:"player_slot"`
}
type Objective struct {
Time int `json:"time"`
Type string `json:"type"`
Team int `json:"team,omitempty"`
Slot int `json:"slot,omitempty"`
PlayerSlot int `json:"player_slot,omitempty"`
Unit string `json:"unit,omitempty"`
}
type ObsLog struct {
Time int `json:"time"`
Type string `json:"type"`
Key string `json:"key"`
Slot int `json:"slot"`
X int `json:"x"`
Y int `json:"y"`
Z int `json:"z"`
Entityleft bool `json:"entityleft"`
Ehandle int `json:"ehandle"`
PlayerSlot int `json:"player_slot"`
}
type PickBans struct {
IsPick bool `json:"is_pick"`
HeroID int `json:"hero_id"`
Team int `json:"team"`
Order int `json:"order"`
Ord int `json:"ord"`
MatchID int64 `json:"match_id"`
}
type RawPCT struct {
Raw float64 `json:"raw"`
Pct float64 `json:"pct"`
}
type RunesLog struct {
Time int `json:"time"`
Key int `json:"key"`
}
type TeamfightPlayers struct {
AbilityUses map[string]int `json:"ability_uses"`
ItemUses map[string]int `json:"item_uses"`
Killed map[string]int `json:"killed"`
Deaths int `json:"deaths"`
Buybacks int `json:"buybacks"`
Damage int `json:"damage"`
Healing int `json:"healing"`
GoldDelta int `json:"gold_delta"`
XpDelta int `json:"xp_delta"`
XpStart int `json:"xp_start"`
XpEnd int `json:"xp_end"`
}
type Teamfights struct {
Start int `json:"start"`
End int `json:"end"`
LastDeath int `json:"last_death"`
Deaths int `json:"deaths"`
Players []TeamfightPlayers `json:"players"`
}
// Match takes a Match ID and returns a collection about match.
// https://docs.opendota.com/#tag/matches
func (s *MatchService) Match(matchID int64) (Match, *http.Response, error) {
match := new(Match)
apiError := new(APIError)
resp, err := s.sling.New().Get(strconv.Itoa(int(matchID))).Receive(match, apiError)
return *match, resp, relevantError(err, *apiError)
}