diff options
author | guntasgrewal <guntasgrewal@gmail.com> | 2014-04-26 20:35:55 -0400 |
---|---|---|
committer | guntasgrewal <guntasgrewal@gmail.com> | 2014-04-26 20:35:55 -0400 |
commit | 1d24cb050f198e9c8bec8dd014de203d889ab56a (patch) | |
tree | 9f10e7a5be75d7ffb4cb829d3738a144b5250b9b /app/controllers/matches_controller.rb | |
parent | 2d0fe1a4197e70cb99f4285a8b32a645914d8beb (diff) | |
parent | dfbbe46fdcca392b3dec703cf347d1b1d57ca94f (diff) |
Merge branch 'master' of https://github.com/LukeShu/leaguer
Diffstat (limited to 'app/controllers/matches_controller.rb')
-rw-r--r-- | app/controllers/matches_controller.rb | 55 |
1 files changed, 21 insertions, 34 deletions
diff --git a/app/controllers/matches_controller.rb b/app/controllers/matches_controller.rb index b1b283b..a2a1269 100644 --- a/app/controllers/matches_controller.rb +++ b/app/controllers/matches_controller.rb @@ -168,6 +168,10 @@ class MatchesController < ApplicationController def update case params[:update_action] when "start" + # + # Redirect to the current match page for this tournament with the correct sampling view rendered + # + @match.status = 1 respond_to do |format| if @match.save @@ -179,39 +183,13 @@ class MatchesController < ApplicationController end end when "finish" + # + # Get the winner and blowout status from the params given by the correct sampling view + # - #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 - - # Team scores (processing for manual) - team_scores = {} - @match.teams.each do |team| - team_scores[team] = 0 - team.users.each do |user| - team_scores[team] += scores[user.user_name].to_i - end + unless @match.tournament_stage.tournament.sampling.sampling_done? + @match.tournament_stage.tournament.sampling.handle_user_interaction(@match, current_user, params) end - teams = team_scores.invert - @match.winner = teams[teams.keys.sort.last] - - # Schedule next match - #cur_match_num = @tournament.matches_ordered.invert[@match] - #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 @@ -222,7 +200,6 @@ 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.' } @@ -233,6 +210,12 @@ class MatchesController < ApplicationController end end when "peer" + # + # Update user scores via scoring method + # + + #update this to use scoring interface + order = params[:review_action] base_score = 2 next_score = 3 @@ -262,10 +245,14 @@ class MatchesController < ApplicationController end end when "reset" - @match.status = 0 + # + # Reset Match Status to 1 in case something needs to be replayed. + # + + @match.status = 1 respond_to do |format| if @match.save - format.html { redirect_to tournament_match_path(@tournament, @match), notice: 'Match Status Reset to 0' } + format.html { redirect_to tournament_match_path(@tournament, @match), notice: 'Match Status Reset to 1' } format.json { head :no_content } else format.html { redirect_to @tournament, notice: "You don't have permission to start this match." } |