mirror of
https://github.com/jcwimer/wrestlingApp
synced 2026-03-25 01:14:43 +00:00
Advance wrestlers after teampointadjust in case its added after the last match in a pool. Also added coin flip tie breaker
This commit is contained in:
@@ -45,6 +45,7 @@ class Poolorder
|
|||||||
ifWrestlersWithSamePointsIsSameAsOriginal(originalTieSize) { headToHead }
|
ifWrestlersWithSamePointsIsSameAsOriginal(originalTieSize) { headToHead }
|
||||||
end
|
end
|
||||||
ifWrestlersWithSamePointsIsSameAsOriginal(originalTieSize) { deductedPoints }
|
ifWrestlersWithSamePointsIsSameAsOriginal(originalTieSize) { deductedPoints }
|
||||||
|
ifWrestlersWithSamePointsIsSameAsOriginal(originalTieSize) { coinFlip }
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
||||||
@@ -81,4 +82,10 @@ class Poolorder
|
|||||||
addPoints(wr)
|
addPoints(wr)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def coinFlip
|
||||||
|
wrestler = wrestlersWithSamePoints.sample
|
||||||
|
addPointsToWrestlersAhead(wrestler)
|
||||||
|
addPoints(wrestler)
|
||||||
|
end
|
||||||
end
|
end
|
||||||
@@ -1,3 +1,7 @@
|
|||||||
class Teampointadjust < ActiveRecord::Base
|
class Teampointadjust < ActiveRecord::Base
|
||||||
belongs_to :wrestler
|
belongs_to :wrestler
|
||||||
|
|
||||||
|
after_save do
|
||||||
|
self.wrestler.lastFinishedMatch.advance_wrestlers
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|||||||
@@ -10,6 +10,10 @@ class Wrestler < ActiveRecord::Base
|
|||||||
self.tournament.destroyAllMatches
|
self.tournament.destroyAllMatches
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def lastFinishedMatch
|
||||||
|
allMatches.select{|m| m.finished == 1}.sort_by{|m| m.bout_number}.last
|
||||||
|
end
|
||||||
|
|
||||||
def totalDeductedPoints
|
def totalDeductedPoints
|
||||||
points = 0
|
points = 0
|
||||||
self.deductedPoints.each do |d|
|
self.deductedPoints.each do |d|
|
||||||
|
|||||||
@@ -59,13 +59,12 @@ class PoolAdvancementTest < ActionDispatch::IntegrationTest
|
|||||||
endMatch(1005,"Guy7",@matches)
|
endMatch(1005,"Guy7",@matches)
|
||||||
endMatch(2004,"Guy3",@matches)
|
endMatch(2004,"Guy3",@matches)
|
||||||
endMatch(2005,"Guy9",@matches)
|
endMatch(2005,"Guy9",@matches)
|
||||||
#DEDUCT HAS TO HAPPEN BEFORE LAST MATCH IN POOL OR ELSE ITS NOT AVAILABLE FOR POOLORDER TO CHECK
|
endMatch(3004,"Guy7",@matches)
|
||||||
|
endMatch(3005,"Guy3",@matches)
|
||||||
@deduct = Teampointadjust.new
|
@deduct = Teampointadjust.new
|
||||||
@deduct.wrestler_id = translateNameToId("Guy7")
|
@deduct.wrestler_id = translateNameToId("Guy7")
|
||||||
@deduct.points = 1
|
@deduct.points = 1
|
||||||
@deduct.save
|
@deduct.save
|
||||||
endMatch(3004,"Guy7",@matches)
|
|
||||||
endMatch(3005,"Guy3",@matches)
|
|
||||||
end
|
end
|
||||||
|
|
||||||
def endMatch(bout,winner,matches)
|
def endMatch(bout,winner,matches)
|
||||||
|
|||||||
Reference in New Issue
Block a user