From fd3308f9aacc9efb2a2692dbff8090dfcd663c88 Mon Sep 17 00:00:00 2001 From: guntasgrewal Date: Mon, 7 Apr 2014 00:51:27 -0400 Subject: Matches move forward more --- app/controllers/matches_controller.rb | 52 +++++++++++++++++++++++++---------- 1 file changed, 37 insertions(+), 15 deletions(-) (limited to 'app/controllers') diff --git a/app/controllers/matches_controller.rb b/app/controllers/matches_controller.rb index f196978..0074eb9 100644 --- a/app/controllers/matches_controller.rb +++ b/app/controllers/matches_controller.rb @@ -21,24 +21,20 @@ class MatchesController < ApplicationController tournament_matches_path(@tournament) end - def get_riot_info - if signed_in? + 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/#{current_user.user_name}?api_key=ad539f86-22fd-474d-9279-79a7a296ac38") + 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") - id = response["#{current_user.user_name.downcase}"]['id'] + id = response["#{pull.downcase}"]['id'] #recent game information - recent = HTTParty.get("https://prod.api.pvp.net/api/lol/na/v1.3/game/by-summoner/#{response["#{current_user.user_name.downcase}"]['id']}/recent?api_key=ad539f86-22fd-474d-9279-79a7a296ac38") + 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") game_id = recent["games"][0]["gameId"] - #remote_user_id = 6651654651354 - #remove_user_name = TeslasMind - #How to Add - #how do I access - #members of most recent game id's player1 = recent["games"][0]["fellowPlayers"][0]["summonerId"] player2 = recent["games"][0]["fellowPlayers"][1]["summonerId"] @@ -121,8 +117,8 @@ class MatchesController < ApplicationController @purp = purple @blue = blue - end #end if - end #end def + end #end if + end #end def # GET /matches/1 # GET /matches/1.json @@ -150,7 +146,10 @@ class MatchesController < ApplicationController if (@match.status == 1) @scores = @match.scores end - + file_blue = "blue.yaml" + file_purple = "purple.yaml" + @blue2 = YAML.load_file(file_blue) + @purp2 = YAML.load_file(file_purple) end @@ -185,13 +184,36 @@ class MatchesController < ApplicationController @match.status = 2; respond_to do |format| if @match.save - format.html { redirect_to tournament_match_path(@tournament, @match), notice: 'Scores submitted' } + format.html { redirect_to tournament_match_path(@tournament, @match), notice: 'Scores Submitted' } format.json { head :no_content } else format.html { redirect_to @tournament, notice: "You don't have permission to start this match." } format.json { render json: "Permission denied", status: :forbidden } end - end + end + when "finish" + @match.status = 3 + respond_to do |format| + if @match.save + format.html { redirect_to tournament_match_path(@tournament, @match), notice: 'Peer Review Submitted' } + format.json { head :no_content } + else + format.html { redirect_to @tournament, notice: "You don't have permission to start this match." } + format.json { render json: "Permission denied", status: :forbidden } + end + end + when "reset" + @match.status = 0 + respond_to do |format| + if @match.save + format.html { redirect_to tournament_match_path(@tournament, @match), notice: 'Match Status Reset to 0' } + format.json { head :no_content } + else + format.html { redirect_to @tournament, notice: "You don't have permission to start this match." } + format.json { render json: "Permission denied", status: :forbidden } + end + end + else respond_to do |format| format.html { redirect_to @tournament, notice: "Invalid action", status: :unprocessable_entity } -- cgit v1.2.3-54-g00ecf From c524bba025ffd09044ce35efc85ee720f3179111 Mon Sep 17 00:00:00 2001 From: tkimia Date: Mon, 7 Apr 2014 01:06:50 -0400 Subject: lol# On branch master --- app/controllers/matches_controller.rb | 5 +- app/views/matches/index.html.erb | 90 ++++++++++++++++++++------------ app/views/tournaments/_selected.html.erb | 1 - 3 files changed, 61 insertions(+), 35 deletions(-) (limited to 'app/controllers') diff --git a/app/controllers/matches_controller.rb b/app/controllers/matches_controller.rb index f196978..1d4ee27 100644 --- a/app/controllers/matches_controller.rb +++ b/app/controllers/matches_controller.rb @@ -9,10 +9,11 @@ class MatchesController < ApplicationController def index @matches = @tournament.matches - # width of SVG - @width = 300 * (Math.log2(@matches.count).floor + 1); + # depth of SVG tree + @depth = Math.log2(@matches.count).floor+1; # height of SVG @height = 200 * 2**Math.log2(@matches.count).floor + 100; + @h_sector = 2**(@depth-1)+1 end # For compatability with the router assumptions made by ApplicationController#check_permission diff --git a/app/views/matches/index.html.erb b/app/views/matches/index.html.erb index 052d176..1941179 100644 --- a/app/views/matches/index.html.erb +++ b/app/views/matches/index.html.erb @@ -37,8 +37,19 @@
+ <% lastrx = 0 + lastry = 0 + lastrh = 0 + lastrw = 0 %> + + + + + + <% (1..@matches.count).each do |i| %> - - - <% when 0 %> - <% if @matches[i-1].teams.count < @tournament.min_teams_per_match %> - stroke="red" - fill-opacity="0.6" - <% else %> - stroke="green" - <% end %> - <% when 1 %> - stroke="orange" - <% when 2 %> - stroke="yellow" - <% when 3 %> - stroke="grey" - <% end %> + + + <% when 0 %> + <% if @matches[i-1].teams.count < @tournament.min_teams_per_match %> + stroke="red" + fill-opacity="0.6" + <% else %> + stroke="green" + <% end %> + <% when 1 %> + stroke="orange" + <% when 2 %> + stroke="yellow" + <% when 3 %> + stroke="grey" + <% end %> /> + + + <% if @matches[i-1].teams.first %> + Team <%= @matches[i-1].teams.first.id %> + <% end %> + + VS + + + + <% if @matches[i-1].teams[1] %> + Team <%= @matches[i-1].teams[1].id %> + <% end %> + + + <% if i > 1 %> + + <% end %> + <% lastrx = rx + lastry = ry + lastrh = rh + lastrw = rw %> - <% if i > 1 %> - - <% end %> + <% end %>
diff --git a/app/views/tournaments/_selected.html.erb b/app/views/tournaments/_selected.html.erb index b66acb0..c3a1736 100644 --- a/app/views/tournaments/_selected.html.erb +++ b/app/views/tournaments/_selected.html.erb @@ -17,5 +17,4 @@

<% end %> - <%= f.submit %> <% end %> -- cgit v1.2.3-54-g00ecf