From e1ef99a9ade5723c7bc65977546b4e1fdaab9688 Mon Sep 17 00:00:00 2001 From: AndrewMurrell Date: Thu, 24 Apr 2014 21:55:49 -0400 Subject: Mixed things up a bit on the matches controller and show view. --- app/controllers/matches_controller.rb | 23 ++++++++++++++--------- app/views/matches/show.html.erb | 34 +++++++++++++++++++--------------- 2 files changed, 33 insertions(+), 24 deletions(-) diff --git a/app/controllers/matches_controller.rb b/app/controllers/matches_controller.rb index 138cf28..b1b283b 100644 --- a/app/controllers/matches_controller.rb +++ b/app/controllers/matches_controller.rb @@ -55,7 +55,6 @@ class MatchesController < ApplicationController @purp = purple @blue = blue - end def get_riot_info_fake @@ -151,8 +150,7 @@ class MatchesController < ApplicationController @purp = purple @blue = blue - - end #end def + end # GET /tournaments/1/matches/1 # GET /tournaments/1/matches/1.json @@ -184,13 +182,18 @@ class MatchesController < ApplicationController #make this use the statistics interface for scoring and ScoringAlgorithms + @match.winner = @match.teams.find_by_id(params['winner']) + @match.blowout = false + @match.statistics['Score'] = @tournament.settings['ScoringMethod'].constantize.score(@match, @match.statistics) + +=begin # Individual scores - scores = params["scores"] - scores.each do |user_name, score| - Statistic.create(user: User.find_by_user_name(user_name), match: @match, name: "score", value: score.to_i) - end + #scores = params["scores"] + #scores.each do |user_name, score| + # Statistic.create(user: User.find_by_user_name(user_name), match: @match, name: "score", value: score.to_i) + #end # Team scores (processing for manual) team_scores = {} @@ -208,6 +211,7 @@ class MatchesController < ApplicationController #unless cur_match_num == 1 # @match.winner.matches.push(@tournament.matches_ordered[cur_match_num/2]) #end +=end # Skip peer evaluation if there aren't enough players per team peer = false @@ -218,12 +222,13 @@ class MatchesController < ApplicationController 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.' } format.json { head :no_content } else - format.html { redirect_to @tournament, notice: "You don't have permission to start this match." } + format.html { redirect_to @tournament, notice: "Permission denied" } format.json { render json: "Permission denied", status: :forbidden } end end @@ -273,7 +278,6 @@ class MatchesController < ApplicationController format.json { render json: @tournament.errors, status: :unprocessable_entity } end end - end private @@ -282,6 +286,7 @@ class MatchesController < ApplicationController @match = Match.find(params[:id]) @tournament = @match.tournament_stage.tournament end + def set_tournament @tournament = Tournament.find(params[:tournament_id]) end diff --git a/app/views/matches/show.html.erb b/app/views/matches/show.html.erb index e1fe29e..2ec0ea6 100644 --- a/app/views/matches/show.html.erb +++ b/app/views/matches/show.html.erb @@ -47,7 +47,8 @@ function score_peers() { <% if @match.status <= 1 %>
  • <%= user.user_name %>
  • <% else %> -
  • <%= user.user_name %> - SCORE: <%= Statistic.where(:name => "score", :user => user, :match => @match).first.value %>
  • + <% score = Statistic.where(:name => "score", :user => user, :match => @match).first%> +
  • <%= user.user_name %> - SCORE: <%= score ? score.value : 0 %>
  • <% end %> <% end %> @@ -76,21 +77,24 @@ function score_peers() { <% when 1 %> - <% if @tournament.hosts.include? current_user %> - - <% @match.teams.each do |team| %> -
    Team <%= team.id.to_s %> - <% team.users.collect{|u| u.user_name}.each do |k| %><% end %> -
    + + <% case @tournament.sampling_method %> + <% when "Manual" %> + <% if @tournament.hosts.include? current_user %> + + <% @match.teams.each do |team| %> + <%= tag :input, {"type" => "radio", "name" => "winner", "value" => "#{team.id}" } %> + <%= "Team #{team.id} Won" %> + <% end %> + <%= submit_tag("Finish match") %> + <%= @tournament.settings['ScoringMethod'] %> + <% else %> +

    The match is running; the host has yet to post the scores of the match.

    <% end %> - <%= submit_tag("Finish match") %> - <% else %> -

    The match is running; the host has yet to post the scores of the match.

    + <% when "Double Blind" %> +

    Double Blind isn't implemented yet.

    + <% when "RiotAPI" %> +

    Riot API is being called for Statistics. Results will appear shortly.

    <% end %> <% when 2 %> -- cgit v1.1-4-g5e80