parent
938ae92f59
commit
fcf276ed31
|
|
@ -4,14 +4,18 @@ FactoryBot.define do
|
||||||
factory :playoff_match, aliases: [:match], class: Match do
|
factory :playoff_match, aliases: [:match], class: Match do
|
||||||
stage
|
stage
|
||||||
position { 0 }
|
position { 0 }
|
||||||
|
|
||||||
factory :running_playoff_match do
|
factory :running_playoff_match do
|
||||||
transient do
|
transient do
|
||||||
match_scores_count { 2 }
|
match_scores_count { 2 }
|
||||||
end
|
end
|
||||||
|
|
||||||
after(:create) do |match, evaluator|
|
after(:create) do |match, evaluator|
|
||||||
match.match_scores = create_list(:match_score, evaluator.match_scores_count)
|
match.match_scores = create_list(:match_score, evaluator.match_scores_count)
|
||||||
end
|
end
|
||||||
|
|
||||||
state { :in_progress }
|
state { :in_progress }
|
||||||
|
|
||||||
factory :finished_playoff_match do
|
factory :finished_playoff_match do
|
||||||
state { :finished }
|
state { :finished }
|
||||||
end
|
end
|
||||||
|
|
@ -32,11 +36,13 @@ FactoryBot.define do
|
||||||
transient do
|
transient do
|
||||||
match_scores_count { 2 }
|
match_scores_count { 2 }
|
||||||
end
|
end
|
||||||
|
|
||||||
after(:create) do |match, evaluator|
|
after(:create) do |match, evaluator|
|
||||||
match.match_scores = create_list(:match_score, evaluator.match_scores_count, points: 37)
|
match.match_scores = create_list(:match_score, evaluator.match_scores_count, points: 37)
|
||||||
# random number generated by blapplications
|
# random number generated by blapplications
|
||||||
match.match_scores.first.points += 1
|
match.match_scores.first.points += 1
|
||||||
end
|
end
|
||||||
|
|
||||||
state { :finished }
|
state { :finished }
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
@ -44,6 +50,7 @@ FactoryBot.define do
|
||||||
factory :group_match, class: Match do
|
factory :group_match, class: Match do
|
||||||
group
|
group
|
||||||
position { 0 }
|
position { 0 }
|
||||||
|
|
||||||
factory :filled_group_match do
|
factory :filled_group_match do
|
||||||
transient do
|
transient do
|
||||||
match_scores_count { 2 }
|
match_scores_count { 2 }
|
||||||
|
|
@ -66,9 +73,24 @@ FactoryBot.define do
|
||||||
transient do
|
transient do
|
||||||
match_scores_count { 2 }
|
match_scores_count { 2 }
|
||||||
end
|
end
|
||||||
|
|
||||||
after(:create) do |match, evaluator|
|
after(:create) do |match, evaluator|
|
||||||
match.match_scores = create_list(:match_score, evaluator.match_scores_count, points: 3)
|
match.match_scores = create_list(:match_score, evaluator.match_scores_count, points: 3)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
state { :finished }
|
||||||
|
end
|
||||||
|
|
||||||
|
factory :decided_group_match do
|
||||||
|
transient do
|
||||||
|
match_scores_count { 2 }
|
||||||
|
end
|
||||||
|
|
||||||
|
after(:create) do |match, evaluator|
|
||||||
|
match.match_scores = create_list(:match_score, evaluator.match_scores_count, points: 37)
|
||||||
|
match.match_scores.first.points += 1
|
||||||
|
end
|
||||||
|
|
||||||
state { :finished }
|
state { :finished }
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
|
||||||
|
|
@ -3,6 +3,7 @@
|
||||||
FactoryBot.define do
|
FactoryBot.define do
|
||||||
factory :stage do
|
factory :stage do
|
||||||
tournament
|
tournament
|
||||||
|
|
||||||
factory :group_stage do
|
factory :group_stage do
|
||||||
level { -1 }
|
level { -1 }
|
||||||
state { :in_progress }
|
state { :in_progress }
|
||||||
|
|
@ -22,8 +23,6 @@ FactoryBot.define do
|
||||||
match_count { 4 }
|
match_count { 4 }
|
||||||
end
|
end
|
||||||
after(:create) do |stage, evaluator|
|
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(evaluator.match_type,
|
stage.matches = create_list(evaluator.match_type,
|
||||||
evaluator.match_count == -1 ? 2**stage.level : evaluator.match_count)
|
evaluator.match_count == -1 ? 2**stage.level : evaluator.match_count)
|
||||||
stage.matches.each_with_index do |match, i|
|
stage.matches.each_with_index do |match, i|
|
||||||
|
|
@ -32,5 +31,17 @@ FactoryBot.define do
|
||||||
stage.save!
|
stage.save!
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
factory :decided_group_stage do
|
||||||
|
level { -1 }
|
||||||
|
state { :finished }
|
||||||
|
transient do
|
||||||
|
group_count { 8 }
|
||||||
|
match_factory { :decided_group_match }
|
||||||
|
end
|
||||||
|
after(:create) do |stage, evaluator|
|
||||||
|
stage.groups = create_list(:group, evaluator.group_count, match_factory: evaluator.match_factory)
|
||||||
|
end
|
||||||
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
@ -60,5 +60,22 @@ FactoryBot.define do
|
||||||
tournament.stages.concat create_list(:stage, evaluator.stage_count)
|
tournament.stages.concat create_list(:stage, evaluator.stage_count)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
factory :beerpong_tournament, parent: :tournament do
|
||||||
|
transient do
|
||||||
|
teams_count { 32 }
|
||||||
|
group_count { 8 }
|
||||||
|
match_factory { :group_match }
|
||||||
|
end
|
||||||
|
|
||||||
|
after(:create) do |tournament, evaluator|
|
||||||
|
tournament.stages << create(:group_stage,
|
||||||
|
match_factory: evaluator.match_factory,
|
||||||
|
group_count: evaluator.group_count)
|
||||||
|
tournament.teams = create_list(:team, evaluator.teams_count, tournament: tournament)
|
||||||
|
tournament.playoff_teams_amount = 16
|
||||||
|
tournament.save!
|
||||||
|
end
|
||||||
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue