Showing
1 changed file
with
162 additions
and
475 deletions
1 | -module.exports = function(app){ | 1 | +module.exports = function (app) { |
2 | 2 | ||
3 | var request = require("request"); | 3 | var request = require("request"); |
4 | var urlenconde = require('urlencode'); | 4 | var urlenconde = require('urlencode'); |
... | @@ -12,16 +12,67 @@ module.exports = function(app){ | ... | @@ -12,16 +12,67 @@ module.exports = function(app){ |
12 | var summonerLevel; //소환사 | 12 | var summonerLevel; //소환사 |
13 | var rotation_champ = new Array(); | 13 | var rotation_champ = new Array(); |
14 | var rotation_champ_newbie = new Array(); | 14 | var rotation_champ_newbie = new Array(); |
15 | + var champion; | ||
16 | + var champ_count = 0; | ||
17 | + var spell; | ||
18 | + var match; | ||
19 | + | ||
20 | + app.get('/', function (req, res) { | ||
21 | + var rotation_name = new Array(); | ||
22 | + var rotation_name_newbie = new Array(); | ||
23 | + var rotation_pic = new Array(); | ||
24 | + var rotation_pic_newbie = new Array(); | ||
25 | + | ||
26 | + var rotationUrl = "https://kr.api.riotgames.com/lol/platform/v3/champion-rotations?api_key=" + apikey; | ||
27 | + request(rotationUrl, function (error, response, body) { | ||
28 | + var info_rotation = JSON.parse(body); | ||
29 | + var keys = Object.keys(info_rotation); | ||
30 | + for (var k = 0; k < info_rotation[keys[0]].length; k++) | ||
31 | + rotation_champ[k] = info_rotation[keys[0]][k]; | ||
32 | + for (var k = 0; k < info_rotation[keys[1]].length; k++) | ||
33 | + rotation_champ_newbie[k] = info_rotation[keys[1]][k]; | ||
34 | + | ||
35 | + | ||
36 | + var staticUrl = "http://ddragon.leagueoflegends.com/cdn/10.11.1/data/en_US/champion.json"; | ||
37 | + request(staticUrl, function (error, response, body) { | ||
38 | + var info_static_champ_json = JSON.parse(body); | ||
39 | + champion = info_static_champ_json["data"]; | ||
15 | 40 | ||
16 | - app.get('/', function(req, res) { | 41 | + for (var name in champion) { |
17 | - res.render('main', { title: 'LOL INFO' }); | 42 | + if (champion.hasOwnProperty(name)) { |
43 | + champ_count++; | ||
44 | + } | ||
45 | + } | ||
46 | + | ||
47 | + for (var i = 0; i < champ_count; i++) { | ||
48 | + for (js in champion) { | ||
49 | + for (j in champion[js]) { | ||
50 | + if (champion[js]["key"] == rotation_champ[i]) { | ||
51 | + rotation_name[i] = champion[js]["id"]; | ||
52 | + rotation_pic[i] = "http://ddragon.leagueoflegends.com/cdn/10.11.1/img/champion/" + rotation_name[i] + ".png"; | ||
53 | + } | ||
54 | + if (champion[js]["key"] == rotation_champ_newbie[i]) { | ||
55 | + rotation_name_newbie[i] = champion[js]["id"] | ||
56 | + rotation_pic_newbie[i] = "http://ddragon.leagueoflegends.com/cdn/10.11.1/img/champion/" + rotation_name_newbie[i] + ".png"; | ||
57 | + } | ||
58 | + } | ||
59 | + } | ||
60 | + } | ||
61 | + res.render('main', { | ||
62 | + title: 'LOL INFO', | ||
63 | + c_rotation: rotation_pic, | ||
64 | + c_rotation_newbie: rotation_pic_newbie | ||
65 | + }); | ||
66 | + }); | ||
67 | + }); | ||
18 | }); | 68 | }); |
19 | 69 | ||
20 | - app.get('/search/:username/', function(req, res, next){ | 70 | + |
71 | + app.get('/search/:username/', function (req, res, next) { | ||
21 | //롤 api url | 72 | //롤 api url |
22 | name = req.params.username; | 73 | name = req.params.username; |
23 | - var nameUrl = "https://kr.api.riotgames.com/lol/summoner/v4/summoners/by-name/" + urlenconde(name)+"?api_key="+ apikey; | 74 | + var nameUrl = "https://kr.api.riotgames.com/lol/summoner/v4/summoners/by-name/" + urlenconde(name) + "?api_key=" + apikey; |
24 | - request(nameUrl,function(error,response,body){ | 75 | + request(nameUrl, function (error, response, body) { |
25 | 76 | ||
26 | // 요청에 대한 응답이 성공적으로 왔는지 검사. | 77 | // 요청에 대한 응답이 성공적으로 왔는지 검사. |
27 | // status code가 200이 아니면 오류가 있었던 것으로 간주하고 함수 종료. | 78 | // status code가 200이 아니면 오류가 있었던 것으로 간주하고 함수 종료. |
... | @@ -42,134 +93,72 @@ module.exports = function(app){ | ... | @@ -42,134 +93,72 @@ module.exports = function(app){ |
42 | revisionDate = info_summoner_json["revisionDate"]; | 93 | revisionDate = info_summoner_json["revisionDate"]; |
43 | console.log(info_summoner_json); | 94 | console.log(info_summoner_json); |
44 | 95 | ||
45 | - var champUrl = "https://kr.api.riotgames.com/lol/champion-mastery/v4/champion-masteries/by-summoner/" + urlenconde(id) + "?api_key=" + apikey; | ||
46 | - request(champUrl,function(error,response,body){ | ||
47 | - var info_champ_json = JSON.parse(body); | ||
48 | - var champ_point = new Array(); | ||
49 | - var champ_id = new Array(); | ||
50 | - var champ_name = new Array(); | ||
51 | - var rotation_name = new Array(); | ||
52 | - var rotation_name_newbie = new Array(); | ||
53 | - var champ_pic = new Array(); | ||
54 | - var rotation_pic =new Array(); | ||
55 | - var rotation_pic_newbie = new Array(); | ||
56 | - var champions_length = Object.keys(info_champ_json).length; | ||
57 | - | ||
58 | - // status code가 200이 아니면 종료. | ||
59 | - if (info_champ_json["status"] != undefined) { | ||
60 | - if (info_champ_json["status"]["status_code"] != 200) { | ||
61 | - console.log('Error with response code11 ', info_champ_json["status"]["status_code"]); | ||
62 | - res.end(); | ||
63 | - return; | ||
64 | - } | ||
65 | - } | ||
66 | - | ||
67 | - for(var i=0; i < champions_length; i++){ | ||
68 | - champ_point[i] = (info_champ_json[i]["championPoints"]); | ||
69 | - champ_id[i] = info_champ_json[i]["championId"]; | ||
70 | - } | ||
71 | - var rotationUrl = "https://kr.api.riotgames.com/lol/platform/v3/champion-rotations?api_key="+apikey; | ||
72 | - request(rotationUrl,function(error,response,body){ | ||
73 | - var info_rotation = JSON.parse(body); | ||
74 | - var keys = Object.keys(info_rotation); | ||
75 | - for(var k =0; k < info_rotation[keys[0]].length;k++) | ||
76 | - rotation_champ[k] = info_rotation[keys[0]][k]; | ||
77 | - for(var k =0; k < info_rotation[keys[1]].length;k++) | ||
78 | - rotation_champ_newbie[k] = info_rotation[keys[1]][k]; | ||
79 | - | ||
80 | - | ||
81 | - | ||
82 | - | ||
83 | - | ||
84 | - var staticUrl = "http://ddragon.leagueoflegends.com/cdn/10.11.1/data/en_US/champion.json"; | ||
85 | - request(staticUrl,function(error,response,body) { | ||
86 | - var info_static_champ_json = JSON.parse(body); | ||
87 | - console.log(info_static_champ_json.data); | ||
88 | - var champion = info_static_champ_json["data"]; | ||
89 | - var champ_count = 0; | ||
90 | - | ||
91 | - for(var name in champion) { | ||
92 | - if(champion.hasOwnProperty(name)) { | ||
93 | - champ_count++; | ||
94 | - } | ||
95 | - } | ||
96 | 96 | ||
97 | - for(var i=0; i < champ_count; i++){ | 97 | + var spellUrl = "http://ddragon.leagueoflegends.com/cdn/10.12.1/data/en_US/summoner.json"; |
98 | - for(js in champion) { | 98 | + request(spellUrl, function (error, response, body) { |
99 | - for(j in champion[js]) { | 99 | + spell = (JSON.parse(body)).data; |
100 | - if(champion[js]["key"] == champ_id[i]){ | ||
101 | - champ_name[i] = champion[js]["id"]; | ||
102 | - champ_pic[i] = "http://ddragon.leagueoflegends.com/cdn/10.11.1/img/champion/"+champ_name[i]+".png"; | ||
103 | 100 | ||
104 | - } | ||
105 | - } | ||
106 | - } | ||
107 | - } | ||
108 | - for(var i=0; i < champ_count; i++){ | ||
109 | - for(js in champion){ | ||
110 | - for(j in champion[js]){ | ||
111 | - if(champion[js]["key"] == rotation_champ[i]){ | ||
112 | - rotation_name[i] = champion[js]["id"]; | ||
113 | - rotation_pic[i] = "http://ddragon.leagueoflegends.com/cdn/10.11.1/img/champion/"+rotation_name[i]+".png"; | ||
114 | - } | ||
115 | - if(champion[js]["key"] == rotation_champ_newbie[i]){ | ||
116 | - rotation_name_newbie[i] = champion[js]["id"] | ||
117 | - rotation_pic_newbie[i] = "http://ddragon.leagueoflegends.com/cdn/10.11.1/img/champion/"+rotation_name_newbie[i]+".png"; | ||
118 | - } | ||
119 | - } | ||
120 | - } | ||
121 | - } | ||
122 | 101 | ||
123 | - var userLeagueUrl = "https://kr.api.riotgames.com/lol/league/v4/entries/by-summoner/"+ urlenconde(id)+"?api_key=" + apikey; | 102 | + var userLeagueUrl = "https://kr.api.riotgames.com/lol/league/v4/entries/by-summoner/" + urlenconde(id) + "?api_key=" + apikey; |
124 | - request(userLeagueUrl,function(error,response,body){ | 103 | + request(userLeagueUrl, function (error, response, body) { |
125 | var info_user_league_json = JSON.parse(body); | 104 | var info_user_league_json = JSON.parse(body); |
126 | - //console.log("userLeagueUrl:", userLeagueUrl); | 105 | + if (info_user_league_json[0] != null) { |
127 | - if(info_user_league_json[0] != null){ | ||
128 | - var leagueId = info_user_league_json[0]["leagueId"]; | ||
129 | var wins = info_user_league_json[0]["wins"]; | 106 | var wins = info_user_league_json[0]["wins"]; |
130 | var losses = info_user_league_json[0]["losses"]; | 107 | var losses = info_user_league_json[0]["losses"]; |
131 | - var leagueName = info_user_league_json[0]["leagueName"] | ||
132 | var tier = info_user_league_json[0]["tier"]; | 108 | var tier = info_user_league_json[0]["tier"]; |
133 | var rank = info_user_league_json[0]["rank"]; | 109 | var rank = info_user_league_json[0]["rank"]; |
134 | var leaguePoints = info_user_league_json[0]["leaguePoints"]; | 110 | var leaguePoints = info_user_league_json[0]["leaguePoints"]; |
135 | var img_tier; | 111 | var img_tier; |
136 | - if(tier == "MASTER"){ | 112 | + if (tier == "MASTER") { |
137 | img_tier = "/ranked-emblems/Emblem_Master.png"; | 113 | img_tier = "/ranked-emblems/Emblem_Master.png"; |
138 | - }else if(tier == "CHALLENGER"){ | 114 | + } else if (tier == "CHALLENGER") { |
139 | img_tier = "/ranked-emblems/Emblem_Challenger.png"; | 115 | img_tier = "/ranked-emblems/Emblem_Challenger.png"; |
140 | - }else if(tier == "DIAMOND"){ | 116 | + } else if (tier == "DIAMOND") { |
141 | img_tier = "/ranked-emblems/Emblem_Diamond.png" | 117 | img_tier = "/ranked-emblems/Emblem_Diamond.png" |
142 | - }else if(tier == "PLATINUM"){ | 118 | + } else if (tier == "PLATINUM") { |
143 | img_tier = "/ranked-emblems/Emblem_Platinum.png" | 119 | img_tier = "/ranked-emblems/Emblem_Platinum.png" |
144 | - }else if(tier == "GRANDMASTER"){ | 120 | + } else if (tier == "GRANDMASTER") { |
145 | img_tier = "/ranked-emblems/Emblem_Grandmaster.png" | 121 | img_tier = "/ranked-emblems/Emblem_Grandmaster.png" |
146 | - }else if(tier == "GOLD"){ | 122 | + } else if (tier == "GOLD") { |
147 | img_tier = "/ranked-emblems/Emblem_Gold.png" | 123 | img_tier = "/ranked-emblems/Emblem_Gold.png" |
148 | - }else if(tier == "SILVER"){ | 124 | + } else if (tier == "SILVER") { |
149 | img_tier = "/ranked-emblems/Emblem_Silver.png" | 125 | img_tier = "/ranked-emblems/Emblem_Silver.png" |
150 | - }else if(tier == "BRONZE"){ | 126 | + } else if (tier == "BRONZE") { |
151 | - img_tier ="/ranked-emblems/Emblem_Bronze.png" | 127 | + img_tier = "/ranked-emblems/Emblem_Bronze.png" |
152 | - }else{ | 128 | + } else { |
153 | img_tier = "/ranked-emblems/Emblem_Iron.png" | 129 | img_tier = "/ranked-emblems/Emblem_Iron.png" |
154 | } | 130 | } |
155 | - | 131 | + res.render('userinfo', { |
156 | - | 132 | + title: req.params.username, |
133 | + c_summoner: summoner, | ||
134 | + c_wins: wins, | ||
135 | + c_losses: losses, | ||
136 | + c_tier: tier, | ||
137 | + c_imgtier: img_tier, | ||
138 | + c_rank: rank, | ||
139 | + c_leaguePoint: leaguePoints | ||
140 | + }); | ||
157 | } | 141 | } |
158 | 142 | ||
159 | - var spellUrl = "http://ddragon.leagueoflegends.com/cdn/10.12.1/data/en_US/summoner.json"; | ||
160 | - request(spellUrl,function(error,response,body){ | ||
161 | - var spell = (JSON.parse(body)).data; | ||
162 | - console.log(spell); | ||
163 | 143 | ||
144 | + }); | ||
145 | + }); | ||
146 | + }); | ||
147 | + }); | ||
164 | 148 | ||
149 | + | ||
150 | + app.get('/search/:username/spectator', function (req, res, next) { | ||
151 | + if (true) { | ||
152 | + console.log(id); | ||
165 | var spectatorUrl = "https://kr.api.riotgames.com/lol/spectator/v4/active-games/by-summoner/" + urlenconde(id) + "?api_key=" + apikey; | 153 | var spectatorUrl = "https://kr.api.riotgames.com/lol/spectator/v4/active-games/by-summoner/" + urlenconde(id) + "?api_key=" + apikey; |
166 | - request(spectatorUrl,function(error,response,body) { | 154 | + request(spectatorUrl, function (error, response, body) { |
167 | var flag = true; // 실시간 경기 여부 | 155 | var flag = true; // 실시간 경기 여부 |
168 | 156 | ||
169 | - if(response.statusCode != 200) | 157 | + if (response.statusCode != 200) |
170 | flag = false; | 158 | flag = false; |
171 | 159 | ||
172 | - if(flag) { // 실시간 경기 진행중이면 | 160 | + var spectator; |
161 | + if (flag) { // 실시간 경기 진행중이면 | ||
173 | var spectator_json = JSON.parse(body); | 162 | var spectator_json = JSON.parse(body); |
174 | console.log(spectator_json); | 163 | console.log(spectator_json); |
175 | var spec_bannedChamp = spectator_json.bannedChampions; | 164 | var spec_bannedChamp = spectator_json.bannedChampions; |
... | @@ -185,53 +174,64 @@ module.exports = function(app){ | ... | @@ -185,53 +174,64 @@ module.exports = function(app){ |
185 | var spec_summonerName = new Array(); | 174 | var spec_summonerName = new Array(); |
186 | var spec_spellId = new Array(); | 175 | var spec_spellId = new Array(); |
187 | var spec_spell_image = new Array(); | 176 | var spec_spell_image = new Array(); |
188 | - for(var i=0; i<10; i++){ | 177 | + for (var i = 0; i < 10; i++) { |
189 | spec_summonerName.push(spec_participants[i].summonerName); | 178 | spec_summonerName.push(spec_participants[i].summonerName); |
190 | spec_spellId.push(spec_participants[i].spell1Id); | 179 | spec_spellId.push(spec_participants[i].spell1Id); |
191 | spec_spellId.push(spec_participants[i].spell2Id); | 180 | spec_spellId.push(spec_participants[i].spell2Id); |
192 | } | 181 | } |
193 | 182 | ||
194 | - for(var i=0; i<10; i++) { | 183 | + for (var i = 0; i < 10; i++) { |
195 | - for(key in champion) { | 184 | + for (key in champion) { |
196 | - if(champion.hasOwnProperty(key) && champion[key].key == spec_bannedChamp[i].championId) { | 185 | + if (champion.hasOwnProperty(key) && champion[key].key == spec_bannedChamp[i].championId) { |
197 | - spec_bannedChamp_image.push("http://ddragon.leagueoflegends.com/cdn/10.11.1/img/champion/"+champion[key].id+".png"); | 186 | + spec_bannedChamp_image.push("http://ddragon.leagueoflegends.com/cdn/10.11.1/img/champion/" + champion[key].id + ".png"); |
198 | } | 187 | } |
199 | - if(champion.hasOwnProperty(key) && champion[key].key == spec_participants[i].championId) { | 188 | + if (champion.hasOwnProperty(key) && champion[key].key == spec_participants[i].championId) { |
200 | - spec_selectedChamp_image.push("http://ddragon.leagueoflegends.com/cdn/10.11.1/img/champion/"+champion[key].id+".png"); | 189 | + spec_selectedChamp_image.push("http://ddragon.leagueoflegends.com/cdn/10.11.1/img/champion/" + champion[key].id + ".png"); |
201 | } | 190 | } |
202 | } | 191 | } |
203 | } | 192 | } |
204 | 193 | ||
205 | - for(var i=0; i<20; i++) { | 194 | + for (var i = 0; i < 20; i++) { |
206 | - for(key in spell){ | 195 | + for (key in spell) { |
207 | - if(spell.hasOwnProperty(key) && spell[key].key == spec_spellId[i]){ | 196 | + if (spell.hasOwnProperty(key) && spell[key].key == spec_spellId[i]) { |
208 | - spec_spell_image.push("http://ddragon.leagueoflegends.com/cdn/10.12.1/img/spell/"+spell[key].id+".png"); | 197 | + spec_spell_image.push("http://ddragon.leagueoflegends.com/cdn/10.12.1/img/spell/" + spell[key].id + ".png"); |
209 | } | 198 | } |
210 | } | 199 | } |
211 | } | 200 | } |
212 | 201 | ||
213 | - var spectator = { | 202 | + spectator = { |
214 | - "summonerName" : spec_summonerName, | 203 | + "summonerName": spec_summonerName, |
215 | - "selectedChamp_image" : spec_selectedChamp_image, | 204 | + "selectedChamp_image": spec_selectedChamp_image, |
216 | - "bannedChamp_image" : spec_bannedChamp_image, | 205 | + "bannedChamp_image": spec_bannedChamp_image, |
217 | - "spell_image" : spec_spell_image | 206 | + "spell_image": spec_spell_image |
218 | }; | 207 | }; |
219 | } | 208 | } |
209 | + console.log(flag); | ||
210 | + console.log(spectator); | ||
211 | + res.render('main', { | ||
212 | + flag: flag, | ||
213 | + spectator: spectator | ||
214 | + }); | ||
215 | + }); | ||
216 | + } | ||
217 | + else { | ||
218 | + res.send(); | ||
219 | + } | ||
220 | + }); | ||
220 | 221 | ||
221 | - | 222 | + app.get('/search/:username/match', function (req, res, next) { |
222 | // 게임정보 불러오기 | 223 | // 게임정보 불러오기 |
223 | var matchUrl = "https://kr.api.riotgames.com/lol/match/v4/matchlists/by-account/" + accountId + "?api_key=" + apikey; | 224 | var matchUrl = "https://kr.api.riotgames.com/lol/match/v4/matchlists/by-account/" + accountId + "?api_key=" + apikey; |
224 | - request(matchUrl,function(error,response,body) { | 225 | + request(matchUrl, function (error, response, body) { |
225 | var match_json = JSON.parse(body).matches; | 226 | var match_json = JSON.parse(body).matches; |
226 | - console.log(match_json); | ||
227 | 227 | ||
228 | var match_gameId = new Array(); | 228 | var match_gameId = new Array(); |
229 | var match_mychamp = new Array(); | 229 | var match_mychamp = new Array(); |
230 | 230 | ||
231 | - var count=0 , idx=0; | 231 | + var count = 0, idx = 0; |
232 | - while(count<5){ | 232 | + while (count < 5) { |
233 | // 420 : 5x5 솔로랭크, 440 : 5x5 자유랭크 | 233 | // 420 : 5x5 솔로랭크, 440 : 5x5 자유랭크 |
234 | - if(match_json[idx].queue == 420 || match_json[idx].queue == 440){ | 234 | + if (match_json[idx].queue == 420 || match_json[idx].queue == 440) { |
235 | match_gameId.push(match_json[idx].gameId); | 235 | match_gameId.push(match_json[idx].gameId); |
236 | match_mychamp.push(match_json[idx].champion); | 236 | match_mychamp.push(match_json[idx].champion); |
237 | count++; | 237 | count++; |
... | @@ -239,9 +239,13 @@ module.exports = function(app){ | ... | @@ -239,9 +239,13 @@ module.exports = function(app){ |
239 | idx++; | 239 | idx++; |
240 | } | 240 | } |
241 | 241 | ||
242 | + match = new Array(); | ||
243 | + | ||
244 | + | ||
245 | + for (var i = 0; i < 5; i++) { | ||
242 | // teamId: 100 = Blue , teamId:200 = Red | 246 | // teamId: 100 = Blue , teamId:200 = Red |
243 | - var match1Url = "https://kr.api.riotgames.com/lol/match/v4/matches/" + match_gameId[0] + "?api_key=" + apikey; | 247 | + var match1Url = "https://kr.api.riotgames.com/lol/match/v4/matches/" + match_gameId[i] + "?api_key=" + apikey; |
244 | - request(match1Url,function(error,response,body){ | 248 | + request(match1Url, function (error, response, body) { |
245 | var match1_json = JSON.parse(body); | 249 | var match1_json = JSON.parse(body); |
246 | var match1_gameLength = match_json.gameDuration; | 250 | var match1_gameLength = match_json.gameDuration; |
247 | var match1_teams = match1_json.teams; | 251 | var match1_teams = match1_json.teams; |
... | @@ -258,377 +262,60 @@ module.exports = function(app){ | ... | @@ -258,377 +262,60 @@ module.exports = function(app){ |
258 | var match1_selectedChamp_image = new Array(); | 262 | var match1_selectedChamp_image = new Array(); |
259 | var match1_spell_image = new Array(); | 263 | var match1_spell_image = new Array(); |
260 | 264 | ||
261 | - for(var i=0; i<2; i++){ | 265 | + for (var i = 0; i < 2; i++) { |
262 | var temp = match1_teams[i].bans; | 266 | var temp = match1_teams[i].bans; |
263 | - for(var j=0; j<5; j++){ | 267 | + for (var j = 0; j < 5; j++) { |
264 | match1_bannedChamp.push(temp[j].championId); | 268 | match1_bannedChamp.push(temp[j].championId); |
265 | } | 269 | } |
266 | } | 270 | } |
267 | 271 | ||
268 | - for(var i=0; i<10; i++){ | 272 | + for (var i = 0; i < 10; i++) { |
269 | match1_selectedChamp.push(match1_participants[i].championId); | 273 | match1_selectedChamp.push(match1_participants[i].championId); |
270 | match1_spellId.push(match1_participants[i].spell1Id); | 274 | match1_spellId.push(match1_participants[i].spell1Id); |
271 | match1_spellId.push(match1_participants[i].spell2Id); | 275 | match1_spellId.push(match1_participants[i].spell2Id); |
272 | match1_summonerName.push((match1_participantIdentities[i].player).summonerName); | 276 | match1_summonerName.push((match1_participantIdentities[i].player).summonerName); |
273 | var obj = { | 277 | var obj = { |
274 | - 'k' : (match1_participants[i].stats).kills, | 278 | + 'k': (match1_participants[i].stats).kills, |
275 | - 'd' : (match1_participants[i].stats).deaths, | 279 | + 'd': (match1_participants[i].stats).deaths, |
276 | - 'a' : (match1_participants[i].stats).assists | 280 | + 'a': (match1_participants[i].stats).assists |
277 | }; | 281 | }; |
278 | match1_kda.push(obj); | 282 | match1_kda.push(obj); |
279 | } | 283 | } |
280 | 284 | ||
281 | - for(var i=0; i<10; i++) { | 285 | + for (var i = 0; i < 10; i++) { |
282 | - for(key in champion) { | 286 | + for (key in champion) { |
283 | - if(champion.hasOwnProperty(key) && champion[key].key == match1_bannedChamp[i]) { | 287 | + if (champion.hasOwnProperty(key) && champion[key].key == match1_bannedChamp[i]) { |
284 | - match1_bannedChamp_image.push("http://ddragon.leagueoflegends.com/cdn/10.11.1/img/champion/"+champion[key].id+".png"); | 288 | + match1_bannedChamp_image.push("http://ddragon.leagueoflegends.com/cdn/10.11.1/img/champion/" + champion[key].id + ".png"); |
285 | - } | ||
286 | - if(champion.hasOwnProperty(key) && champion[key].key == match1_selectedChamp[i]) { | ||
287 | - match1_selectedChamp_image.push("http://ddragon.leagueoflegends.com/cdn/10.11.1/img/champion/"+champion[key].id+".png"); | ||
288 | - } | ||
289 | - } | ||
290 | - } | ||
291 | - | ||
292 | - for(var i=0; i<20; i++) { | ||
293 | - for(key in spell){ | ||
294 | - if(spell.hasOwnProperty(key) && spell[key].key == match1_spellId[i]){ | ||
295 | - match1_spell_image.push("http://ddragon.leagueoflegends.com/cdn/10.12.1/img/spell/"+spell[key].id+".png"); | ||
296 | - } | ||
297 | - } | ||
298 | - } | ||
299 | - | ||
300 | - var match1 = { | ||
301 | - "summonerName" : match1_summonerName, | ||
302 | - "selectedChamp_image" : match1_selectedChamp_image, | ||
303 | - "bannedChamp_image" : match1_bannedChamp_image, | ||
304 | - "spell_image" : match1_spell_image, | ||
305 | - "kda" : match1_kda | ||
306 | - }; | ||
307 | - | ||
308 | - var match2Url = "https://kr.api.riotgames.com/lol/match/v4/matches/" + match_gameId[1] + "?api_key=" + apikey; | ||
309 | - request(match2Url,function(error,response,body){ | ||
310 | - var match2_json = JSON.parse(body); | ||
311 | - var match2_gameLength = match_json.gameDuration; | ||
312 | - var match2_teams = match2_json.teams; | ||
313 | - var match2_participants = match2_json.participants; | ||
314 | - var match2_participantIdentities = match2_json.participantIdentities; | ||
315 | - | ||
316 | - var match2_bannedChamp = new Array(); | ||
317 | - var match2_selectedChamp = new Array(); | ||
318 | - var match2_spellId = new Array(); | ||
319 | - var match2_summonerName = new Array(); | ||
320 | - var match2_kda = new Array(); | ||
321 | - | ||
322 | - var match2_bannedChamp_image = new Array(); | ||
323 | - var match2_selectedChamp_image = new Array(); | ||
324 | - var match2_spell_image = new Array(); | ||
325 | - | ||
326 | - for(var i=0; i<2; i++){ | ||
327 | - var temp = match2_teams[i].bans; | ||
328 | - for(var j=0; j<5; j++){ | ||
329 | - match2_bannedChamp.push(temp[j].championId); | ||
330 | - } | ||
331 | - } | ||
332 | - | ||
333 | - for(var i=0; i<10; i++){ | ||
334 | - match2_selectedChamp.push(match2_participants[i].championId); | ||
335 | - match2_spellId.push(match2_participants[i].spell1Id); | ||
336 | - match2_spellId.push(match2_participants[i].spell2Id); | ||
337 | - match2_summonerName.push((match2_participantIdentities[i].player).summonerName); | ||
338 | - var obj = { | ||
339 | - 'k' : (match2_participants[i].stats).kills, | ||
340 | - 'd' : (match2_participants[i].stats).deaths, | ||
341 | - 'a' : (match2_participants[i].stats).assists | ||
342 | - }; | ||
343 | - match2_kda.push(obj); | ||
344 | - } | ||
345 | - | ||
346 | - for(var i=0; i<10; i++) { | ||
347 | - for(key in champion) { | ||
348 | - if(champion.hasOwnProperty(key) && champion[key].key == match2_bannedChamp[i]) { | ||
349 | - match2_bannedChamp_image.push("http://ddragon.leagueoflegends.com/cdn/10.11.1/img/champion/"+champion[key].id+".png"); | ||
350 | - } | ||
351 | - if(champion.hasOwnProperty(key) && champion[key].key == match2_selectedChamp[i]) { | ||
352 | - match2_selectedChamp_image.push("http://ddragon.leagueoflegends.com/cdn/10.11.1/img/champion/"+champion[key].id+".png"); | ||
353 | - } | ||
354 | - } | ||
355 | - } | ||
356 | - | ||
357 | - for(var i=0; i<20; i++) { | ||
358 | - for(key in spell){ | ||
359 | - if(spell.hasOwnProperty(key) && spell[key].key == match2_spellId[i]){ | ||
360 | - match2_spell_image.push("http://ddragon.leagueoflegends.com/cdn/10.12.1/img/spell/"+spell[key].id+".png"); | ||
361 | - } | ||
362 | - } | ||
363 | - } | ||
364 | - | ||
365 | - var match2 = { | ||
366 | - "summonerName" : match2_summonerName, | ||
367 | - "selectedChamp_image" : match2_selectedChamp_image, | ||
368 | - "bannedChamp_image" : match2_bannedChamp_image, | ||
369 | - "spell_image" : match2_spell_image, | ||
370 | - "kda" : match2_kda | ||
371 | - }; | ||
372 | - | ||
373 | - | ||
374 | - var match3Url = "https://kr.api.riotgames.com/lol/match/v4/matches/" + match_gameId[2] + "?api_key=" + apikey; | ||
375 | - request(match3Url,function(error,response,body){ | ||
376 | - var match3_json = JSON.parse(body); | ||
377 | - var match3_gameLength = match_json.gameDuration; | ||
378 | - var match3_teams = match3_json.teams; | ||
379 | - var match3_participants = match3_json.participants; | ||
380 | - var match3_participantIdentities = match3_json.participantIdentities; | ||
381 | - | ||
382 | - var match3_bannedChamp = new Array(); | ||
383 | - var match3_selectedChamp = new Array(); | ||
384 | - var match3_spellId = new Array(); | ||
385 | - var match3_summonerName = new Array(); | ||
386 | - var match3_kda = new Array(); | ||
387 | - | ||
388 | - var match3_bannedChamp_image = new Array(); | ||
389 | - var match3_selectedChamp_image = new Array(); | ||
390 | - var match3_spell_image = new Array(); | ||
391 | - | ||
392 | - for(var i=0; i<2; i++){ | ||
393 | - var temp = match3_teams[i].bans; | ||
394 | - for(var j=0; j<5; j++){ | ||
395 | - match3_bannedChamp.push(temp[j].championId); | ||
396 | - } | ||
397 | - } | ||
398 | - | ||
399 | - for(var i=0; i<10; i++){ | ||
400 | - match3_selectedChamp.push(match3_participants[i].championId); | ||
401 | - match3_spellId.push(match3_participants[i].spell1Id); | ||
402 | - match3_spellId.push(match3_participants[i].spell2Id); | ||
403 | - match3_summonerName.push((match3_participantIdentities[i].player).summonerName); | ||
404 | - var obj = { | ||
405 | - 'k' : (match3_participants[i].stats).kills, | ||
406 | - 'd' : (match3_participants[i].stats).deaths, | ||
407 | - 'a' : (match3_participants[i].stats).assists | ||
408 | - }; | ||
409 | - match3_kda.push(obj); | ||
410 | - } | ||
411 | - | ||
412 | - for(var i=0; i<10; i++) { | ||
413 | - for(key in champion) { | ||
414 | - if(champion.hasOwnProperty(key) && champion[key].key == match3_bannedChamp[i]) { | ||
415 | - match3_bannedChamp_image.push("http://ddragon.leagueoflegends.com/cdn/10.11.1/img/champion/"+champion[key].id+".png"); | ||
416 | - } | ||
417 | - if(champion.hasOwnProperty(key) && champion[key].key == match3_selectedChamp[i]) { | ||
418 | - match3_selectedChamp_image.push("http://ddragon.leagueoflegends.com/cdn/10.11.1/img/champion/"+champion[key].id+".png"); | ||
419 | - } | ||
420 | - } | ||
421 | - } | ||
422 | - | ||
423 | - for(var i=0; i<20; i++) { | ||
424 | - for(key in spell){ | ||
425 | - if(spell.hasOwnProperty(key) && spell[key].key == match3_spellId[i]){ | ||
426 | - match3_spell_image.push("http://ddragon.leagueoflegends.com/cdn/10.12.1/img/spell/"+spell[key].id+".png"); | ||
427 | - } | ||
428 | - } | ||
429 | - } | ||
430 | - | ||
431 | - var match3 = { | ||
432 | - "summonerName" : match3_summonerName, | ||
433 | - "selectedChamp_image" : match3_selectedChamp_image, | ||
434 | - "bannedChamp_image" : match3_bannedChamp_image, | ||
435 | - "spell_image" : match3_spell_image, | ||
436 | - "kda" : match3_kda | ||
437 | - }; | ||
438 | - | ||
439 | - | ||
440 | - var match4Url = "https://kr.api.riotgames.com/lol/match/v4/matches/" + match_gameId[3] + "?api_key=" + apikey; | ||
441 | - request(match4Url,function(error,response,body){ | ||
442 | - var match4_json = JSON.parse(body); | ||
443 | - var match4_gameLength = match_json.gameDuration; | ||
444 | - var match4_teams = match4_json.teams; | ||
445 | - var match4_participants = match4_json.participants; | ||
446 | - var match4_participantIdentities = match4_json.participantIdentities; | ||
447 | - | ||
448 | - var match4_bannedChamp = new Array(); | ||
449 | - var match4_selectedChamp = new Array(); | ||
450 | - var match4_spellId = new Array(); | ||
451 | - var match4_summonerName = new Array(); | ||
452 | - var match4_kda = new Array(); | ||
453 | - | ||
454 | - var match4_bannedChamp_image = new Array(); | ||
455 | - var match4_selectedChamp_image = new Array(); | ||
456 | - var match4_spell_image = new Array(); | ||
457 | - | ||
458 | - for(var i=0; i<2; i++){ | ||
459 | - var temp = match4_teams[i].bans; | ||
460 | - for(var j=0; j<5; j++){ | ||
461 | - match4_bannedChamp.push(temp[j].championId); | ||
462 | - } | ||
463 | - } | ||
464 | - | ||
465 | - for(var i=0; i<10; i++){ | ||
466 | - match4_selectedChamp.push(match4_participants[i].championId); | ||
467 | - match4_spellId.push(match4_participants[i].spell1Id); | ||
468 | - match4_spellId.push(match4_participants[i].spell2Id); | ||
469 | - match4_summonerName.push((match4_participantIdentities[i].player).summonerName); | ||
470 | - var obj = { | ||
471 | - 'k' : (match4_participants[i].stats).kills, | ||
472 | - 'd' : (match4_participants[i].stats).deaths, | ||
473 | - 'a' : (match4_participants[i].stats).assists | ||
474 | - }; | ||
475 | - match4_kda.push(obj); | ||
476 | - } | ||
477 | - | ||
478 | - for(var i=0; i<10; i++) { | ||
479 | - for(key in champion) { | ||
480 | - if(champion.hasOwnProperty(key) && champion[key].key == match4_bannedChamp[i]) { | ||
481 | - match4_bannedChamp_image.push("http://ddragon.leagueoflegends.com/cdn/10.11.1/img/champion/"+champion[key].id+".png"); | ||
482 | } | 289 | } |
483 | - if(champion.hasOwnProperty(key) && champion[key].key == match4_selectedChamp[i]) { | 290 | + if (champion.hasOwnProperty(key) && champion[key].key == match1_selectedChamp[i]) { |
484 | - match4_selectedChamp_image.push("http://ddragon.leagueoflegends.com/cdn/10.11.1/img/champion/"+champion[key].id+".png"); | 291 | + match1_selectedChamp_image.push("http://ddragon.leagueoflegends.com/cdn/10.11.1/img/champion/" + champion[key].id + ".png"); |
485 | } | 292 | } |
486 | } | 293 | } |
487 | } | 294 | } |
488 | 295 | ||
489 | - for(var i=0; i<20; i++) { | 296 | + for (var i = 0; i < 20; i++) { |
490 | - for(key in spell){ | 297 | + for (key in spell) { |
491 | - if(spell.hasOwnProperty(key) && spell[key].key == match4_spellId[i]){ | 298 | + if (spell.hasOwnProperty(key) && spell[key].key == match1_spellId[i]) { |
492 | - match4_spell_image.push("http://ddragon.leagueoflegends.com/cdn/10.12.1/img/spell/"+spell[key].id+".png"); | 299 | + match1_spell_image.push("http://ddragon.leagueoflegends.com/cdn/10.12.1/img/spell/" + spell[key].id + ".png"); |
493 | } | 300 | } |
494 | } | 301 | } |
495 | } | 302 | } |
496 | 303 | ||
497 | - var match4 = { | 304 | + var match_temp = { |
498 | - "summonerName" : match4_summonerName, | 305 | + "summonerName": match1_summonerName, |
499 | - "selectedChamp_image" : match4_selectedChamp_image, | 306 | + "selectedChamp_image": match1_selectedChamp_image, |
500 | - "bannedChamp_image" : match4_bannedChamp_image, | 307 | + "bannedChamp_image": match1_bannedChamp_image, |
501 | - "spell_image" : match4_spell_image, | 308 | + "spell_image": match1_spell_image, |
502 | - "kda" : match4_kda | 309 | + "kda": match1_kda |
503 | }; | 310 | }; |
504 | 311 | ||
505 | - | 312 | + match.push(match_temp); |
506 | - var match5Url = "https://kr.api.riotgames.com/lol/match/v4/matches/" + match_gameId[4] + "?api_key=" + apikey; | ||
507 | - request(match5Url,function(error,response,body){ | ||
508 | - var match5_json = JSON.parse(body); | ||
509 | - var match5_gameLength = match_json.gameDuration; | ||
510 | - var match5_teams = match5_json.teams; | ||
511 | - var match5_participants = match5_json.participants; | ||
512 | - var match5_participantIdentities = match5_json.participantIdentities; | ||
513 | - | ||
514 | - var match5_bannedChamp = new Array(); | ||
515 | - var match5_selectedChamp = new Array(); | ||
516 | - var match5_spellId = new Array(); | ||
517 | - var match5_summonerName = new Array(); | ||
518 | - var match5_kda = new Array(); | ||
519 | - | ||
520 | - var match5_bannedChamp_image = new Array(); | ||
521 | - var match5_selectedChamp_image = new Array(); | ||
522 | - var match5_spell_image = new Array(); | ||
523 | - | ||
524 | - for(var i=0; i<2; i++){ | ||
525 | - var temp = match5_teams[i].bans; | ||
526 | - for(var j=0; j<5; j++){ | ||
527 | - match5_bannedChamp.push(temp[j].championId); | ||
528 | - } | ||
529 | - } | ||
530 | - | ||
531 | - for(var i=0; i<10; i++){ | ||
532 | - match5_selectedChamp.push(match5_participants[i].championId); | ||
533 | - match5_spellId.push(match5_participants[i].spell1Id); | ||
534 | - match5_spellId.push(match5_participants[i].spell2Id); | ||
535 | - match5_summonerName.push((match5_participantIdentities[i].player).summonerName); | ||
536 | - var obj = { | ||
537 | - 'k' : (match5_participants[i].stats).kills, | ||
538 | - 'd' : (match5_participants[i].stats).deaths, | ||
539 | - 'a' : (match5_participants[i].stats).assists | ||
540 | - }; | ||
541 | - match5_kda.push(obj); | ||
542 | - } | ||
543 | - | ||
544 | - for(var i=0; i<10; i++) { | ||
545 | - for(key in champion) { | ||
546 | - if(champion.hasOwnProperty(key) && champion[key].key == match5_bannedChamp[i]) { | ||
547 | - match5_bannedChamp_image.push("http://ddragon.leagueoflegends.com/cdn/10.11.1/img/champion/"+champion[key].id+".png"); | ||
548 | - } | ||
549 | - if(champion.hasOwnProperty(key) && champion[key].key == match5_selectedChamp[i]) { | ||
550 | - match5_selectedChamp_image.push("http://ddragon.leagueoflegends.com/cdn/10.11.1/img/champion/"+champion[key].id+".png"); | ||
551 | - } | ||
552 | - } | ||
553 | - } | ||
554 | - | ||
555 | - for(var i=0; i<20; i++) { | ||
556 | - for(key in spell){ | ||
557 | - if(spell.hasOwnProperty(key) && spell[key].key == match5_spellId[i]){ | ||
558 | - match5_spell_image.push("http://ddragon.leagueoflegends.com/cdn/10.12.1/img/spell/"+spell[key].id+".png"); | ||
559 | - } | ||
560 | - } | ||
561 | - } | ||
562 | - | ||
563 | - var match5 = { | ||
564 | - "summonerName" : match5_summonerName, | ||
565 | - "selectedChamp_image" : match5_selectedChamp_image, | ||
566 | - "bannedChamp_image" : match5_bannedChamp_image, | ||
567 | - "spell_image" : match5_spell_image, | ||
568 | - "kda" : match5_kda | ||
569 | - }; | ||
570 | - | ||
571 | - var summoner_info = { | ||
572 | - "summoner_Name" : summoner, | ||
573 | - "summoner_tierimage" : img_tier, | ||
574 | - "summoner_tier" : tier, | ||
575 | - "summoner_rank" : rank, | ||
576 | - "summoner_leaguepoint" : leaguePoints, | ||
577 | - "summoner_wins" : wins, | ||
578 | - "summoner_losses" : losses, | ||
579 | - "summoner_winrate" : ((wins/(wins+losses))*100).toFixed(2), | ||
580 | - "summoner_carry" : (wins/losses*2).toFixed(2) | ||
581 | - }; | ||
582 | - | ||
583 | - var rotation_info = { | ||
584 | - "rotation_image" : rotation_pic, | ||
585 | - "rotation_image_newbie" : rotation_pic_newbie | ||
586 | - }; | ||
587 | - | ||
588 | - var total_info = { | ||
589 | - "Summoner_info" : summoner_info, | ||
590 | - "Rotation_info" : rotation_info, | ||
591 | - "Spectator_flag" : flag, | ||
592 | - "Spectator" : spectator, | ||
593 | - "Match1" : match1, | ||
594 | - "Match2" : match2, | ||
595 | - "Match3" : match3, | ||
596 | - "Match4" : match4, | ||
597 | - "Match5" : match5 | ||
598 | - }; | ||
599 | - | ||
600 | - console.log(total_info); | ||
601 | - | ||
602 | - | ||
603 | - res.render('index', { title: req.params.username , | ||
604 | - c_id: champ_id, | ||
605 | - c_name: champ_name, | ||
606 | - c_point: champ_point, | ||
607 | - c_pic: champ_pic, | ||
608 | - c_rotation : rotation_pic, | ||
609 | - c_rotation_newbie : rotation_pic_newbie, | ||
610 | - c_summoner: summoner, | ||
611 | - c_wins: wins, | ||
612 | - c_losses: losses, | ||
613 | - c_tier: tier, | ||
614 | - c_imgtier: img_tier, | ||
615 | - c_rank: rank, | ||
616 | - c_leaguePoint: leaguePoints | ||
617 | - }); | ||
618 | - | ||
619 | - }); | ||
620 | - }); | ||
621 | - }); | ||
622 | - }); | ||
623 | - }); | ||
624 | - }); | ||
625 | - }); | ||
626 | - }); | ||
627 | - }); | ||
628 | - }); | ||
629 | }); | 313 | }); |
314 | + } | ||
315 | + console.log(match); | ||
316 | + res.render('match', { | ||
317 | + match: match | ||
630 | }); | 318 | }); |
631 | }); | 319 | }); |
632 | }); | 320 | }); |
633 | - }; | ||
634 | - | ||
... | \ No newline at end of file | ... | \ No newline at end of file |
321 | +} | ||
... | \ No newline at end of file | ... | \ No newline at end of file | ... | ... |
-
Please register or login to post a comment