mirror of
https://github.com/jcwimer/wrestlingApp
synced 2026-04-20 22:18:18 +00:00
Set up blank bracket matches for fourPools
This commit is contained in:
@@ -37,7 +37,7 @@ class StaticPagesController < ApplicationController
|
|||||||
if params[:weight]
|
if params[:weight]
|
||||||
@weight = Weight.find(params[:weight])
|
@weight = Weight.find(params[:weight])
|
||||||
@tournament = Tournament.find(@weight.tournament_id)
|
@tournament = Tournament.find(@weight.tournament_id)
|
||||||
@matches = @tournament.upcomingMatches
|
@matches = @tournament.upcomingMatches.select{|m| m.weight_id == @weight.id}
|
||||||
@wrestlers = Wrestler.where(weight_id: @weight.id)
|
@wrestlers = Wrestler.where(weight_id: @weight.id)
|
||||||
@poolOneWrestlers = @wrestlers.select{|w| w.generatePoolNumber == 1}
|
@poolOneWrestlers = @wrestlers.select{|w| w.generatePoolNumber == 1}
|
||||||
@poolTwoWrestlers = @wrestlers.select{|w| w.generatePoolNumber == 2}
|
@poolTwoWrestlers = @wrestlers.select{|w| w.generatePoolNumber == 2}
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
class Matchup
|
class Matchup
|
||||||
attr_accessor :w1, :w2, :round, :weight_id, :boutNumber, :w1_name, :w2_name
|
attr_accessor :w1, :w2, :round, :weight_id, :boutNumber, :w1_name, :w2_name, :bracket_position
|
||||||
|
|
||||||
def weight_max
|
def weight_max
|
||||||
@weight = Weight.find(self.weight_id)
|
@weight = Weight.find(self.weight_id)
|
||||||
|
|||||||
53
app/models/poolbracket.rb
Normal file
53
app/models/poolbracket.rb
Normal file
@@ -0,0 +1,53 @@
|
|||||||
|
class Poolbracket
|
||||||
|
attr_accessor :weight
|
||||||
|
|
||||||
|
def generateBracketMatches(matches,weight,highest_round)
|
||||||
|
if weight.pool_bracket_type == "twoPoolsToSemi"
|
||||||
|
|
||||||
|
elsif weight.pool_bracket_type == "twoPoolToFinal"
|
||||||
|
|
||||||
|
elsif weight.pool_bracket_type == "fourPoolsToQuarter"
|
||||||
|
|
||||||
|
elsif weight.pool_bracket_type == "fourPoolsToSemi"
|
||||||
|
matches = fourPoolsToSemi(matches,weight,highest_round)
|
||||||
|
end
|
||||||
|
return matches
|
||||||
|
end
|
||||||
|
|
||||||
|
def fourPoolsToSemi(matches,weight,round)
|
||||||
|
@round = round + 1
|
||||||
|
matches = createMatchup(matches,weight,@round,"Winner Pool 1","Winner Pool 4","Semis")
|
||||||
|
matches = createMatchup(matches,weight,@round,"Winner Pool 2","Winner Pool 3","Semis")
|
||||||
|
matches = createMatchup(matches,weight,@round,"Runner Up Pool 1","Runner Up Pool 4","Conso Semis")
|
||||||
|
matches = createMatchup(matches,weight,@round,"Runner Up Pool 2","Runner Up Pool 3","Conso Semis")
|
||||||
|
matches = assignBouts(matches)
|
||||||
|
@round = @round + 1
|
||||||
|
@matches = matches.select{|m| m.weight_id == weight.id}
|
||||||
|
matches = createMatchup(matches,weight,@round,"","","1/2")
|
||||||
|
@match1 = @matches.select{|m| m.w1_name == "Winner Pool 1"}.first
|
||||||
|
@match2 = @matches.select{|m| m.w1_name == "Winner Pool 2"}.first
|
||||||
|
matches = createMatchup(matches,weight,@round,"Loser of #{@match1.boutNumber}","Loser of #{@match2.boutNumber}","3/4")
|
||||||
|
matches = createMatchup(matches,weight,@round,"","","5/6")
|
||||||
|
@match1 = @matches.select{|m| m.w1_name == "Runner Up Pool 1"}.first
|
||||||
|
@match2 = @matches.select{|m| m.w1_name == "Runner Up Pool 2"}.first
|
||||||
|
matches = createMatchup(matches,weight,@round,"Loser of #{@match1.boutNumber}","Loser of #{@match2.boutNumber}","7/8")
|
||||||
|
return matches
|
||||||
|
end
|
||||||
|
|
||||||
|
def createMatchup(matches,weight,round,w1_name,w2_name,bracket_position)
|
||||||
|
@match = Matchup.new
|
||||||
|
@match.w1_name = w1_name
|
||||||
|
@match.w2_name = w2_name
|
||||||
|
@match.weight_id = weight.id
|
||||||
|
@match.round = round
|
||||||
|
@match.bracket_position = bracket_position
|
||||||
|
matches << @match
|
||||||
|
return matches
|
||||||
|
end
|
||||||
|
|
||||||
|
def assignBouts(matches)
|
||||||
|
@bouts = Bout.new
|
||||||
|
@matches = @bouts.assignBouts(matches)
|
||||||
|
return @matches
|
||||||
|
end
|
||||||
|
end
|
||||||
@@ -97,13 +97,17 @@ class Weight < ActiveRecord::Base
|
|||||||
elsif self.wrestlers.size > 11 && self.wrestlers.size <= 16
|
elsif self.wrestlers.size > 11 && self.wrestlers.size <= 16
|
||||||
return "fourPoolsToSemi"
|
return "fourPoolsToSemi"
|
||||||
end
|
end
|
||||||
self.wrestlers.size
|
|
||||||
end
|
end
|
||||||
|
|
||||||
def generateMatchups(matches)
|
def generateMatchups(matches)
|
||||||
@wrestlers = self.wrestlers
|
@wrestlers = self.wrestlers
|
||||||
@pool = Pool.new
|
@pool = Pool.new
|
||||||
@matches = @pool.generatePools(self.pools,@wrestlers,self,self.tournament_id,matches)
|
@matches = @pool.generatePools(self.pools,@wrestlers,self,self.tournament_id,matches)
|
||||||
|
@weight_matches = @matches.select{|m|m.weight_id == self.id}
|
||||||
|
@last_match = @weight_matches.sort_by{|m| m.round}.last
|
||||||
|
@highest_round = @last_match.round
|
||||||
|
@bracket = Poolbracket.new
|
||||||
|
@matches = @bracket.generateBracketMatches(@matches,self,@highest_round)
|
||||||
return @matches
|
return @matches
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|||||||
@@ -1,185 +1,192 @@
|
|||||||
<style>
|
<style>
|
||||||
/*
|
/*
|
||||||
* Flex Layout Specifics
|
* Flex Layout Specifics
|
||||||
*/
|
*/
|
||||||
main{
|
main{
|
||||||
display:flex;
|
display:flex;
|
||||||
flex-direction:row;
|
flex-direction:row;
|
||||||
}
|
}
|
||||||
.round{
|
.round{
|
||||||
display:flex;
|
display:flex;
|
||||||
flex-direction:column;
|
flex-direction:column;
|
||||||
justify-content:center;
|
justify-content:center;
|
||||||
width:200px;
|
width:200px;
|
||||||
list-style:none;
|
list-style:none;
|
||||||
padding:0;
|
padding:0;
|
||||||
}
|
}
|
||||||
.round .spacer{ flex-grow:1; }
|
.round .spacer{ flex-grow:1; }
|
||||||
.round .spacer:first-child,
|
.round .spacer:first-child,
|
||||||
.round .spacer:last-child{ flex-grow:.5; }
|
.round .spacer:last-child{ flex-grow:.5; }
|
||||||
|
|
||||||
.round .game-spacer{
|
.round .game-spacer{
|
||||||
flex-grow:1;
|
flex-grow:1;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* General Styles
|
* General Styles
|
||||||
*/
|
*/
|
||||||
body{
|
body{
|
||||||
font-family:sans-serif;
|
font-family:sans-serif;
|
||||||
font-size:small;
|
font-size:small;
|
||||||
padding:10px;
|
padding:10px;
|
||||||
line-height:1.4em;
|
line-height:1.4em;
|
||||||
}
|
}
|
||||||
|
|
||||||
li.game{
|
li.game{
|
||||||
padding-left:20px;
|
padding-left:20px;
|
||||||
}
|
}
|
||||||
|
|
||||||
li.game.winner{
|
li.game.winner{
|
||||||
font-weight:bold;
|
font-weight:bold;
|
||||||
}
|
}
|
||||||
li.game span{
|
li.game span{
|
||||||
float:right;
|
float:right;
|
||||||
margin-right:5px;
|
margin-right:5px;
|
||||||
}
|
}
|
||||||
|
|
||||||
li.game-top{ border-bottom:1px solid #aaa; }
|
li.game-top{ border-bottom:1px solid #aaa; }
|
||||||
|
|
||||||
li.game-spacer{
|
li.game-spacer{
|
||||||
border-right:1px solid #aaa;
|
border-right:1px solid #aaa;
|
||||||
min-height:40px;
|
min-height:40px;
|
||||||
}
|
}
|
||||||
|
|
||||||
li.game-bottom{
|
li.game-bottom{
|
||||||
border-top:1px solid #aaa;
|
border-top:1px solid #aaa;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
</style>
|
</style>
|
||||||
|
|
||||||
|
|
||||||
<h5>Championship Bracket After Pool</h5>
|
<h5>Championship Bracket After Pool</h5>
|
||||||
<main id="bracket">
|
<main id="bracket">
|
||||||
<ul class="round round-1">
|
<ul class="round round-1">
|
||||||
<li class="spacer"> </li>
|
<% @matches.select{|m|m.bracket_position == "Semis"}.each do |match| %>
|
||||||
|
<li class="spacer"> </li>
|
||||||
<li class="game game-top ">Winner Pool 1 <span>Score</span></li>
|
|
||||||
<li class="game game-spacer"> </li>
|
<li class="game game-top "><%= match.w1_name %> <span>Score</span></li>
|
||||||
<li class="game game-bottom ">Winner Pool 4<span>Score</span></li>
|
<li class="game game-spacer"><%= match.boutNumber %> </li>
|
||||||
|
<li class="game game-bottom "><%= match.w2_name %><span>Score</span></li>
|
||||||
<li class="spacer"> </li>
|
|
||||||
|
<li class="spacer"> </li>
|
||||||
<li class="game game-top ">Winner Pool 3<span>Score</span></li>
|
|
||||||
<li class="game game-spacer"> </li>
|
<% end %>
|
||||||
<li class="game game-bottom ">Winner Pool 2 <span>Score</span></li>
|
</ul>
|
||||||
|
<ul class="round round-2">
|
||||||
<li class="spacer"> </li>
|
<% @matches.select{|m|m.bracket_position == "1/2"}.each do |match| %>
|
||||||
</ul>
|
<li class="spacer"> </li>
|
||||||
<ul class="round round-2">
|
|
||||||
<li class="spacer"> </li>
|
<li class="game game-top "><%= match.w1_name %> <span>Score</span></li>
|
||||||
|
<li class="game game-spacer"><%= match.boutNumber %> </li>
|
||||||
<li class="game game-top "> <span></span></li>
|
<li class="game game-bottom "><%= match.w2_name %><span>Score</span></li>
|
||||||
<li class="game game-spacer"> </li>
|
|
||||||
<li class="game game-bottom "><span></span></li>
|
<li class="spacer"> </li>
|
||||||
|
|
||||||
<li class="spacer"> </li>
|
<% end %>
|
||||||
|
</ul>
|
||||||
|
<ul class="round round-3">
|
||||||
</ul>
|
<li class="spacer"> </li>
|
||||||
<ul class="round round-3">
|
|
||||||
<li class="spacer"> </li>
|
<li class="game game-top "> <span></span></li>
|
||||||
|
1st
|
||||||
<li class="game game-top "> <span></span></li>
|
|
||||||
1st
|
<li class="spacer"> </li>
|
||||||
|
|
||||||
<li class="spacer"> </li>
|
</ul>
|
||||||
|
</main>
|
||||||
</ul>
|
</br>
|
||||||
</main>
|
|
||||||
</br>
|
<h5>3rd/4th</h5>
|
||||||
<h5>3rd/4th</h5>
|
<main id="bracket">
|
||||||
<main id="bracket">
|
<ul class="round round-1">
|
||||||
<ul class="round round-1">
|
<% @matches.select{|m|m.bracket_position == "3/4"}.each do |match| %>
|
||||||
<li class="spacer"> </li>
|
<li class="spacer"> </li>
|
||||||
|
|
||||||
<li class="game game-top "> <span>Score</span></li>
|
<li class="game game-top "><%= match.w1_name %> <span>Score</span></li>
|
||||||
<li class="game game-spacer"> </li>
|
<li class="game game-spacer"><%= match.boutNumber %> </li>
|
||||||
<li class="game game-bottom "><span>Score</span></li>
|
<li class="game game-bottom "><%= match.w2_name %><span>Score</span></li>
|
||||||
|
|
||||||
<li class="spacer"> </li>
|
<li class="spacer"> </li>
|
||||||
</ul>
|
|
||||||
<ul class="round round-2">
|
<% end %>
|
||||||
<li class="spacer"> </li>
|
</ul>
|
||||||
|
<ul class="round round-2">
|
||||||
<li class="game game-top "> <span></span></li>
|
<li class="spacer"> </li>
|
||||||
3rd
|
|
||||||
<li class="spacer"> </li>
|
<li class="game game-top "> <span></span></li>
|
||||||
|
3rd
|
||||||
|
|
||||||
</ul>
|
<li class="spacer"> </li>
|
||||||
|
|
||||||
</main>
|
</ul>
|
||||||
|
</main>
|
||||||
</br>
|
</br>
|
||||||
<h5>Consolation Bracket After Pool</h5>
|
|
||||||
<main id="bracket">
|
|
||||||
<ul class="round round-1">
|
<h5>Consolation Bracket After Pool</h5>
|
||||||
<li class="spacer"> </li>
|
<main id="bracket">
|
||||||
|
<ul class="round round-1">
|
||||||
<li class="game game-top ">Runner Up Pool 1 <span>Score</span></li>
|
<% @matches.select{|m|m.bracket_position == "Conso Semis"}.each do |match| %>
|
||||||
<li class="game game-spacer"> </li>
|
<li class="spacer"> </li>
|
||||||
<li class="game game-bottom ">Runner Up Pool 4<span>Score</span></li>
|
|
||||||
|
<li class="game game-top "><%= match.w1_name %> <span>Score</span></li>
|
||||||
<li class="spacer"> </li>
|
<li class="game game-spacer"><%= match.boutNumber %> </li>
|
||||||
|
<li class="game game-bottom "><%= match.w2_name %><span>Score</span></li>
|
||||||
<li class="game game-top ">Runner Up Pool 3<span>Score</span></li>
|
|
||||||
<li class="game game-spacer"> </li>
|
<li class="spacer"> </li>
|
||||||
<li class="game game-bottom ">Runner Up Pool 2 <span>Score</span></li>
|
|
||||||
|
<% end %>
|
||||||
<li class="spacer"> </li>
|
</ul>
|
||||||
</ul>
|
<ul class="round round-2">
|
||||||
<ul class="round round-2">
|
<% @matches.select{|m|m.bracket_position == "5/6"}.each do |match| %>
|
||||||
<li class="spacer"> </li>
|
<li class="spacer"> </li>
|
||||||
|
|
||||||
<li class="game game-top "> <span></span></li>
|
<li class="game game-top "><%= match.w1_name %> <span>Score</span></li>
|
||||||
<li class="game game-spacer"> </li>
|
<li class="game game-spacer"><%= match.boutNumber %> </li>
|
||||||
<li class="game game-bottom "><span></span></li>
|
<li class="game game-bottom "><%= match.w2_name %><span>Score</span></li>
|
||||||
|
|
||||||
<li class="spacer"> </li>
|
<li class="spacer"> </li>
|
||||||
|
|
||||||
|
<% end %>
|
||||||
</ul>
|
</ul>
|
||||||
<ul class="round round-3">
|
<ul class="round round-3">
|
||||||
<li class="spacer"> </li>
|
<li class="spacer"> </li>
|
||||||
|
|
||||||
<li class="game game-top "> <span></span></li>
|
<li class="game game-top "> <span></span></li>
|
||||||
5th
|
5th
|
||||||
|
|
||||||
<li class="spacer"> </li>
|
<li class="spacer"> </li>
|
||||||
|
|
||||||
</ul>
|
</ul>
|
||||||
</main>
|
</main>
|
||||||
</br>
|
<br>
|
||||||
<h5>7th/8th</h5>
|
<h5>7th/8th</h5>
|
||||||
<main id="bracket">
|
<main id="bracket">
|
||||||
<ul class="round round-1">
|
<ul class="round round-1">
|
||||||
<li class="spacer"> </li>
|
<% @matches.select{|m|m.bracket_position == "7/8"}.each do |match| %>
|
||||||
|
<li class="spacer"> </li>
|
||||||
<li class="game game-top "> <span>Score</span></li>
|
|
||||||
<li class="game game-spacer"> </li>
|
<li class="game game-top "><%= match.w1_name %> <span>Score</span></li>
|
||||||
<li class="game game-bottom "><span>Score</span></li>
|
<li class="game game-spacer"><%= match.boutNumber %> </li>
|
||||||
|
<li class="game game-bottom "><%= match.w2_name %><span>Score</span></li>
|
||||||
<li class="spacer"> </li>
|
|
||||||
</ul>
|
<li class="spacer"> </li>
|
||||||
<ul class="round round-2">
|
|
||||||
<li class="spacer"> </li>
|
<% end %>
|
||||||
|
</ul>
|
||||||
<li class="game game-top "> <span></span></li>
|
<ul class="round round-2">
|
||||||
7th
|
<li class="spacer"> </li>
|
||||||
<li class="spacer"> </li>
|
|
||||||
|
<li class="game game-top "> <span></span></li>
|
||||||
|
7th
|
||||||
</ul>
|
|
||||||
|
<li class="spacer"> </li>
|
||||||
</main>
|
|
||||||
|
</ul>
|
||||||
|
</main>
|
||||||
|
</br>
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user