From f20dc8df17187027c1881803dbc72b1d3802ff1a Mon Sep 17 00:00:00 2001 From: guntasgrewal Date: Mon, 7 Apr 2014 03:48:51 -0400 Subject: Tournament advancement stuff. IT'S 4 AM --- app/views/matches/index.html.erb | 35 ++++---- app/views/matches/show.html.erb | 189 +++++++++++++++++---------------------- 2 files changed, 100 insertions(+), 124 deletions(-) (limited to 'app/views') diff --git a/app/views/matches/index.html.erb b/app/views/matches/index.html.erb index 80d12ab..6c93321 100644 --- a/app/views/matches/index.html.erb +++ b/app/views/matches/index.html.erb @@ -11,24 +11,23 @@ - - <% @tournament.matches.order(:id).reverse.each do |match| %> - - <%= match.name %> - <%= match.status %> - <%= (match.winner.nil? ? "-" : "Team #{match.winner.id}") %> - <%= link_to "Show", tournament_match_path(@tournament, match) %> - <%# If user is the host, let them start the tournment %> - <% if @tournament.hosts.include?(current_user) %> - <%= form_tag(tournament_match_path(@tournament, match), method: "put") do %> - - <%= submit_tag("Start Match", :dissabled => match.teams.count < @tournament.min_teams_per_match) %> - <% end %> - <% end %> - - - <% end %> - + + <% @tournament.matches.order(:id).reverse.each do |match| %> + <%= match.name %> + <%= match.status %> + <%= (match.winner.nil? ? "-" : "Team #{match.winner.id}") %> + <%= link_to "Show", tournament_match_path(@tournament, match) %> + <%# If user is the host, let them start the tournment %> + <% if @tournament.hosts.include?(current_user) %> + <%= form_tag(tournament_match_path(@tournament, match), method: "put") do %> + + <% @startable = (match.status == 0) and (match.teams.count >= @tournament.min_teams_per_match) %> + <%= submit_tag("Start Match", :disabled => ! @startable) %> + <% end %> + <% end %> + + <% end %> +
diff --git a/app/views/matches/show.html.erb b/app/views/matches/show.html.erb index cd30926..a832d17 100644 --- a/app/views/matches/show.html.erb +++ b/app/views/matches/show.html.erb @@ -1,21 +1,21 @@

- Status: - <%= @match.status %> + Status: + <%= @match.status %>

- Tournament: - <%= @match.tournament.id %> + Tournament: + <%= @match.tournament.id %>

- Name: - <%= @match.name %> + Name: + <%= @match.name %>

-<% if (@match.status== 0) || !@tournament.players.include?(current_user) %> +
+

Teams/users

+ <% end %> - - - -<% elsif (@match.status==1) %> - <% if @tournament.hosts.include?(current_user) && @scores.empty? %> - <%= form_tag(tournament_match_path(@tournament, @match), method: "put") do %> - - <% @match.teams.each do |team| %> -
Team <%= team.id.to_s %> - <% team.users.collect{|u| u.user_name}.each do |k| %> - - <% end %> -
- <% end %> - <%= submit_tag("Enter Scores") %> - <% end %> - <% else %> - <% if @scores.empty? %> -

The host has yet to post the scores of the match

- <% @match.teams.each do |team| %> -
    - <% team.users.collect{|u| u.user_name}.each do |k| %> -
  1. <%= k %>
  2. - <% end %> -
- <% end %> - <% else %> - <% @match.teams.each do |team| %> -
    - <% team.users.each do |user| %> -
  1. <%= user.user_name %> - SCORE: <%= @scores.select{|s| s.user == user}.first.value %>
  2. - <% end %> -
- <% end %> - <% end %> - <% end %> - - -<% elsif (@match.status==2) %> - <% if (@tournament.players.include?(current_user)) %> - <% @match.teams.each do |team| %> - <% if team.users.include?(current_user) %> -
    - <% team.users.collect{|u| u.user_name}.each do |k| %> -
  1. <%= k%> -
    - <% if (@tournament.game_id == 1) %> - <%= if @blue2["#{k}"] == nil - "Level: #{@purp2["#{k}"]["level"]} K/D/A: #{@purp2["#{k}"]["championsKilled"]}/#{@purp2["#{k}"]["numDeaths"]}/#{@purp2["#{k}"]["assists"]} Gold:#{@purp2["#{k}"]["goldEarned"]}" - else - "Level: #{@blue2["#{k}"]["level"]} K/D/A: #{@blue2["#{k}"]["championsKilled"]}/#{@blue2["#{k}"]["numDeaths"]}/#{@blue2["#{k}"]["assists"]} Gold:#{@blue2["#{k}"]["goldEarned"]}" - end %> - <% end %> -
  2. - <% end %> -
- <% end %> - <% end %> - <% elsif (@tournament.hosts.include?(current_user)) %> - - <% end %> -<% end %> + +
<% unless @match.winner.nil? %>

@@ -114,25 +51,65 @@

<% end %> -<% if @tournament.players.include?(current_user) %> -
-
- <%= form_tag(tournament_match_path(@tournament, @match), method: "put") do %> - <% case @match.status %> +
+ <%= form_tag(tournament_match_path(@tournament, @match), method: "put") do %> + <% case @match.status %> <% when 0 %> - - <%= submit_tag("Start Match") %> - <% when 1 %> - - <%= submit_tag("Begin Peer Evaluation") %> - <% when 2 %> - - <%= submit_tag("End Match") %> - <% when 3 %> - - <%= submit_tag("Reset Status") %> - <% end %> - <% end %> - + + <% if @tournament.hosts.include? current_user %> + + <%= submit_tag("Start Match", :disabled => @match.teams.count < @tournament.min_teams_per_match) %> + <% else %> +

Match is waiting to start.

+ <% end %> + <% 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 %> +
+ <% end %> + <%= submit_tag("Finish match") %> + <% else %> +

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

+ <% end %> + <% when 2 %> + + + <% users = []; @match.teams.each{|t| users.concat(t.users)}; %> + <% if users.include? current_user %> + <% @match.teams.each do |team| %> + <% if team.users.include?(current_user) %> +
    + <% team.users.collect{|u| u.user_name}.each do |k| %> +
  1. <%= k%> +
    + <% if (@tournament.game_id == 1) %> + <%= if @blue2["#{k}"] == nil + "Level: #{@purp2["#{k}"]["level"]} K/D/A: #{@purp2["#{k}"]["championsKilled"]}/#{@purp2["#{k}"]["numDeaths"]}/#{@purp2["#{k}"]["assists"]} Gold:#{@purp2["#{k}"]["goldEarned"]}" + else + "Level: #{@blue2["#{k}"]["level"]} K/D/A: #{@blue2["#{k}"]["championsKilled"]}/#{@blue2["#{k}"]["numDeaths"]}/#{@blue2["#{k}"]["assists"]} Gold:#{@blue2["#{k}"]["goldEarned"]}" + end %> + <% end %> +
  2. + <% end %> +
+ <% end %> + <% end %> + <%= submit_tag("Submit peer evaluation") %> + <% else %> + Waiting for peer evaluations to be submitted. + <% end %> + <% when 3 %> + + This match is done. + + <%= submit_tag("Reset Status") %> + <% end # case %> + <% end # form %>
-<% end %> -- cgit v1.2.3-2-g168b