Create realistic number of Matches
When match_count is -1 the number of matches generated is automatically 2 ^ stage.level -> This is the amount of stages present in a "real" tournament stage. When supplying a positive number, it generates that many matches like before. This also now adds the position to the match list after creating them
This commit is contained in:
parent
55f1656328
commit
7afb5ae552
|
|
@ -19,7 +19,10 @@ FactoryBot.define do
|
||||||
match_count { 4 }
|
match_count { 4 }
|
||||||
end
|
end
|
||||||
after(:create) do |stage, evaluator|
|
after(:create) do |stage, evaluator|
|
||||||
stage.matches = create_list(:match, evaluator.match_count)
|
# match_count -1 automatically generates 2 ^ stage.level matches
|
||||||
|
# (as this would be the amount of stages present in the real world)
|
||||||
|
stage.matches = create_list(:match, evaluator.match_count == -1 ? 2**stage.level : evaluator.match_count)
|
||||||
|
stage.matches.each_with_index { |match, i| match.position = i }
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue