summaryrefslogtreecommitdiff
path: root/lib/seeding/early_bird_seeding.rb
blob: 30e15fcf67abfd096b6f042191df56a6d4efd6a4 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
module Seeding
	class EarlyBirdSeeding
		def seed_matches(tournament)
			matches = tournament.current_stage.matches
			match = matches.first
			match_num = 0
			teams = 0
			tournament.players.each_slice(tournament.min_players_per_team) do |slice|
				if teams < tournament.min_teams_per_match
					match.teams[teams].players += slice
					teams += 1
				else
					match_num += 1
					match = matches[match_num]
					teams = 0
				end
			end
		end
	end
end