1
0
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:
RJ Osborne
2015-05-27 23:57:37 -04:00
parent 9b2c2dde60
commit 062396da0a
4 changed files with 34 additions and 55 deletions

View 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