1
0
mirror of https://github.com/jcwimer/wrestlingApp synced 2026-03-25 01:14:43 +00:00

Advance in pool for previous matches

This commit is contained in:
2016-01-11 20:06:43 +00:00
parent 76865f7e3b
commit a8d54a2213
3 changed files with 8 additions and 7 deletions

View File

@@ -52,8 +52,8 @@ class Match < ActiveRecord::Base
if self.w1 && self.w2
@w1 = wrestler1
@w2 = wrestler2
@w1.advanceInBracket
@w2.advanceInBracket
@w1.advanceInBracket(self)
@w2.advanceInBracket(self)
if self.mat
self.mat.assignNextMatch
end

View File

@@ -1,7 +1,8 @@
class PoolAdvance
def initialize(wrestler)
def initialize(wrestler,previousMatch)
@wrestler = wrestler
@previousMatch = previousMatch
end
def advanceWrestler
@@ -29,10 +30,10 @@ class PoolAdvance
end
def bracketAdvancment
if @wrestler.winnerOfLastMatch?
if @previousMatch.winner_id == @wrestler.id
winnerAdvance
end
if !@wrestler.winnerOfLastMatch?
if @previousMatch.winner_id != @wrestler.id
loserAdvance
end
end

View File

@@ -201,7 +201,7 @@ class Wrestler < ActiveRecord::Base
end
end
def advanceInBracket
PoolAdvance.new(self).advanceWrestler
def advanceInBracket(match)
PoolAdvance.new(self,match).advanceWrestler
end
end