mirror of
https://github.com/jcwimer/wrestlingApp
synced 2026-03-25 01:14:43 +00:00
Mock advancment from pools to brackets
This commit is contained in:
@@ -26,5 +26,15 @@ class Match < ActiveRecord::Base
|
||||
def weight_max
|
||||
Weight.find(self.weight_id).max
|
||||
end
|
||||
|
||||
|
||||
def replaceLoserNameWithWrestler(w,loserName)
|
||||
if self.loser1_name == loserName
|
||||
self.w1 = w.id
|
||||
self.save
|
||||
end
|
||||
if self.loser2_name == loserName
|
||||
self.w2 = w.id
|
||||
self.save
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
@@ -28,6 +28,7 @@ class Pool
|
||||
w1: bout[0].id,
|
||||
w2: bout[1].id,
|
||||
weight_id: @weight.id,
|
||||
bracket_position: "Pool",
|
||||
round: round)
|
||||
matches << match
|
||||
end
|
||||
|
||||
56
app/models/pool_advance.rb
Normal file
56
app/models/pool_advance.rb
Normal file
@@ -0,0 +1,56 @@
|
||||
class Pooladvance
|
||||
|
||||
attr_accessor :wrestler
|
||||
|
||||
def poolRank
|
||||
#Give wrestlers pool points then give extra points for tie breakers and spit them out
|
||||
#in order from first to last
|
||||
#Calculate wrestlers pool points in their model
|
||||
#Order wrestlers by pool in the weight model
|
||||
end
|
||||
|
||||
def advanceWrestler
|
||||
if self.wrestler.poolMatches.size > self.wrestler.finishedMatches.size
|
||||
exit
|
||||
end
|
||||
poolToBracketAdvancment
|
||||
bracketAdvancment
|
||||
end
|
||||
|
||||
def poolToBracketAdvancment
|
||||
@pool = self.wrestler.generatePoolNumber
|
||||
@poolWrestlers = self.wrestler.weight.wrestlers_for_pool(@pool)
|
||||
@poolWrestlers.each do |w|
|
||||
if w.finishedBracketMatches.size > 0
|
||||
exit
|
||||
end
|
||||
end
|
||||
#Move to correct spot in bracket from pool
|
||||
#Pool criteria
|
||||
#Wins
|
||||
#Head to head
|
||||
#Team points
|
||||
#Pin time
|
||||
#Time on mat
|
||||
#Coin flip
|
||||
#if not one pool
|
||||
if self.wrestler.weight.wrestlers.size > 6
|
||||
|
||||
@poolOrder = self.wrestler.weight.poolOrder
|
||||
#Take pool order and move winner and runner up to correct match based on w1_name and w2_name
|
||||
@matches = self.wrestler.weight.matches
|
||||
@winnerMatch = @matches.select{|m| m.loser1_name == "Winner Pool #{@pool}" || m.loser2_name == "Winner Pool #{@pool}"}.first
|
||||
@runnerUpMatch = @matches.select{|m| m.loser1_name == "Runner Up Pool #{@pool}" || m.loser2_name == "Runner Up Pool #{@pool}"}.first
|
||||
@winner = @poolOrder.first
|
||||
@runnerUp = @poolOrder.second
|
||||
@runnerUpMatch.replaceLoserNameWithWrestler(@runnerUp,"Runner Up Pool #{@pool}")
|
||||
@winnerMatch.replaceLoserNameWithWrestler(@winner,"Winner Pool #{@pool}")
|
||||
end
|
||||
end
|
||||
|
||||
def bracketAdvancment
|
||||
#Move to next correct spot in bracket
|
||||
end
|
||||
|
||||
|
||||
end
|
||||
@@ -5,6 +5,7 @@ class School < ActiveRecord::Base
|
||||
|
||||
#calculate score here
|
||||
def score
|
||||
#Add score per wrestler. Calculate score in wrestler model.
|
||||
return 0
|
||||
end
|
||||
end
|
||||
|
||||
@@ -111,7 +111,7 @@ class Weight < ActiveRecord::Base
|
||||
|
||||
def poolRounds(matches)
|
||||
@matchups = matches.select{|m| m.weight_id == self.id}
|
||||
@poolMatches = @matchups.select{|m| m.bracket_position == nil}
|
||||
@poolMatches = @matchups.select{|m| m.bracket_position == "Pool"}
|
||||
return @poolMatches.sort_by{|m| m.round}.last.round
|
||||
end
|
||||
|
||||
@@ -128,5 +128,9 @@ class Weight < ActiveRecord::Base
|
||||
end
|
||||
return @count
|
||||
end
|
||||
|
||||
|
||||
def poolOrder
|
||||
@wrestlers = self.wrestlers
|
||||
@wrestlers.sort_by{|w| w.poolWins}.reverse
|
||||
end
|
||||
end
|
||||
|
||||
@@ -34,8 +34,25 @@ class Wrestler < ActiveRecord::Base
|
||||
@matches = Match.where("w1 = ? or w2 = ?",self.id,self.id)
|
||||
return @matches
|
||||
end
|
||||
|
||||
def poolMatches
|
||||
allMatches.select{|m| m.bracket_position == "Pool"}
|
||||
end
|
||||
|
||||
def finishedMatches
|
||||
allMatches.select{|m| m.finished == 1}
|
||||
end
|
||||
|
||||
def finishedBracketMatches
|
||||
finishedMatches.select{|m| m.bracket_position != "Pool"}
|
||||
end
|
||||
|
||||
def finishedPoolMatches
|
||||
finishedMatches.select{|m| m.bracket_position == "Pool"}
|
||||
end
|
||||
def poolWins
|
||||
allMatches.select{|m| m.winner_id == self.id && m.bracket_position == "Pool"}
|
||||
end
|
||||
def seasonWinPercentage
|
||||
@win = self.season_win.to_f
|
||||
@loss = self.season_loss.to_f
|
||||
|
||||
Reference in New Issue
Block a user