1 | View Code Duplication | import { getJSON, getRegion } from './utils'; |
|
2 | var SummonerMastery = /** @class */ (function () { |
||
3 | function SummonerMastery(APIKEY, region, summonerId) { |
||
4 | this.summonerId = summonerId; |
||
5 | this.APIKEY = APIKEY; |
||
6 | this.region = region; |
||
7 | } |
||
8 | SummonerMastery.prototype.level = function (callback) { |
||
9 | var url = getRegion(this.region) + "/lol/champion-mastery/v3/scores/by-summoner/" |
||
10 | + (this.summonerId + "?api_key=" + this.APIKEY); |
||
11 | getJSON(url, function (res, err) { |
||
12 | if (err) { |
||
13 | callback(null, err); |
||
14 | } |
||
15 | else { |
||
16 | callback(res.data); |
||
17 | } |
||
18 | }); |
||
19 | }; |
||
20 | SummonerMastery.prototype.points = function (callback) { |
||
21 | var url = getRegion(this.region) + "/lol/champion-mastery/v3/champion-masteries/by-summoner/" |
||
22 | + (this.summonerId + "?api_key=" + this.APIKEY); |
||
23 | getJSON(url, function (res) { |
||
24 | var points = 0; |
||
25 | res.data.forEach(function (champion) { |
||
26 | points += champion.championPoints; |
||
27 | }); |
||
28 | callback(points); |
||
29 | }); |
||
30 | }; |
||
31 | SummonerMastery.prototype.top = function (amount, callback) { |
||
32 | if (amount === void 0) { amount = 0; } |
||
0 ignored issues
–
show
Coding Style
introduced
by
![]() |
|||
33 | var url = getRegion(this.region) + "/lol/champion-mastery/v3/champion-masteries/by-summoner/" |
||
34 | + (this.summonerId + "?api_key=" + this.APIKEY); |
||
35 | getJSON(url, function (res) { |
||
36 | var slice = amount === 0 ? res.data.length : amount; |
||
37 | callback(res.data.slice(0, slice)); |
||
38 | }); |
||
39 | }; |
||
40 | SummonerMastery.prototype.champion = function (champion, callback) { |
||
41 | if (Array.isArray(champion)) { |
||
42 | var url = getRegion(this.region) + "/lol/champion-mastery/v3/champion-masteries/by-summoner/" |
||
43 | + (this.summonerId + "?api_key=" + this.APIKEY); |
||
44 | var returner_1 = []; |
||
45 | getJSON(url, function (res) { |
||
46 | res.data.forEach(function (element) { |
||
47 | if (champion.indexOf(element.championId) !== -1) { |
||
48 | returner_1.push(element); |
||
49 | } |
||
50 | }); |
||
51 | callback(returner_1); |
||
52 | }); |
||
53 | } |
||
54 | else { |
||
55 | var url = getRegion(this.region) + "/lol/champion-mastery/v3/champion-masteries/by-summoner/" |
||
56 | + (this.summonerId + "/by-champion/" + champion + "?api_key=" + this.APIKEY); |
||
57 | getJSON(url, function (res, err) { |
||
58 | if (err) { |
||
59 | callback(null, err); |
||
60 | } |
||
61 | else { |
||
62 | callback(res.data); |
||
63 | } |
||
64 | }); |
||
65 | } |
||
66 | }; |
||
67 | return SummonerMastery; |
||
68 | }()); |
||
69 | export { SummonerMastery }; |
||
70 | //# sourceMappingURL=mastery.js.map |