mirror of
https://github.com/jcwimer/wrestlingApp
synced 2026-04-02 04:35:26 +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
|
||||
|
||||
Reference in New Issue
Block a user