황성연

예외 처리

...@@ -268,6 +268,8 @@ module.exports = function(app){ ...@@ -268,6 +268,8 @@ module.exports = function(app){
268 }; 268 };
269 } 269 }
270 270
271 +
272 + // 게임정보 불러오기
271 var matchUrl = "https://kr.api.riotgames.com/lol/match/v4/matchlists/by-account/" + accountId + "?api_key=" + apikey; 273 var matchUrl = "https://kr.api.riotgames.com/lol/match/v4/matchlists/by-account/" + accountId + "?api_key=" + apikey;
272 request(matchUrl,function(error,response,body) { 274 request(matchUrl,function(error,response,body) {
273 var match_json = JSON.parse(body).matches; 275 var match_json = JSON.parse(body).matches;
...@@ -276,9 +278,15 @@ module.exports = function(app){ ...@@ -276,9 +278,15 @@ module.exports = function(app){
276 var match_gameId = new Array(); 278 var match_gameId = new Array();
277 var match_mychamp = new Array(); 279 var match_mychamp = new Array();
278 280
279 - for(var i=0; i<5; i++){ 281 + var count=0 , idx=0;
280 - match_gameId.push(match_json[i].gameId); 282 + while(count<5){
281 - match_mychamp.push(match_json[i].champion); 283 + // 420 : 5x5 솔로랭크, 440 : 5x5 자유랭크
284 + if(match_json[idx].queue == 420 || match_json[idx].queue == 440){
285 + match_gameId.push(match_json[idx].gameId);
286 + match_mychamp.push(match_json[idx].champion);
287 + count++;
288 + }
289 + idx++;
282 } 290 }
283 291
284 // teamId: 100 = Blue , teamId:200 = Red 292 // teamId: 100 = Blue , teamId:200 = Red
...@@ -347,8 +355,6 @@ module.exports = function(app){ ...@@ -347,8 +355,6 @@ module.exports = function(app){
347 "kda" : match1_kda 355 "kda" : match1_kda
348 }; 356 };
349 357
350 - console.log(match1);
351 -
352 var match2Url = "https://kr.api.riotgames.com/lol/match/v4/matches/" + match_gameId[1] + "?api_key=" + apikey; 358 var match2Url = "https://kr.api.riotgames.com/lol/match/v4/matches/" + match_gameId[1] + "?api_key=" + apikey;
353 request(match2Url,function(error,response,body){ 359 request(match2Url,function(error,response,body){
354 var match2_json = JSON.parse(body); 360 var match2_json = JSON.parse(body);
...@@ -414,7 +420,6 @@ module.exports = function(app){ ...@@ -414,7 +420,6 @@ module.exports = function(app){
414 "kda" : match2_kda 420 "kda" : match2_kda
415 }; 421 };
416 422
417 - console.log(match2);
418 423
419 var match3Url = "https://kr.api.riotgames.com/lol/match/v4/matches/" + match_gameId[2] + "?api_key=" + apikey; 424 var match3Url = "https://kr.api.riotgames.com/lol/match/v4/matches/" + match_gameId[2] + "?api_key=" + apikey;
420 request(match3Url,function(error,response,body){ 425 request(match3Url,function(error,response,body){
...@@ -481,7 +486,6 @@ module.exports = function(app){ ...@@ -481,7 +486,6 @@ module.exports = function(app){
481 "kda" : match3_kda 486 "kda" : match3_kda
482 }; 487 };
483 488
484 - console.log(match3);
485 489
486 var match4Url = "https://kr.api.riotgames.com/lol/match/v4/matches/" + match_gameId[3] + "?api_key=" + apikey; 490 var match4Url = "https://kr.api.riotgames.com/lol/match/v4/matches/" + match_gameId[3] + "?api_key=" + apikey;
487 request(match4Url,function(error,response,body){ 491 request(match4Url,function(error,response,body){
...@@ -548,7 +552,6 @@ module.exports = function(app){ ...@@ -548,7 +552,6 @@ module.exports = function(app){
548 "kda" : match4_kda 552 "kda" : match4_kda
549 }; 553 };
550 554
551 - console.log(match4);
552 555
553 var match5Url = "https://kr.api.riotgames.com/lol/match/v4/matches/" + match_gameId[4] + "?api_key=" + apikey; 556 var match5Url = "https://kr.api.riotgames.com/lol/match/v4/matches/" + match_gameId[4] + "?api_key=" + apikey;
554 request(match5Url,function(error,response,body){ 557 request(match5Url,function(error,response,body){
...@@ -615,10 +618,6 @@ module.exports = function(app){ ...@@ -615,10 +618,6 @@ module.exports = function(app){
615 "kda" : match5_kda 618 "kda" : match5_kda
616 }; 619 };
617 620
618 - console.log(match5);
619 -
620 -
621 -
622 var summoner_info = { 621 var summoner_info = {
623 "summoner_Name" : summoner, 622 "summoner_Name" : summoner,
624 "summoner_tierimage" : img_tier, 623 "summoner_tierimage" : img_tier,
...@@ -628,7 +627,7 @@ module.exports = function(app){ ...@@ -628,7 +627,7 @@ module.exports = function(app){
628 "summoner_wins" : wins, 627 "summoner_wins" : wins,
629 "summoner_losses" : losses, 628 "summoner_losses" : losses,
630 "summoner_winrate" : ((wins/(wins+losses))*100).toFixed(2), 629 "summoner_winrate" : ((wins/(wins+losses))*100).toFixed(2),
631 - "summoner_carry" : (win/losses*2).toFixed(2) 630 + "summoner_carry" : (wins/losses*2).toFixed(2)
632 }; 631 };
633 632
634 var rotation_info = { 633 var rotation_info = {
...@@ -636,7 +635,19 @@ module.exports = function(app){ ...@@ -636,7 +635,19 @@ module.exports = function(app){
636 "rotation_image_newbie" : rotation_pic_newbie 635 "rotation_image_newbie" : rotation_pic_newbie
637 }; 636 };
638 637
638 + var total_info = {
639 + "Summoner_info" : summoner_info,
640 + "Rotation_info" : rotation_info,
641 + "Spectator_flag" : flag,
642 + "Spectator" : spectator,
643 + "Match1" : match1,
644 + "Match2" : match2,
645 + "Match3" : match3,
646 + "Match4" : match4,
647 + "Match5" : match5
648 + };
639 649
650 + console.log(total_info);
640 651
641 652
642 res.render('index', { title: req.params.username , 653 res.render('index', { title: req.params.username ,
......