summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDavisLWebb <davislwebb@ymail.com>2014-04-24 13:27:08 -0400
committerDavisLWebb <davislwebb@ymail.com>2014-04-24 13:27:08 -0400
commit62780a89fb04e1d96c3bbc8c8dd2db9efdc656f1 (patch)
treedf00d164472e2dbc62477fdf60da4e0697c9dc1c
parent55fa26ca1517a15e366b475a8152cf61aef6dc9c (diff)
Added get_riot function which to gather, score, and place members in their proper blue/purple teams. Also changed the user view so that once the remote_username for League of Legends was added the button would be removed (since we are only supporting league for the remote_usernames right now)
-rw-r--r--app/controllers/matches_controller.rb39
-rw-r--r--app/controllers/users_controller.rb3
-rw-r--r--app/views/users/show.html.erb4
3 files changed, 43 insertions, 3 deletions
diff --git a/app/controllers/matches_controller.rb b/app/controllers/matches_controller.rb
index 59b354d..1ad86d0 100644
--- a/app/controllers/matches_controller.rb
+++ b/app/controllers/matches_controller.rb
@@ -17,6 +17,45 @@ class MatchesController < ApplicationController
end
def get_riot
+
+ players_id = Array.new
+ players = Array.new
+
+ @match.teams.each do |team|
+ team.users.each do |user|
+ players_id.push(user.remote_usernames[0]["json_value"]["id"])
+ players.push(user.remote_usernames[0]["json_value"]["id"])
+ end
+ end
+
+ recent = HTTParty.get("https://prod.api.pvp.net/api/lol/na/v1.3/game/by-summoner/#{players_id[0]}/recent?api_key=ad539f86-22fd-474d-9279-79a7a296ac38")
+
+ blue = Hash.new
+ purple = Hash.new
+
+ for i in 0..8
+ current_player = players_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 == info["games"][0]["stats"]["team"]
+ blue.merge!("#{place}" => info["games"][0]["stats"])
+ else
+ purple.merge!("#{place}" => info["games"][0]["stats"])
+ end
+ sleep(1)
+ end
+
+ #look into this glitch
+ 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
+
end
def get_riot_info_fake
diff --git a/app/controllers/users_controller.rb b/app/controllers/users_controller.rb
index bbc6ef3..27b3c61 100644
--- a/app/controllers/users_controller.rb
+++ b/app/controllers/users_controller.rb
@@ -64,10 +64,7 @@ class UsersController < ApplicationController
game = Game.find_by_name(game_name)
remote_username = HTTParty.get("https://prod.api.pvp.net/api/lol/na/v1.3/summoner/by-name/#{user_name.downcase}?api_key=ad539f86-22fd-474d-9279-79a7a296ac38")
- puts "#{user_name}"
-
id = "#{remote_username["#{user_name.downcase}"]["id"]}".to_i
-
username = "#{remote_username["#{user_name.downcase}"]["name"]}"
hash = {:username => username, :id => id}
diff --git a/app/views/users/show.html.erb b/app/views/users/show.html.erb
index dfebf08..a67aed9 100644
--- a/app/views/users/show.html.erb
+++ b/app/views/users/show.html.erb
@@ -20,15 +20,19 @@
too single
</p>
+
<p>
+<% if @user.remote_usernames[0].nil? %>
<%= form_for @user do |f| %>
<label>Have a League of Legends Account?
<input type=text name="user[remote_usernames][League of Legends]">
</label>
<%= f.submit "Add Username", :class => 'signup' %>
<% end %>
+<% end %>
</p>
+
<div class="row">
<div class="col-md-6">
<h3> Recent Tournaments Played </h3>