lib/rrschedule.rb in rrschedule-0.3.3 vs lib/rrschedule.rb in rrschedule-0.3.4
- old
+ new
@@ -44,11 +44,11 @@
while !t.empty? do
team_a = t.shift
team_b = t.reverse!.shift
t.reverse!
- x = [team_a,team_b].shuffle
+ x = (current_cycle % 2) == 0 ? [team_a,team_b] : [team_b,team_a]
matchup = {:team_a => x[0], :team_b => x[1]}
games << matchup
end
#done processing round
@@ -61,10 +61,12 @@
#add the round in memory
@rounds ||= []
@rounds[flight_id] ||= []
@rounds[flight_id] << Round.new(
:round => current_round,
+ :cycle => current_cycle + 1,
+ :round_with_cycle => current_cycle * (teams.size-1) + current_round,
:flight => flight_id,
:games => games.collect { |g|
Game.new(
:team_a => g[:team_a],
:team_b => g[:team_b]
@@ -398,13 +400,15 @@
self.game_date = params[:game_date]
end
end
class Round
- attr_accessor :round, :games,:flight
+ attr_accessor :round, :cycle, :round_with_cycle, :games, :flight
def initialize(params={})
self.round = params[:round]
+ self.cycle = params[:cycle]
+ self.round_with_cycle = params[:round_with_cycle]
self.flight = params[:flight]
self.games = params[:games] || []
end
def to_s