Skip to content

Commit d13d900

Browse files
committed
fix: solve tournment bracket rules
1 parent 1c34eaa commit d13d900

File tree

1 file changed

+14
-1
lines changed

1 file changed

+14
-1
lines changed

app/modules/tournaments/services/bracket_generator_service.rb

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -77,14 +77,27 @@ def build_round_matches(side, round, start_number)
7777
[matches, number]
7878
end
7979

80+
# BO per phase:
81+
# UB Semifinals → BO3
82+
# Grand Final → BO5
83+
# everything else uses the tournament default (usually BO1)
84+
BO_OVERRIDES = {
85+
'UB Semifinals' => 3,
86+
'Grand Final' => 5
87+
}.freeze
88+
89+
def bo_for_round(label)
90+
BO_OVERRIDES.fetch(label, @tournament.bo_format)
91+
end
92+
8093
def create_match(side, round, match_number)
8194
TournamentMatch.create!(
8295
tournament: @tournament,
8396
bracket_side: side,
8497
round_label: round[:label],
8598
round_order: round[:order],
8699
match_number: match_number,
87-
bo_format: @tournament.bo_format,
100+
bo_format: bo_for_round(round[:label]),
88101
status: 'scheduled'
89102
)
90103
end

0 commit comments

Comments
 (0)