summaryrefslogtreecommitdiff
path: root/app
diff options
context:
space:
mode:
authortkimia <tkimia@purdue.edu>2014-04-26 20:14:11 -0400
committertkimia <tkimia@purdue.edu>2014-04-26 20:14:11 -0400
commit853c307700fa81b924e00bf430c878a3b7029ffe (patch)
tree4e082a6e7f189e11f9d5297e06cb220f40c0ddc6 /app
parente60adb874faffd9bac678a19043532ff33dc6b07 (diff)
parent0151cd4e338cee9cef1d44292c7e80cc8d6d9b4e (diff)
Merge branch 'master' of https://github.com/LukeShu/leaguer
Diffstat (limited to 'app')
-rw-r--r--app/controllers/matches_controller.rb37
-rw-r--r--app/views/matches/show.html.erb20
2 files changed, 34 insertions, 23 deletions
diff --git a/app/controllers/matches_controller.rb b/app/controllers/matches_controller.rb
index b1b283b..6709a53 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
@@ -180,15 +184,30 @@ class MatchesController < ApplicationController
end
when "finish"
+ #
+ # Get the winner and blowout status from the params given by the correct sampling view
+ #
+
+
+ #in general
+ #provide contribution
+ #if all contributions are in, update statistics
+
+
#make this use the statistics interface for scoring and ScoringAlgorithms
@match.winner = @match.teams.find_by_id(params['winner'])
- @match.blowout = false
+ @match.statistics.create(name: "blowout", user: nil, value: 0)
- @match.statistics['Score'] = @tournament.settings['ScoringMethod'].constantize.score(@match, @match.statistics)
-=begin
+ #How to access the blowout statistic of a match:
+ @match.statistics.where(:name => "blowout").first.value
+
+
+ #@match.statistics.create(name: 'score', value: @tournament.settings.where(:name => 'Scoring Method').value.constantize.score(@match, @match.statistics)
+
+=begin
# Individual scores
#scores = params["scores"]
#scores.each do |user_name, score|
@@ -233,6 +252,10 @@ class MatchesController < ApplicationController
end
end
when "peer"
+ #
+ # Update user scores via scoring method
+ #
+
order = params[:review_action]
base_score = 2
next_score = 3
@@ -262,10 +285,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." }
diff --git a/app/views/matches/show.html.erb b/app/views/matches/show.html.erb
index 7a82527..8344a7a 100644
--- a/app/views/matches/show.html.erb
+++ b/app/views/matches/show.html.erb
@@ -78,24 +78,8 @@ function score_peers() {
<!-- Started, waiting to finish -->
<!-- This will depend on the Sampling Method Eventually instead of always being Manual -->
- <% case @tournament.sampling_method %>
- <% when "Manual" %>
- <% if @tournament.hosts.include? current_user %>
- <input type="hidden" name="update_action" value="finish">
- <% @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 %>
- <p>The match is running; the host has yet to post the scores of the match.</p>
- <% end %>
- <% when "Double Blind" %>
- <p>Double Blind isn't implemented yet.</p>
- <% when "RiotAPI" %>
- <p>Riot API is being called for Statistics. Results will appear shortly.</p>
- <% end %>
+ <%= raw @match.tournament_stage.tournament.sampling_method.camelcase.constantize.render_user_interaction(@match, current_user) %>
+
<% when 2 %>
<!-- Finished, waiting for peer reviews -->
<input type="hidden" name="update_action" value="peer">