-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathmatches.go
288 lines (272 loc) · 10.2 KB
/
matches.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
package smitego
import (
"encoding/json"
"io/ioutil"
"net/http"
)
// These constants represent the various Queue IDs in the game.
const (
Conquest5v5 = "423"
NoviceQueue = "424"
Conquest = "426"
Practice = "427"
ConquestChallenge = "429"
ConquestRanked = "430"
Domination = "433"
MatchOfTheDay = "434"
Arena = "435"
ArenaChallenge = "438"
DominationChallenge = "439"
JoustLeague = "440"
JoustChallenge = "441"
ConquestTeamRanked = "442"
Assault = "445"
AssaultChallenge = "446"
Joust3v3 = "448"
ConquestLeague = "451"
ArenaLeague = "452"
)
// MatchHistory is a struct that represents a player's match history information.
type MatchHistory struct {
Activeid1 int `json:"ActiveId1"`
Activeid2 int `json:"ActiveId2"`
Active1 string `json:"Active_1"`
Active2 string `json:"Active_2"`
Active3 string `json:"Active_3"`
Assists int `json:"Assists"`
Ban1 int `json:"Ban1"`
Ban1ID int `json:"Ban1Id"`
Ban2 int `json:"Ban2"`
Ban2ID int `json:"Ban2Id"`
Ban3 int `json:"Ban3"`
Ban3ID int `json:"Ban3Id"`
Ban4 int `json:"Ban4"`
Ban4ID int `json:"Ban4Id"`
Ban5 int `json:"Ban5"`
Ban5ID int `json:"Ban5Id"`
Ban6 int `json:"Ban6"`
Ban6ID int `json:"Ban6Id"`
Creeps int `json:"Creeps"`
Damage int `json:"Damage"`
DamageBot int `json:"Damage_Bot"`
DamageMitigated int `json:"Datamage_Mitigated"`
DamageStructure int `json:"Damage_Structure"`
DamageTaken int `json:"Damage_Taken"`
Deaths int `json:"Deaths"`
God string `json:"God"`
GodID int `json:"GodId"`
Gold int `json:"Gold"`
Healing int `json:"Healing"`
Itemid1 int `json:"Itemid1"`
Itemid2 int `json:"Itemid2"`
Itemid3 int `json:"Itemid3"`
Itemid4 int `json:"Itemid4"`
Itemid5 int `json:"Itemid5"`
Itemid6 int `json:"Itemid6"`
KillingSpree int `json:"Killing_Spree"`
Kills int `json:"Kills"`
Level int `json:"Level"`
Match int `json:"Match"`
MatchTime string `json:"Match_Time"`
Minutes int `json:"Minutes"`
MultiKillMax int `json:"Multi_kill_max"`
Queue string `json:"Queue"`
Skin string `json:"Skin"`
Skinid int `json:"SkinId"`
Surrendered string `json:"Surrendered"`
Team1score int `json:"Team1Score"`
Team2score int `json:"Team2Score"`
WinStatus string `json:"Win_Status"`
Playername string `json:"playerName"`
ReturnMessage string `json:"ret_msg"`
}
// MatchPlayer is a struct that represents a player that participated in a Smite
// match.
type MatchPlayer struct {
AccountLevel int `json:"Account_Level"`
Activeid1 int `json:"ActiveId1"`
Activeid2 int `json:"ActiveId2"`
Assists int `json:"Assists"`
Ban1 string `json:"Ban1"`
Ban1id int `json:"Ban1Id"`
Ban2 string `json:"Ban2"`
Ban2id int `json:"Ban2Id"`
Ban3 string `json:"Ban3"`
Ban3id int `json:"Ban3Id"`
Ban4 string `json:"Ban4"`
Ban4id int `json:"Ban4Id"`
DamageBot int `json:"Damage_Bot"`
DamageDoneMagical int `json:"Damage_Done_Magical"`
DamageDonePhysical int `json:"Damage_Done_Physical"`
DamagePlayer int `json:"Damage_Player"`
DamageTaken int `json:"Damage_Taken"`
Deaths int `json:"Deaths"`
EntryDatetime string `json:"Entry_Datetime"`
FinalMatchLevel int `json:"Final_Match_Level"`
Godid int `json:"GodId"`
GoldEarned int `json:"Gold_Earned"`
GoldPerMinute int `json:"Gold_Per_Minute"`
Healing int `json:"Healing"`
Itemid1 int `json:"ItemId1"`
Itemid2 int `json:"ItemId2"`
Itemid3 int `json:"ItemId3"`
Itemid4 int `json:"ItemId4"`
Itemid5 int `json:"ItemId5"`
Itemid6 int `json:"ItemId6"`
ItemActive1 string `json:"Item_Active_1"`
ItemActive2 string `json:"Item_Active_2"`
ItemActive3 string `json:"Item_Active_3"`
ItemPurch1 string `json:"Item_Purch_1"`
ItemPurch2 string `json:"Item_Purch_2"`
ItemPurch3 string `json:"Item_Purch_3"`
ItemPurch4 string `json:"Item_Purch_4"`
ItemPurch5 string `json:"Item_Purch_5"`
ItemPurch6 string `json:"Item_Purch_6"`
KillingSpree int `json:"Killing_Spree"`
KillsBot int `json:"Kills_Bot"`
KillsPlayer int `json:"Kills_Player"`
MasteryLevel int `json:"Mastery_Level"`
Match int `json:"Match"`
Minutes int `json:"Minutes"`
MultiKillMax int `json:"Multi_kill_Max"`
Partyid int `json:"PartyId"`
ReferenceName string `json:"Reference_Name"`
Skin string `json:"Skin"`
Skinid int `json:"SkinId"`
StructureDamage int `json:"Structure_Damage"`
Surrendered string `json:"Surrendered"`
Team1score int `json:"Team1Score"`
Team2score int `json:"Team2Score"`
Teamid int `json:"TeamId"`
TeamName string `json:"Team_Name"`
WinStatus string `json:"Win_Status"`
Name string `json:"name"`
Playername string `json:"playerName"`
RetMsg string `json:"ret_msg"`
}
// ModeDetail is a struct that represents the mode information of a given match.
type ModeDetail struct {
Ban1 string `json:"Ban1"`
Ban2 string `json:"Ban2"`
EntryDatetime string `json:"Entry_Datetime"`
Match int `json:"Match"`
MatchTime int `json:"Match_Time"`
OfflineSpectators int `json:"Offline_Spectators"`
RealtimeSpectators int `json:"Realtime_Spectators"`
RecordingEnded string `json:"Recording_Ended"`
RecordingStarted string `json:"Recording_Started"`
Team1Avglevel int `json:"Team1_AvgLevel"`
Team1Gold int `json:"Team1_Gold"`
Team1Kills int `json:"Team1_Kills"`
Team1Score int `json:"Team1_Score"`
Team2Avglevel int `json:"Team2_AvgLevel"`
Team2Gold int `json:"Team2_Gold"`
Team2Kills int `json:"Team2_Kills"`
Team2Score int `json:"Team2_Score"`
WinningTeam int `json:"Winning_Team"`
ReturnMessage string `json:"ret_msg"`
}
// GetModeDetails returns a ModeDetail instance loaded with mode information
// for a specific match ID.
func GetModeDetails(matchID string) ModeDetail {
hash := getMD5Hash(DevID + "getdemodetails" + AuthKey + getTimestamp())
url := "http://api.smitegame.com/smiteapi.svc/getdemodetailsJson/" + DevID + "/" + hash + "/" + SessionID + "/" + getTimestamp() + "/" + matchID
response, err := http.Get(url)
if err != nil {
perror(err)
} else {
defer response.Body.Close()
contents, err := ioutil.ReadAll(response.Body)
if err != nil {
perror(err)
} else {
var modeDetail []ModeDetail
json.Unmarshal(contents, &modeDetail)
return modeDetail[0]
}
}
modeDetail := ModeDetail{ReturnMessage: "Not found"}
return modeDetail
}
// GetMatchHistory returns a MatchHistory array instance loaded with each
// match information for a player.
func GetMatchHistory(playerName string) []MatchHistory {
hash := getMD5Hash(DevID + "getmatchhistory" + AuthKey + getTimestamp())
url := "http://api.smitegame.com/smiteapi.svc/getmatchhistoryJson/" + DevID + "/" + hash + "/" + SessionID + "/" + getTimestamp() + "/" + playerName
response, err := http.Get(url)
if err != nil {
perror(err)
} else {
defer response.Body.Close()
contents, err := ioutil.ReadAll(response.Body)
if err != nil {
perror(err)
} else {
var matchHistory []MatchHistory
json.Unmarshal(contents, &matchHistory)
return matchHistory
}
}
matchHistory := []MatchHistory{}
return matchHistory
}
// GetMatchDetails returns a MatchPlayer array instance loaded with each
// player's information for the match.
func GetMatchDetails(matchID string) []MatchPlayer {
hash := getMD5Hash(DevID + "getmatchdetails" + AuthKey + getTimestamp())
url := "http://api.smitegame.com/smiteapi.svc/getmatchdetailsJson/" + DevID + "/" + hash + "/" + SessionID + "/" + getTimestamp() + "/" + matchID
response, err := http.Get(url)
if err != nil {
perror(err)
} else {
defer response.Body.Close()
contents, err := ioutil.ReadAll(response.Body)
if err != nil {
perror(err)
} else {
var matchDetail []MatchPlayer
json.Unmarshal(contents, &matchDetail)
return matchDetail
}
}
matchDetail := []MatchPlayer{}
return matchDetail
}
// GetMatchIDsByQueue returns a JSON string of match IDs for a given queue on
// a given date. Currently this API endpoint is not working well on HiRez's end.
func GetMatchIDsByQueue(queue string, date string) string {
hash := getMD5Hash(DevID + "getmatchidsbyqueue" + AuthKey + getTimestamp())
url := "http://api.smitegame.com/smiteapi.svc/getmatchidsbyqueueJson/" + DevID + "/" + hash + "/" + SessionID + "/" + getTimestamp() + "/" + queue + "/" + date
response, err := http.Get(url)
if err != nil {
perror(err)
} else {
defer response.Body.Close()
contents, err := ioutil.ReadAll(response.Body)
if err != nil {
perror(err)
} else {
return string(contents)
}
}
return ""
}
// GetLeagueSeasons returns a JSON string of league seasons for a given queue.
// Currently this API endpoint is not working well on HiRez's end.
func GetLeagueSeasons(queue string) string {
hash := getMD5Hash(DevID + "getleagueseasons" + AuthKey + getTimestamp())
url := "http://api.smitegame.com/smiteapi.svc/getleagueseasonsJson/" + DevID + "/" + hash + "/" + SessionID + "/" + getTimestamp() + "/" + queue
response, err := http.Get(url)
if err != nil {
perror(err)
} else {
defer response.Body.Close()
contents, err := ioutil.ReadAll(response.Body)
if err != nil {
perror(err)
} else {
return string(contents)
}
}
return ""
}