mirror of
https://github.com/jcwimer/wrestlingApp
synced 2026-04-06 14:36:59 +00:00
38 lines
832 B
Ruby
38 lines
832 B
Ruby
class Tournamentmatchgen
|
|
|
|
def initialize(tournament)
|
|
@tournament = tournament
|
|
end
|
|
|
|
def genMatches
|
|
if @tournament.tournament_type == "Pool to bracket"
|
|
poolToBracket()
|
|
end
|
|
@tournament.matches
|
|
end
|
|
|
|
def poolToBracket
|
|
destroyMatches
|
|
buildTournamentWeights
|
|
generateMatches
|
|
end
|
|
|
|
def destroyMatches
|
|
@tournament.destroyAllMatches
|
|
end
|
|
|
|
def buildTournamentWeights
|
|
@tournament.weights.order(:max).each do |weight|
|
|
Pool.new(weight).generatePools()
|
|
last_match = @tournament.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
|
|
@tournament.assignBouts
|
|
Losernamegen.new.assignLoserNames(@tournament)
|
|
end
|
|
end
|