mirror of
https://github.com/jcwimer/wrestlingApp
synced 2026-04-14 17:06:46 +00:00
Realigned file and sorted matches by weight and round when assigning bouts
This commit is contained in:
@@ -42,41 +42,41 @@ class GenerateTournamentMatches
|
|||||||
end
|
end
|
||||||
|
|
||||||
def assignBouts
|
def assignBouts
|
||||||
bout_counts = Hash.new(0)
|
bout_counts = Hash.new(0)
|
||||||
@tournament.matches.each do |m|
|
@tournament.matches.sort_by{|m| [m.round, m.weight_max]}.each do |m|
|
||||||
m.bout_number = m.round * 1000 + bout_counts[m.round]
|
m.bout_number = m.round * 1000 + bout_counts[m.round]
|
||||||
bout_counts[m.round] += 1
|
bout_counts[m.round] += 1
|
||||||
m.save!
|
m.save!
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
def moveFinalsMatchesToLastRound
|
def moveFinalsMatchesToLastRound
|
||||||
finalsRound = @tournament.totalRounds
|
finalsRound = @tournament.totalRounds
|
||||||
finalsMatches = @tournament.matches.select{|m| m.bracket_position == "1/2" || m.bracket_position == "3/4" || m.bracket_position == "5/6" || m.bracket_position == "7/8"}
|
finalsMatches = @tournament.matches.select{|m| m.bracket_position == "1/2" || m.bracket_position == "3/4" || m.bracket_position == "5/6" || m.bracket_position == "7/8"}
|
||||||
finalsMatches. each do |m|
|
finalsMatches. each do |m|
|
||||||
m.round = finalsRound
|
m.round = finalsRound
|
||||||
m.save
|
m.save
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
def assignFirstMatchesToMats
|
def assignFirstMatchesToMats
|
||||||
matsToAssign = @tournament.mats
|
matsToAssign = @tournament.mats
|
||||||
if matsToAssign.count > 0
|
if matsToAssign.count > 0
|
||||||
until matsToAssign.sort_by{|m| m.id}.last.matches.count == 4
|
until matsToAssign.sort_by{|m| m.id}.last.matches.count == 4
|
||||||
matsToAssign.sort_by{|m| m.id}.each do |m|
|
matsToAssign.sort_by{|m| m.id}.each do |m|
|
||||||
m.assignNextMatch
|
m.assignNextMatch
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
def unAssignBouts
|
def unAssignBouts
|
||||||
bout_counts = Hash.new(0)
|
bout_counts = Hash.new(0)
|
||||||
@tournament.matches.each do |m|
|
@tournament.matches.each do |m|
|
||||||
m.bout_number = nil
|
m.bout_number = nil
|
||||||
m.save!
|
m.save!
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user