Toggle navigation
Toggle navigation
This project
Loading...
Sign in
허연우
/
FindMe.GG
Go to a project
Toggle navigation
Toggle navigation pinning
Projects
Groups
Snippets
Help
Project
Activity
Repository
Pipelines
Graphs
Issues
0
Merge Requests
0
Wiki
Snippets
Network
Create a new issue
Builds
Commits
Issue Boards
Authored by
LIANG XIAOTONG
2022-11-24 23:08:45 +0900
Browse Files
Options
Browse Files
Download
Email Patches
Plain Diff
Commit
cef00772e9d419c95b2dd9a3ed0d1efbe6d24665
cef00772
1 parent
af6b59bc
api1,2 completed, index.ejs modified
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
59 additions
and
152 deletions
RUTROLL/app.js
RUTROLL/router/main.js
RUTROLL/views/index.ejs
RUTROLL/app.js
View file @
cef0077
var
express
=
require
(
'express'
);
var
app
=
express
();
var
router
=
require
(
'./router/
Test
'
)(
app
);
var
router
=
require
(
'./router/
main
'
)(
app
);
var
bodyParser
=
require
(
'body-parser'
);
app
.
set
(
'views'
,
__dirname
+
'/views'
);
...
...
RUTROLL/router/main.js
View file @
cef0077
module
.
exports
=
function
(
app
)
{
module
.
exports
=
function
(
app
)
{
var
request
=
require
(
"request"
);
var
urlenconde
=
require
(
'urlencode'
);
var
apikey
=
"RGAPI-df870784-f399-4104-bfbb-1b209aeb597f
"
//api
var
request
=
require
(
"request"
);
var
urlenconde
=
require
(
'urlencode'
);
var
apikey
=
"RGAPI-899abd44-2f7c-4e2d-981e-7cad9e50d1cb
"
//api
var
profileIconId
;
//아이콘 번호
var
revisionDate
;
//수정날짜
var
id
;
//소환사ID
var
accountId
;
//계정Id
var
name
;
//소환사 이름
var
summonerLevel
;
//소환사 레벨
var
startIndex
;
var
endIndex
;
var
totalGames
;
var
matches
;
//경기정보
app
.
get
(
'/'
,
function
(
req
,
res
)
{
app
.
get
(
'/'
,
function
(
req
,
res
)
{
res
.
render
(
'main'
,
{
title
:
'R U TROLL?'
});
});
app
.
get
(
'/search/:username/'
,
function
(
req
,
res
)
{
app
.
get
(
'/search/:username/'
,
function
(
req
,
res
)
{
//롤 api url
name
=
req
.
params
.
username
;
var
nameUrl
=
"https://kr.api.riotgames.com/lol/summoner/v3/summoners/by-name/"
+
urlenconde
(
name
)
+
"?api_key="
+
apikey
;
request
(
nameUrl
,
function
(
error
,
response
,
body
){
var
info_summoner_json
=
JSON
.
parse
(
body
);
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
rankedUrl
=
"https://kr.api.pvp.net/api/lol/kr/v2.5/league/by-summoner/"
+
urlenconde
(
id
)
+
"?api_key="
+
apikey
;
var
champUrl
=
"https://kr.api.pvp.net/api/lol/kr/v1.3/stats/by-summoner/"
+
urlenconde
(
id
)
+
"/ranked?api_key="
+
apikey
;
request
(
champUrl
,
function
(
error
,
response
,
body
){
var
info_champ_json
=
JSON
.
parse
(
body
);
var
champions
=
info_champ_json
[
"champions"
];
var
champ_point
=
new
Array
();
var
champ_id
=
new
Array
();
var
champ_name
=
new
Array
();
var
champ_pic
=
new
Array
();
var
champions_length
=
Object
.
keys
(
champions
).
length
;
for
(
var
i
=
0
;
i
<
champions_length
;
i
++
){
champ_point
[
i
]
=
(
champions
[
i
][
"stats"
][
"totalSessionsWon"
]
/
champions
[
i
][
"stats"
][
"totalSessionsPlayed"
]
*
200
)
+
((
champions
[
i
][
"stats"
][
"totalAssists"
]
+
champions
[
i
][
"stats"
][
"totalChampionKills"
])
/
champions
[
i
][
"stats"
][
"totalDeathsPerSession"
]
*
100
)
+
(
champions
[
i
][
"stats"
][
"totalSessionsPlayed"
]
*
3
);
champ_id
[
i
]
=
champions
[
i
][
"id"
];
}
var
staticUrl
=
"https://global.api.pvp.net/api/lol/static-data/kr/v1.2/champion/?api_key="
+
apikey
;
request
(
staticUrl
,
function
(
error
,
response
,
body
){
var
info_static_champ_json
=
JSON
.
parse
(
body
);
var
champion
=
info_static_champ_json
[
"data"
];
for
(
var
i
=
0
;
i
<
champ_id
.
length
;
i
++
){
for
(
js
in
champion
){
for
(
j
in
champion
[
js
]){
if
(
champion
[
js
][
"id"
]
==
champ_id
[
i
]){
champ_name
[
i
]
=
champion
[
js
][
"key"
];
champ_pic
[
i
]
=
"https://opgg-static.akamaized.net/images/lol/champion/"
+
champ_name
[
i
]
+
".png?image=c_scale,w_46"
;
}
}
}
}
champ_name
[
champ_name
.
length
]
=
"total"
;
var
temp_id
;
var
temp_name
;
var
temp_point
;
var
temp_pic
;
for
(
var
i
=
0
;
i
<
champ_id
.
length
-
1
;
i
++
){
for
(
var
j
=
i
+
1
;
j
<
champ_id
.
length
-
1
;
j
++
)
if
(
champ_point
[
i
]
>
champ_point
[
j
]){
temp_id
=
champ_id
[
i
];
temp_name
=
champ_name
[
i
];
temp_point
=
champ_point
[
i
];
temp_pic
=
champ_pic
[
i
];
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_id
[
j
]
=
temp_id
champ_name
[
j
]
=
temp_name
;
champ_point
[
j
]
=
temp_point
;
champ_pic
[
j
]
=
temp_pic
;
}
}
const
summonerName
=
req
.
params
.
username
;
var
nameUrl
=
`https://kr.api.riotgames.com/tft/summoner/v1/summoners/by-name/
${
summonerName
}
?api_key=
${
apikey
}
`
request
(
nameUrl
,
function
(
error
,
response
,
body
)
{
res
.
render
(
'index'
,
{
title
:
req
.
params
.
username
,
c_id
:
champ_id
,
c_name
:
champ_name
,
c_point
:
champ_point
,
c_pic
:
champ_pic
,
c_summoner
:
summoner
var
info_summoner_json
=
JSON
.
parse
(
body
);
console
.
log
(
'summoner'
,
body
);
if
(
info_summoner_json
.
status
?.
status_code
)
{
return
res
.
render
(
'index'
,
{
title
:
req
.
params
.
username
,
error_message
:
info_summoner_json
.
status
?.
message
});
}
const
summonerId
=
info_summoner_json
[
"id"
];
const
summoner
=
info_summoner_json
[
"name"
];
const
leagueUrl
=
`https://kr.api.riotgames.com/tft/league/v1/entries/by-summoner/
${
summonerId
}
?api_key=
${
apikey
}
`
;
request
(
leagueUrl
,
function
(
error
,
response
,
body
)
{
const
info_league_json
=
JSON
.
parse
(
body
);
console
.
log
(
'league'
,
body
);
res
.
render
(
'index'
,
{
title
:
req
.
params
.
username
,
error_message
:
false
,
c_summoner
:
summoner
,
c_leagueList
:
info_league_json
});
});
});
...
...
RUTROLL/views/index.ejs
View file @
cef0077
...
...
@@ -35,77 +35,47 @@
</div>
</div>
<br></br>
<
% if (error_message) { %>
<h2>
<
%= error_message %>
</h2>
<
% } else { %>
<font
size=
10em
>
<strong>
<
%= c_summoner + "\n"%>
</strong>
</font>
<table
class=
"basic"
>
<table
class=
"table"
>
<thead>
<tr>
<th>
Tier
</th>
<th>
Win
</th>
<th>
Lose
</th>
<th>
승률
</th>
<th>
캐리력
</th>
</tr>
</thead>
<
% if (c_leagueList.length>0) { %>
<tbody>
<tr><td>
<img
src=
<%=c_imgtier%
>
width=120, height=120>
</td></tr>
<tr><td>
<
%= "Tier : " + c_tier + " " + c_rank + " / " + c_leaguePoint + "점"%>
</td></tr>
<tr><td>
<
%= "Win : " + c_wins + " / Lose : " + c_losses%>
</td></tr>
<tr><td>
<
%= "승률 : " + ((c_wins/(c_wins+c_losses))*100).toFixed(2) + "%" %>
</td></tr>
<tr><td>
<
%= "캐리력 : " + (c_wins/c_losses*2).toFixed(2) %>
</td></tr>
<
%
c_leagueList.forEach(function(league){ %>
<tr>
<td>
<
%= league.tier + " " + league.rank + " / " + league.leaguePoints + "점"%>
</td>
<td>
<
%= league.wins %>
</td>
<td>
<
%= league.losses %>
</td>
<td>
<
%= ((league.wins/(league.wins+league.losses))*100).toFixed(2) + "%" %>
</td>
<td>
<
%= (league.wins/league.losses*2).toFixed(2) %>
</td>
</tr>
<
% }); %>
</tbody>
<
% } else { %>
<tbody>
<tr
>
<td
colspan=
"5"
style=
"text-align: center;"
>
no league
</td>
</tr>
</tbody>
</table>
<br></br>
<div
class=
"center"
>
<strong>
<
%= "로테이션 챔피언: " %>
</strong>
<
% for (var i=0; i
<c
_rotation
.
length-1
;
i
++){
%
>
<img
src=
<%=c_rotation[i]%
>
width=50, height=50>
<
% } %>
</div>
<br></br>
</div>
<div
class=
"center"
>
<strong>
<
%= "추측 MMR:" %>
<
%if (c_tier=="SILVER") {%>
<
%="1200~1500"%>
<
%}%>
<
%if (c_tier=="GOLD") {%>
<
%="1500~1800"%>
<
%}%>
<
%if (c_tier=="PLATINUM") {%>
<
%="1800~2100"%>
<
%}%>
<
%if (c_tier=="DIAMOND") {%>
<
%="2100~2400"%>
<
%}%>
<
%if (c_tier=="MASTER") {%>
<
%="2400~2600"%>
<
%}%>
<
%if (c_tier=="GRANDMASTER") {%>
<
%="2600~2800"%>
<
%}%>
<
%if (c_tier=="CHALLENGER") {%>
<
%=">3000"%>
<
%}%>
</strong>
</div>
<
% for (var i=0; i
<c
_id
.
length-1
;
i
++){
%
>
<div
class=
"champImage"
>
<div
class=
"center"
>
<img
src=
<%=c_pic[i]%
>
width=50, height=50>
<
%= c_name[i] %>
<
%= "point: " + (1000000/c_point[i]).toFixed(2) %>
</table>
<
% } %>
</div>
</div>
</body>
</html>
...
...
Please
register
or
login
to post a comment