1
0
mirror of https://github.com/jcwimer/wrestlingApp synced 2026-04-07 06:54:16 +00:00

Working on generating rounds in tournament model

This commit is contained in:
2015-02-02 15:45:46 -05:00
parent 9de0215a5e
commit 7ea80b2997
8 changed files with 78 additions and 9 deletions

View File

@@ -10,6 +10,7 @@ class Tournament < ActiveRecord::Base
puts weight.inspect
weight.generatePool
end
assignRound
end
def destroyAllMatches
@@ -19,4 +20,33 @@ class Tournament < ActiveRecord::Base
end
end
def assignRound
@matches = Match.where(tournament_id: self.id)
@matches.each do |match|
@round = 1
@w1 = Wrestler.find(match.r_id)
@w2 = Wrestler.find(match.g_id)
checkRound(@w1,@w2,@round)
while checkRound(@w1,@w2,@round) == false
@round = @round + 1
end
match.round = @round
match.save
end
end
def checkRound(w1,w2,round)
if w1.isWrestlingThisRound(round) == true or
w2.isWrestlingThisRound(round) == true
puts "They wrestle this round"
return false
else
puts "They do not wrestle this round"
return true
end
end
end
#@weights.sort_by{|x|[x.max]}