diff options
author | nfoy <nfoy@purdue.edu> | 2014-04-07 12:57:07 -0400 |
---|---|---|
committer | nfoy <nfoy@purdue.edu> | 2014-04-07 12:57:07 -0400 |
commit | ca883abbaa80209df098292a138b7c2668f0e94e (patch) | |
tree | 48e18e858969d93b6a1f0976587a47e7ea0900f0 /app/controllers/matches_controller.rb | |
parent | 677f914b0d1c9cefcbd9aacbd48e83ab98916f8f (diff) | |
parent | f11351569b922e7613259aa8968294536f7b41bd (diff) |
Merge branch 'master' of https://github.com/LukeShu/leaguer
Conflicts:
app/controllers/matches_controller.rb
Diffstat (limited to 'app/controllers/matches_controller.rb')
-rw-r--r-- | app/controllers/matches_controller.rb | 40 |
1 files changed, 29 insertions, 11 deletions
diff --git a/app/controllers/matches_controller.rb b/app/controllers/matches_controller.rb index 53f9f47..95f99a6 100644 --- a/app/controllers/matches_controller.rb +++ b/app/controllers/matches_controller.rb @@ -1,12 +1,12 @@ class MatchesController < ApplicationController before_action :set_tournament, only: [:index, :update] - # GET /matches - # GET /matches.json require 'httparty' require 'json' require 'delayed_job' + # GET /tournaments/1/matches + # GET /tournaments/1/matches.json def index @matches = @tournament.matches # depth of SVG tree @@ -22,8 +22,8 @@ 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 @@ -107,7 +107,7 @@ class MatchesController < ApplicationController purple.merge!("#{place}" => info["games"][0]["stats"]) end sleep(1) - end + end if 100 == recent["games"][0]["stats"]["team"] blue.merge!("#{players[9]}" => recent["games"][0]["stats"]) @@ -118,11 +118,22 @@ class MatchesController < ApplicationController @purp = purple @blue = blue - end #end if - end #end def - # GET /matches/1 - # GET /matches/1.json + end #end if + end #end def + + # GET /tournaments/1/matches/1 + # GET /tournaments/1/matches/1.json + def show + if Tournament.find_by_id(@match.tournament_id).game_id == 1 + file_blue = "blue.yaml" + file_purple = "purple.yaml" + @blue2 = YAML.load_file(file_blue) + @purp2 = YAML.load_file(file_purple) + end + end + # PATCH/PUT /tournaments/1/matches/1 + # PATCH/PUT /tournaments/1/matches/1.json def update case params[:update_action] when "start" @@ -137,8 +148,6 @@ class MatchesController < ApplicationController end end when "finish" - @match.status = 2 - # Individual scores scores = params["scores"] scores.each do |user_name, score| @@ -162,6 +171,15 @@ class MatchesController < ApplicationController @match.winner.matches.push(@tournament.matches_ordered[cur_match_num/2]) end + # Skip peer evaluation if there aren't enough players per team + peer = false + @match.teams.each do |team| + if team.users.count > 2 + peer = true + end + end + @match.status = peer ? 2 : 3 + respond_to do |format| if @match.save format.html { redirect_to tournament_match_path(@tournament, @match), notice: 'Peer evaluation started.' } |