Put running playoff matches in a playoff stage (only on first level)
This commit is contained in:
parent
c0ac3a5f54
commit
7e4b800748
|
|
@ -16,12 +16,15 @@ FactoryBot.define do
|
|||
factory :playoff_stage do
|
||||
level { rand(10) }
|
||||
transient do
|
||||
match_state { :not_started }
|
||||
match_count { 4 }
|
||||
end
|
||||
after(:create) do |stage, evaluator|
|
||||
# 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 = create_list(:running_playoff_match,
|
||||
evaluator.match_count == -1 ? 2**stage.level : evaluator.match_count,
|
||||
state: evaluator.match_state)
|
||||
stage.matches.each_with_index { |match, i| match.position = i }
|
||||
end
|
||||
end
|
||||
|
|
|
|||
Loading…
Reference in New Issue