황성연

SPECTATOR-V4 api 추가

......@@ -93,11 +93,19 @@ module.exports = function(app){
var staticUrl = "http://ddragon.leagueoflegends.com/cdn/10.11.1/data/en_US/champion.json";
request(staticUrl,function(error,response,body) {
var info_static_champ_json = JSON.parse(body);
console.log(info_static_champ_json);
console.log(info_static_champ_json.data);
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]){
var champ_count = 0;
for(var name in champion) {
if(champion.hasOwnProperty(name)) {
champ_count++;
}
}
for(var i=0; i < champ_count; i++){
for(js in champion) {
for(j in champion[js]) {
if(champion[js]["key"] == champ_id[i]){
champ_name[i] = champion[js]["id"];
champ_pic[i] = "http://ddragon.leagueoflegends.com/cdn/10.11.1/img/champion/"+champ_name[i]+".png";
......@@ -106,7 +114,7 @@ module.exports = function(app){
}
}
}
for(var i=0; i < champ_id.length; i++){
for(var i=0; i < champ_count; i++){
for(js in champion){
for(j in champion[js]){
if(champion[js]["key"] == rotation_champ[i]){
......@@ -122,7 +130,7 @@ module.exports = function(app){
}
console.log(rotation_name);
console.log("챔프길이:"+champ_pic.length);
console.log("챔프길이:" + champ_count);
var userLeagueUrl = "https://kr.api.riotgames.com/lol/league/v4/entries/by-summoner/"+ urlenconde(id)+"?api_key=" + apikey;
request(userLeagueUrl,function(error,response,body){
......@@ -211,8 +219,13 @@ module.exports = function(app){
var spectatorUrl = "https://kr.api.riotgames.com/lol/spectator/v4/active-games/by-summoner/" + urlenconde(id) + "?api_key=" + apikey;
request(spectatorUrl,function(error,response,body) {
var spectator_json = JSON.parse(body);
var flag = true;
if(response.statusCode != 200)
flag = false;
if(flag) {
var spectator_json = JSON.parse(body);
console.log(spectator_json);
var spec_bannedChamp = spectator_json.bannedChampions;
var spec_gameId = spectator_json.gameId;
......@@ -222,6 +235,33 @@ module.exports = function(app){
var spec_mapId = spectator_json.mapId;
var spec_participants = spectator_json.participants;
// var spec_bannedChamp_Id = new Array();
var spec_bannedChamp_image = new Array();
var spec_selectedChamp_image = new Array();
for(var i=0; i<10; i++) {
if((spec_bannedChamp[i]).championId == -1)
continue;
for(var key in champion) {
if(champion.hasOwnProperty(key) && champion[key].key == spec_bannedChamp[i].championId) {
spec_bannedChamp_image.push("http://ddragon.leagueoflegends.com/cdn/10.11.1/img/champion/"+champion[key].id+".png");
}
if(champion.hasOwnProperty(key) && champion[key].key == spec_participants[i].championId) {
spec_selectedChamp_image.push("http://ddragon.leagueoflegends.com/cdn/10.11.1/img/champion/"+champion[key].id+".png");
}
}
}
console.log(spec_bannedChamp_image);
console.log(spec_selectedChamp_image);
}
......