김성준

Rotation added

...@@ -2,7 +2,7 @@ module.exports = function(app){ ...@@ -2,7 +2,7 @@ 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');
5 -var apikey = "RGAPI-d871b6f2-cf20-4e39-8ee1-4c3a663b2d01"//api 5 +var apikey = "RGAPI-539b7900-4377-44be-80ea-f0a88bb9b641"//api
6 6
7 var profileIconId; //아이콘 번호 7 var profileIconId; //아이콘 번호
8 var revisionDate; //수정날짜 8 var revisionDate; //수정날짜
...@@ -10,6 +10,7 @@ var id; //소환사ID ...@@ -10,6 +10,7 @@ var id; //소환사ID
10 var accountId; //계정Id 10 var accountId; //계정Id
11 var name; //소환사 이름 11 var name; //소환사 이름
12 var summonerLevel; //소환사 12 var summonerLevel; //소환사
13 +var lotation_champ = new Array();
13 14
14 app.get('/', function(req, res) { 15 app.get('/', function(req, res) {
15 res.render('main', { title: 'R U TROLL?' }); 16 res.render('main', { title: 'R U TROLL?' });
...@@ -25,7 +26,7 @@ var summonerLevel; //소환사 ...@@ -25,7 +26,7 @@ var summonerLevel; //소환사
25 // status code가 200이 아니면 오류가 있었던 것으로 간주하고 함수 종료. 26 // status code가 200이 아니면 오류가 있었던 것으로 간주하고 함수 종료.
26 console.log('response code ', response.statusCode); 27 console.log('response code ', response.statusCode);
27 if (response.statusCode != 200) { 28 if (response.statusCode != 200) {
28 - console.log('Error with response code ', response.statusCode); 29 + console.log('Error with response code22 ', response.statusCode);
29 res.end(); 30 res.end();
30 return; 31 return;
31 } 32 }
...@@ -45,7 +46,9 @@ var summonerLevel; //소환사 ...@@ -45,7 +46,9 @@ var summonerLevel; //소환사
45 var champ_point = new Array(); 46 var champ_point = new Array();
46 var champ_id = new Array(); 47 var champ_id = new Array();
47 var champ_name = new Array(); 48 var champ_name = new Array();
49 + var lotation_name = new Array();
48 var champ_pic = new Array(); 50 var champ_pic = new Array();
51 + var lotation_pic =new Array();
49 var champions_length = Object.keys(info_champ_json).length; 52 var champions_length = Object.keys(info_champ_json).length;
50 53
51 //console.log("\n\ninfo_champ_json\n\n", info_champ_json); 54 //console.log("\n\ninfo_champ_json\n\n", info_champ_json);
...@@ -53,7 +56,7 @@ var summonerLevel; //소환사 ...@@ -53,7 +56,7 @@ var summonerLevel; //소환사
53 // status code가 200이 아니면 종료. 56 // status code가 200이 아니면 종료.
54 if (info_champ_json["status"] != undefined) { 57 if (info_champ_json["status"] != undefined) {
55 if (info_champ_json["status"]["status_code"] != 200) { 58 if (info_champ_json["status"]["status_code"] != 200) {
56 - console.log('Error with response code ', info_champ_json["status"]["status_code"]); 59 + console.log('Error with response code11 ', info_champ_json["status"]["status_code"]);
57 res.end(); 60 res.end();
58 return; 61 return;
59 } 62 }
...@@ -62,8 +65,23 @@ var summonerLevel; //소환사 ...@@ -62,8 +65,23 @@ var summonerLevel; //소환사
62 for(var i=0; i < champions_length; i++){ 65 for(var i=0; i < champions_length; i++){
63 champ_point[i] = (info_champ_json[i]["championPoints"]); 66 champ_point[i] = (info_champ_json[i]["championPoints"]);
64 champ_id[i] = info_champ_json[i]["championId"]; 67 champ_id[i] = info_champ_json[i]["championId"];
68 +
69 + }
70 + var lotationUrl = "https://kr.api.riotgames.com/lol/platform/v3/champion-rotations?api_key="+apikey;
71 + request(lotationUrl,function(error,response,body){
72 + var info_lotation = JSON.parse(body);
73 + var keys = Object.keys(info_lotation);
74 + for(var k =0; k < info_lotation[keys[0]].length;k++)
75 + {
76 + lotation_champ[k] =info_lotation[keys[0]][k]
77 + console.log("lotation_champ:"+lotation_champ[k]);
78 + console.log("로테길이:"+lotation_champ.length);
65 } 79 }
66 80
81 +
82 +
83 +
84 +
67 var staticUrl = "http://ddragon.leagueoflegends.com/cdn/9.23.1/data/en_US/champion.json"; 85 var staticUrl = "http://ddragon.leagueoflegends.com/cdn/9.23.1/data/en_US/champion.json";
68 request(staticUrl,function(error,response,body){ 86 request(staticUrl,function(error,response,body){
69 var info_static_champ_json = JSON.parse(body); 87 var info_static_champ_json = JSON.parse(body);
...@@ -74,10 +92,25 @@ var summonerLevel; //소환사 ...@@ -74,10 +92,25 @@ var summonerLevel; //소환사
74 if(champion[js]["key"] == champ_id[i]){ 92 if(champion[js]["key"] == champ_id[i]){
75 champ_name[i] = champion[js]["id"]; 93 champ_name[i] = champion[js]["id"];
76 champ_pic[i] = "http://ddragon.leagueoflegends.com/cdn/9.23.1/img/champion/"+champ_name[i]+".png"; 94 champ_pic[i] = "http://ddragon.leagueoflegends.com/cdn/9.23.1/img/champion/"+champ_name[i]+".png";
95 +
96 + }
97 + }
98 + }
99 + }
100 + for(var i=0; i < champ_id.length; i++){
101 + for(js in champion){
102 + for(j in champion[js]){
103 + if(champion[js]["key"] == lotation_champ[i]){
104 + lotation_name[i] = champion[js]["id"];
105 + lotation_pic[i] = "http://ddragon.leagueoflegends.com/cdn/9.23.1/img/champion/"+lotation_name[i]+".png";
106 +
77 } 107 }
78 } 108 }
79 } 109 }
80 } 110 }
111 +
112 + console.log("챔프길이:"+champ_pic.length);
113 +
81 var userLeagueUrl = "https://kr.api.riotgames.com/lol/league/v4/entries/by-summoner/"+ urlenconde(id)+"?api_key=" + apikey; 114 var userLeagueUrl = "https://kr.api.riotgames.com/lol/league/v4/entries/by-summoner/"+ urlenconde(id)+"?api_key=" + apikey;
82 request(userLeagueUrl,function(error,response,body){ 115 request(userLeagueUrl,function(error,response,body){
83 var info_user_league_json = JSON.parse(body); 116 var info_user_league_json = JSON.parse(body);
...@@ -169,6 +202,7 @@ var summonerLevel; //소환사 ...@@ -169,6 +202,7 @@ var summonerLevel; //소환사
169 c_name: champ_name, 202 c_name: champ_name,
170 c_point: champ_point, 203 c_point: champ_point,
171 c_pic: champ_pic, 204 c_pic: champ_pic,
205 + c_lotation : lotation_pic,
172 c_summoner: summoner, 206 c_summoner: summoner,
173 c_wins: wins, 207 c_wins: wins,
174 c_losses: losses, 208 c_losses: losses,
...@@ -180,6 +214,7 @@ var summonerLevel; //소환사 ...@@ -180,6 +214,7 @@ var summonerLevel; //소환사
180 }); 214 });
181 }); 215 });
182 }); 216 });
217 + });
183 }); 218 });
184 }); 219 });
185 }; 220 };
......
...@@ -56,6 +56,14 @@ ...@@ -56,6 +56,14 @@
56 <%= "point: " + (c_wins/c_losses*2).toFixed(2) %> 56 <%= "point: " + (c_wins/c_losses*2).toFixed(2) %>
57 </strong> 57 </strong>
58 </div> 58 </div>
59 + <div class="center">
60 + <strong>
61 + <%= "로테이션 챔피언: " %>
62 + </strong>
63 + <% for (var i=0; i<c_lotation.length-1; i++){ %>
64 + <img src= <%=c_lotation[i]%> width=50, height=50>
65 + <% } %>
66 + </div>
59 <% for (var i=0; i<c_id.length-1; i++){ %> 67 <% for (var i=0; i<c_id.length-1; i++){ %>
60 <div class="champImage"> 68 <div class="champImage">
61 <div class="center"> 69 <div class="center">
...@@ -64,6 +72,8 @@ ...@@ -64,6 +72,8 @@
64 <%= "point: " + (1000000/c_point[i]).toFixed(2) %> 72 <%= "point: " + (1000000/c_point[i]).toFixed(2) %>
65 <% } %> 73 <% } %>
66 </div> 74 </div>
75 +
76 +
67 </div> 77 </div>
68 </body> 78 </body>
69 </html> 79 </html>
......