mirror of
https://github.com/jcwimer/wrestlingApp
synced 2026-04-09 23:44:52 +00:00
Move two highest pool seeds match to last pool round
This commit is contained in:
@@ -18,6 +18,7 @@ module GeneratesTournamentMatches
|
|||||||
destroyAllMatches
|
destroyAllMatches
|
||||||
buildTournamentWeights
|
buildTournamentWeights
|
||||||
generateMatches
|
generateMatches
|
||||||
|
movePoolSeedsToFinalPoolRound
|
||||||
end
|
end
|
||||||
|
|
||||||
def buildTournamentWeights
|
def buildTournamentWeights
|
||||||
@@ -51,6 +52,10 @@ module GeneratesTournamentMatches
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def movePoolSeedsToFinalPoolRound
|
||||||
|
self.weights.each do |w|
|
||||||
|
w.setOriginalSeedsToWrestleLastPoolRound
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|||||||
@@ -136,4 +136,42 @@ class Tournament < ActiveRecord::Base
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def swapWrestlers(wrestler1_id,wrestler2_id)
|
||||||
|
w1 = Wrestler.find(wrestler1_id)
|
||||||
|
w2 = Wrestler.find(wrestler2_id)
|
||||||
|
|
||||||
|
#placeholder guy
|
||||||
|
w3 = Wrestler.new
|
||||||
|
w3.name = w1.name
|
||||||
|
w3.school_id = w1.school_id
|
||||||
|
w3.weight_id = w1.weight_id
|
||||||
|
w3.season_win = w1.season_win
|
||||||
|
w3.season_loss = w1.season_loss
|
||||||
|
w3.criteria = w1.criteria
|
||||||
|
w3.original_seed = w1.original_seed
|
||||||
|
w3.seed = w1.seed
|
||||||
|
|
||||||
|
#Swap wrestler 1 and wrestler 2
|
||||||
|
w1.name = w2.name
|
||||||
|
w1.school_id = w2.school_id
|
||||||
|
w1.weight_id = w2.weight_id
|
||||||
|
w1.season_win = w2.season_win
|
||||||
|
w1.season_loss = w2.season_loss
|
||||||
|
w1.criteria = w2.criteria
|
||||||
|
w1.original_seed = w2.original_seed
|
||||||
|
w1.seed = w2.seed
|
||||||
|
|
||||||
|
w2.name = w3.name
|
||||||
|
w2.school_id = w3.school_id
|
||||||
|
w2.weight_id = w3.weight_id
|
||||||
|
w2.season_win = w3.season_win
|
||||||
|
w2.season_loss = w3.season_loss
|
||||||
|
w2.criteria = w3.criteria
|
||||||
|
w2.original_seed = w3.original_seed
|
||||||
|
w2.seed = w3.seed
|
||||||
|
|
||||||
|
w1.save
|
||||||
|
w2.save
|
||||||
|
end
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|||||||
@@ -41,6 +41,31 @@ class Weight < ActiveRecord::Base
|
|||||||
self.pools = 4
|
self.pools = 4
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def poolSeedOrder(pool)
|
||||||
|
wrestlersForPool(pool).sort_by{|w| [w.original_seed ? 0 : 1, w.original_seed || 0]}
|
||||||
|
end
|
||||||
|
|
||||||
|
def setOriginalSeedsToWrestleLastPoolRound
|
||||||
|
pool = 1
|
||||||
|
until pool > self.pools
|
||||||
|
wrestler1 = poolSeedOrder(pool).first
|
||||||
|
wrestler2 = poolSeedOrder(pool).second
|
||||||
|
match = wrestler1.poolMatches.sort_by{|m| m.round}.last
|
||||||
|
if match.w1 != wrestler2.id or match.w2 != wrestler2.id
|
||||||
|
if match.w1 == wrestler1.id
|
||||||
|
swapWrestlers(match.w2,wrestler2.id)
|
||||||
|
elsif match.w2 == wrestler1.id
|
||||||
|
swapWrestlers(match.w1,wrestler2.id)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
pool += 1
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
def swapWrestlers(wrestler1_id,wrestler2_id)
|
||||||
|
self.tournament.swapWrestlers(wrestler1_id,wrestler2_id)
|
||||||
|
end
|
||||||
|
|
||||||
def returnPoolNumber(wrestler)
|
def returnPoolNumber(wrestler)
|
||||||
if self.pools == 4
|
if self.pools == 4
|
||||||
|
|||||||
Reference in New Issue
Block a user