김환

merge

......@@ -5,6 +5,7 @@ var urlenconde = require('urlencode');
var apikey = "RGAPI-0c7096fc-2511-4654-a889-40879eae0370"//api
var profileIconId; //아이콘 번호
var revisionDate; //수정날짜
var id; //소환사ID
......@@ -16,7 +17,66 @@ var rotation_champ = new Array();
app.get('/', function(req, res) {
res.render('main', { title: 'R U TROLL?' });
});
app.get('/data/:championname',function(req,res,net){
var champ_name=req.params.championname;
var champUrl = "https://kr.api.riotgames.com/lol/champion-mastery/v4/champion-masteries/by-summoner/" + urlenconde(id) + "?api_key=" + apikey;
request(champUrl,function(error,response,body){
var info_champ_json = JSON.parse(body);
var champ_id = new Array();
var champions_length = Object.keys(info_champ_json).length;
var staticUrl = "http://ddragon.leagueoflegends.com/cdn/10.23.1/data/ko_KR/champion.json";
var title;
var blub;
var champ_stats=new Array();
var champ_pic;
var champ_kor;
request(staticUrl,function(error,response,body){
var info_static_champ_json = JSON.parse(body);
var champion = info_static_champ_json["data"];
for(js in champion){
for(j in champion[js]){
if(champion[js]["id"]==champ_name){
title=champion[js]["title"];
blub=champion[js]["blurb"];
champ_kor=champion[js]["name"];
champ_pic = "http://ddragon.leagueoflegends.com/cdn/10.23.1/img/champion/"+champ_name+".png";
champ_stats[0]=champion[js]["stats"]["hp"];
champ_stats[1]=champion[js]["stats"]["hpperlevel"];
champ_stats[2]=champion[js]["stats"]["mp"];
champ_stats[3]=champion[js]["stats"]["mpperlevel"];
champ_stats[4]=champion[js]["stats"]["movespeed"];
champ_stats[5]=champion[js]["stats"]["armor"];
champ_stats[6]=champion[js]["stats"]["armorperlevel"];
champ_stats[7]=champion[js]["stats"]["spellblock"];
champ_stats[8]=champion[js]["stats"]["spellblockperlevel"];
champ_stats[9]=champion[js]["stats"]["attackrange"];
champ_stats[10]=champion[js]["stats"]["hpregen"];
champ_stats[11]=champion[js]["stats"]["hpregenperlevel"];
champ_stats[12]=champion[js]["stats"]["mpregen"];
champ_stats[13]=champion[js]["stats"]["mpregenperlevel"];
champ_stats[14]=champion[js]["stats"]["crit"];
champ_stats[15]=champion[js]["stats"]["critperlevel"];
champ_stats[16]=champion[js]["stats"]["attackdamage"];
champ_stats[17]=champion[js]["stats"]["attackdamageperlevel"];
champ_stats[18]=champion[js]["stats"]["attackspeedperlevel"];
champ_stats[19]=champion[js]["stats"]["attackspeed"];
}
}
}
res.render('data',{
c_blb:blub,
c_title:title,
c_stats:champ_stats,
c_pic:champ_pic,
c_name:champ_kor
})
})
})
})
app.get('/search/:username/', function(req, res, next){
//롤 api url
name = req.params.username;
......@@ -34,22 +94,28 @@ var rotation_champ = new Array();
var info_summoner_json = JSON.parse(body);
accountId = info_summoner_json["accountId"]; // GZC51rstNY47-cmgcap94mfLe7JNjF1fz3dGAdwS6pEo
id = info_summoner_json["id"]; // T6cI_Zn5LEqyPuhCZz1do0Y-IJztJX1I1mvcQZRt9YKygA
summoner = info_summoner_json["name"]; // 환하다 추야
profileIconId = info_summoner_json["profileIconId"]; // 980
summonerLevel = info_summoner_json["summonerLevel"]; // 250
revisionDate = info_summoner_json["revisionDate"]; // 1605519790000
accountId = info_summoner_json["accountId"];
id = info_summoner_json["id"];
summoner = info_summoner_json["name"];
profileIconId = info_summoner_json["profileIconId"];
summonerLevel = info_summoner_json["summonerLevel"];
revisionDate = info_summoner_json["revisionDate"];
var profileUrl="http://ddragon.leagueoflegends.com/cdn/10.23.1/img/profileicon/";
request(profileUrl,function(error,response,body){
var profileIcon;
profileIcon="http://ddragon.leagueoflegends.com/cdn/10.23.1/img/profileicon/"+profileIconId+".png";
var champUrl = "https://kr.api.riotgames.com/lol/champion-mastery/v4/champion-masteries/by-summoner/" + urlenconde(id) + "?api_key=" + apikey;
request(champUrl,function(error,response,body){
var info_champ_json = JSON.parse(body);
var champ_point = new Array();
var champ_id = new Array();
var champ_name = new Array();
var champ_korname=new Array();
var rotation_name = new Array();
var champ_pic = new Array();
var rotation_pic =new Array();
var champ_level=new Array();//숙련도 레벨
var champions_length = Object.keys(info_champ_json).length;
//console.log("\n\ninfo_champ_json\n\n", info_champ_json);
......@@ -66,7 +132,7 @@ var rotation_champ = new Array();
for(var i=0; i < champions_length; i++){
champ_point[i] = (info_champ_json[i]["championPoints"]);
champ_id[i] = info_champ_json[i]["championId"];
champ_level[i]=info_champ_json[i]["championLevel"]
}
var rotationUrl = "https://kr.api.riotgames.com/lol/platform/v3/champion-rotations?api_key="+apikey;
request(rotationUrl,function(error,response,body){
......@@ -81,9 +147,9 @@ var rotation_champ = new Array();
var staticUrl = "http://ddragon.leagueoflegends.com/cdn/10.23.1/data/en_US/champion.json";
var staticUrl = "http://ddragon.leagueoflegends.com/cdn/10.23.1/data/ko_KR/champion.json";
request(staticUrl,function(error,response,body){
var info_static_champ_json = JSON.parse(body);
var champion = info_static_champ_json["data"];
......@@ -92,6 +158,7 @@ var rotation_champ = new Array();
for(j in champion[js]){
if(champion[js]["key"] == champ_id[i]){
champ_name[i] = champion[js]["id"];
champ_korname[i]=champion[js]["name"];
champ_pic[i] = "http://ddragon.leagueoflegends.com/cdn/10.23.1/img/champion/"+champ_name[i]+".png";
}
......@@ -180,17 +247,21 @@ var rotation_champ = new Array();
var temp_name;
var temp_point;
var temp_pic;
var temp_chamlev;
for(var i=0; i < champ_id.length-1; i++){//챔피언 포인트 순으로 sorting
for(var j=i+1;j <champ_id.length-1; j++)
if(champ_point[i] < champ_point[j]){
temp_chamlev=champ_level[i];
temp_id = champ_id[i];
temp_name = champ_name[i];
temp_point = champ_point[i];
temp_pic = champ_pic[i];
champ_level[i]=champ_level[j];
champ_id[i] = champ_id[j]
champ_name[i] = champ_name[j];
champ_point[i] = champ_point[j];
champ_pic[i] = champ_pic[j];
champ_level[j]=champ_level[i];
champ_id[j] = temp_id
champ_name[j] = temp_name;
champ_point[j] = temp_point;
......@@ -229,8 +300,12 @@ var rotation_champ = new Array();
res.render('index', { title: req.params.username ,//데이터를 ejs로 넘길 때 사용
c_lev: champ_level,
c_summonerlev: summonerLevel,
c_profile: profileIcon,
c_id: champ_id,
c_name: champ_name,
c_korname: champ_korname,
c_point: champ_point,
c_pic: champ_pic,
c_rotation : rotation_pic,
......@@ -252,6 +327,7 @@ var rotation_champ = new Array();
});
});
});
});
});
});
};
......
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<link rel="icon" href = "FindMelogo.png">
<link rel="stylesheet" href="css/style.css">
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.2/css/bootstrap.min.css">
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.2/css/bootstrap-theme.min.css">
<script src="https://code.jquery.com/jquery-3.2.1.min.js" integrity="sha256-hwg4gsxgFZhOsEEamdOYGBf13FyQuiTwlAQgxVSNgt4=" crossorigin="anonymous"></script>
<style> @import url("http://fonts.googleapis.com/earlyaccess/nanumgothic.css");</style>
<script>
</script>
</head>
<body>
<img src= <%=c_pic%> width=300, height=300>
<font size=10em>
<strong>
<%= c_title +"\n"%>
<%= c_name + "\n"%>
</strong>
</font>
<font size=5em>
<table border="5" bordercolor="blue">
<tbody>
<tr>
<td> <%= "체력 : "+c_stats[0]+"+ lev*" + c_stats[1]%></td>
<td> <%= "마력 : "+c_stats[2]+"+ lev*" + c_stats[3]%></td>
</tr>
<tr>
<td> <%= "체력자연회복량 : "+c_stats[10]+"+ lev*" + c_stats[11]%></td>
<td> <%= "마력자연회복량 : "+c_stats[12]+"+ lev*" + c_stats[13]%></td>
</tr>
<tr>
<td> <%= "방어력 : "+c_stats[5]+"+ lev*" + c_stats[6]%></td>
<td> <%= "마법방어력 : "+c_stats[7]+"+ lev*" + c_stats[8]%></td>
</tr>
<tr>
<td> <%= "공격력 : "+c_stats[16]+"+ lev*" + c_stats[17]%></td>
<td> <%= "공격속도 : "+c_stats[19]+"+ lev*" + c_stats[18]+"%"%></td>
</tr>
<tr>
<td> <%= "이동속도 : "+c_stats[4]%></td>
<td> <%= "사정거리 : "+c_stats[9]%></td>
</tr>
<tr><td> <%= "치명타 : "+c_stats[14]+"+ lev*" + c_stats[15]%></td>
<td> </td>
</tr>
<br></br>
</tbody>
</table>
<br></br>
<p>
<%= c_blb %>
</p>
</font>
</body>
</html>
......@@ -12,18 +12,19 @@
<script>
$(document).ready(function(){
$("button#searchButton").click(function(){
var name = $("input").val();
location.href = "http://localhost:3000/search/" + name;
})
});
</script>
</head>
<body>
<div class="imgOpacity">
<div class="center">
<img src= "/FindMelogo.png" width = 150, height = 150/>
......@@ -127,11 +128,21 @@
<% for (var i=0; i<6; i++){ %>
<div class="champImage">
<div class="center">
<img src= <%=c_pic[i]%> width=50, height=50>
<%= c_name[i] %>
<%= "point: " + c_point[i] %>
<input type="image" src=<%=c_pic[i]%> onClick="location.href='http://localhost:3000/data/'+ '<%=c_name[i]%>'">
<B>
<%= c_korname[i] %>
</B>
<%= "point: " + c_point[i]+ " \tchampion level: " + c_lev[i] %>
<% } %>
</div>
</div>
</div>
</font>
</body>
</html>
......
......@@ -11,16 +11,18 @@
<style> @import url("http://fonts.googleapis.com/earlyaccess/nanumgothic.css");</style>
<script>
$(document).ready(function(){
$("button#searchButton").click(function(){
var name = $("input").val();
location.href = "http://localhost:3000/search/" + name;
})
});
</script>
</head>
<body>
<div class="imgOpacity">
<div class="center">
<img src= "FindMelogo.png" width = 300, height = 300/>
......