mirror of
https://github.com/jcwimer/wrestlingApp
synced 2026-04-19 14:00:27 +00:00
A Tournament can now generate its own matches.
This was again extracted as a module. Modules get more powerful as they get more generic. This is far from generic.
This commit is contained in:
28
app/models/generates_tournament_matches.rb
Normal file
28
app/models/generates_tournament_matches.rb
Normal file
@@ -0,0 +1,28 @@
|
||||
module GeneratesTournamentMatches
|
||||
|
||||
def generateMatchups
|
||||
poolToBracket() if tournament_type == "Pool to bracket"
|
||||
matches
|
||||
end
|
||||
|
||||
def poolToBracket
|
||||
destroyAllMatches
|
||||
buildTournamentWeights
|
||||
generateMatches
|
||||
end
|
||||
|
||||
def buildTournamentWeights
|
||||
weights.order(:max).each do |weight|
|
||||
Pool.new(weight).generatePools()
|
||||
last_match = matches.where(weight: weight).order(round: :desc).limit(1).first
|
||||
highest_round = last_match.round
|
||||
Poolbracket.new(weight, highest_round).generateBracketMatches()
|
||||
end
|
||||
end
|
||||
|
||||
def generateMatches
|
||||
assignBouts
|
||||
assignLoserNames
|
||||
end
|
||||
|
||||
end
|
||||
Reference in New Issue
Block a user