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