Repository navigation
Expand file tree
/
Copy pathriot.DS.go
More file actions
208 lines (199 loc) · 4.64 KB
/
Copy pathriot.DS.go
File metadata and controls
208 lines (199 loc) · 4.64 KB
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
package main
import (
"image"
"regexp"
"github.com/yuhanfang/riot/constants/champion"
"github.com/yuhanfang/riot/constants/region"
"github.com/yuhanfang/riot/constants/tier"
)
type cardTemplate struct {
images map[string]imageData
text map[string]textData
}
type imageData struct {
image image.Image
area image.Rectangle
point image.Point
hasMask bool
mask image.Image
}
type textData struct {
text string
point image.Point
fontSize int
}
type errChan struct {
value interface{}
err error
}
type riotVerifyData struct {
code string
puuid string
summonerID string
region region.Region
}
type ddchamp struct {
ID string
Key int `json:",string"`
}
type riotInGameCH struct {
card *image.RGBA
num int
}
type ddchampions struct {
Data map[string]ddchamp
}
func (obj *ddchampions) toMap() map[champion.Champion]string {
newMap := make(map[champion.Champion]string)
for _, v := range obj.Data {
newMap[champion.Champion(v.Key)] = v.ID
}
return newMap
}
var (
riotInGameFile = regexp.MustCompile(`[A-Z]+[0-9]?(_[0-9]+)+`)
riotVerified = make(map[string]riotVerifyData)
riotRegions = map[string]region.Region{
"na": region.NA1,
"br": region.BR1,
"eune": region.EUN1,
"euw": region.EUW1,
"jp": region.JP1,
"kr": region.KR,
"lan": region.LA1,
"las": region.LA2,
"oce": region.OC1,
"tr": region.TR1,
"ru": region.RU,
}
riotRanks = map[tier.Tier]int{
"IRON": 1,
"BRONZE": 2,
"SILVER": 3,
"GOLD": 4,
"PLATINUM": 5,
"DIAMOND": 6,
"MASTER": 7,
"GRANDMASTER": 8,
"CHALLENGER": 9,
}
)
func summonerCardFront() cardTemplate {
return cardTemplate{
images: map[string]imageData{
"background": imageData{
area: image.Rect(0, 0, 320, 570),
point: image.Pt(80, 141),
}, "profileIcon": imageData{
area: image.Rect(110, 32, 210, 132),
point: image.ZP,
}, "insignia": imageData{
area: image.Rect(32, 190, 288, 225),
point: image.ZP,
}, "solo": imageData{
area: image.Rect(44, 230, 144, 330),
point: image.ZP,
}, "flex": imageData{
area: image.Rect(176, 230, 276, 330),
point: image.ZP,
}, "masteryBorder": imageData{
area: image.Rect(104, 380, 226, 520),
point: image.ZP,
}, "masteryChamp": imageData{
area: image.Rect(114, 386, 206, 479),
point: image.ZP,
hasMask: true,
},
},
text: map[string]textData{
"name": textData{
point: image.Pt(160, 178),
fontSize: 32,
}, "Solo": textData{
text: "Solo",
point: image.Pt(74, 345),
fontSize: 20,
}, "Flex": textData{
text: "Flex",
point: image.Pt(208, 345),
fontSize: 20,
}, "soloRank": textData{
point: image.Pt(94, 365), // X is where the center of the text should be here
fontSize: 16,
}, "flexRank": textData{
point: image.Pt(226, 365), // X is where the center of the text should be here
fontSize: 16,
}, "masteryPoints": textData{
point: image.Pt(160, 540),
fontSize: 16,
},
},
}
}
func summonerCardBack() cardTemplate {
return cardTemplate{
images: map[string]imageData{
"insignia": imageData{
area: image.Rect(32, 205, 288, 240),
point: image.ZP,
},
},
text: map[string]textData{
"mainRole": textData{
text: "Main Role: ",
point: image.Pt(160, 260),
fontSize: 16,
}, "secondaryRole": textData{
text: "Secondary Role: ",
point: image.Pt(160, 280),
fontSize: 16,
},
},
}
}
func mostChampsTemplates(n int) []imageData {
return [3][]imageData{
[]imageData{
imageData{
area: image.Rect(123, 64, 197, 139),
point: image.ZP,
},
}, []imageData{
imageData{
area: image.Rect(68, 64, 143, 139),
point: image.ZP,
}, imageData{
area: image.Rect(177, 64, 252, 139),
point: image.ZP,
},
}, []imageData{
imageData{
area: image.Rect(33, 64, 107, 139),
point: image.ZP,
}, imageData{
area: image.Rect(123, 64, 197, 139),
point: image.ZP,
}, imageData{
area: image.Rect(213, 64, 287, 139),
point: image.ZP,
},
},
}[n-1]
}
func mostChampsText() map[string]textData {
return map[string]textData{
"played": textData{
text: "Played: ",
point: image.Pt(0, 156),
fontSize: 16,
}, "winrate": textData{
text: "WR: ",
point: image.Pt(0, 176),
fontSize: 16,
}, "kda": textData{
text: "KDA: ",
point: image.Pt(0, 194),
fontSize: 16,
},
}
}