1
0
mirror of https://github.com/jcwimer/wrestlingApp synced 2026-03-25 01:14:43 +00:00

Pretty up wrestler show page

This commit is contained in:
2017-12-14 09:03:31 -05:00
parent 03f3b8dcff
commit ba05573928
3 changed files with 95 additions and 46 deletions

View File

@@ -3,19 +3,19 @@ class CalculateWrestlerTeamScore
@wrestler = wrestler @wrestler = wrestler
@tournament = @wrestler.tournament @tournament = @wrestler.tournament
end end
def totalScore def totalScore
if @wrestler.extra or @wrestler.matches.count == 0 if @wrestler.extra or @wrestler.matches.count == 0
return 0 return 0
else else
earnedPoints - deductedPoints earnedPoints - deductedPoints
end end
end end
def earnedPoints def earnedPoints
return poolPoints + bracketPoints + placementPoints + bonusWinPoints return poolPoints + bracketPoints + placementPoints + bonusWinPoints + byePoints
end end
def deductedPoints def deductedPoints
points = 0 points = 0
@wrestler.deductedPoints.each do |d| @wrestler.deductedPoints.each do |d|
@@ -23,29 +23,37 @@ class CalculateWrestlerTeamScore
end end
points points
end end
def placementPoints def placementPoints
PoolBracketPlacementPoints.new(@wrestler).calcPoints if @tournament.tournament_type == "Pool to bracket" PoolBracketPlacementPoints.new(@wrestler).calcPoints if @tournament.tournament_type == "Pool to bracket"
end end
def bracketPoints def bracketPoints
(@wrestler.championshipAdvancementWins.size * 2) + (@wrestler.consoAdvancementWins.size * 1) (@wrestler.championshipAdvancementWins.size * 2) + (@wrestler.consoAdvancementWins.size * 1)
end end
def poolPoints def poolPoints
if @tournament.tournament_type == "Pool to bracket" if @tournament.tournament_type == "Pool to bracket"
if @wrestler.poolWins.size >= 1 and @wrestler.hasAPoolBye == true (@wrestler.poolWins.size * 2)
((@wrestler.poolWins.size * 2) + 2)
else
(@wrestler.poolWins.size * 2)
end
else else
0 0
end end
end end
def bonusWinPoints def byePoints
(@wrestler.pinWins.size * 2) + (@wrestler.techWins.size * 1.5) + (@wrestler.majorWins.size * 1) if @tournament.tournament_type == "Pool to bracket"
if @wrestler.poolWins.size >= 1 and @wrestler.hasAPoolBye == true
2
else
0
end
else
0
end
end end
end def bonusWinPoints
(@wrestler.pinWins.size * 2) + (@wrestler.techWins.size * 1.5) + (@wrestler.majorWins.size * 1)
end
end

Binary file not shown.

View File

@@ -22,37 +22,78 @@
<%= @wrestler.weight.max %> <%= @wrestler.weight.max %>
</p> </p>
<p> <p>
<strong>Team Points Earned:</strong> <strong>Extra?:</strong>
<%= @wrestler.teamPointsEarned %> <%= @wrestler.extra %>
</p> </p>
<p> <br>
<strong>Team Points Deducted:</strong> <br>
<%= @wrestler.totalDeductedPoints %> <h4>Point Breakdown</h4>
</p> <br>
<p> <table class="table">
<strong>Total Team Points Scored:</strong> <thead>
<%= @wrestler.totalTeamPoints %> <tr>
</p> <th>Point Modifier</th>
<p> <th>Points</th>
<strong>Points Breakdown:</strong></br> </tr>
Pool Win Points (including BYE points): <%= @wrestler_points_calc.poolPoints %></br> </thead>
Bracket Win Points: <%= @wrestler_points_calc.bracketPoints %></br> <tbody>
Bonus Points: <%= @wrestler_points_calc.bonusWinPoints %></br> <tr>
Placement Points:<%= @wrestler_points_calc.placementPoints %></br> <td>Pool Win Points</td>
</p> <td>+<%= @wrestler_points_calc.poolPoints %></td>
</tr>
<tr>
<td>BYE Points</td>
<td>+<%= @wrestler_points_calc.byePoints %></td>
</tr>
<tr>
<td>Bracket Win Points</td>
<td>+<%= @wrestler_points_calc.bracketPoints %></td>
</tr>
<tr>
<td>Bonus Points (pins,major,tech,etc)</td>
<td>+<%= @wrestler_points_calc.bonusWinPoints %></td>
</tr>
<tr>
<td>Placement Points</td>
<td>+<%= @wrestler_points_calc.placementPoints %></td>
</tr>
<tr>
<td>Deducted Points</td>
<td>-<%= @wrestler_points_calc.deductedPoints %></td>
</tr>
<tr>
<td>Total Points Earned</td>
<td><%= @wrestler_points_calc.earnedPoints %></td>
</tr>
<tr>
<td><strong>Total Points Toward Team Score (0 if entered as extra)</strong></td>
<td><strong><%= @wrestler_points_calc.totalScore %></strong></td>
</tr>
</tbody>
</table>
<br> <br>
<br> <br>
<h4>Matches</h4> <h4>Matches</h4>
<br> <br>
<% @wrestler.allMatches.each do |m| %> <table class="table">
<div> Bout: <%= m.bout_number %> <%= m.bracket_position %> <%= m.wrestler1.name %> vs. <%= m.wrestler2.name %> <%= @wrestler.resultByBout(m.bout_number) %></div> <thead>
<% if m.w1_stat || m.w2_stat %> <tr>
<div>Stats:</div> <th>Bout</th>
<div><%= m.list_w1_stats %></div> <th>Match Bracket Position</th>
<div><%= m.list_w2_stats %></div> <th>Stats</th>
</br> <th>Result</th>
<% end %> </tr>
<% end %> </thead>
<tbody>
<% @wrestler.allMatches.each do |m| %>
<tr>
<td><%= m.bout_number %></td>
<td><%= m.bracket_position %></td>
<td><%= m.list_w1_stats %><br><%= m.list_w2_stats %></td>
<td><%= @wrestler.resultByBout(m.bout_number) %>
</tr>
<% end %>
</tbody>
</table>
<% end %> <% end %>