diff options
Diffstat (limited to 'app/controllers')
-rw-r--r-- | app/controllers/matches_controller.rb | 144 |
1 files changed, 72 insertions, 72 deletions
diff --git a/app/controllers/matches_controller.rb b/app/controllers/matches_controller.rb index 1604564..59b354d 100644 --- a/app/controllers/matches_controller.rb +++ b/app/controllers/matches_controller.rb @@ -16,103 +16,103 @@ class MatchesController < ApplicationController tournament_matches_path(@tournament) end - def get_riot_info - if signed_in? - - pull = "Kaceytron" - #current user information - response = HTTParty.get("https://prod.api.pvp.net/api/lol/na/v1.3/summoner/by-name/#{pull.downcase}?api_key=ad539f86-22fd-474d-9279-79a7a296ac38") + def get_riot + end - id = response["#{pull.downcase}"]['id'] + def get_riot_info_fake + pull = "Kaceytron" + #current user information + response = HTTParty.get("https://prod.api.pvp.net/api/lol/na/v1.3/summoner/by-name/#{pull.downcase}?api_key=ad539f86-22fd-474d-9279-79a7a296ac38") - #recent game information - recent = HTTParty.get("https://prod.api.pvp.net/api/lol/na/v1.3/game/by-summoner/#{response["#{pull.downcase}"]['id']}/recent?api_key=ad539f86-22fd-474d-9279-79a7a296ac38") + id = response["#{pull.downcase}"]['id'] - game_id = recent["games"][0]["gameId"] + #recent game information + recent = HTTParty.get("https://prod.api.pvp.net/api/lol/na/v1.3/game/by-summoner/#{response["#{pull.downcase}"]['id']}/recent?api_key=ad539f86-22fd-474d-9279-79a7a296ac38") - #members of most recent game id's - player1 = recent["games"][0]["fellowPlayers"][0]["summonerId"] - player2 = recent["games"][0]["fellowPlayers"][1]["summonerId"] - player3 = recent["games"][0]["fellowPlayers"][2]["summonerId"] - player4 = recent["games"][0]["fellowPlayers"][3]["summonerId"] - player5 = recent["games"][0]["fellowPlayers"][4]["summonerId"] - player6 = recent["games"][0]["fellowPlayers"][5]["summonerId"] - player7 = recent["games"][0]["fellowPlayers"][6]["summonerId"] - player8 = recent["games"][0]["fellowPlayers"][7]["summonerId"] - player9 = recent["games"][0]["fellowPlayers"][8]["summonerId"] + game_id = recent["games"][0]["gameId"] - players_by_id = [player1, player2, player3, player4, player5, player6, player7, player8, player9] + #members of most recent game id's + player1 = recent["games"][0]["fellowPlayers"][0]["summonerId"] + player2 = recent["games"][0]["fellowPlayers"][1]["summonerId"] + player3 = recent["games"][0]["fellowPlayers"][2]["summonerId"] + player4 = recent["games"][0]["fellowPlayers"][3]["summonerId"] + player5 = recent["games"][0]["fellowPlayers"][4]["summonerId"] + player6 = recent["games"][0]["fellowPlayers"][5]["summonerId"] + player7 = recent["games"][0]["fellowPlayers"][6]["summonerId"] + player8 = recent["games"][0]["fellowPlayers"][7]["summonerId"] + player9 = recent["games"][0]["fellowPlayers"][8]["summonerId"] - #collect summoner names - memb1 = HTTParty.get("https://prod.api.pvp.net/api/lol/na/v1.3/summoner/#{player1}/name?api_key=ad539f86-22fd-474d-9279-79a7a296ac38") - memb1 = memb1["#{player1}"] - sleep(1); + players_by_id = [player1, player2, player3, player4, player5, player6, player7, player8, player9] - memb2 = HTTParty.get("https://prod.api.pvp.net/api/lol/na/v1.3/summoner/#{player2}/name?api_key=ad539f86-22fd-474d-9279-79a7a296ac38") - memb2 = memb2["#{player2}"] - sleep(1); + #collect summoner names + memb1 = HTTParty.get("https://prod.api.pvp.net/api/lol/na/v1.3/summoner/#{player1}/name?api_key=ad539f86-22fd-474d-9279-79a7a296ac38") + memb1 = memb1["#{player1}"] + sleep(1); - memb3 = HTTParty.get("https://prod.api.pvp.net/api/lol/na/v1.3/summoner/#{player3}/name?api_key=ad539f86-22fd-474d-9279-79a7a296ac38") - memb3 = memb3["#{player3}"] - sleep(1); + memb2 = HTTParty.get("https://prod.api.pvp.net/api/lol/na/v1.3/summoner/#{player2}/name?api_key=ad539f86-22fd-474d-9279-79a7a296ac38") + memb2 = memb2["#{player2}"] + sleep(1); - memb4 = HTTParty.get("https://prod.api.pvp.net/api/lol/na/v1.3/summoner/#{player4}/name?api_key=ad539f86-22fd-474d-9279-79a7a296ac38") - memb4 = memb4["#{player4}"] - sleep(1); + memb3 = HTTParty.get("https://prod.api.pvp.net/api/lol/na/v1.3/summoner/#{player3}/name?api_key=ad539f86-22fd-474d-9279-79a7a296ac38") + memb3 = memb3["#{player3}"] + sleep(1); - memb5 = HTTParty.get("https://prod.api.pvp.net/api/lol/na/v1.3/summoner/#{player5}/name?api_key=ad539f86-22fd-474d-9279-79a7a296ac38") - memb5 = memb5["#{player5}"] - sleep(1); + memb4 = HTTParty.get("https://prod.api.pvp.net/api/lol/na/v1.3/summoner/#{player4}/name?api_key=ad539f86-22fd-474d-9279-79a7a296ac38") + memb4 = memb4["#{player4}"] + sleep(1); - memb6 = HTTParty.get("https://prod.api.pvp.net/api/lol/na/v1.3/summoner/#{player6}/name?api_key=ad539f86-22fd-474d-9279-79a7a296ac38") - memb6 = memb6["#{player6}"] - sleep(1); + memb5 = HTTParty.get("https://prod.api.pvp.net/api/lol/na/v1.3/summoner/#{player5}/name?api_key=ad539f86-22fd-474d-9279-79a7a296ac38") + memb5 = memb5["#{player5}"] + sleep(1); - memb7 = HTTParty.get("https://prod.api.pvp.net/api/lol/na/v1.3/summoner/#{player7}/name?api_key=ad539f86-22fd-474d-9279-79a7a296ac38") - memb7 = memb7["#{player7}"] - sleep(1); + memb6 = HTTParty.get("https://prod.api.pvp.net/api/lol/na/v1.3/summoner/#{player6}/name?api_key=ad539f86-22fd-474d-9279-79a7a296ac38") + memb6 = memb6["#{player6}"] + sleep(1); - memb8 = HTTParty.get("https://prod.api.pvp.net/api/lol/na/v1.3/summoner/#{player8}/name?api_key=ad539f86-22fd-474d-9279-79a7a296ac38") - memb8 = memb8["#{player8}"] - sleep(1); + memb7 = HTTParty.get("https://prod.api.pvp.net/api/lol/na/v1.3/summoner/#{player7}/name?api_key=ad539f86-22fd-474d-9279-79a7a296ac38") + memb7 = memb7["#{player7}"] + sleep(1); - memb9 = HTTParty.get("https://prod.api.pvp.net/api/lol/na/v1.3/summoner/#{player9}/name?api_key=ad539f86-22fd-474d-9279-79a7a296ac38") - memb9 = memb9["#{player9}"] - sleep(1); + memb8 = HTTParty.get("https://prod.api.pvp.net/api/lol/na/v1.3/summoner/#{player8}/name?api_key=ad539f86-22fd-474d-9279-79a7a296ac38") + memb8 = memb8["#{player8}"] + sleep(1); - memb10 = HTTParty.get("https://prod.api.pvp.net/api/lol/na/v1.3/summoner/#{id}/name?api_key=ad539f86-22fd-474d-9279-79a7a296ac38") - memb10 = memb10["#{id}"] + memb9 = HTTParty.get("https://prod.api.pvp.net/api/lol/na/v1.3/summoner/#{player9}/name?api_key=ad539f86-22fd-474d-9279-79a7a296ac38") + memb9 = memb9["#{player9}"] + sleep(1); - players = ["#{memb1}", "#{memb2}", "#{memb3}", "#{memb4}", "#{memb5}", "#{memb6}", "#{memb7}", "#{memb8}", "#{memb9}", "#{memb10}"] + memb10 = HTTParty.get("https://prod.api.pvp.net/api/lol/na/v1.3/summoner/#{id}/name?api_key=ad539f86-22fd-474d-9279-79a7a296ac38") + memb10 = memb10["#{id}"] - sleep(5); + players = ["#{memb1}", "#{memb2}", "#{memb3}", "#{memb4}", "#{memb5}", "#{memb6}", "#{memb7}", "#{memb8}", "#{memb9}", "#{memb10}"] - blue = Hash.new - purple = Hash.new + sleep(5); - for i in 0..8 - current_player = players_by_id[i] - place = players[i] - info = HTTParty.get("https://prod.api.pvp.net/api/lol/na/v1.3/game/by-summoner/#{current_player}/recent?api_key=ad539f86-22fd-474d-9279-79a7a296ac38") + blue = Hash.new + purple = Hash.new - if 100 == info["games"][0]["stats"]["team"] - blue.merge!("#{place}" => info["games"][0]["stats"]) - else - purple.merge!("#{place}" => info["games"][0]["stats"]) - end - sleep(1) - end + for i in 0..8 + current_player = players_by_id[i] + place = players[i] + info = HTTParty.get("https://prod.api.pvp.net/api/lol/na/v1.3/game/by-summoner/#{current_player}/recent?api_key=ad539f86-22fd-474d-9279-79a7a296ac38") - if 100 == recent["games"][0]["stats"]["team"] - blue.merge!("#{players[9]}" => recent["games"][0]["stats"]) + if 100 == info["games"][0]["stats"]["team"] + blue.merge!("#{place}" => info["games"][0]["stats"]) else - purple.merge!("#{players[9]}" => recent["games"][0]["stats"]) + purple.merge!("#{place}" => info["games"][0]["stats"]) end + sleep(1) + end + + if 100 == recent["games"][0]["stats"]["team"] + blue.merge!("#{players[9]}" => recent["games"][0]["stats"]) + else + purple.merge!("#{players[9]}" => recent["games"][0]["stats"]) + end - @purp = purple - @blue = blue + @purp = purple + @blue = blue - end #end if end #end def # GET /tournaments/1/matches/1 |