mirror of
https://github.com/jcwimer/wrestlingApp
synced 2026-03-25 01:14:43 +00:00
Add boutNumber to upcomgingMatches
This commit is contained in:
@@ -1,15 +1,8 @@
|
||||
class Bout
|
||||
def assignBouts(tournament_id)
|
||||
@round = 1
|
||||
until matchesByRound(@round, tournament_id).blank? do
|
||||
@matches = matchesByRound(@round, tournament_id)
|
||||
giveBout(@matches)
|
||||
@round += 1
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
def matchesByRound(round, tournament_id)
|
||||
@matches = Match.where(tournament_id: tournament_id, round: round)
|
||||
def matchesByRound(round, matches)
|
||||
@matches = matches.select {|m| m.round == round}
|
||||
return @matches
|
||||
end
|
||||
|
||||
@@ -18,7 +11,21 @@ class Bout
|
||||
@matches.each_with_index do |m, i|
|
||||
bout = m.round * 1000 + i
|
||||
m.boutNumber = bout
|
||||
m.save
|
||||
end
|
||||
return @matches
|
||||
end
|
||||
|
||||
def assignBouts(matches)
|
||||
@round = 1
|
||||
until matchesByRound(@round, matches).blank? do
|
||||
@matches = matchesByRound(@round, matches)
|
||||
giveBout(@matches)
|
||||
@round += 1
|
||||
end
|
||||
return matches
|
||||
end
|
||||
|
||||
|
||||
|
||||
|
||||
end
|
||||
@@ -1,5 +1,5 @@
|
||||
class Matchup
|
||||
attr_accessor :w1, :w2, :round, :weight_id
|
||||
attr_accessor :w1, :w2, :round, :weight_id, :boutNumber
|
||||
|
||||
# def w1
|
||||
# end
|
||||
|
||||
@@ -17,6 +17,7 @@ class Tournament < ActiveRecord::Base
|
||||
self.weights.sort_by{|x|[x.max]}.each do |weight|
|
||||
@upcomingMatches = weight.generateMatchups(@matches)
|
||||
end
|
||||
@upcomingMatches = assignBouts(@upcomingMatches)
|
||||
return @upcomingMatches
|
||||
end
|
||||
|
||||
@@ -40,9 +41,10 @@ class Tournament < ActiveRecord::Base
|
||||
|
||||
|
||||
|
||||
def assignBouts
|
||||
def assignBouts(matches)
|
||||
@bouts = Bout.new
|
||||
@bouts.assignBouts(self.id)
|
||||
@matches = @bouts.assignBouts(matches)
|
||||
return @matches
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
@@ -18,7 +18,7 @@
|
||||
<% @matches.each.map do |m| %>
|
||||
<tr>
|
||||
<td>Round <%= m.round %></td>
|
||||
<td></td>
|
||||
<td><%= m.boutNumber %></td>
|
||||
<td><%= m.weight_max %> lbs</td>
|
||||
<td><%= m.w_name(m.w1) %> vs. <%= m.w_name(m.w2) %></td>
|
||||
</tr>
|
||||
|
||||
Reference in New Issue
Block a user