Showing
1 changed file
with
47 additions
and
7 deletions
... | @@ -93,11 +93,19 @@ module.exports = function(app){ | ... | @@ -93,11 +93,19 @@ module.exports = function(app){ |
93 | var staticUrl = "http://ddragon.leagueoflegends.com/cdn/10.11.1/data/en_US/champion.json"; | 93 | var staticUrl = "http://ddragon.leagueoflegends.com/cdn/10.11.1/data/en_US/champion.json"; |
94 | request(staticUrl,function(error,response,body) { | 94 | request(staticUrl,function(error,response,body) { |
95 | var info_static_champ_json = JSON.parse(body); | 95 | var info_static_champ_json = JSON.parse(body); |
96 | - console.log(info_static_champ_json); | 96 | + console.log(info_static_champ_json.data); |
97 | var champion = info_static_champ_json["data"]; | 97 | var champion = info_static_champ_json["data"]; |
98 | - for(var i=0; i < champ_id.length; i++){ | 98 | + var champ_count = 0; |
99 | - for(js in champion){ | 99 | + |
100 | - for(j in champion[js]){ | 100 | + for(var name in champion) { |
101 | + if(champion.hasOwnProperty(name)) { | ||
102 | + champ_count++; | ||
103 | + } | ||
104 | + } | ||
105 | + | ||
106 | + for(var i=0; i < champ_count; i++){ | ||
107 | + for(js in champion) { | ||
108 | + for(j in champion[js]) { | ||
101 | if(champion[js]["key"] == champ_id[i]){ | 109 | if(champion[js]["key"] == champ_id[i]){ |
102 | champ_name[i] = champion[js]["id"]; | 110 | champ_name[i] = champion[js]["id"]; |
103 | champ_pic[i] = "http://ddragon.leagueoflegends.com/cdn/10.11.1/img/champion/"+champ_name[i]+".png"; | 111 | champ_pic[i] = "http://ddragon.leagueoflegends.com/cdn/10.11.1/img/champion/"+champ_name[i]+".png"; |
... | @@ -106,7 +114,7 @@ module.exports = function(app){ | ... | @@ -106,7 +114,7 @@ module.exports = function(app){ |
106 | } | 114 | } |
107 | } | 115 | } |
108 | } | 116 | } |
109 | - for(var i=0; i < champ_id.length; i++){ | 117 | + for(var i=0; i < champ_count; i++){ |
110 | for(js in champion){ | 118 | for(js in champion){ |
111 | for(j in champion[js]){ | 119 | for(j in champion[js]){ |
112 | if(champion[js]["key"] == rotation_champ[i]){ | 120 | if(champion[js]["key"] == rotation_champ[i]){ |
... | @@ -122,7 +130,7 @@ module.exports = function(app){ | ... | @@ -122,7 +130,7 @@ module.exports = function(app){ |
122 | } | 130 | } |
123 | console.log(rotation_name); | 131 | console.log(rotation_name); |
124 | 132 | ||
125 | - console.log("챔프길이:"+champ_pic.length); | 133 | + console.log("챔프길이:" + champ_count); |
126 | 134 | ||
127 | var userLeagueUrl = "https://kr.api.riotgames.com/lol/league/v4/entries/by-summoner/"+ urlenconde(id)+"?api_key=" + apikey; | 135 | var userLeagueUrl = "https://kr.api.riotgames.com/lol/league/v4/entries/by-summoner/"+ urlenconde(id)+"?api_key=" + apikey; |
128 | request(userLeagueUrl,function(error,response,body){ | 136 | request(userLeagueUrl,function(error,response,body){ |
... | @@ -211,8 +219,13 @@ module.exports = function(app){ | ... | @@ -211,8 +219,13 @@ module.exports = function(app){ |
211 | 219 | ||
212 | var spectatorUrl = "https://kr.api.riotgames.com/lol/spectator/v4/active-games/by-summoner/" + urlenconde(id) + "?api_key=" + apikey; | 220 | var spectatorUrl = "https://kr.api.riotgames.com/lol/spectator/v4/active-games/by-summoner/" + urlenconde(id) + "?api_key=" + apikey; |
213 | request(spectatorUrl,function(error,response,body) { | 221 | request(spectatorUrl,function(error,response,body) { |
214 | - var spectator_json = JSON.parse(body); | ||
215 | var flag = true; | 222 | var flag = true; |
223 | + | ||
224 | + if(response.statusCode != 200) | ||
225 | + flag = false; | ||
226 | + | ||
227 | + if(flag) { | ||
228 | + var spectator_json = JSON.parse(body); | ||
216 | console.log(spectator_json); | 229 | console.log(spectator_json); |
217 | var spec_bannedChamp = spectator_json.bannedChampions; | 230 | var spec_bannedChamp = spectator_json.bannedChampions; |
218 | var spec_gameId = spectator_json.gameId; | 231 | var spec_gameId = spectator_json.gameId; |
... | @@ -222,6 +235,33 @@ module.exports = function(app){ | ... | @@ -222,6 +235,33 @@ module.exports = function(app){ |
222 | var spec_mapId = spectator_json.mapId; | 235 | var spec_mapId = spectator_json.mapId; |
223 | var spec_participants = spectator_json.participants; | 236 | var spec_participants = spectator_json.participants; |
224 | 237 | ||
238 | + // var spec_bannedChamp_Id = new Array(); | ||
239 | + var spec_bannedChamp_image = new Array(); | ||
240 | + var spec_selectedChamp_image = new Array(); | ||
241 | + | ||
242 | + for(var i=0; i<10; i++) { | ||
243 | + if((spec_bannedChamp[i]).championId == -1) | ||
244 | + continue; | ||
245 | + | ||
246 | + for(var key in champion) { | ||
247 | + if(champion.hasOwnProperty(key) && champion[key].key == spec_bannedChamp[i].championId) { | ||
248 | + spec_bannedChamp_image.push("http://ddragon.leagueoflegends.com/cdn/10.11.1/img/champion/"+champion[key].id+".png"); | ||
249 | + } | ||
250 | + if(champion.hasOwnProperty(key) && champion[key].key == spec_participants[i].championId) { | ||
251 | + spec_selectedChamp_image.push("http://ddragon.leagueoflegends.com/cdn/10.11.1/img/champion/"+champion[key].id+".png"); | ||
252 | + } | ||
253 | + } | ||
254 | + } | ||
255 | + console.log(spec_bannedChamp_image); | ||
256 | + console.log(spec_selectedChamp_image); | ||
257 | + | ||
258 | + } | ||
259 | + | ||
260 | + | ||
261 | + | ||
262 | + | ||
263 | + | ||
264 | + | ||
225 | 265 | ||
226 | 266 | ||
227 | 267 | ... | ... |
-
Please register or login to post a comment