<%= @tournament.name %> - Matches

<% @tournament.matches.each do |match| %> <% end %>
Status Name Winner
<%= match.status %> <%= match.id%> <%= match.name %> <%= 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") %> <% end %> <% end %>

<% lastrx = 0 lastry = 0 lastrh = 0 lastrw = 0 %> <% (1..@matches.count).each do |i| %> <% when 0 %> <% if @matches[i-1].teams.count < @tournament.min_teams_per_match %> stroke="red" fill-opacity="0.6" <% else %> stroke="green" <% end %> <% when 1 %> stroke="orange" <% when 2 %> stroke="yellow" <% when 3 %> stroke="grey" <% end %> /> " stroke="black" /> <% if @matches[i-1].teams.first %> Team <%= @matches[i-1].teams.first.id %> <% end %> VS " stroke="black" /> <% if @matches[i-1].teams[1] %> Team <%= @matches[i-1].teams[1].id %> <% end %> <% if i > 1 %> <% end %> <% if Math.log2(i+1) == Math.log2(i+1).ceil %> <% lastrx = rx lastry = ry lastrh = rh lastrw = rw %> <% end %> <% end %>