summaryrefslogtreecommitdiff
path: root/app/controllers/matches_controller.rb
diff options
context:
space:
mode:
authorguntasgrewal <guntasgrewal@gmail.com>2014-04-07 03:58:45 -0400
committerguntasgrewal <guntasgrewal@gmail.com>2014-04-07 03:58:45 -0400
commit26738698ae3a26c98d81a03309c150c7e38e3488 (patch)
treed118af5019890b00518d9da9099205bdb51ccfff /app/controllers/matches_controller.rb
parentf20dc8df17187027c1881803dbc72b1d3802ff1a (diff)
parent641e968a7ffaaa31724b34422cc165d4b66ae131 (diff)
Merge branch 'master' of https://github.com/LukeShu/leaguer
Conflicts: app/controllers/matches_controller.rb app/views/matches/show.html.erb
Diffstat (limited to 'app/controllers/matches_controller.rb')
-rw-r--r--app/controllers/matches_controller.rb30
1 files changed, 24 insertions, 6 deletions
diff --git a/app/controllers/matches_controller.rb b/app/controllers/matches_controller.rb
index 7d6bf43..9e376f7 100644
--- a/app/controllers/matches_controller.rb
+++ b/app/controllers/matches_controller.rb
@@ -144,11 +144,12 @@ class MatchesController < ApplicationController
handle_asynchronously :is_match_over
def show
- file_blue = "blue.yaml"
- file_purple = "purple.yaml"
- @blue2 = YAML.load_file(file_blue)
- @purp2 = YAML.load_file(file_purple)
-
+ 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
def update
@@ -200,7 +201,24 @@ class MatchesController < ApplicationController
end
end
when "peer"
- @match.status = 3;
+ order = params[:review_action]
+ base_score = 2
+ next_score = 3
+ order.split(",").reverse.each do |elem|
+ player_score = base_score
+ if @match.winner.user.include?(@current_user)
+ player_score += 10
+ else
+ player_score += 7
+ end
+ Score.create(user: elem, match: @match, value: player_score )
+ base_score = next_score
+ next_score += base_score
+ end
+ @match.submitted_peer_reviews += 1
+ if (@match.submitted_peer_reviews == @match.players.count)
+ @match.status = 3
+ end
respond_to do |format|
if @match.save
format.html { redirect_to tournament_match_path(@tournament, @match), notice: 'Scores Submitted' }