Class: FootballManager::TeamPicker

Inherits:
Object
  • Object
show all
Defined in:
lib/football-manager/team_picker.rb

Class Method Summary collapse

Class Method Details

.calculate_fair_teams(players) ⇒ Object



3
4
5
6
7
8
9
10
11
12
13
14
15
# File 'lib/football-manager/team_picker.rb', line 3

def self.calculate_fair_teams(players)
  team_a, team_b  = FootballManager::Team.new, FootballManager::Team.new

  players_in_descending_order(players).each do |player|
    if team_a.empty? || team_a.points <= team_b.points
      team_a << player
    else
      team_b << player
    end
  end

  return [team_a, team_b]
end