1
0
mirror of https://github.com/jcwimer/wrestlingApp synced 2026-04-12 00:09:32 +00:00

Added stats to wrestler -> show

This commit is contained in:
2017-11-14 07:43:06 -05:00
parent 62faa4f307
commit 0c9af7fcb3
2 changed files with 28 additions and 16 deletions

View File

@@ -4,12 +4,12 @@ class Match < ActiveRecord::Base
belongs_to :mat, touch: true belongs_to :mat, touch: true
has_many :wrestlers, :through => :weight has_many :wrestlers, :through => :weight
after_update do
after_update do
after_update_actions after_update_actions
end end
def after_update_actions def after_update_actions
if self.finished == 1 && self.winner_id != nil if self.finished == 1 && self.winner_id != nil
if self.w1 && self.w2 if self.w1 && self.w2
@@ -30,9 +30,9 @@ class Match < ActiveRecord::Base
if self.w1 && self.w2 if self.w1 && self.w2
wrestler1.school.calcScore wrestler1.school.calcScore
wrestler2.school.calcScore wrestler2.school.calcScore
end end
end end
def mat_assigned def mat_assigned
if self.mat if self.mat
@@ -41,7 +41,7 @@ class Match < ActiveRecord::Base
"" ""
end end
end end
def pinTime def pinTime
if self.win_type == "Pin" if self.win_type == "Pin"
time = self.score.delete("") time = self.score.delete("")
@@ -54,7 +54,7 @@ class Match < ActiveRecord::Base
end end
def advance_wrestlers def advance_wrestlers
if self.w1 && self.w2 if self.w1 && self.w2
AdvanceWrestler.new(wrestler1).advance AdvanceWrestler.new(wrestler1).advance
AdvanceWrestler.new(wrestler2).advance AdvanceWrestler.new(wrestler2).advance
end end
@@ -117,7 +117,7 @@ class Match < ActiveRecord::Base
def weight_max def weight_max
self.weight.max self.weight.max
end end
def replaceLoserNameWithWrestler(w,loserName) def replaceLoserNameWithWrestler(w,loserName)
if self.loser1_name == loserName if self.loser1_name == loserName
self.w1 = w.id self.w1 = w.id
@@ -133,6 +133,12 @@ class Match < ActiveRecord::Base
wrestler1.pool wrestler1.pool
end end
end end
def list_w2_stats
"#{w2_name}: #{w2_stat}"
end
def list_w1_stats
"#{w1_name}: #{w1_stat}"
end
end end

View File

@@ -1,22 +1,22 @@
<%= link_to "Back to #{@school.name}", "/schools/#{@school.id}", :class=>"btn btn-default" %> <%= link_to "Back to #{@school.name}", "/schools/#{@school.id}", :class=>"btn btn-default" %>
<% if can? :manage, @school %> <% if can? :manage, @school %>
| <%= link_to "Edit #{@wrestler.name}", edit_wrestler_path(@wrestler), :class=>"btn btn-primary" %> | <%= link_to "Edit #{@wrestler.name}", edit_wrestler_path(@wrestler), :class=>"btn btn-primary" %>
<% end %> <% end %>
<% cache ["#{@wrestler.id}", @wrestler] do %> <% cache ["#{@wrestler.id}", @wrestler] do %>
<br> <br>
<br> <br>
<p> <p>
<strong>Name:</strong> <strong>Name:</strong>
<%= @wrestler.name %> <%= @wrestler.name %>
</p> </p>
<p> <p>
<strong>School:</strong> <strong>School:</strong>
<%= @wrestler.school.name %> <%= @wrestler.school.name %>
</p> </p>
<p> <p>
<strong>Weight:</strong> <strong>Weight:</strong>
<%= @wrestler.weight.max %> <%= @wrestler.weight.max %>
@@ -33,12 +33,18 @@
<strong>Total Team Points Scored:</strong> <strong>Total Team Points Scored:</strong>
<%= @wrestler.totalTeamPoints %> <%= @wrestler.totalTeamPoints %>
</p> </p>
<br> <br>
<br> <br>
<h4>Matches</h4> <h4>Matches</h4>
<br> <br>
<% @wrestler.allMatches.each do |m| %> <% @wrestler.allMatches.each do |m| %>
<div> Bout: <%= m.bout_number %> <%= m.bracket_position %> <%= m.wrestler1.name %> vs. <%= m.wrestler2.name %> <%= @wrestler.resultByBout(m.bout_number) %></div> <div> Bout: <%= m.bout_number %> <%= m.bracket_position %> <%= m.wrestler1.name %> vs. <%= m.wrestler2.name %> <%= @wrestler.resultByBout(m.bout_number) %></div>
<% if m.w1_stat || m.w2_stat %>
<div>Stats:</div>
<div><%= m.list_w1_stats %></div>
<div><%= m.list_w2_stats %></div>
</br>
<% end %>
<% end %> <% end %>
<% end %> <% end %>