Module: TournamentSystem::PagePlayoff
Overview
Implements the page playoff system.
Instance Method Summary collapse
-
#generate(driver, options = {}) ⇒ Object
Generate matches with the given driver.
-
#guess_round(driver) ⇒ Integer
Guess the next round number (starting at 0) from the state in a driver.
-
#total_rounds(_ = nil) ⇒ Integer
The total number of rounds in a page playoff tournament.
Instance Method Details
#generate(driver, options = {}) ⇒ Object
Generate matches with the given driver.
15 16 17 18 19 20 21 22 23 24 25 26 27 28 |
# File 'lib/tournament_system/page_playoff.rb', line 15 def generate(driver, = {}) teams = driver.ranked_teams raise 'Page Playoffs only works with 4 teams' if teams.length != 4 round = [:round] || guess_round(driver) case round when 0 then semi_finals(driver, teams) when 1 then preliminary_finals(driver) when 2 then grand_finals(driver, ) else raise 'Invalid round number' end end |
#guess_round(driver) ⇒ Integer
Guess the next round number (starting at 0) from the state in a driver.
47 48 49 |
# File 'lib/tournament_system/page_playoff.rb', line 47 def guess_round(driver) Algorithm::PagePlayoff.guess_round(driver.matches.length) end |
#total_rounds(_ = nil) ⇒ Integer
The total number of rounds in a page playoff tournament
37 38 39 |
# File 'lib/tournament_system/page_playoff.rb', line 37 def total_rounds(_ = nil) Algorithm::PagePlayoff::TOTAL_ROUNDS end |