mirror of
https://github.com/jcwimer/wrestlingApp
synced 2026-04-10 15:50:50 +00:00
Mock advancment from pools to brackets
This commit is contained in:
@@ -27,4 +27,14 @@ class Match < ActiveRecord::Base
|
|||||||
Weight.find(self.weight_id).max
|
Weight.find(self.weight_id).max
|
||||||
end
|
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
|
end
|
||||||
|
|||||||
@@ -28,6 +28,7 @@ class Pool
|
|||||||
w1: bout[0].id,
|
w1: bout[0].id,
|
||||||
w2: bout[1].id,
|
w2: bout[1].id,
|
||||||
weight_id: @weight.id,
|
weight_id: @weight.id,
|
||||||
|
bracket_position: "Pool",
|
||||||
round: round)
|
round: round)
|
||||||
matches << match
|
matches << match
|
||||||
end
|
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
|
#calculate score here
|
||||||
def score
|
def score
|
||||||
|
#Add score per wrestler. Calculate score in wrestler model.
|
||||||
return 0
|
return 0
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|||||||
@@ -111,7 +111,7 @@ class Weight < ActiveRecord::Base
|
|||||||
|
|
||||||
def poolRounds(matches)
|
def poolRounds(matches)
|
||||||
@matchups = matches.select{|m| m.weight_id == self.id}
|
@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
|
return @poolMatches.sort_by{|m| m.round}.last.round
|
||||||
end
|
end
|
||||||
|
|
||||||
@@ -129,4 +129,8 @@ class Weight < ActiveRecord::Base
|
|||||||
return @count
|
return @count
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def poolOrder
|
||||||
|
@wrestlers = self.wrestlers
|
||||||
|
@wrestlers.sort_by{|w| w.poolWins}.reverse
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|||||||
@@ -35,7 +35,24 @@ class Wrestler < ActiveRecord::Base
|
|||||||
return @matches
|
return @matches
|
||||||
end
|
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
|
def seasonWinPercentage
|
||||||
@win = self.season_win.to_f
|
@win = self.season_win.to_f
|
||||||
@loss = self.season_loss.to_f
|
@loss = self.season_loss.to_f
|
||||||
|
|||||||
Reference in New Issue
Block a user