mirror of
https://github.com/jcwimer/wrestlingApp
synced 2026-04-30 11:04:56 +00:00
Fixed pooladvance and updated views for when tournament ends
This commit is contained in:
@@ -7,9 +7,11 @@ class MatsController < ApplicationController
|
|||||||
# GET /mats/1.json
|
# GET /mats/1.json
|
||||||
def show
|
def show
|
||||||
@match = @mat.unfinishedMatches.first
|
@match = @mat.unfinishedMatches.first
|
||||||
@w1 = @match.wrestler1
|
if @match
|
||||||
@w2 = @match.wrestler2
|
@w1 = @match.wrestler1
|
||||||
@wrestlers = [@w1,@w2]
|
@w2 = @match.wrestler2
|
||||||
|
@wrestlers = [@w1,@w2]
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
# GET /mats/new
|
# GET /mats/new
|
||||||
|
|||||||
@@ -148,9 +148,9 @@ class TournamentsController < ApplicationController
|
|||||||
|
|
||||||
def check_for_matches
|
def check_for_matches
|
||||||
if @tournament
|
if @tournament
|
||||||
if @tournament.matches.empty?
|
if @tournament.matches.empty?
|
||||||
redirect_to "/tournaments/#{@tournament.id}/no_matches"
|
redirect_to "/tournaments/#{@tournament.id}/no_matches"
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|||||||
@@ -4,9 +4,11 @@ class Mat < ActiveRecord::Base
|
|||||||
|
|
||||||
def assignNextMatch
|
def assignNextMatch
|
||||||
t_matches = tournament.matches.where(mat_id: nil)
|
t_matches = tournament.matches.where(mat_id: nil)
|
||||||
match = t_matches.order(:bout_number).first
|
if t_matches.size > 0
|
||||||
match.mat_id = self.id
|
match = t_matches.order(:bout_number).first
|
||||||
match.save
|
match.mat_id = self.id
|
||||||
|
match.save
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
def unfinishedMatches
|
def unfinishedMatches
|
||||||
|
|||||||
@@ -56,11 +56,11 @@ class Pooladvance
|
|||||||
def updateNewMatch(match)
|
def updateNewMatch(match)
|
||||||
if @wrestler.nextMatchPositionNumber == @wrestler.nextMatchPositionNumber.ceil
|
if @wrestler.nextMatchPositionNumber == @wrestler.nextMatchPositionNumber.ceil
|
||||||
match.w2 = @wrestler.id
|
match.w2 = @wrestler.id
|
||||||
match.update
|
match.save
|
||||||
end
|
end
|
||||||
if @wrestler.nextMatchPositionNumber != @wrestler.nextMatchPositionNumber.ceil
|
if @wrestler.nextMatchPositionNumber != @wrestler.nextMatchPositionNumber.ceil
|
||||||
match.w1 = @wrestler.id
|
match.w1 = @wrestler.id
|
||||||
match.update
|
match.save
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|||||||
@@ -157,13 +157,13 @@ class Wrestler < ActiveRecord::Base
|
|||||||
end
|
end
|
||||||
|
|
||||||
def seasonWinPercentage
|
def seasonWinPercentage
|
||||||
@win = self.season_win.to_f
|
win = self.season_win.to_f
|
||||||
@loss = self.season_loss.to_f
|
loss = self.season_loss.to_f
|
||||||
if @win > 0 and @loss != nil
|
if win > 0 and loss != nil
|
||||||
@matchTotal = @win + @loss
|
matchTotal = win + loss
|
||||||
@percentageDec = @win / @matchTotal
|
percentageDec = win / matchTotal
|
||||||
@percentage = @percentageDec * 100
|
percentage = percentageDec * 100
|
||||||
return @percentage.to_i
|
return percentage.to_i
|
||||||
elsif self.season_win == 0
|
elsif self.season_win == 0
|
||||||
return 0
|
return 0
|
||||||
elsif self.season_win == nil or self.season_loss == nil
|
elsif self.season_win == nil or self.season_loss == nil
|
||||||
|
|||||||
@@ -14,6 +14,9 @@
|
|||||||
|
|
||||||
<br>
|
<br>
|
||||||
<br>
|
<br>
|
||||||
|
<% if @match %>
|
||||||
<%= render 'match_edit_form' %>
|
<%= render 'match_edit_form' %>
|
||||||
|
<% else %>
|
||||||
|
<p>No matches assigned to this mat.</p>
|
||||||
|
<% end %>
|
||||||
|
|
||||||
|
|||||||
@@ -30,10 +30,10 @@
|
|||||||
<% @mats.each.map do |m| %>
|
<% @mats.each.map do |m| %>
|
||||||
<tr>
|
<tr>
|
||||||
<td><%= m.name %></td>
|
<td><%= m.name %></td>
|
||||||
<td><%=m.unfinishedMatches.first.bout_number%><br><%= m.unfinishedMatches.first.w1_name %> vs. <%= m.unfinishedMatches.first.w2_name %></td>
|
<td><% if m.unfinishedMatches.first %><%=m.unfinishedMatches.first.bout_number%><br><%= m.unfinishedMatches.first.w1_name %> vs. <%= m.unfinishedMatches.first.w2_name %><% end %></td>
|
||||||
<td><%=m.unfinishedMatches.second.bout_number%><br><%= m.unfinishedMatches.second.w1_name %> vs. <%= m.unfinishedMatches.second.w2_name %></td>
|
<td><% if m.unfinishedMatches.second %><%=m.unfinishedMatches.second.bout_number%><br><%= m.unfinishedMatches.second.w1_name %> vs. <%= m.unfinishedMatches.second.w2_name %><% end %></td>
|
||||||
<td><%=m.unfinishedMatches.third.bout_number%><br><%= m.unfinishedMatches.third.w1_name %> vs. <%= m.unfinishedMatches.third.w2_name %></td>
|
<td><% if m.unfinishedMatches.third %><%=m.unfinishedMatches.third.bout_number%><br><%= m.unfinishedMatches.third.w1_name %> vs. <%= m.unfinishedMatches.third.w2_name %><% end %></td>
|
||||||
<td><%=m.unfinishedMatches.fourth.bout_number%><br><%= m.unfinishedMatches.fourth.w1_name %> vs. <%= m.unfinishedMatches.fourth.w2_name %></td>
|
<td><% if m.unfinishedMatches.fourth %><%=m.unfinishedMatches.fourth.bout_number%><br><%= m.unfinishedMatches.fourth.w1_name %> vs. <%= m.unfinishedMatches.fourth.w2_name %><% end %></td>
|
||||||
</tr>
|
</tr>
|
||||||
<% end %>
|
<% end %>
|
||||||
</tbody>
|
</tbody>
|
||||||
@@ -54,6 +54,7 @@
|
|||||||
</thead>
|
</thead>
|
||||||
|
|
||||||
<tbody>
|
<tbody>
|
||||||
|
<% if @matches.size > 0 %>
|
||||||
<% @matches.each.map do |m| %>
|
<% @matches.each.map do |m| %>
|
||||||
<tr>
|
<tr>
|
||||||
<td>Round <%= m.round %></td>
|
<td>Round <%= m.round %></td>
|
||||||
@@ -62,6 +63,7 @@
|
|||||||
<td><%= m.w1_name %> vs. <%= m.w2_name %></td>
|
<td><%= m.w1_name %> vs. <%= m.w2_name %></td>
|
||||||
</tr>
|
</tr>
|
||||||
<% end %>
|
<% end %>
|
||||||
|
<% end %>
|
||||||
</tbody>
|
</tbody>
|
||||||
</table>
|
</table>
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user