mirror of
https://github.com/jcwimer/wrestlingApp
synced 2026-03-25 01:14:43 +00:00
Merge branch 'development'
This commit is contained in:
@@ -2,7 +2,7 @@ class GenerateTournamentMatches
|
|||||||
def initialize( tournament )
|
def initialize( tournament )
|
||||||
@tournament = tournament
|
@tournament = tournament
|
||||||
end
|
end
|
||||||
|
|
||||||
def generateWeight(weight)
|
def generateWeight(weight)
|
||||||
WipeTournamentMatches.new(@tournament).wipeWeightMatches(weight)
|
WipeTournamentMatches.new(@tournament).wipeWeightMatches(weight)
|
||||||
@tournament.curently_generating_matches = 1
|
@tournament.curently_generating_matches = 1
|
||||||
@@ -25,14 +25,14 @@ class GenerateTournamentMatches
|
|||||||
if Rails.env.production?
|
if Rails.env.production?
|
||||||
handle_asynchronously :generate
|
handle_asynchronously :generate
|
||||||
end
|
end
|
||||||
|
|
||||||
def standardStartingActions
|
def standardStartingActions
|
||||||
@tournament.curently_generating_matches = 1
|
@tournament.curently_generating_matches = 1
|
||||||
@tournament.save
|
@tournament.save
|
||||||
WipeTournamentMatches.new(@tournament).setUpMatchGeneration
|
WipeTournamentMatches.new(@tournament).setUpMatchGeneration
|
||||||
TournamentSeeding.new(@tournament).setSeeds
|
TournamentSeeding.new(@tournament).setSeeds
|
||||||
end
|
end
|
||||||
|
|
||||||
def postMatchCreationActions
|
def postMatchCreationActions
|
||||||
moveFinalsMatchesToLastRound
|
moveFinalsMatchesToLastRound
|
||||||
assignBouts
|
assignBouts
|
||||||
@@ -40,44 +40,44 @@ class GenerateTournamentMatches
|
|||||||
@tournament.curently_generating_matches = nil
|
@tournament.curently_generating_matches = nil
|
||||||
@tournament.save
|
@tournament.save
|
||||||
end
|
end
|
||||||
|
|
||||||
def assignBouts
|
|
||||||
bout_counts = Hash.new(0)
|
|
||||||
@tournament.matches.each do |m|
|
|
||||||
m.bout_number = m.round * 1000 + bout_counts[m.round]
|
|
||||||
bout_counts[m.round] += 1
|
|
||||||
m.save!
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
def moveFinalsMatchesToLastRound
|
|
||||||
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. each do |m|
|
|
||||||
m.round = finalsRound
|
|
||||||
m.save
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
def assignFirstMatchesToMats
|
|
||||||
matsToAssign = @tournament.mats
|
|
||||||
if matsToAssign.count > 0
|
|
||||||
until matsToAssign.sort_by{|m| m.id}.last.matches.count == 4
|
|
||||||
matsToAssign.sort_by{|m| m.id}.each do |m|
|
|
||||||
m.assignNextMatch
|
|
||||||
end
|
|
||||||
end
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
def unAssignBouts
|
|
||||||
bout_counts = Hash.new(0)
|
|
||||||
@tournament.matches.each do |m|
|
|
||||||
m.bout_number = nil
|
|
||||||
m.save!
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
end
|
def assignBouts
|
||||||
|
bout_counts = Hash.new(0)
|
||||||
|
@tournament.matches.sort_by{|m| [m.round, m.weight_max]}.each do |m|
|
||||||
|
m.bout_number = m.round * 1000 + bout_counts[m.round]
|
||||||
|
bout_counts[m.round] += 1
|
||||||
|
m.save!
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
def moveFinalsMatchesToLastRound
|
||||||
|
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. each do |m|
|
||||||
|
m.round = finalsRound
|
||||||
|
m.save
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
def assignFirstMatchesToMats
|
||||||
|
matsToAssign = @tournament.mats
|
||||||
|
if matsToAssign.count > 0
|
||||||
|
until matsToAssign.sort_by{|m| m.id}.last.matches.count == 4
|
||||||
|
matsToAssign.sort_by{|m| m.id}.each do |m|
|
||||||
|
m.assignNextMatch
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
def unAssignBouts
|
||||||
|
bout_counts = Hash.new(0)
|
||||||
|
@tournament.matches.each do |m|
|
||||||
|
m.bout_number = nil
|
||||||
|
m.save!
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
end
|
||||||
|
|||||||
Reference in New Issue
Block a user