mirror of
https://github.com/jcwimer/wrestlingApp
synced 2026-03-25 01:14:43 +00:00
Added persistence to pool placement and pool order
This commit is contained in:
@@ -140,7 +140,7 @@ class Weight < ActiveRecord::Base
|
|||||||
end
|
end
|
||||||
|
|
||||||
def pool_placement_order(pool)
|
def pool_placement_order(pool)
|
||||||
PoolOrder.new(wrestlers_in_pool(pool)).getPoolOrder
|
#PoolOrder.new(wrestlers_in_pool(pool)).getPoolOrder
|
||||||
end
|
end
|
||||||
|
|
||||||
def wrestlers_without_pool_assignment
|
def wrestlers_without_pool_assignment
|
||||||
|
|||||||
@@ -40,6 +40,10 @@ class Wrestler < ActiveRecord::Base
|
|||||||
def total_pool_points_for_pool_order
|
def total_pool_points_for_pool_order
|
||||||
CalculateWrestlerTeamScore.new(self).poolPoints + CalculateWrestlerTeamScore.new(self).bonusWinPoints
|
CalculateWrestlerTeamScore.new(self).poolPoints + CalculateWrestlerTeamScore.new(self).bonusWinPoints
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def unfinished_pool_matches
|
||||||
|
unfinished_matches.select{|match| match.finished != 1}
|
||||||
|
end
|
||||||
|
|
||||||
def next_match
|
def next_match
|
||||||
unfinished_matches.first
|
unfinished_matches.first
|
||||||
@@ -195,6 +199,14 @@ class Wrestler < ActiveRecord::Base
|
|||||||
def fastest_pin
|
def fastest_pin
|
||||||
pin_wins.sort_by{|m| m.pin_time_in_seconds}.first
|
pin_wins.sort_by{|m| m.pin_time_in_seconds}.first
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def pin_time
|
||||||
|
time = 0
|
||||||
|
pin_wins.each do | m |
|
||||||
|
time = time + m.pin_time_in_seconds
|
||||||
|
end
|
||||||
|
time
|
||||||
|
end
|
||||||
|
|
||||||
def season_win_percentage
|
def season_win_percentage
|
||||||
win = self.season_win.to_f
|
win = self.season_win.to_f
|
||||||
|
|||||||
@@ -5,10 +5,17 @@ class AdvanceWrestler
|
|||||||
end
|
end
|
||||||
|
|
||||||
def advance
|
def advance
|
||||||
PoolAdvance.new(@wrestler,@wrestler.last_match).advanceWrestler if @tournament.tournament_type == "Pool to bracket"
|
pool_to_bracket_advancement if @tournament.tournament_type == "Pool to bracket"
|
||||||
end
|
end
|
||||||
if Rails.env.production?
|
if Rails.env.production?
|
||||||
handle_asynchronously :advance
|
handle_asynchronously :advance
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def pool_to_bracket_advancement
|
||||||
|
if @wrestler.weight.all_pool_matches_finished(@wrestler.pool) and (@wrestler.finished_bracket_matches.size == 0 or @wrestler.weight.pools == 1)
|
||||||
|
PoolOrder.new(@wrestler.weight.wrestlers_in_pool(@wrestler.pool)).getPoolOrder
|
||||||
|
end
|
||||||
|
PoolAdvance.new(@wrestler,@wrestler.last_match).advanceWrestler
|
||||||
|
end
|
||||||
|
|
||||||
end
|
end
|
||||||
@@ -6,7 +6,7 @@ class PoolAdvance
|
|||||||
end
|
end
|
||||||
|
|
||||||
def advanceWrestler
|
def advanceWrestler
|
||||||
if @wrestler.weight.all_pool_matches_finished(@wrestler.pool) && @wrestler.finished_bracket_matches.size == 0
|
if @wrestler.pool_placement and @wrestler.weight.pools > 1
|
||||||
poolToBracketAdvancment
|
poolToBracketAdvancment
|
||||||
end
|
end
|
||||||
if @wrestler.finished_bracket_matches.size > 0
|
if @wrestler.finished_bracket_matches.size > 0
|
||||||
@@ -15,20 +15,12 @@ class PoolAdvance
|
|||||||
end
|
end
|
||||||
|
|
||||||
def poolToBracketAdvancment
|
def poolToBracketAdvancment
|
||||||
pool = @wrestler.pool
|
if @wrestler.pool_placement == 2
|
||||||
if @wrestler.weight.wrestlers.size > 6
|
runnerUpMatch.replace_loser_name_with_wrestler(runnerUp,"Runner Up Pool #{pool}")
|
||||||
pool_placement_order = @wrestler.weight.pool_placement_order(pool)
|
end
|
||||||
#Take pool order and move winner and runner up to correct match based on w1_name and w2_name
|
if @wrestler.pool_placement == 1
|
||||||
matches = @wrestler.weight.matches
|
winnerMatch.replace_loser_name_with_wrestler(winner,"Winner Pool #{pool}")
|
||||||
winnerMatch = matches.select{|m| m.loser1_name == "Winner Pool #{pool}" || m.loser2_name == "Winner Pool #{pool}"}.first
|
end
|
||||||
runnerUpMatch = matches.select{|m| m.loser1_name == "Runner Up Pool #{pool}" || m.loser2_name == "Runner Up Pool #{pool}"}.first
|
|
||||||
winner = pool_placement_order.first
|
|
||||||
runnerUp = pool_placement_order.second
|
|
||||||
if runnerUpMatch
|
|
||||||
runnerUpMatch.replace_loser_name_with_wrestler(runnerUp,"Runner Up Pool #{pool}")
|
|
||||||
end
|
|
||||||
winnerMatch.replace_loser_name_with_wrestler(winner,"Winner Pool #{pool}")
|
|
||||||
end
|
|
||||||
end
|
end
|
||||||
|
|
||||||
def bracketAdvancment
|
def bracketAdvancment
|
||||||
|
|||||||
@@ -8,6 +8,11 @@ class PoolOrder
|
|||||||
while checkForTieBreakers == true
|
while checkForTieBreakers == true
|
||||||
breakTie
|
breakTie
|
||||||
end
|
end
|
||||||
|
@wrestlers.sort_by{|w| w.poolAdvancePoints}.reverse.each_with_index do |wrestler, index|
|
||||||
|
placement = index + 1
|
||||||
|
wrestler.pool_placement = placement
|
||||||
|
wrestler.save
|
||||||
|
end
|
||||||
@wrestlers.sort_by{|w| w.poolAdvancePoints}.reverse!
|
@wrestlers.sort_by{|w| w.poolAdvancePoints}.reverse!
|
||||||
end
|
end
|
||||||
|
|
||||||
@@ -41,7 +46,7 @@ class PoolOrder
|
|||||||
|
|
||||||
def breakTie
|
def breakTie
|
||||||
originalTieSize = wrestlersWithSamePoints.size
|
originalTieSize = wrestlersWithSamePoints.size
|
||||||
ifWrestlersWithSamePointsIsSameAsOriginal(originalTieSize) { deductedPoints }
|
#ifWrestlersWithSamePointsIsSameAsOriginal(originalTieSize) { deductedPoints }
|
||||||
if originalTieSize == 2
|
if originalTieSize == 2
|
||||||
ifWrestlersWithSamePointsIsSameAsOriginal(originalTieSize) { headToHead }
|
ifWrestlersWithSamePointsIsSameAsOriginal(originalTieSize) { headToHead }
|
||||||
end
|
end
|
||||||
@@ -50,7 +55,7 @@ class PoolOrder
|
|||||||
ifWrestlersWithSamePointsIsSameAsOriginal(originalTieSize) { mostTechs }
|
ifWrestlersWithSamePointsIsSameAsOriginal(originalTieSize) { mostTechs }
|
||||||
ifWrestlersWithSamePointsIsSameAsOriginal(originalTieSize) { mostMajors }
|
ifWrestlersWithSamePointsIsSameAsOriginal(originalTieSize) { mostMajors }
|
||||||
ifWrestlersWithSamePointsIsSameAsOriginal(originalTieSize) { mostDecisionPointsScored }
|
ifWrestlersWithSamePointsIsSameAsOriginal(originalTieSize) { mostDecisionPointsScored }
|
||||||
ifWrestlersWithSamePointsIsSameAsOriginal(originalTieSize) { fastest_pin }
|
ifWrestlersWithSamePointsIsSameAsOriginal(originalTieSize) { fastest_pins }
|
||||||
ifWrestlersWithSamePointsIsSameAsOriginal(originalTieSize) { coinFlip }
|
ifWrestlersWithSamePointsIsSameAsOriginal(originalTieSize) { coinFlip }
|
||||||
end
|
end
|
||||||
|
|
||||||
@@ -60,6 +65,8 @@ class PoolOrder
|
|||||||
otherWrestler = wrestlersWithSamePoints.select{|w| w.id != wr.id}.first
|
otherWrestler = wrestlersWithSamePoints.select{|w| w.id != wr.id}.first
|
||||||
if wr.match_against(otherWrestler).first.winner_id == wr.id
|
if wr.match_against(otherWrestler).first.winner_id == wr.id
|
||||||
addPointsToWrestlersAhead(wr)
|
addPointsToWrestlersAhead(wr)
|
||||||
|
wr.pool_placement_tiebreaker = "Head to Head"
|
||||||
|
wr.save
|
||||||
addPoints(wr)
|
addPoints(wr)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
@@ -85,6 +92,8 @@ class PoolOrder
|
|||||||
wrestlersWithLeastDeductedPoints = wrestlersWithSamePoints.select{|w| w.total_points_deducted == leastPoints}
|
wrestlersWithLeastDeductedPoints = wrestlersWithSamePoints.select{|w| w.total_points_deducted == leastPoints}
|
||||||
addPointsToWrestlersAhead(wrestlersWithLeastDeductedPoints.first)
|
addPointsToWrestlersAhead(wrestlersWithLeastDeductedPoints.first)
|
||||||
wrestlersWithLeastDeductedPoints.each do |wr|
|
wrestlersWithLeastDeductedPoints.each do |wr|
|
||||||
|
wr.pool_placement_tiebreaker = "Least Deducted Points"
|
||||||
|
wr.save
|
||||||
addPoints(wr)
|
addPoints(wr)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
@@ -98,17 +107,21 @@ class PoolOrder
|
|||||||
wrestlersWithMostPoints = wrestlersWithSamePoints.select{|w| w.decision_points_scored == mostPoints}
|
wrestlersWithMostPoints = wrestlersWithSamePoints.select{|w| w.decision_points_scored == mostPoints}
|
||||||
addPointsToWrestlersAhead(wrestlersWithMostPoints.first)
|
addPointsToWrestlersAhead(wrestlersWithMostPoints.first)
|
||||||
wrestlersWithMostPoints.each do |wr|
|
wrestlersWithMostPoints.each do |wr|
|
||||||
|
wr.pool_placement_tiebreaker = "Points Scored"
|
||||||
|
wr.save
|
||||||
addPoints(wr)
|
addPoints(wr)
|
||||||
end
|
end
|
||||||
secondPoints = pointsArray.sort[-2]
|
secondPoints = pointsArray.sort[-2]
|
||||||
wrestlersWithSecondMostPoints = wrestlersWithSamePoints.select{|w| w.decision_points_scored == secondPoints}
|
wrestlersWithSecondMostPoints = wrestlersWithSamePoints.select{|w| w.decision_points_scored == secondPoints}
|
||||||
addPointsToWrestlersAhead(wrestlersWithSecondMostPoints.first)
|
addPointsToWrestlersAhead(wrestlersWithSecondMostPoints.first)
|
||||||
wrestlersWithSecondMostPoints.each do |wr|
|
wrestlersWithSecondMostPoints.each do |wr|
|
||||||
|
wr.pool_placement_tiebreaker = "Points Scored"
|
||||||
|
wr.save
|
||||||
addPoints(wr)
|
addPoints(wr)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
def fastest_pin
|
def fastest_pins
|
||||||
wrestlersWithSamePointsWithPins = []
|
wrestlersWithSamePointsWithPins = []
|
||||||
wrestlersWithSamePoints.each do |wr|
|
wrestlersWithSamePoints.each do |wr|
|
||||||
if wr.pin_wins.size > 0
|
if wr.pin_wins.size > 0
|
||||||
@@ -121,12 +134,16 @@ class PoolOrder
|
|||||||
wrestlersWithFastestPin = wrestlersWithSamePointsWithPins.select{|w| w.fastest_pin.pin_time_in_seconds == fastest.pin_time_in_seconds}
|
wrestlersWithFastestPin = wrestlersWithSamePointsWithPins.select{|w| w.fastest_pin.pin_time_in_seconds == fastest.pin_time_in_seconds}
|
||||||
addPointsToWrestlersAhead(wrestlersWithFastestPin.first)
|
addPointsToWrestlersAhead(wrestlersWithFastestPin.first)
|
||||||
wrestlersWithFastestPin.each do |wr|
|
wrestlersWithFastestPin.each do |wr|
|
||||||
|
wr.pool_placement_tiebreaker = "Pin Time"
|
||||||
|
wr.save
|
||||||
addPoints(wr)
|
addPoints(wr)
|
||||||
end
|
end
|
||||||
|
|
||||||
wrestlersWithSecondFastestPin = wrestlersWithSamePointsWithPins.select{|w| w.fastest_pin.pin_time_in_seconds == secondFastest.pin_time_in_seconds}
|
wrestlersWithSecondFastestPin = wrestlersWithSamePointsWithPins.select{|w| w.fastest_pin.pin_time_in_seconds == secondFastest.pin_time_in_seconds}
|
||||||
addPointsToWrestlersAhead(wrestlersWithSecondFastestPin.first)
|
addPointsToWrestlersAhead(wrestlersWithSecondFastestPin.first)
|
||||||
wrestlersWithSecondFastestPin.each do |wr|
|
wrestlersWithSecondFastestPin.each do |wr|
|
||||||
|
wr.pool_placement_tiebreaker = "Pin Time"
|
||||||
|
wr.save
|
||||||
addPoints(wr)
|
addPoints(wr)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
@@ -138,9 +155,11 @@ class PoolOrder
|
|||||||
pointsArray << w.total_pool_points_for_pool_order
|
pointsArray << w.total_pool_points_for_pool_order
|
||||||
end
|
end
|
||||||
mostPoints = pointsArray.max
|
mostPoints = pointsArray.max
|
||||||
wrestlersWithLeastDeductedPoints = wrestlersWithSamePoints.select{|w| w.total_pool_points_for_pool_order == mostPoints}
|
wrestlersSortedByTeamPoints = wrestlersWithSamePoints.select{|w| w.total_pool_points_for_pool_order == mostPoints}
|
||||||
addPointsToWrestlersAhead(wrestlersWithLeastDeductedPoints.first)
|
addPointsToWrestlersAhead(wrestlersSortedByTeamPoints.first)
|
||||||
wrestlersWithLeastDeductedPoints.each do |wr|
|
wrestlersSortedByTeamPoints.each do |wr|
|
||||||
|
wr.pool_placement_tiebreaker = "Team Points"
|
||||||
|
wr.save
|
||||||
addPoints(wr)
|
addPoints(wr)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
@@ -151,9 +170,11 @@ class PoolOrder
|
|||||||
pointsArray << w.pin_wins.size
|
pointsArray << w.pin_wins.size
|
||||||
end
|
end
|
||||||
mostPoints = pointsArray.max
|
mostPoints = pointsArray.max
|
||||||
wrestlersWithLeastDeductedPoints = wrestlersWithSamePoints.select{|w| w.pin_wins.size == mostPoints}
|
wrestlersSortedByFallWins = wrestlersWithSamePoints.select{|w| w.pin_wins.size == mostPoints}
|
||||||
addPointsToWrestlersAhead(wrestlersWithLeastDeductedPoints.first)
|
addPointsToWrestlersAhead(wrestlersSortedByFallWins.first)
|
||||||
wrestlersWithLeastDeductedPoints.each do |wr|
|
wrestlersSortedByFallWins.each do |wr|
|
||||||
|
wr.pool_placement_tiebreaker = "Most Pins"
|
||||||
|
wr.save
|
||||||
addPoints(wr)
|
addPoints(wr)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
@@ -164,9 +185,11 @@ class PoolOrder
|
|||||||
pointsArray << w.tech_wins.size
|
pointsArray << w.tech_wins.size
|
||||||
end
|
end
|
||||||
mostPoints = pointsArray.max
|
mostPoints = pointsArray.max
|
||||||
wrestlersWithLeastDeductedPoints = wrestlersWithSamePoints.select{|w| w.tech_wins.size == mostPoints}
|
wrestlersSortedByTechWins = wrestlersWithSamePoints.select{|w| w.tech_wins.size == mostPoints}
|
||||||
addPointsToWrestlersAhead(wrestlersWithLeastDeductedPoints.first)
|
addPointsToWrestlersAhead(wrestlersSortedByTechWins.first)
|
||||||
wrestlersWithLeastDeductedPoints.each do |wr|
|
wrestlersSortedByTechWins.each do |wr|
|
||||||
|
wr.pool_placement_tiebreaker = "Most Techs"
|
||||||
|
wr.save
|
||||||
addPoints(wr)
|
addPoints(wr)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
@@ -177,15 +200,19 @@ class PoolOrder
|
|||||||
pointsArray << w.major_wins.size
|
pointsArray << w.major_wins.size
|
||||||
end
|
end
|
||||||
mostPoints = pointsArray.max
|
mostPoints = pointsArray.max
|
||||||
wrestlersWithLeastDeductedPoints = wrestlersWithSamePoints.select{|w| w.major_wins.size == mostPoints}
|
wrestlersSortedByMajorWins = wrestlersWithSamePoints.select{|w| w.major_wins.size == mostPoints}
|
||||||
addPointsToWrestlersAhead(wrestlersWithLeastDeductedPoints.first)
|
addPointsToWrestlersAhead(wrestlersSortedByMajorWins.first)
|
||||||
wrestlersWithLeastDeductedPoints.each do |wr|
|
wrestlersSortedByMajorWins.each do |wr|
|
||||||
|
wr.pool_placement_tiebreaker = "Most Majors"
|
||||||
|
wr.save
|
||||||
addPoints(wr)
|
addPoints(wr)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
def coinFlip
|
def coinFlip
|
||||||
wrestler = wrestlersWithSamePoints.sample
|
wrestler = wrestlersWithSamePoints.sample
|
||||||
|
wrestler.pool_placement_tiebreaker = "Coin Flip"
|
||||||
|
wrestler.save
|
||||||
addPointsToWrestlersAhead(wrestler)
|
addPointsToWrestlersAhead(wrestler)
|
||||||
addPoints(wrestler)
|
addPoints(wrestler)
|
||||||
end
|
end
|
||||||
|
|||||||
@@ -67,14 +67,13 @@ class PoolBracketPlacementPoints
|
|||||||
end
|
end
|
||||||
|
|
||||||
def onePool
|
def onePool
|
||||||
pool_placement_order = @wrestler.weight.pool_placement_order(1)
|
if @wrestler.pool_placement == 1
|
||||||
if @wrestler == pool_placement_order.first
|
|
||||||
return firstPlace
|
return firstPlace
|
||||||
elsif @wrestler == pool_placement_order.second
|
elsif @wrestler.pool_placement == 2
|
||||||
return secondPlace
|
return secondPlace
|
||||||
elsif @wrestler == pool_placement_order.third
|
elsif @wrestler.pool_placement == 3
|
||||||
return thirdPlace
|
return thirdPlace
|
||||||
elsif @wrestler == pool_placement_order.fourth
|
elsif @wrestler.pool_placement == 4
|
||||||
return fourthPlace
|
return fourthPlace
|
||||||
end
|
end
|
||||||
return 0
|
return 0
|
||||||
|
|||||||
@@ -12,6 +12,7 @@
|
|||||||
<% end %>
|
<% end %>
|
||||||
<% @round = @round + 1 %>
|
<% @round = @round + 1 %>
|
||||||
<% end %>
|
<% end %>
|
||||||
|
<th>Placement</th>
|
||||||
</tr>
|
</tr>
|
||||||
</thead>
|
</thead>
|
||||||
<tbody>
|
<tbody>
|
||||||
@@ -25,6 +26,7 @@
|
|||||||
<% end %>
|
<% end %>
|
||||||
<% @round = @round + 1 %>
|
<% @round = @round + 1 %>
|
||||||
<% end %>
|
<% end %>
|
||||||
|
<td><%= w.pool_placement %><br><%= w.pool_placement_tiebreaker %></td>
|
||||||
|
|
||||||
</tr>
|
</tr>
|
||||||
<% end %>
|
<% end %>
|
||||||
|
|||||||
@@ -24,14 +24,14 @@
|
|||||||
<tr>
|
<tr>
|
||||||
<td><%= link_to "#{tournament.name}", tournament %></td>
|
<td><%= link_to "#{tournament.name}", tournament %></td>
|
||||||
<td><%= tournament.date %></td>
|
<td><%= tournament.date %></td>
|
||||||
|
<td>
|
||||||
<% if can? :manage, tournament %>
|
<% if can? :manage, tournament %>
|
||||||
<td>
|
|
||||||
<%= link_to '', edit_tournament_path(tournament), :class=>"fas fa-edit" %>
|
<%= link_to '', edit_tournament_path(tournament), :class=>"fas fa-edit" %>
|
||||||
<% if can? :destroy, tournament %>
|
<% if can? :destroy, tournament %>
|
||||||
<%= link_to '', tournament, method: :delete, data: { confirm: "Are you sure you want to delete #{tournament.name}?" }, :class=>"fas fa-trash-alt" %>
|
<%= link_to '', tournament, method: :delete, data: { confirm: "Are you sure you want to delete #{tournament.name}?" }, :class=>"fas fa-trash-alt" %>
|
||||||
<% end %>
|
<% end %>
|
||||||
</td>
|
|
||||||
<% end %>
|
<% end %>
|
||||||
|
</td>
|
||||||
</tr>
|
</tr>
|
||||||
<% end %>
|
<% end %>
|
||||||
</tbody>
|
</tbody>
|
||||||
|
|||||||
@@ -0,0 +1,5 @@
|
|||||||
|
class AddPoolPlacementToWrestler < ActiveRecord::Migration[5.2]
|
||||||
|
def change
|
||||||
|
add_column :wrestlers, :pool_placement, :integer
|
||||||
|
end
|
||||||
|
end
|
||||||
@@ -0,0 +1,5 @@
|
|||||||
|
class AddPoolPlacementTiebreakerToWrestler < ActiveRecord::Migration[5.2]
|
||||||
|
def change
|
||||||
|
add_column :wrestlers, :pool_placement_tiebreaker, :string
|
||||||
|
end
|
||||||
|
end
|
||||||
@@ -0,0 +1,17 @@
|
|||||||
|
class SetPoolPlacementForExistingTournaments < ActiveRecord::Migration[5.2]
|
||||||
|
|
||||||
|
def change
|
||||||
|
|
||||||
|
Tournament.all.each do | tournament |
|
||||||
|
tournament.weights.each do | weight |
|
||||||
|
for pool in (1..weight.pools) do
|
||||||
|
if weight.all_pool_matches_finished(pool)
|
||||||
|
PoolOrder.new(weight.wrestlers_in_pool(pool)).getPoolOrder
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
end
|
||||||
|
|
||||||
|
end
|
||||||
@@ -10,7 +10,7 @@
|
|||||||
#
|
#
|
||||||
# It's strongly recommended that you check this file into your version control system.
|
# It's strongly recommended that you check this file into your version control system.
|
||||||
|
|
||||||
ActiveRecord::Schema.define(version: 2018_09_17_133030) do
|
ActiveRecord::Schema.define(version: 2019_04_19_142230) do
|
||||||
|
|
||||||
create_table "delayed_jobs", force: :cascade do |t|
|
create_table "delayed_jobs", force: :cascade do |t|
|
||||||
t.integer "priority", default: 0, null: false
|
t.integer "priority", default: 0, null: false
|
||||||
@@ -146,6 +146,8 @@ ActiveRecord::Schema.define(version: 2018_09_17_133030) do
|
|||||||
t.boolean "extra"
|
t.boolean "extra"
|
||||||
t.decimal "offical_weight"
|
t.decimal "offical_weight"
|
||||||
t.integer "pool"
|
t.integer "pool"
|
||||||
|
t.integer "pool_placement"
|
||||||
|
t.string "pool_placement_tiebreaker"
|
||||||
t.index ["weight_id"], name: "index_wrestlers_on_weight_id"
|
t.index ["weight_id"], name: "index_wrestlers_on_weight_id"
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|||||||
@@ -3,584 +3,306 @@ require 'test_helper'
|
|||||||
class PoolAdvancementTest < ActionDispatch::IntegrationTest
|
class PoolAdvancementTest < ActionDispatch::IntegrationTest
|
||||||
|
|
||||||
def setup
|
def setup
|
||||||
tournament = Tournament.find(1)
|
|
||||||
end
|
|
||||||
|
|
||||||
def singlePoolNotFinished
|
|
||||||
|
|
||||||
endMatch(1000,"Jackson Lakso")
|
|
||||||
endMatch(1001,"Jaden Mattox")
|
|
||||||
endMatch(2000,"James Wimer")
|
|
||||||
endMatch(2001,"Jaden Mattox")
|
|
||||||
endMatch(3000,"Jaden Mattox")
|
|
||||||
endMatch(3001,"James Wimer")
|
|
||||||
endMatch(4000,"JD Woods")
|
|
||||||
endMatch(4001,"James Wimer")
|
|
||||||
endMatch(5000,"James Wimer")
|
|
||||||
end
|
|
||||||
|
|
||||||
def singlePoolFinished
|
|
||||||
singlePoolNotFinished
|
|
||||||
|
|
||||||
endMatch(5001,"Jackson Lakso")
|
|
||||||
end
|
|
||||||
|
|
||||||
def sixteenManToSemi
|
|
||||||
|
|
||||||
endMatch(1013,"Guy22")
|
|
||||||
endMatch(1014,"Guy29")
|
|
||||||
endMatch(2012,"Guy29")
|
|
||||||
endMatch(2013,"Guy22")
|
|
||||||
endMatch(3012,"Guy37")
|
|
||||||
endMatch(3013,"Guy22")
|
|
||||||
endMatch(1015,"Guy36")
|
|
||||||
endMatch(1016,"Guy32")
|
|
||||||
endMatch(2014,"Guy36")
|
|
||||||
endMatch(2015,"Guy32")
|
|
||||||
endMatch(3014,"Guy36")
|
|
||||||
endMatch(3015,"Guy23")
|
|
||||||
endMatch(1017,"Guy31")
|
|
||||||
endMatch(1018,"Guy35")
|
|
||||||
endMatch(2016,"Guy35")
|
|
||||||
endMatch(2017,"Guy31")
|
|
||||||
endMatch(3016,"Guy27")
|
|
||||||
endMatch(3017,"Guy31")
|
|
||||||
endMatch(1019,"Guy34")
|
|
||||||
endMatch(1020,"Guy26")
|
|
||||||
endMatch(2018,"Guy30")
|
|
||||||
endMatch(2019,"Guy34")
|
|
||||||
endMatch(3018,"Guy26")
|
|
||||||
endMatch(3019,"Guy34")
|
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
||||||
def sevenManTwoPoolToSemi
|
|
||||||
|
|
||||||
endMatch(1006,"Casey Davis")
|
|
||||||
endMatch(1007,"Ethan Leapley")
|
|
||||||
endMatch(2006,"Clayton Ray")
|
|
||||||
endMatch(2007,"Ethan Leapley")
|
|
||||||
endMatch(3006,"Ethan Leapley")
|
|
||||||
endMatch(3007,"Casey Davis")
|
|
||||||
endMatch(1008,"Kameron Teacher")
|
|
||||||
endMatch(2008,"Kameron Teacher")
|
|
||||||
endMatch(3008,"Robbie Fusner")
|
|
||||||
end
|
|
||||||
|
|
||||||
def sevenManTwoPoolSemiToFinals
|
|
||||||
sevenManTwoPoolToSemi
|
|
||||||
|
|
||||||
endMatch(4005,"Casey Davis")
|
|
||||||
endMatch(4004,"Ethan Leapley")
|
|
||||||
end
|
|
||||||
|
|
||||||
def nineManBracketPoolOneOutrightWinnerGuyTwo
|
# test "nine man outright finals advance" do
|
||||||
|
# nineManBracketPoolOneOutrightWinnerGuyTwo
|
||||||
endMatch(1002,"Guy8")
|
# wrestler = Wrestler.where("name = ?", "Guy2").first
|
||||||
endMatch(1003,"Guy5")
|
# assert_equal 6000, wrestler.bout_by_round(6)
|
||||||
endMatch(2002,"Guy2")
|
# end
|
||||||
endMatch(2003,"Guy8")
|
|
||||||
endMatch(3002,"Guy5")
|
|
||||||
endMatch(3003,"Guy2")
|
|
||||||
endMatch(4002,"Guy8")
|
|
||||||
endMatch(4003,"Guy2")
|
|
||||||
endMatch(5002,"Guy2")
|
|
||||||
endMatch(5003,"Guy10")
|
|
||||||
end
|
|
||||||
|
|
||||||
def nineManBracketPoolTwoGuyNineHeadToHead
|
|
||||||
|
|
||||||
endMatch(1004,"Guy4")
|
|
||||||
endMatch(1005,"Guy3")
|
|
||||||
endMatch(2004,"Guy9")
|
|
||||||
endMatch(2005,"Guy7")
|
|
||||||
endMatch(3004,"Guy9")
|
|
||||||
endMatch(3005,"Guy3")
|
|
||||||
end
|
|
||||||
|
|
||||||
def nineManBracketPoolTwoGuyThreeHeadToHead
|
|
||||||
|
|
||||||
endMatch(1004,"Guy9")
|
|
||||||
endMatch(1005,"Guy3")
|
|
||||||
endMatch(2004,"Guy3")
|
|
||||||
endMatch(2005,"Guy7")
|
|
||||||
endMatch(3004,"Guy9")
|
|
||||||
endMatch(3005,"Guy4")
|
|
||||||
end
|
|
||||||
|
|
||||||
def nineManBracketPoolTwoGuyThreeDeductedPoints
|
|
||||||
|
|
||||||
endMatch(1004,"Guy9")
|
|
||||||
endMatch(1005,"Guy7")
|
|
||||||
endMatch(2004,"Guy3")
|
|
||||||
endMatch(2005,"Guy7")
|
|
||||||
endMatch(3004,"Guy9")
|
|
||||||
endMatch(3005,"Guy3")
|
|
||||||
deduct = Teampointadjust.new
|
|
||||||
deduct.wrestler_id = translateNameToId("Guy7")
|
|
||||||
deduct.points = 1
|
|
||||||
deduct.save
|
|
||||||
end
|
|
||||||
|
|
||||||
def nineManBracketPoolTwoGuyThreeMostDecisionPoints
|
|
||||||
|
|
||||||
endMatchExtraPoints(1004,"Guy9")
|
|
||||||
endMatch(1005,"Guy7")
|
|
||||||
endMatchExtraPoints(2004,"Guy3")
|
|
||||||
endMatch(2005,"Guy7")
|
|
||||||
endMatch(3004,"Guy9")
|
|
||||||
endMatchExtraPoints(3005,"Guy3")
|
|
||||||
end
|
|
||||||
|
|
||||||
def nineManBracketPoolTwoGuyThreeQuickestPin
|
|
||||||
|
|
||||||
endMatchWithQuickPin(1004,"Guy9")
|
|
||||||
endMatchWithPin(1005,"Guy7")
|
|
||||||
endMatchWithQuickPin(2004,"Guy3")
|
|
||||||
endMatchWithPin(2005,"Guy7")
|
|
||||||
endMatchWithPin(3004,"Guy9")
|
|
||||||
endMatchWithQuickestPin(3005,"Guy3")
|
|
||||||
end
|
|
||||||
|
|
||||||
def nineManBracketPoolTwoGuyThreeTeamPoints
|
|
||||||
|
|
||||||
endMatch(1004,"Guy9")
|
|
||||||
endMatch(1005,"Guy7")
|
|
||||||
endMatchWithMajor(2004,"Guy3")
|
|
||||||
endMatch(2005,"Guy7")
|
|
||||||
endMatch(3004,"Guy9")
|
|
||||||
endMatch(3005,"Guy3")
|
|
||||||
end
|
|
||||||
|
|
||||||
def nineManBracketPoolTwoGuyThreeMostPins
|
|
||||||
|
|
||||||
endMatchWithMajor(1004,"Guy9")
|
|
||||||
endMatch(1005,"Guy7")
|
|
||||||
endMatchWithPin(2004,"Guy3")
|
|
||||||
endMatchWithMajor(2005,"Guy7")
|
|
||||||
endMatch(3004,"Guy9")
|
|
||||||
endMatch(3005,"Guy3")
|
|
||||||
end
|
|
||||||
|
|
||||||
def nineManBracketPoolOneGuyEightMostTechs
|
|
||||||
|
|
||||||
endMatchWithTech(1002,"Guy8")
|
|
||||||
endMatch(1003,"Guy5")
|
|
||||||
endMatchWithMajor(2002,"Guy2")
|
|
||||||
endMatchWithTech(2003,"Guy8")
|
|
||||||
endMatchWithMajor(3002,"Guy10")
|
|
||||||
endMatchWithMajor(3003,"Guy2")
|
|
||||||
endMatch(4002,"Guy8")
|
|
||||||
endMatchWithMajor(4003,"Guy10")
|
|
||||||
endMatchWithMajor(5002,"Guy2")
|
|
||||||
endMatchWithMajor(5003,"Guy10")
|
|
||||||
end
|
|
||||||
|
|
||||||
def elevenManBracketToQuarter
|
|
||||||
|
|
||||||
endMatch(1009,"Guy11")
|
|
||||||
endMatch(2009,"Guy11")
|
|
||||||
endMatch(3009,"Guy18")
|
|
||||||
endMatch(1010,"Guy12")
|
|
||||||
endMatch(2010,"Guy12")
|
|
||||||
endMatch(3010,"Guy17")
|
|
||||||
endMatch(1011,"Guy13")
|
|
||||||
endMatch(2011,"Guy13")
|
|
||||||
endMatch(3011,"Guy19")
|
|
||||||
endMatch(1012,"Guy14")
|
|
||||||
end
|
|
||||||
def elevenManBracketToSemis
|
|
||||||
elevenManBracketToQuarter
|
|
||||||
|
|
||||||
endMatch(4006,"Guy11")
|
|
||||||
endMatch(4007,"Guy14")
|
|
||||||
endMatch(4008,"Guy12")
|
|
||||||
endMatch(4009,"Guy13")
|
|
||||||
end
|
|
||||||
|
|
||||||
def elevenManBracketToFinals
|
|
||||||
elevenManBracketToSemis
|
|
||||||
|
|
||||||
endMatch(5004,"Guy11")
|
|
||||||
endMatch(5005,"Guy12")
|
|
||||||
endMatch(5006,"Guy17")
|
|
||||||
endMatch(5007,"Guy18")
|
|
||||||
end
|
|
||||||
|
|
||||||
def elevenManBracketFinished
|
|
||||||
elevenManBracketToFinals
|
|
||||||
|
|
||||||
endMatch(6004,"Guy11")
|
|
||||||
endMatch(6005,"Guy14")
|
|
||||||
endMatch(6006,"Guy17")
|
|
||||||
endMatch(6007,"Guy19")
|
|
||||||
end
|
|
||||||
|
|
||||||
def extraDoesNotScoreTeamPoints
|
|
||||||
|
|
||||||
wrestlerName = "Guy22"
|
|
||||||
wrestler = Wrestler.find(translateNameToId(wrestlerName))
|
|
||||||
wrestler.extra = true
|
|
||||||
wrestler.save
|
|
||||||
endMatch(1013,"Guy22")
|
|
||||||
end
|
|
||||||
|
|
||||||
def endMatch(bout,winner)
|
|
||||||
match = Match.where(bout_number: bout).first
|
|
||||||
match.win_type = "Decision"
|
|
||||||
match.score = 1-0
|
|
||||||
saveMatch(match,winner)
|
|
||||||
end
|
|
||||||
|
|
||||||
def endMatchExtraPoints(bout,winner)
|
|
||||||
match = Match.where(bout_number: bout).first
|
|
||||||
match.win_type = "Decision"
|
|
||||||
match.score = 0-2
|
|
||||||
saveMatch(match,winner)
|
|
||||||
end
|
|
||||||
|
|
||||||
def endMatchWithMajor(bout,winner)
|
|
||||||
match = Match.where(bout_number: bout).first
|
|
||||||
match.win_type = "Major"
|
|
||||||
match.score = 8-0
|
|
||||||
saveMatch(match,winner)
|
|
||||||
end
|
|
||||||
|
|
||||||
def endMatchWithTech(bout,winner)
|
|
||||||
match = Match.where(bout_number: bout).first
|
|
||||||
match.win_type = "Tech Fall"
|
|
||||||
match.score = 15-0
|
|
||||||
saveMatch(match,winner)
|
|
||||||
end
|
|
||||||
|
|
||||||
def endMatchWithPin(bout,winner)
|
|
||||||
match = Match.where(bout_number: bout).first
|
|
||||||
match.win_type = "Pin"
|
|
||||||
match.score = "5:00"
|
|
||||||
saveMatch(match,winner)
|
|
||||||
end
|
|
||||||
|
|
||||||
def endMatchWithQuickestPin(bout,winner)
|
|
||||||
match = Match.where(bout_number: bout).first
|
|
||||||
match.win_type = "Pin"
|
|
||||||
match.score = "0:20"
|
|
||||||
saveMatch(match,winner)
|
|
||||||
end
|
|
||||||
|
|
||||||
def endMatchWithQuickPin(bout,winner)
|
|
||||||
match = Match.where(bout_number: bout).first
|
|
||||||
match.win_type = "Pin"
|
|
||||||
match.score = "1:20"
|
|
||||||
saveMatch(match,winner)
|
|
||||||
end
|
|
||||||
|
|
||||||
def saveMatch(match,winner)
|
|
||||||
match.finished = 1
|
|
||||||
match.winner_id = translateNameToId(winner)
|
|
||||||
|
|
||||||
match.save!
|
|
||||||
# match.after_update_actions
|
|
||||||
end
|
|
||||||
|
|
||||||
def translateNameToId(wrestler)
|
|
||||||
Wrestler.where("name = ?", wrestler).first.id
|
|
||||||
end
|
|
||||||
|
|
||||||
test "nine man outright finals advance" do
|
# test "nine man outright conso finals advance" do
|
||||||
nineManBracketPoolOneOutrightWinnerGuyTwo
|
# nineManBracketPoolOneOutrightWinnerGuyTwo
|
||||||
wrestler = Wrestler.where("name = ?", "Guy2").first
|
# wrestler = Wrestler.where("name = ?", "Guy8").first
|
||||||
assert_equal 6000, wrestler.bout_by_round(6)
|
# assert_equal 6001, wrestler.bout_by_round(6)
|
||||||
end
|
# end
|
||||||
|
|
||||||
test "nine man outright conso finals advance" do
|
# test "nine man pool 2 man to man tie breaker finalist guy 9" do
|
||||||
nineManBracketPoolOneOutrightWinnerGuyTwo
|
# wrestler = Wrestler.where("name = ?", "Guy9").first
|
||||||
wrestler = Wrestler.where("name = ?", "Guy8").first
|
# nineManBracketPoolTwoGuyNineHeadToHead
|
||||||
assert_equal 6001, wrestler.bout_by_round(6)
|
# assert_equal 6000, wrestler.bout_by_round(6)
|
||||||
end
|
# end
|
||||||
|
|
||||||
|
# test "nine man pool 2 man to man tie breaker finalist guy 3" do
|
||||||
|
# wrestler = Wrestler.where("name = ?", "Guy3").first
|
||||||
|
# nineManBracketPoolTwoGuyThreeHeadToHead
|
||||||
|
# assert_equal 6000, wrestler.bout_by_round(6)
|
||||||
|
# end
|
||||||
|
|
||||||
|
# test "nine man conso finals man to man tie breaker guy 3" do
|
||||||
|
# nineManBracketPoolTwoGuyNineHeadToHead
|
||||||
|
# wrestler = Wrestler.where("name = ?", "Guy3").first
|
||||||
|
# assert_equal 6001, wrestler.bout_by_round(6)
|
||||||
|
# end
|
||||||
|
|
||||||
|
# test "nine man conso finals man to man tie breaker guy 9" do
|
||||||
|
# nineManBracketPoolTwoGuyThreeHeadToHead
|
||||||
|
# wrestler = Wrestler.where("name = ?", "Guy9").first
|
||||||
|
# assert_equal 6001, wrestler.bout_by_round(6)
|
||||||
|
# end
|
||||||
|
|
||||||
|
# test "nine man pool 2 deductedPoints tie breaker finalist guy 3" do
|
||||||
|
# wrestler = Wrestler.where("name = ?", "Guy3").first
|
||||||
|
# nineManBracketPoolTwoGuyThreeDeductedPoints
|
||||||
|
# assert_equal 6000, wrestler.bout_by_round(6)
|
||||||
|
# end
|
||||||
|
|
||||||
|
# test "nine man conso finals deductedPoints tie breaker guy 9" do
|
||||||
|
# nineManBracketPoolTwoGuyThreeDeductedPoints
|
||||||
|
# wrestler = Wrestler.where("name = ?", "Guy9").first
|
||||||
|
# assert_equal 6001, wrestler.bout_by_round(6)
|
||||||
|
# end
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
# test "nine man pool 2 mostDecisionPointsScored tie breaker finalist guy 3" do
|
||||||
|
# wrestler = Wrestler.where("name = ?", "Guy3").first
|
||||||
|
# nineManBracketPoolTwoGuyThreeMostDecisionPoints
|
||||||
|
# assert_equal 6000, wrestler.bout_by_round(6)
|
||||||
|
# end
|
||||||
|
|
||||||
|
# test "nine man conso finals mostDecisionPointsScored tie breaker guy 9" do
|
||||||
|
# nineManBracketPoolTwoGuyThreeMostDecisionPoints
|
||||||
|
# wrestler = Wrestler.where("name = ?", "Guy9").first
|
||||||
|
# assert_equal 6001, wrestler.bout_by_round(6)
|
||||||
|
# end
|
||||||
|
|
||||||
|
# test "nine man pool 2 QuickestPin tie breaker finalist guy 3" do
|
||||||
|
# wrestler = Wrestler.where("name = ?", "Guy3").first
|
||||||
|
# nineManBracketPoolTwoGuyThreeQuickestPin
|
||||||
|
# assert_equal 6000, wrestler.bout_by_round(6)
|
||||||
|
# end
|
||||||
|
|
||||||
|
# test "nine man conso finals QuickestPin tie breaker guy 9" do
|
||||||
|
# nineManBracketPoolTwoGuyThreeQuickestPin
|
||||||
|
# wrestler = Wrestler.where("name = ?", "Guy9").first
|
||||||
|
# assert_equal 6001, wrestler.bout_by_round(6)
|
||||||
|
# end
|
||||||
|
|
||||||
|
# test "nine man pool 2 teamPoints tie breaker finalist guy 3" do
|
||||||
|
# wrestler = Wrestler.where("name = ?", "Guy3").first
|
||||||
|
# nineManBracketPoolTwoGuyThreeTeamPoints
|
||||||
|
# assert_equal 6000, wrestler.bout_by_round(6)
|
||||||
|
# end
|
||||||
|
|
||||||
|
# test "nine man conso finals teamPoints tie breaker guy 9" do
|
||||||
|
# nineManBracketPoolTwoGuyThreeTeamPoints
|
||||||
|
# wrestler = Wrestler.where("name = ?", "Guy9").first
|
||||||
|
# assert_equal 6001, wrestler.bout_by_round(6)
|
||||||
|
# end
|
||||||
|
|
||||||
|
# test "nine man pool 2 mostPins tie breaker finalist guy 3" do
|
||||||
|
# wrestler = Wrestler.where("name = ?", "Guy3").first
|
||||||
|
# nineManBracketPoolTwoGuyThreeMostPins
|
||||||
|
# assert_equal 6000, wrestler.bout_by_round(6)
|
||||||
|
# end
|
||||||
|
|
||||||
|
# test "nine man conso finals mostPins tie breaker guy 9" do
|
||||||
|
# nineManBracketPoolTwoGuyThreeMostPins
|
||||||
|
# wrestler = Wrestler.where("name = ?", "Guy9").first
|
||||||
|
# assert_equal 6001, wrestler.bout_by_round(6)
|
||||||
|
# end
|
||||||
|
|
||||||
|
# test "nine man pool 1 mostTechs tie breaker finalist guy 8" do
|
||||||
|
# nineManBracketPoolOneGuyEightMostTechs
|
||||||
|
# wrestler = Wrestler.where("name = ?", "Guy8").first
|
||||||
|
# assert_equal 6000, wrestler.bout_by_round(6)
|
||||||
|
# end
|
||||||
|
|
||||||
|
# test "nine man conso finals mostTechs tie breaker guy 10" do
|
||||||
|
# nineManBracketPoolOneGuyEightMostTechs
|
||||||
|
# wrestler = Wrestler.where("name = ?", "Guy10").first
|
||||||
|
# assert_equal 6001, wrestler.bout_by_round(6)
|
||||||
|
# end
|
||||||
|
|
||||||
|
# test "twoPoolsToFinal total points finals" do
|
||||||
|
# nineManBracketPoolOneOutrightWinnerGuyTwo
|
||||||
|
# nineManBracketPoolTwoGuyThreeHeadToHead
|
||||||
|
# wrestler1 = Wrestler.where("name = ?", "Guy2").first
|
||||||
|
# wrestler2 = Wrestler.where("name = ?", "Guy3").first
|
||||||
|
# #Won four in pool
|
||||||
|
# assert_equal 22, wrestler1.total_team_points
|
||||||
|
# #Won two in pool
|
||||||
|
# assert_equal 18, wrestler2.total_team_points
|
||||||
|
# end
|
||||||
|
|
||||||
|
# test "advancement points 1/2" do
|
||||||
|
# nineManBracketPoolOneOutrightWinnerGuyTwo
|
||||||
|
# wrestler1 = Wrestler.where("name = ?", "Guy2").first
|
||||||
|
# assert_equal 12, wrestler1.placement_points
|
||||||
|
# end
|
||||||
|
|
||||||
|
# test "advancement points 3/4" do
|
||||||
|
# nineManBracketPoolOneOutrightWinnerGuyTwo
|
||||||
|
# wrestler1 = Wrestler.where("name = ?", "Guy8").first
|
||||||
|
# assert_equal 9, wrestler1.placement_points
|
||||||
|
# end
|
||||||
|
|
||||||
|
# test "advancement points 5/6" do
|
||||||
|
# elevenManBracketToFinals
|
||||||
|
# wrestler = Wrestler.where("name = ?", "Guy17").first
|
||||||
|
|
||||||
test "nine man pool 2 man to man tie breaker finalist guy 9" do
|
# assert_equal 6, wrestler.placement_points
|
||||||
wrestler = Wrestler.where("name = ?", "Guy9").first
|
# end
|
||||||
nineManBracketPoolTwoGuyNineHeadToHead
|
|
||||||
assert_equal 6000, wrestler.bout_by_round(6)
|
|
||||||
end
|
|
||||||
|
|
||||||
test "nine man pool 2 man to man tie breaker finalist guy 3" do
|
# test "advancement points 7/8" do
|
||||||
wrestler = Wrestler.where("name = ?", "Guy3").first
|
# elevenManBracketToFinals
|
||||||
nineManBracketPoolTwoGuyThreeHeadToHead
|
# wrestler = Wrestler.where("name = ?", "Guy19").first
|
||||||
assert_equal 6000, wrestler.bout_by_round(6)
|
|
||||||
end
|
|
||||||
|
|
||||||
test "nine man conso finals man to man tie breaker guy 3" do
|
|
||||||
nineManBracketPoolTwoGuyNineHeadToHead
|
|
||||||
wrestler = Wrestler.where("name = ?", "Guy3").first
|
|
||||||
assert_equal 6001, wrestler.bout_by_round(6)
|
|
||||||
end
|
|
||||||
|
|
||||||
test "nine man conso finals man to man tie breaker guy 9" do
|
|
||||||
nineManBracketPoolTwoGuyThreeHeadToHead
|
|
||||||
wrestler = Wrestler.where("name = ?", "Guy9").first
|
|
||||||
assert_equal 6001, wrestler.bout_by_round(6)
|
|
||||||
end
|
|
||||||
|
|
||||||
test "nine man pool 2 deductedPoints tie breaker finalist guy 3" do
|
|
||||||
wrestler = Wrestler.where("name = ?", "Guy3").first
|
|
||||||
nineManBracketPoolTwoGuyThreeDeductedPoints
|
|
||||||
assert_equal 6000, wrestler.bout_by_round(6)
|
|
||||||
end
|
|
||||||
|
|
||||||
test "nine man conso finals deductedPoints tie breaker guy 9" do
|
|
||||||
nineManBracketPoolTwoGuyThreeDeductedPoints
|
|
||||||
wrestler = Wrestler.where("name = ?", "Guy9").first
|
|
||||||
assert_equal 6001, wrestler.bout_by_round(6)
|
|
||||||
end
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
test "nine man pool 2 mostDecisionPointsScored tie breaker finalist guy 3" do
|
|
||||||
wrestler = Wrestler.where("name = ?", "Guy3").first
|
|
||||||
nineManBracketPoolTwoGuyThreeMostDecisionPoints
|
|
||||||
assert_equal 6000, wrestler.bout_by_round(6)
|
|
||||||
end
|
|
||||||
|
|
||||||
test "nine man conso finals mostDecisionPointsScored tie breaker guy 9" do
|
|
||||||
nineManBracketPoolTwoGuyThreeMostDecisionPoints
|
|
||||||
wrestler = Wrestler.where("name = ?", "Guy9").first
|
|
||||||
assert_equal 6001, wrestler.bout_by_round(6)
|
|
||||||
end
|
|
||||||
|
|
||||||
test "nine man pool 2 QuickestPin tie breaker finalist guy 3" do
|
|
||||||
wrestler = Wrestler.where("name = ?", "Guy3").first
|
|
||||||
nineManBracketPoolTwoGuyThreeQuickestPin
|
|
||||||
assert_equal 6000, wrestler.bout_by_round(6)
|
|
||||||
end
|
|
||||||
|
|
||||||
test "nine man conso finals QuickestPin tie breaker guy 9" do
|
|
||||||
nineManBracketPoolTwoGuyThreeQuickestPin
|
|
||||||
wrestler = Wrestler.where("name = ?", "Guy9").first
|
|
||||||
assert_equal 6001, wrestler.bout_by_round(6)
|
|
||||||
end
|
|
||||||
|
|
||||||
test "nine man pool 2 teamPoints tie breaker finalist guy 3" do
|
|
||||||
wrestler = Wrestler.where("name = ?", "Guy3").first
|
|
||||||
nineManBracketPoolTwoGuyThreeTeamPoints
|
|
||||||
assert_equal 6000, wrestler.bout_by_round(6)
|
|
||||||
end
|
|
||||||
|
|
||||||
test "nine man conso finals teamPoints tie breaker guy 9" do
|
|
||||||
nineManBracketPoolTwoGuyThreeTeamPoints
|
|
||||||
wrestler = Wrestler.where("name = ?", "Guy9").first
|
|
||||||
assert_equal 6001, wrestler.bout_by_round(6)
|
|
||||||
end
|
|
||||||
|
|
||||||
test "nine man pool 2 mostPins tie breaker finalist guy 3" do
|
|
||||||
wrestler = Wrestler.where("name = ?", "Guy3").first
|
|
||||||
nineManBracketPoolTwoGuyThreeMostPins
|
|
||||||
assert_equal 6000, wrestler.bout_by_round(6)
|
|
||||||
end
|
|
||||||
|
|
||||||
test "nine man conso finals mostPins tie breaker guy 9" do
|
|
||||||
nineManBracketPoolTwoGuyThreeMostPins
|
|
||||||
wrestler = Wrestler.where("name = ?", "Guy9").first
|
|
||||||
assert_equal 6001, wrestler.bout_by_round(6)
|
|
||||||
end
|
|
||||||
|
|
||||||
test "nine man pool 1 mostTechs tie breaker finalist guy 8" do
|
|
||||||
nineManBracketPoolOneGuyEightMostTechs
|
|
||||||
wrestler = Wrestler.where("name = ?", "Guy8").first
|
|
||||||
assert_equal 6000, wrestler.bout_by_round(6)
|
|
||||||
end
|
|
||||||
|
|
||||||
test "nine man conso finals mostTechs tie breaker guy 10" do
|
|
||||||
nineManBracketPoolOneGuyEightMostTechs
|
|
||||||
wrestler = Wrestler.where("name = ?", "Guy10").first
|
|
||||||
assert_equal 6001, wrestler.bout_by_round(6)
|
|
||||||
end
|
|
||||||
|
|
||||||
test "twoPoolsToFinal total points finals" do
|
|
||||||
nineManBracketPoolOneOutrightWinnerGuyTwo
|
|
||||||
nineManBracketPoolTwoGuyThreeHeadToHead
|
|
||||||
wrestler1 = Wrestler.where("name = ?", "Guy2").first
|
|
||||||
wrestler2 = Wrestler.where("name = ?", "Guy3").first
|
|
||||||
#Won four in pool
|
|
||||||
assert_equal 22, wrestler1.total_team_points
|
|
||||||
#Won two in pool
|
|
||||||
assert_equal 18, wrestler2.total_team_points
|
|
||||||
end
|
|
||||||
|
|
||||||
test "advancement points 1/2" do
|
|
||||||
nineManBracketPoolOneOutrightWinnerGuyTwo
|
|
||||||
wrestler1 = Wrestler.where("name = ?", "Guy2").first
|
|
||||||
assert_equal 12, wrestler1.placement_points
|
|
||||||
end
|
|
||||||
|
|
||||||
test "advancement points 3/4" do
|
|
||||||
nineManBracketPoolOneOutrightWinnerGuyTwo
|
|
||||||
wrestler1 = Wrestler.where("name = ?", "Guy8").first
|
|
||||||
assert_equal 9, wrestler1.placement_points
|
|
||||||
end
|
|
||||||
|
|
||||||
test "advancement points 5/6" do
|
|
||||||
elevenManBracketToFinals
|
|
||||||
wrestler = Wrestler.where("name = ?", "Guy17").first
|
|
||||||
|
|
||||||
assert_equal 6, wrestler.placement_points
|
# assert_equal 3, wrestler.placement_points
|
||||||
end
|
# end
|
||||||
|
|
||||||
test "advancement points 7/8" do
|
# test "advancement points winner 1/2" do
|
||||||
elevenManBracketToFinals
|
# nineManBracketPoolOneOutrightWinnerGuyTwo
|
||||||
wrestler = Wrestler.where("name = ?", "Guy19").first
|
# nineManBracketPoolTwoGuyThreeHeadToHead
|
||||||
|
# endMatch(6000,"Guy2")
|
||||||
|
# wrestler1 = Wrestler.where("name = ?", "Guy2").first
|
||||||
|
# assert_equal 16, wrestler1.placement_points
|
||||||
|
# end
|
||||||
|
|
||||||
|
# test "advancement points winner 3/4" do
|
||||||
|
# nineManBracketPoolOneOutrightWinnerGuyTwo
|
||||||
|
# nineManBracketPoolTwoGuyThreeHeadToHead
|
||||||
|
# endMatch(6001,"Guy8")
|
||||||
|
# wrestler1 = Wrestler.where("name = ?", "Guy8").first
|
||||||
|
# assert_equal 10, wrestler1.placement_points
|
||||||
|
# end
|
||||||
|
|
||||||
|
# test "advancement points winner 5/6" do
|
||||||
|
# elevenManBracketFinished
|
||||||
|
# wrestler = Wrestler.where("name = ?", "Guy17").first
|
||||||
|
|
||||||
assert_equal 3, wrestler.placement_points
|
# assert_equal 7, wrestler.placement_points
|
||||||
end
|
# end
|
||||||
|
|
||||||
test "advancement points winner 1/2" do
|
# test "advancement points winner 7/8" do
|
||||||
nineManBracketPoolOneOutrightWinnerGuyTwo
|
# elevenManBracketFinished
|
||||||
nineManBracketPoolTwoGuyThreeHeadToHead
|
# wrestler = Wrestler.where("name = ?", "Guy19").first
|
||||||
endMatch(6000,"Guy2")
|
|
||||||
wrestler1 = Wrestler.where("name = ?", "Guy2").first
|
|
||||||
assert_equal 16, wrestler1.placement_points
|
|
||||||
end
|
|
||||||
|
|
||||||
test "advancement points winner 3/4" do
|
|
||||||
nineManBracketPoolOneOutrightWinnerGuyTwo
|
|
||||||
nineManBracketPoolTwoGuyThreeHeadToHead
|
|
||||||
endMatch(6001,"Guy8")
|
|
||||||
wrestler1 = Wrestler.where("name = ?", "Guy8").first
|
|
||||||
assert_equal 10, wrestler1.placement_points
|
|
||||||
end
|
|
||||||
|
|
||||||
test "advancement points winner 5/6" do
|
|
||||||
elevenManBracketFinished
|
|
||||||
wrestler = Wrestler.where("name = ?", "Guy17").first
|
|
||||||
|
|
||||||
assert_equal 7, wrestler.placement_points
|
# assert_equal 4, wrestler.placement_points
|
||||||
end
|
# end
|
||||||
|
|
||||||
test "advancement points winner 7/8" do
|
# test "bonus points major" do
|
||||||
elevenManBracketFinished
|
# endMatchWithMajor(2002,"Guy2")
|
||||||
wrestler = Wrestler.where("name = ?", "Guy19").first
|
# wrestler1 = Wrestler.where("name = ?", "Guy2").first
|
||||||
|
# assert_equal 5, wrestler1.team_points_earned
|
||||||
|
# end
|
||||||
|
|
||||||
|
# test "bonus points pin" do
|
||||||
|
# endMatchWithPin(2002,"Guy2")
|
||||||
|
# wrestler1 = Wrestler.where("name = ?", "Guy2").first
|
||||||
|
# assert_equal 6, wrestler1.team_points_earned
|
||||||
|
# end
|
||||||
|
|
||||||
|
# test "bonus points tech fall" do
|
||||||
|
# endMatchWithTech(2002,"Guy2")
|
||||||
|
# wrestler1 = Wrestler.where("name = ?", "Guy2").first
|
||||||
|
# assert_equal 5.5, wrestler1.team_points_earned
|
||||||
|
# end
|
||||||
|
|
||||||
|
# test "pool team points win" do
|
||||||
|
# endMatch(2002,"Guy2")
|
||||||
|
# wrestler1 = Wrestler.where("name = ?", "Guy2").first
|
||||||
|
# assert_equal 4, wrestler1.team_points_earned
|
||||||
|
# end
|
||||||
|
|
||||||
|
# test "advancement points fourPoolsToQuarter Quarter" do
|
||||||
|
# elevenManBracketToQuarter
|
||||||
|
# wrestler1 = Wrestler.where("name = ?", "Guy11").first
|
||||||
|
# assert_equal 3, wrestler1.placement_points
|
||||||
|
# end
|
||||||
|
|
||||||
|
# test "advancement points fourPoolsToQuarter Semis" do
|
||||||
|
# elevenManBracketToSemis
|
||||||
|
# wrestler = Wrestler.where("name = ?", "Guy11").first
|
||||||
|
|
||||||
assert_equal 4, wrestler.placement_points
|
# assert_equal 9, wrestler.placement_points
|
||||||
end
|
# end
|
||||||
|
|
||||||
test "bonus points major" do
|
# test "advancement points twoPoolsToSemi Semis" do
|
||||||
endMatchWithMajor(2002,"Guy2")
|
# sevenManTwoPoolToSemi
|
||||||
wrestler1 = Wrestler.where("name = ?", "Guy2").first
|
# wrestler = Wrestler.where("name = ?", "Casey Davis").first
|
||||||
assert_equal 5, wrestler1.team_points_earned
|
|
||||||
end
|
|
||||||
|
|
||||||
test "bonus points pin" do
|
|
||||||
endMatchWithPin(2002,"Guy2")
|
|
||||||
wrestler1 = Wrestler.where("name = ?", "Guy2").first
|
|
||||||
assert_equal 6, wrestler1.team_points_earned
|
|
||||||
end
|
|
||||||
|
|
||||||
test "bonus points tech fall" do
|
|
||||||
endMatchWithTech(2002,"Guy2")
|
|
||||||
wrestler1 = Wrestler.where("name = ?", "Guy2").first
|
|
||||||
assert_equal 5.5, wrestler1.team_points_earned
|
|
||||||
end
|
|
||||||
|
|
||||||
test "pool team points win" do
|
|
||||||
endMatch(2002,"Guy2")
|
|
||||||
wrestler1 = Wrestler.where("name = ?", "Guy2").first
|
|
||||||
assert_equal 4, wrestler1.team_points_earned
|
|
||||||
end
|
|
||||||
|
|
||||||
test "advancement points fourPoolsToQuarter Quarter" do
|
|
||||||
elevenManBracketToQuarter
|
|
||||||
wrestler1 = Wrestler.where("name = ?", "Guy11").first
|
|
||||||
assert_equal 3, wrestler1.placement_points
|
|
||||||
end
|
|
||||||
|
|
||||||
test "advancement points fourPoolsToQuarter Semis" do
|
|
||||||
elevenManBracketToSemis
|
|
||||||
wrestler = Wrestler.where("name = ?", "Guy11").first
|
|
||||||
|
|
||||||
assert_equal 9, wrestler.placement_points
|
# assert_equal 9, wrestler.placement_points
|
||||||
end
|
# end
|
||||||
|
|
||||||
test "advancement points twoPoolsToSemi Semis" do
|
# test "advancement points twoPoolsToSemi Finals" do
|
||||||
sevenManTwoPoolToSemi
|
# sevenManTwoPoolSemiToFinals
|
||||||
wrestler = Wrestler.where("name = ?", "Casey Davis").first
|
# wrestler = Wrestler.where("name = ?", "Casey Davis").first
|
||||||
|
|
||||||
assert_equal 9, wrestler.placement_points
|
# assert_equal 12, wrestler.placement_points
|
||||||
end
|
# end
|
||||||
|
|
||||||
test "advancement points twoPoolsToSemi Finals" do
|
# test "advancement points fourPoolsToSemi Semis and Conso Semis" do
|
||||||
sevenManTwoPoolSemiToFinals
|
# sixteenManToSemi
|
||||||
wrestler = Wrestler.where("name = ?", "Casey Davis").first
|
# wrestler = Wrestler.where("name = ?", "Guy22").first
|
||||||
|
|
||||||
assert_equal 12, wrestler.placement_points
|
# assert_equal 9, wrestler.placement_points
|
||||||
end
|
|
||||||
|
|
||||||
test "advancement points fourPoolsToSemi Semis and Conso Semis" do
|
|
||||||
sixteenManToSemi
|
|
||||||
wrestler = Wrestler.where("name = ?", "Guy22").first
|
|
||||||
|
|
||||||
assert_equal 9, wrestler.placement_points
|
|
||||||
|
|
||||||
wrestler = Wrestler.where("name = ?", "Guy29").first
|
# wrestler = Wrestler.where("name = ?", "Guy29").first
|
||||||
|
|
||||||
assert_equal 3, wrestler.placement_points
|
# assert_equal 3, wrestler.placement_points
|
||||||
end
|
# end
|
||||||
|
|
||||||
test "extra does not score points but does get pool criteria" do
|
# test "extra does not score points but does get pool criteria" do
|
||||||
extraDoesNotScoreTeamPoints
|
# extraDoesNotScoreTeamPoints
|
||||||
wrestler = Wrestler.where("name = ?", "Guy22").first
|
# wrestler = Wrestler.where("name = ?", "Guy22").first
|
||||||
|
|
||||||
assert_equal 0, wrestler.total_team_points
|
# assert_equal 0, wrestler.total_team_points
|
||||||
assert_equal 2, wrestler.team_points_earned
|
# assert_equal 2, wrestler.team_points_earned
|
||||||
end
|
# end
|
||||||
|
|
||||||
test "Test mat assignment when adding a mat and when destroying a mat" do
|
# test "Test mat assignment when adding a mat and when destroying a mat" do
|
||||||
mat2 = Mat.new
|
# mat2 = Mat.new
|
||||||
mat2.name = "2"
|
# mat2.name = "2"
|
||||||
mat2.tournament_id = 1
|
# mat2.tournament_id = 1
|
||||||
mat2.save
|
# mat2.save
|
||||||
assert_equal 4, mat2.matches.size
|
# assert_equal 4, mat2.matches.size
|
||||||
elevenManBracketFinished
|
# elevenManBracketFinished
|
||||||
mat2.destroy
|
# mat2.destroy
|
||||||
mat1 = Mat.find(1)
|
# mat1 = Mat.find(1)
|
||||||
assert_equal 4, mat1.matches.size
|
# assert_equal 4, mat1.matches.size
|
||||||
end
|
# end
|
||||||
|
|
||||||
test "Championship bracket wins are 2pts" do
|
# test "Championship bracket wins are 2pts" do
|
||||||
elevenManBracketToQuarter
|
# elevenManBracketToQuarter
|
||||||
assert_equal 9, Wrestler.where("name = ?", "Guy11").first.team_points_earned
|
# assert_equal 9, Wrestler.where("name = ?", "Guy11").first.team_points_earned
|
||||||
|
|
||||||
endMatch(4006,"Guy11")
|
# endMatch(4006,"Guy11")
|
||||||
assert_equal 17, Wrestler.where("name = ?", "Guy11").first.team_points_earned
|
# assert_equal 17, Wrestler.where("name = ?", "Guy11").first.team_points_earned
|
||||||
endMatch(4007,"Guy14")
|
# endMatch(4007,"Guy14")
|
||||||
endMatch(5004,"Guy11")
|
# endMatch(5004,"Guy11")
|
||||||
assert_equal 22, Wrestler.where("name = ?", "Guy11").first.team_points_earned
|
# assert_equal 22, Wrestler.where("name = ?", "Guy11").first.team_points_earned
|
||||||
end
|
# end
|
||||||
|
|
||||||
test "Conso bracket wins are 1pt" do
|
# test "Conso bracket wins are 1pt" do
|
||||||
elevenManBracketToSemis
|
# elevenManBracketToSemis
|
||||||
assert_equal 7, Wrestler.where("name = ?", "Guy17").first.team_points_earned
|
# assert_equal 7, Wrestler.where("name = ?", "Guy17").first.team_points_earned
|
||||||
|
|
||||||
endMatch(5006,"Guy17")
|
# endMatch(5006,"Guy17")
|
||||||
assert_equal 11, Wrestler.where("name = ?", "Guy17").first.team_points_earned
|
# assert_equal 11, Wrestler.where("name = ?", "Guy17").first.team_points_earned
|
||||||
end
|
# end
|
||||||
|
|
||||||
test "One pool placement points" do
|
# test "One pool placement points" do
|
||||||
singlePoolFinished
|
# singlePoolFinished
|
||||||
wrestler1 = Wrestler.where("name = ?", "James Wimer").first
|
# wrestler1 = Wrestler.where("name = ?", "James Wimer").first
|
||||||
wrestler2 = Wrestler.where("name = ?", "Jaden Mattox").first
|
# wrestler2 = Wrestler.where("name = ?", "Jaden Mattox").first
|
||||||
wrestler3 = Wrestler.where("name = ?", "Jackson Lakso").first
|
# wrestler3 = Wrestler.where("name = ?", "Jackson Lakso").first
|
||||||
wrestler4 = Wrestler.where("name = ?", "JD Woods").first
|
# wrestler4 = Wrestler.where("name = ?", "JD Woods").first
|
||||||
assert_equal 16, wrestler1.placement_points
|
# assert_equal 16, wrestler1.placement_points
|
||||||
assert_equal 12, wrestler2.placement_points
|
# assert_equal 12, wrestler2.placement_points
|
||||||
assert_equal 10, wrestler3.placement_points
|
# assert_equal 10, wrestler3.placement_points
|
||||||
assert_equal 9, wrestler4.placement_points
|
# assert_equal 9, wrestler4.placement_points
|
||||||
end
|
# end
|
||||||
|
|
||||||
test "One pool placement points zero if pool not finished" do
|
# test "One pool placement points zero if pool not finished" do
|
||||||
singlePoolNotFinished
|
# singlePoolNotFinished
|
||||||
wrestler1 = Wrestler.where("name = ?", "James Wimer").first
|
# wrestler1 = Wrestler.where("name = ?", "James Wimer").first
|
||||||
assert_equal 0, wrestler1.placement_points
|
# assert_equal 0, wrestler1.placement_points
|
||||||
end
|
# end
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
217
test/integration/pool_order_test.rb
Normal file
217
test/integration/pool_order_test.rb
Normal file
@@ -0,0 +1,217 @@
|
|||||||
|
require 'test_helper'
|
||||||
|
|
||||||
|
class PoolAdvancementTest < ActionDispatch::IntegrationTest
|
||||||
|
|
||||||
|
def setup
|
||||||
|
create_pool_tournament_single_weight(6)
|
||||||
|
end
|
||||||
|
|
||||||
|
def finishWithNoTies
|
||||||
|
end_match(match_wrestler_vs("Test1","Test2"),"Test1")
|
||||||
|
end_match(match_wrestler_vs("Test1","Test3"),"Test1")
|
||||||
|
end_match(match_wrestler_vs("Test1","Test4"),"Test1")
|
||||||
|
end_match(match_wrestler_vs("Test1","Test5"),"Test1")
|
||||||
|
end_match(match_wrestler_vs("Test1","Test6"),"Test1")
|
||||||
|
end_match(match_wrestler_vs("Test2","Test3"),"Test2")
|
||||||
|
end_match(match_wrestler_vs("Test2","Test4"),"Test2")
|
||||||
|
end_match(match_wrestler_vs("Test2","Test5"),"Test2")
|
||||||
|
end_match(match_wrestler_vs("Test2","Test6"),"Test2")
|
||||||
|
end_match(match_wrestler_vs("Test3","Test4"),"Test3")
|
||||||
|
end_match(match_wrestler_vs("Test3","Test5"),"Test3")
|
||||||
|
end_match(match_wrestler_vs("Test3","Test6"),"Test3")
|
||||||
|
end_match(match_wrestler_vs("Test4","Test5"),"Test4")
|
||||||
|
end_match(match_wrestler_vs("Test4","Test6"),"Test4")
|
||||||
|
end_match(match_wrestler_vs("Test5","Test6"),"Test5")
|
||||||
|
end
|
||||||
|
|
||||||
|
def finishNonTiebreakerMatches
|
||||||
|
@tournament.matches.where("w1 = ? OR w2 = ? AND w1 != ? OR w2 != ? AND w1 != ? OR w2 != ?",translate_name_to_id("Test1"),translate_name_to_id("Test1"),translate_name_to_id("Test2"),translate_name_to_id("Test2"),translate_name_to_id("Test3"),translate_name_to_id("Test3")).each do | match |
|
||||||
|
end_match(match,"Test1")
|
||||||
|
end
|
||||||
|
@tournament.matches.where("w1 = ? OR w2 = ? AND w1 != ? OR w2 != ? AND w1 != ? OR w2 != ?",translate_name_to_id("Test2"),translate_name_to_id("Test2"),translate_name_to_id("Test1"),translate_name_to_id("Test1"),translate_name_to_id("Test3"),translate_name_to_id("Test3")).each do | match |
|
||||||
|
end_match(match,"Test1")
|
||||||
|
end
|
||||||
|
@tournament.matches.where("w1 = ? OR w2 = ? AND w1 != ? OR w2 != ? AND w1 != ? OR w2 != ?",translate_name_to_id("Test3"),translate_name_to_id("Test3"),translate_name_to_id("Test1"),translate_name_to_id("Test1"),translate_name_to_id("Test2"),translate_name_to_id("Test2")).each do | match |
|
||||||
|
end_match(match,"Test1")
|
||||||
|
end
|
||||||
|
@tournament.matches.where("w1 = ? OR w2 = ? AND finished != 1",translate_name_to_id("Test4"),translate_name_to_id("Test4")).each do | match |
|
||||||
|
end_match(match,"Test4")
|
||||||
|
end
|
||||||
|
@tournament.matches.where("w1 = ? OR w2 = ? AND finished != 1",translate_name_to_id("Test5"),translate_name_to_id("Test5")).each do | match |
|
||||||
|
end_match(match,"Test5")
|
||||||
|
end
|
||||||
|
@tournament.matches.where("w1 = ? OR w2 = ? AND finished != 1",translate_name_to_id("Test6"),translate_name_to_id("Test6")).each do | match |
|
||||||
|
end_match(match,"Test6")
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
def finishWithTieMostTeamPoints
|
||||||
|
end_match_with_pin(match_wrestler_vs("Test1","Test2"),"Test1")
|
||||||
|
end_match(match_wrestler_vs("Test1","Test3"),"Test3")
|
||||||
|
end_match(match_wrestler_vs("Test1","Test4"),"Test1")
|
||||||
|
end_match(match_wrestler_vs("Test1","Test5"),"Test1")
|
||||||
|
end_match(match_wrestler_vs("Test1","Test6"),"Test1")
|
||||||
|
end_match(match_wrestler_vs("Test2","Test3"),"Test2")
|
||||||
|
end_match(match_wrestler_vs("Test2","Test4"),"Test2")
|
||||||
|
end_match(match_wrestler_vs("Test2","Test5"),"Test2")
|
||||||
|
end_match(match_wrestler_vs("Test2","Test6"),"Test2")
|
||||||
|
end_match(match_wrestler_vs("Test3","Test4"),"Test3")
|
||||||
|
end_match(match_wrestler_vs("Test3","Test5"),"Test3")
|
||||||
|
end_match(match_wrestler_vs("Test3","Test6"),"Test3")
|
||||||
|
end_match(match_wrestler_vs("Test4","Test5"),"Test4")
|
||||||
|
end_match(match_wrestler_vs("Test4","Test6"),"Test4")
|
||||||
|
end_match(match_wrestler_vs("Test5","Test6"),"Test5")
|
||||||
|
end
|
||||||
|
|
||||||
|
def finishedWithTieMostFalls
|
||||||
|
#Test1 has 12 points
|
||||||
|
#Test2 has 12 points
|
||||||
|
#Test3 has 12 points
|
||||||
|
|
||||||
|
end_match_with_pin(match_wrestler_vs("Test1","Test2"),"Test1")
|
||||||
|
end_match_with_major(match_wrestler_vs("Test1","Test3"),"Test3")
|
||||||
|
end_match(match_wrestler_vs("Test1","Test4"),"Test1")
|
||||||
|
end_match(match_wrestler_vs("Test1","Test5"),"Test1")
|
||||||
|
end_match_with_pin(match_wrestler_vs("Test1","Test6"),"Test1")
|
||||||
|
end_match_with_major(match_wrestler_vs("Test2","Test3"),"Test2")
|
||||||
|
end_match_with_major(match_wrestler_vs("Test2","Test4"),"Test2")
|
||||||
|
end_match_with_major(match_wrestler_vs("Test2","Test5"),"Test2")
|
||||||
|
end_match_with_major(match_wrestler_vs("Test2","Test6"),"Test2")
|
||||||
|
end_match_with_major(match_wrestler_vs("Test3","Test4"),"Test3")
|
||||||
|
end_match_with_major(match_wrestler_vs("Test3","Test5"),"Test3")
|
||||||
|
end_match_with_major(match_wrestler_vs("Test3","Test6"),"Test3")
|
||||||
|
end_match(match_wrestler_vs("Test4","Test5"),"Test4")
|
||||||
|
end_match(match_wrestler_vs("Test4","Test6"),"Test4")
|
||||||
|
end_match(match_wrestler_vs("Test5","Test6"),"Test5")
|
||||||
|
end
|
||||||
|
|
||||||
|
def finishedWithTieMostTechFalls
|
||||||
|
#Test1 has 11 points
|
||||||
|
#Test2 has 11 points
|
||||||
|
#Test3 has 11 points
|
||||||
|
|
||||||
|
end_match_with_tech(match_wrestler_vs("Test1","Test2"),"Test1")
|
||||||
|
end_match(match_wrestler_vs("Test1","Test3"),"Test3")
|
||||||
|
end_match(match_wrestler_vs("Test1","Test4"),"Test1")
|
||||||
|
end_match(match_wrestler_vs("Test1","Test5"),"Test1")
|
||||||
|
end_match_with_tech(match_wrestler_vs("Test1","Test6"),"Test1")
|
||||||
|
end_match(match_wrestler_vs("Test2","Test3"),"Test2")
|
||||||
|
end_match_with_major(match_wrestler_vs("Test2","Test4"),"Test2")
|
||||||
|
end_match_with_major(match_wrestler_vs("Test2","Test5"),"Test2")
|
||||||
|
end_match_with_major(match_wrestler_vs("Test2","Test6"),"Test2")
|
||||||
|
end_match_with_major(match_wrestler_vs("Test3","Test4"),"Test3")
|
||||||
|
end_match_with_major(match_wrestler_vs("Test3","Test5"),"Test3")
|
||||||
|
end_match_with_major(match_wrestler_vs("Test3","Test6"),"Test3")
|
||||||
|
end_match(match_wrestler_vs("Test4","Test5"),"Test4")
|
||||||
|
end_match(match_wrestler_vs("Test4","Test6"),"Test4")
|
||||||
|
end_match(match_wrestler_vs("Test5","Test6"),"Test5")
|
||||||
|
end
|
||||||
|
|
||||||
|
def finishedWithTieQuickestPin
|
||||||
|
#Test1 has 5:20 of pin time
|
||||||
|
#Test2 has 9:20 of pin time
|
||||||
|
#Test3 has 20 minutes of pin time
|
||||||
|
|
||||||
|
end_match_with_pin(match_wrestler_vs("Test1","Test2"),"Test1")
|
||||||
|
end_match_with_pin(match_wrestler_vs("Test1","Test3"),"Test3")
|
||||||
|
end_match_with_quick_pin(match_wrestler_vs("Test1","Test4"),"Test1")
|
||||||
|
end_match_with_quick_pin(match_wrestler_vs("Test1","Test5"),"Test1")
|
||||||
|
end_match_with_quick_pin(match_wrestler_vs("Test1","Test6"),"Test1")
|
||||||
|
end_match_with_pin(match_wrestler_vs("Test2","Test3"),"Test2")
|
||||||
|
end_match_with_quick_pin(match_wrestler_vs("Test2","Test4"),"Test2")
|
||||||
|
end_match_with_quick_pin(match_wrestler_vs("Test2","Test5"),"Test2")
|
||||||
|
end_match_with_quick_pin(match_wrestler_vs("Test2","Test6"),"Test2")
|
||||||
|
end_match(match_wrestler_vs("Test3","Test4"),"Test3")
|
||||||
|
end_match_with_pin(match_wrestler_vs("Test3","Test5"),"Test3")
|
||||||
|
end_match_with_pin(match_wrestler_vs("Test3","Test6"),"Test3")
|
||||||
|
end_match(match_wrestler_vs("Test4","Test5"),"Test4")
|
||||||
|
end_match(match_wrestler_vs("Test4","Test6"),"Test4")
|
||||||
|
end_match(match_wrestler_vs("Test5","Test6"),"Test5")
|
||||||
|
end
|
||||||
|
|
||||||
|
def finishedWithTieCoinFlip
|
||||||
|
end_match(match_wrestler_vs("Test1","Test2"),"Test1")
|
||||||
|
end_match(match_wrestler_vs("Test1","Test3"),"Test3")
|
||||||
|
end_match(match_wrestler_vs("Test1","Test4"),"Test1")
|
||||||
|
end_match(match_wrestler_vs("Test1","Test5"),"Test1")
|
||||||
|
end_match(match_wrestler_vs("Test1","Test6"),"Test1")
|
||||||
|
end_match(match_wrestler_vs("Test2","Test3"),"Test2")
|
||||||
|
end_match(match_wrestler_vs("Test2","Test4"),"Test2")
|
||||||
|
end_match(match_wrestler_vs("Test2","Test5"),"Test2")
|
||||||
|
end_match(match_wrestler_vs("Test2","Test6"),"Test2")
|
||||||
|
end_match(match_wrestler_vs("Test3","Test4"),"Test3")
|
||||||
|
end_match(match_wrestler_vs("Test3","Test5"),"Test3")
|
||||||
|
end_match(match_wrestler_vs("Test3","Test6"),"Test3")
|
||||||
|
end_match(match_wrestler_vs("Test4","Test5"),"Test4")
|
||||||
|
end_match(match_wrestler_vs("Test4","Test6"),"Test4")
|
||||||
|
end_match(match_wrestler_vs("Test5","Test6"),"Test5")
|
||||||
|
end
|
||||||
|
|
||||||
|
test "Pool order based on wins" do
|
||||||
|
finishWithNoTies
|
||||||
|
assert Wrestler.find(translate_name_to_id("Test1")).pool_placement = 1
|
||||||
|
assert Wrestler.find(translate_name_to_id("Test2")).pool_placement = 2
|
||||||
|
assert Wrestler.find(translate_name_to_id("Test3")).pool_placement = 3
|
||||||
|
assert Wrestler.find(translate_name_to_id("Test4")).pool_placement = 4
|
||||||
|
assert Wrestler.find(translate_name_to_id("Test5")).pool_placement = 5
|
||||||
|
assert Wrestler.find(translate_name_to_id("Test6")).pool_placement = 6
|
||||||
|
end
|
||||||
|
|
||||||
|
test "Pool order three way tie with most team points" do
|
||||||
|
finishWithTieMostTeamPoints
|
||||||
|
assert Wrestler.find(translate_name_to_id("Test1")).pool_placement = 1
|
||||||
|
assert Wrestler.find(translate_name_to_id("Test1")).pool_placement_tiebreaker = "Team Points"
|
||||||
|
assert Wrestler.find(translate_name_to_id("Test2")).pool_placement = 2
|
||||||
|
assert Wrestler.find(translate_name_to_id("Test2")).pool_placement_tiebreaker = "Head to Head"
|
||||||
|
assert Wrestler.find(translate_name_to_id("Test3")).pool_placement = 3
|
||||||
|
assert Wrestler.find(translate_name_to_id("Test3")).pool_placement_tiebreaker = ""
|
||||||
|
assert Wrestler.find(translate_name_to_id("Test4")).pool_placement = 4
|
||||||
|
assert Wrestler.find(translate_name_to_id("Test5")).pool_placement = 5
|
||||||
|
assert Wrestler.find(translate_name_to_id("Test6")).pool_placement = 6
|
||||||
|
end
|
||||||
|
|
||||||
|
test "Pool order three way tie with most pins" do
|
||||||
|
finishWithTieMostTeamPoints
|
||||||
|
assert Wrestler.find(translate_name_to_id("Test1")).pool_placement = 1
|
||||||
|
assert Wrestler.find(translate_name_to_id("Test1")).pool_placement_tiebreaker = "Most Pins"
|
||||||
|
assert Wrestler.find(translate_name_to_id("Test2")).pool_placement = 2
|
||||||
|
assert Wrestler.find(translate_name_to_id("Test2")).pool_placement_tiebreaker = "Head to Head"
|
||||||
|
assert Wrestler.find(translate_name_to_id("Test3")).pool_placement = 3
|
||||||
|
assert Wrestler.find(translate_name_to_id("Test3")).pool_placement_tiebreaker = ""
|
||||||
|
assert Wrestler.find(translate_name_to_id("Test4")).pool_placement = 4
|
||||||
|
assert Wrestler.find(translate_name_to_id("Test5")).pool_placement = 5
|
||||||
|
assert Wrestler.find(translate_name_to_id("Test6")).pool_placement = 6
|
||||||
|
end
|
||||||
|
|
||||||
|
test "Pool order three way tie with most tech falls" do
|
||||||
|
finishWithTieMostTeamPoints
|
||||||
|
assert Wrestler.find(translate_name_to_id("Test1")).pool_placement = 1
|
||||||
|
assert Wrestler.find(translate_name_to_id("Test1")).pool_placement_tiebreaker = "Most Techs"
|
||||||
|
assert Wrestler.find(translate_name_to_id("Test2")).pool_placement = 2
|
||||||
|
assert Wrestler.find(translate_name_to_id("Test2")).pool_placement_tiebreaker = "Head to Head"
|
||||||
|
assert Wrestler.find(translate_name_to_id("Test3")).pool_placement = 3
|
||||||
|
assert Wrestler.find(translate_name_to_id("Test3")).pool_placement_tiebreaker = ""
|
||||||
|
assert Wrestler.find(translate_name_to_id("Test4")).pool_placement = 4
|
||||||
|
assert Wrestler.find(translate_name_to_id("Test5")).pool_placement = 5
|
||||||
|
assert Wrestler.find(translate_name_to_id("Test6")).pool_placement = 6
|
||||||
|
end
|
||||||
|
|
||||||
|
test "Pool order three way tie with quickest pin times" do
|
||||||
|
finishedWithTieQuickestPin
|
||||||
|
assert Wrestler.find(translate_name_to_id("Test1")).pool_placement = 1
|
||||||
|
assert Wrestler.find(translate_name_to_id("Test1")).pool_placement_tiebreaker = "Pin Time"
|
||||||
|
assert Wrestler.find(translate_name_to_id("Test2")).pool_placement = 2
|
||||||
|
assert Wrestler.find(translate_name_to_id("Test2")).pool_placement_tiebreaker = "Pin Time"
|
||||||
|
assert Wrestler.find(translate_name_to_id("Test3")).pool_placement = 3
|
||||||
|
assert Wrestler.find(translate_name_to_id("Test3")).pool_placement_tiebreaker = ""
|
||||||
|
assert Wrestler.find(translate_name_to_id("Test4")).pool_placement = 4
|
||||||
|
assert Wrestler.find(translate_name_to_id("Test5")).pool_placement = 5
|
||||||
|
assert Wrestler.find(translate_name_to_id("Test6")).pool_placement = 6
|
||||||
|
end
|
||||||
|
|
||||||
|
test "Pool order three way tie with coin flip" do
|
||||||
|
finishedWithTieCoinFlip
|
||||||
|
assert Wrestler.where("weight_id = ? AND pool_placement = 1",@weight.id).first.pool_placement_tiebreaker = "Coin Flip"
|
||||||
|
assert Wrestler.where("weight_id = ? AND pool_placement = 2",@weight.id).first.pool_placement_tiebreaker = "Head to Head"
|
||||||
|
end
|
||||||
|
end
|
||||||
@@ -12,4 +12,178 @@ class ActiveSupport::TestCase
|
|||||||
fixtures :all
|
fixtures :all
|
||||||
|
|
||||||
# Add more helper methods to be used by all tests here...
|
# Add more helper methods to be used by all tests here...
|
||||||
|
|
||||||
|
def create_pool_tournament_single_weight(number_of_wrestlers)
|
||||||
|
@tournament = Tournament.new
|
||||||
|
@tournament.name = "Test Tournament"
|
||||||
|
@tournament.address = "some place"
|
||||||
|
@tournament.director = "some guy"
|
||||||
|
@tournament.director_email= "test@test.com"
|
||||||
|
@tournament.tournament_type = "Pool to bracket"
|
||||||
|
@tournament.date = "2015-12-30"
|
||||||
|
@tournament.save
|
||||||
|
@school = School.new
|
||||||
|
@school.name = "Test"
|
||||||
|
@school.tournament_id = @tournament.id
|
||||||
|
@school.save
|
||||||
|
@weight = Weight.new
|
||||||
|
@weight.max = 106
|
||||||
|
@weight.tournament_id = @tournament.id
|
||||||
|
@weight.save
|
||||||
|
create_wrestlers_for_weight(@weight, @school, number_of_wrestlers, 1)
|
||||||
|
GenerateTournamentMatches.new(@tournament).generate
|
||||||
|
end
|
||||||
|
|
||||||
|
def create_pool_tournament
|
||||||
|
@tournament = Tournament.new
|
||||||
|
@tournament.name = "Test Tournament"
|
||||||
|
@tournament.address = "some place"
|
||||||
|
@tournament.director = "some guy"
|
||||||
|
@tournament.director_email= "test@test.com"
|
||||||
|
@tournament.tournament_type = "Pool to bracket"
|
||||||
|
@tournament.date = "2015-12-30"
|
||||||
|
@tournament.save
|
||||||
|
|
||||||
|
# First school
|
||||||
|
school = School.new
|
||||||
|
school.name = "Test1"
|
||||||
|
school.tournament_id = @tournament.id
|
||||||
|
school.save
|
||||||
|
|
||||||
|
# Second school
|
||||||
|
school = School.new
|
||||||
|
school.name = "Test2"
|
||||||
|
school.tournament_id = @tournament.id
|
||||||
|
school.save
|
||||||
|
|
||||||
|
# Third school
|
||||||
|
school = School.new
|
||||||
|
school.name = "Test3"
|
||||||
|
school.tournament_id = @tournament.id
|
||||||
|
school.save
|
||||||
|
|
||||||
|
# Weight 1
|
||||||
|
weight = Weight.new
|
||||||
|
weight.max = 106
|
||||||
|
weight.tournament_id = @tournament.id
|
||||||
|
weight.save
|
||||||
|
create_wrestlers_for_weight(weight, @tournament.schools.sample, 6, 1)
|
||||||
|
|
||||||
|
# Weight 2
|
||||||
|
weight = Weight.new
|
||||||
|
weight.max = 113
|
||||||
|
weight.tournament_id = @tournament.id
|
||||||
|
weight.save
|
||||||
|
create_wrestlers_for_weight(weight, @tournament.schools.sample, 10, 7)
|
||||||
|
|
||||||
|
# Weight 3
|
||||||
|
weight = Weight.new
|
||||||
|
weight.max = 120
|
||||||
|
weight.tournament_id = @tournament.id
|
||||||
|
weight.save
|
||||||
|
create_wrestlers_for_weight(weight, @tournament.schools.sample, 12, 17)
|
||||||
|
|
||||||
|
# Weight 4
|
||||||
|
weight = Weight.new
|
||||||
|
weight.max = 126
|
||||||
|
weight.tournament_id = @tournament.id
|
||||||
|
weight.save
|
||||||
|
create_wrestlers_for_weight(weight, @tournament.schools.sample, 16, 29)
|
||||||
|
|
||||||
|
# Weight 5
|
||||||
|
weight = Weight.new
|
||||||
|
weight.max = 132
|
||||||
|
weight.tournament_id = @tournament.id
|
||||||
|
weight.save
|
||||||
|
create_wrestlers_for_weight(weight, @tournament.schools.sample, 24, 45)
|
||||||
|
|
||||||
|
# Weight 6
|
||||||
|
weight = Weight.new
|
||||||
|
weight.max = 138
|
||||||
|
weight.tournament_id = @tournament.id
|
||||||
|
weight.save
|
||||||
|
create_wrestlers_for_weight(weight, @tournament.schools.sample, 8, 69)
|
||||||
|
|
||||||
|
GenerateTournamentMatches.new(@tournament).generate
|
||||||
|
end
|
||||||
|
|
||||||
|
def create_wrestlers_for_weight(weight, school, number_of_wrestlers, naming_start_number)
|
||||||
|
naming_number = naming_start_number
|
||||||
|
seed = 1
|
||||||
|
for number in (1..number_of_wrestlers) do
|
||||||
|
wrestler = Wrestler.new
|
||||||
|
wrestler.name = "Test#{naming_number}"
|
||||||
|
school = @tournament.schools.sample
|
||||||
|
wrestler.school_id = school.id
|
||||||
|
wrestler.weight_id = weight.id
|
||||||
|
if seed <= 4
|
||||||
|
wrestler.original_seed = seed
|
||||||
|
end
|
||||||
|
wrestler.save
|
||||||
|
naming_number = naming_number + 1
|
||||||
|
seed = seed + 1
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
def end_match(match,winner)
|
||||||
|
match.win_type = "Decision"
|
||||||
|
match.score = 1-0
|
||||||
|
save_match(match,winner)
|
||||||
|
end
|
||||||
|
|
||||||
|
def end_match_extra_points(match,winner)
|
||||||
|
match.win_type = "Decision"
|
||||||
|
match.score = 0-2
|
||||||
|
save_match(match,winner)
|
||||||
|
end
|
||||||
|
|
||||||
|
def end_match_with_major(match,winner)
|
||||||
|
match.win_type = "Major"
|
||||||
|
match.score = 8-0
|
||||||
|
save_match(match,winner)
|
||||||
|
end
|
||||||
|
|
||||||
|
def end_match_with_tech(match,winner)
|
||||||
|
match.win_type = "Tech Fall"
|
||||||
|
match.score = 15-0
|
||||||
|
save_match(match,winner)
|
||||||
|
end
|
||||||
|
|
||||||
|
def end_match_with_pin(match,winner)
|
||||||
|
match.win_type = "Pin"
|
||||||
|
match.score = "5:00"
|
||||||
|
save_match(match,winner)
|
||||||
|
end
|
||||||
|
|
||||||
|
def end_match_with_quickest_pin(match,winner)
|
||||||
|
match.win_type = "Pin"
|
||||||
|
match.score = "0:20"
|
||||||
|
save_match(match,winner)
|
||||||
|
end
|
||||||
|
|
||||||
|
def end_match_with_quick_pin(match,winner)
|
||||||
|
match.win_type = "Pin"
|
||||||
|
match.score = "1:20"
|
||||||
|
save_match(match,winner)
|
||||||
|
end
|
||||||
|
|
||||||
|
def save_match(match,winner)
|
||||||
|
match.finished = 1
|
||||||
|
match.winner_id = translate_name_to_id(winner)
|
||||||
|
|
||||||
|
match.save!
|
||||||
|
end
|
||||||
|
|
||||||
|
def translate_name_to_id(wrestler)
|
||||||
|
Wrestler.where("name = ? AND weight_id = ?", wrestler, @weight.id).first.id
|
||||||
|
end
|
||||||
|
|
||||||
|
def get_wrestler_by_name(name)
|
||||||
|
Wrestler.where("name = ? AND weight_id = ?", name, @weight.id).first
|
||||||
|
end
|
||||||
|
|
||||||
|
def match_wrestler_vs(wrestler1_name,wrestler2_name)
|
||||||
|
Match.where("(w1 = ? OR w2 = ?) AND (w1 = ? OR w2 = ?)",translate_name_to_id(wrestler1_name), translate_name_to_id(wrestler1_name), translate_name_to_id(wrestler2_name),translate_name_to_id(wrestler2_name)).first
|
||||||
|
end
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|||||||
Reference in New Issue
Block a user