김세윤

챔피언 스탯 추가

...@@ -2,12 +2,7 @@ module.exports = function(app){ ...@@ -2,12 +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 -<<<<<<< HEAD 5 +var apikey = "RGAPI-b504dbbe-5a17-440c-9c4e-1da918946d60"//api
6 -var apikey = "RGAPI-26fe9028-bf28-4baa-a0e0-34c116c57742"//api
7 -=======
8 -var apikey = "RGAPI-e4aabf85-2067-48cb-82ab-39bdf7c07325"//api
9 -
10 ->>>>>>> 2405bb4c8a3dae402c7d281fdffcda56ffb4ecfb
11 6
12 var profileIconId; //아이콘 번호 7 var profileIconId; //아이콘 번호
13 var revisionDate; //수정날짜 8 var revisionDate; //수정날짜
...@@ -20,7 +15,66 @@ var rotation_champ = new Array(); ...@@ -20,7 +15,66 @@ var rotation_champ = new Array();
20 app.get('/', function(req, res) { 15 app.get('/', function(req, res) {
21 res.render('main', { title: 'R U TROLL?' }); 16 res.render('main', { title: 'R U TROLL?' });
22 }); 17 });
18 + app.get('/data/:championname',function(req,res,net){
19 + var champ_name=req.params.championname;
20 + var champUrl = "https://kr.api.riotgames.com/lol/champion-mastery/v4/champion-masteries/by-summoner/" + urlenconde(id) + "?api_key=" + apikey;
21 + request(champUrl,function(error,response,body){
22 + var info_champ_json = JSON.parse(body);
23 +
24 + var champ_id = new Array();
25 +
26 + var champions_length = Object.keys(info_champ_json).length;
27 + var staticUrl = "http://ddragon.leagueoflegends.com/cdn/10.23.1/data/ko_KR/champion.json";
28 + var title;
29 + var blub;
30 + var champ_stats=new Array();
31 + var champ_pic;
32 + var champ_kor;
33 + request(staticUrl,function(error,response,body){
34 + var info_static_champ_json = JSON.parse(body);
35 + var champion = info_static_champ_json["data"];
36 + for(js in champion){
37 + for(j in champion[js]){
38 + if(champion[js]["id"]==champ_name){
39 + title=champion[js]["title"];
40 + blub=champion[js]["blurb"];
41 + champ_kor=champion[js]["name"];
42 + champ_pic = "http://ddragon.leagueoflegends.com/cdn/10.23.1/img/champion/"+champ_name+".png";
43 + champ_stats[0]=champion[js]["stats"]["hp"];
44 + champ_stats[1]=champion[js]["stats"]["hpperlevel"];
45 + champ_stats[2]=champion[js]["stats"]["mp"];
46 + champ_stats[3]=champion[js]["stats"]["mpperlevel"];
47 + champ_stats[4]=champion[js]["stats"]["movespeed"];
48 + champ_stats[5]=champion[js]["stats"]["armor"];
49 + champ_stats[6]=champion[js]["stats"]["armorperlevel"];
50 + champ_stats[7]=champion[js]["stats"]["spellblock"];
51 + champ_stats[8]=champion[js]["stats"]["spellblockperlevel"];
52 + champ_stats[9]=champion[js]["stats"]["attackrange"];
53 + champ_stats[10]=champion[js]["stats"]["hpregen"];
54 + champ_stats[11]=champion[js]["stats"]["hpregenperlevel"];
55 + champ_stats[12]=champion[js]["stats"]["mpregen"];
56 + champ_stats[13]=champion[js]["stats"]["mpregenperlevel"];
57 + champ_stats[14]=champion[js]["stats"]["crit"];
58 + champ_stats[15]=champion[js]["stats"]["critperlevel"];
59 + champ_stats[16]=champion[js]["stats"]["attackdamage"];
60 + champ_stats[17]=champion[js]["stats"]["attackdamageperlevel"];
61 + champ_stats[18]=champion[js]["stats"]["attackspeedperlevel"];
62 + champ_stats[19]=champion[js]["stats"]["attackspeed"];
23 63
64 + }
65 + }
66 + }
67 +
68 + res.render('data',{
69 + c_blb:blub,
70 + c_title:title,
71 + c_stats:champ_stats,
72 + c_pic:champ_pic,
73 + c_name:champ_kor
74 + })
75 + })
76 + })
77 + })
24 app.get('/search/:username/', function(req, res, next){ 78 app.get('/search/:username/', function(req, res, next){
25 //롤 api url 79 //롤 api url
26 name = req.params.username; 80 name = req.params.username;
...@@ -38,7 +92,6 @@ var rotation_champ = new Array(); ...@@ -38,7 +92,6 @@ var rotation_champ = new Array();
38 92
39 var info_summoner_json = JSON.parse(body); 93 var info_summoner_json = JSON.parse(body);
40 94
41 -<<<<<<< HEAD
42 accountId = info_summoner_json["accountId"]; 95 accountId = info_summoner_json["accountId"];
43 id = info_summoner_json["id"]; 96 id = info_summoner_json["id"];
44 summoner = info_summoner_json["name"]; 97 summoner = info_summoner_json["name"];
...@@ -50,21 +103,13 @@ var rotation_champ = new Array(); ...@@ -50,21 +103,13 @@ var rotation_champ = new Array();
50 var profileIcon; 103 var profileIcon;
51 profileIcon="http://ddragon.leagueoflegends.com/cdn/10.23.1/img/profileicon/"+profileIconId+".png"; 104 profileIcon="http://ddragon.leagueoflegends.com/cdn/10.23.1/img/profileicon/"+profileIconId+".png";
52 105
53 -=======
54 - accountId = info_summoner_json["accountId"]; // GZC51rstNY47-cmgcap94mfLe7JNjF1fz3dGAdwS6pEo
55 - id = info_summoner_json["id"]; // T6cI_Zn5LEqyPuhCZz1do0Y-IJztJX1I1mvcQZRt9YKygA
56 - summoner = info_summoner_json["name"]; // 환하다 추야
57 - profileIconId = info_summoner_json["profileIconId"]; // 980
58 - summonerLevel = info_summoner_json["summonerLevel"]; // 250
59 - revisionDate = info_summoner_json["revisionDate"]; // 1605519790000
60 -
61 ->>>>>>> 2405bb4c8a3dae402c7d281fdffcda56ffb4ecfb
62 var champUrl = "https://kr.api.riotgames.com/lol/champion-mastery/v4/champion-masteries/by-summoner/" + urlenconde(id) + "?api_key=" + apikey; 106 var champUrl = "https://kr.api.riotgames.com/lol/champion-mastery/v4/champion-masteries/by-summoner/" + urlenconde(id) + "?api_key=" + apikey;
63 request(champUrl,function(error,response,body){ 107 request(champUrl,function(error,response,body){
64 var info_champ_json = JSON.parse(body); 108 var info_champ_json = JSON.parse(body);
65 var champ_point = new Array(); 109 var champ_point = new Array();
66 var champ_id = new Array(); 110 var champ_id = new Array();
67 var champ_name = new Array(); 111 var champ_name = new Array();
112 + var champ_korname=new Array();
68 var rotation_name = new Array(); 113 var rotation_name = new Array();
69 var champ_pic = new Array(); 114 var champ_pic = new Array();
70 var rotation_pic =new Array(); 115 var rotation_pic =new Array();
...@@ -102,7 +147,7 @@ var rotation_champ = new Array(); ...@@ -102,7 +147,7 @@ var rotation_champ = new Array();
102 147
103 148
104 149
105 - var staticUrl = "http://ddragon.leagueoflegends.com/cdn/10.23.1/data/en_US/champion.json"; 150 + var staticUrl = "http://ddragon.leagueoflegends.com/cdn/10.23.1/data/ko_KR/champion.json";
106 request(staticUrl,function(error,response,body){ 151 request(staticUrl,function(error,response,body){
107 var info_static_champ_json = JSON.parse(body); 152 var info_static_champ_json = JSON.parse(body);
108 var champion = info_static_champ_json["data"]; 153 var champion = info_static_champ_json["data"];
...@@ -111,6 +156,7 @@ var rotation_champ = new Array(); ...@@ -111,6 +156,7 @@ var rotation_champ = new Array();
111 for(j in champion[js]){ 156 for(j in champion[js]){
112 if(champion[js]["key"] == champ_id[i]){ 157 if(champion[js]["key"] == champ_id[i]){
113 champ_name[i] = champion[js]["id"]; 158 champ_name[i] = champion[js]["id"];
159 + champ_korname[i]=champion[js]["name"];
114 champ_pic[i] = "http://ddragon.leagueoflegends.com/cdn/10.23.1/img/champion/"+champ_name[i]+".png"; 160 champ_pic[i] = "http://ddragon.leagueoflegends.com/cdn/10.23.1/img/champion/"+champ_name[i]+".png";
115 161
116 } 162 }
...@@ -223,9 +269,11 @@ var rotation_champ = new Array(); ...@@ -223,9 +269,11 @@ var rotation_champ = new Array();
223 269
224 res.render('index', { title: req.params.username ,//데이터를 ejs로 넘길 때 사용 270 res.render('index', { title: req.params.username ,//데이터를 ejs로 넘길 때 사용
225 c_lev: champ_level, 271 c_lev: champ_level,
272 + c_summonerlev: summonerLevel,
226 c_profile: profileIcon, 273 c_profile: profileIcon,
227 c_id: champ_id, 274 c_id: champ_id,
228 c_name: champ_name, 275 c_name: champ_name,
276 + c_korname: champ_korname,
229 c_point: champ_point, 277 c_point: champ_point,
230 c_pic: champ_pic, 278 c_pic: champ_pic,
231 c_rotation : rotation_pic, 279 c_rotation : rotation_pic,
......
1 +<!DOCTYPE html>
2 +<html>
3 + <head>
4 + <meta charset="utf-8">
5 +
6 + <link rel="icon" href = "FindMelogo.png">
7 + <link rel="stylesheet" href="css/style.css">
8 + <link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.2/css/bootstrap.min.css">
9 + <link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.2/css/bootstrap-theme.min.css">
10 + <script src="https://code.jquery.com/jquery-3.2.1.min.js" integrity="sha256-hwg4gsxgFZhOsEEamdOYGBf13FyQuiTwlAQgxVSNgt4=" crossorigin="anonymous"></script>
11 + <style> @import url("http://fonts.googleapis.com/earlyaccess/nanumgothic.css");</style>
12 + <script>
13 +
14 + </script>
15 + </head>
16 + <body>
17 +
18 +
19 +
20 +
21 + <img src= <%=c_pic%> width=300, height=300>
22 + <font size=10em>
23 + <strong>
24 + <%= c_title +"\n"%>
25 + <%= c_name + "\n"%>
26 +
27 + </strong>
28 + </font>
29 +
30 +
31 + <font size=5em>
32 + <table border="5" bordercolor="blue">
33 + <tbody>
34 +
35 +
36 +
37 +
38 +
39 + <tr>
40 + <td> <%= "체력 : "+c_stats[0]+"+ lev*" + c_stats[1]%></td>
41 + <td> <%= "마력 : "+c_stats[2]+"+ lev*" + c_stats[3]%></td>
42 + </tr>
43 +
44 +
45 + <tr>
46 + <td> <%= "체력자연회복량 : "+c_stats[10]+"+ lev*" + c_stats[11]%></td>
47 + <td> <%= "마력자연회복량 : "+c_stats[12]+"+ lev*" + c_stats[13]%></td>
48 + </tr>
49 +
50 + <tr>
51 + <td> <%= "방어력 : "+c_stats[5]+"+ lev*" + c_stats[6]%></td>
52 + <td> <%= "마법방어력 : "+c_stats[7]+"+ lev*" + c_stats[8]%></td>
53 + </tr>
54 +
55 + <tr>
56 + <td> <%= "공격력 : "+c_stats[16]+"+ lev*" + c_stats[17]%></td>
57 + <td> <%= "공격속도 : "+c_stats[19]+"+ lev*" + c_stats[18]+"%"%></td>
58 + </tr>
59 +
60 + <tr>
61 + <td> <%= "이동속도 : "+c_stats[4]%></td>
62 +
63 + <td> <%= "사정거리 : "+c_stats[9]%></td>
64 + </tr>
65 +
66 +
67 + <tr><td> <%= "치명타 : "+c_stats[14]+"+ lev*" + c_stats[15]%></td>
68 + <td> </td>
69 + </tr>
70 +
71 +
72 + <br></br>
73 +
74 +
75 +
76 +
77 + </tbody>
78 + </table>
79 + <br></br>
80 + <p>
81 + <%= c_blb %>
82 + </p>
83 + </font>
84 +
85 +
86 +
87 +
88 +
89 +</body>
90 +</html>
...@@ -11,17 +11,13 @@ ...@@ -11,17 +11,13 @@
11 <style> @import url("http://fonts.googleapis.com/earlyaccess/nanumgothic.css");</style> 11 <style> @import url("http://fonts.googleapis.com/earlyaccess/nanumgothic.css");</style>
12 <script> 12 <script>
13 $(document).ready(function(){ 13 $(document).ready(function(){
14 - $("#enter").on("keypress",function(event){ 14 +
15 - if(event.keyCode==13){
16 - var name = $("input").val();
17 - location.href = "http://localhost:3000/search/" + name;
18 - }
19 - });
20 15
21 $("button#searchButton").click(function(){ 16 $("button#searchButton").click(function(){
22 var name = $("input").val(); 17 var name = $("input").val();
23 location.href = "http://localhost:3000/search/" + name; 18 location.href = "http://localhost:3000/search/" + name;
24 }) 19 })
20 +
25 }); 21 });
26 </script> 22 </script>
27 </head> 23 </head>
...@@ -49,10 +45,13 @@ ...@@ -49,10 +45,13 @@
49 <%= c_summoner + "\n"%> 45 <%= c_summoner + "\n"%>
50 </strong> 46 </strong>
51 </font> 47 </font>
48 + <font size=5em>
49 +
52 50
53 <table class="basic"> 51 <table class="basic">
54 <tbody> 52 <tbody>
55 <tr><td> <img src= <%=c_profile%> width=120, height=120></td></tr> 53 <tr><td> <img src= <%=c_profile%> width=120, height=120></td></tr>
54 + <tr><td> <%= "소환사 레벨 : "+c_summonerlev%></td></tr>
56 <tr><td> <img src= <%=c_imgtier%> width=120, height=120></td></tr> 55 <tr><td> <img src= <%=c_imgtier%> width=120, height=120></td></tr>
57 <tr><td><%= "Tier : " + c_tier + " " + c_rank + " / " + c_leaguePoint + "점"%></td></tr> 56 <tr><td><%= "Tier : " + c_tier + " " + c_rank + " / " + c_leaguePoint + "점"%></td></tr>
58 <tr><td><%= "Win : " + c_wins + " / Lose : " + c_losses%></td></tr> 57 <tr><td><%= "Win : " + c_wins + " / Lose : " + c_losses%></td></tr>
...@@ -107,9 +106,12 @@ ...@@ -107,9 +106,12 @@
107 <% for (var i=0; i<c_id.length-1; i++){ %> 106 <% for (var i=0; i<c_id.length-1; i++){ %>
108 <div class="champImage"> 107 <div class="champImage">
109 <div class="center"> 108 <div class="center">
110 - <img src= <%=c_pic[i]%> width=50, height=50> 109 +
110 + <input type="image" src=<%=c_pic[i]%> onClick="location.href='http://localhost:3000/data/'+ '<%=c_name[i]%>'">
111 +
112 +
111 <B> 113 <B>
112 - <%= c_name[i] %> 114 + <%= c_korname[i] %>
113 </B> 115 </B>
114 <%= "point: " + c_point[i]+ " \tchampion level: " + c_lev[i] %> 116 <%= "point: " + c_point[i]+ " \tchampion level: " + c_lev[i] %>
115 117
...@@ -118,5 +120,6 @@ ...@@ -118,5 +120,6 @@
118 120
119 121
120 </div> 122 </div>
123 +</font>
121 </body> 124 </body>
122 </html> 125 </html>
......
...@@ -11,12 +11,7 @@ ...@@ -11,12 +11,7 @@
11 <style> @import url("http://fonts.googleapis.com/earlyaccess/nanumgothic.css");</style> 11 <style> @import url("http://fonts.googleapis.com/earlyaccess/nanumgothic.css");</style>
12 <script> 12 <script>
13 $(document).ready(function(){ 13 $(document).ready(function(){
14 - $("#enter").on("keypress",function(event){ 14 +
15 - if(event.keyCode==13){
16 - var name = $("input").val();
17 - location.href = "http://localhost:3000/search/" + name;
18 - }
19 - });
20 15
21 $("button#searchButton").click(function(){ 16 $("button#searchButton").click(function(){
22 var name = $("input").val(); 17 var name = $("input").val();
......