Subtract one off required stages if the number of teams is a power of 2

This way we now calculate the right amount of stages for every number.
(I would test every number, but Jonas won't let me write tests for all of them..)
This commit is contained in:
Daniel Schädler 2019-04-17 18:30:17 +02:00
parent 00bc8c82e3
commit 1c2d051364
1 changed files with 2 additions and 1 deletions

View File

@ -65,7 +65,8 @@ class PlayoffStageService
0 0
else else
# black voodoo magic # black voodoo magic
stage_count = Math.log(Utils.previous_power_of_two(number_of_teams)) / Math.log(2) stage_count = Math.log(Utils.next_power_of_two(number_of_teams)) / Math.log(2)
stage_count -= 1 if Utils.po2?(number_of_teams)
stage_count.to_int stage_count.to_int
end end
end end