1
0
mirror of https://github.com/jcwimer/wrestlingApp synced 2026-03-24 17:04:43 +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
has_many :wrestlers, :through => :weight
after_update do
after_update do
after_update_actions
end
def after_update_actions
if self.finished == 1 && self.winner_id != nil
if self.w1 && self.w2
@@ -30,9 +30,9 @@ class Match < ActiveRecord::Base
if self.w1 && self.w2
wrestler1.school.calcScore
wrestler2.school.calcScore
end
end
end
def mat_assigned
if self.mat
@@ -41,7 +41,7 @@ class Match < ActiveRecord::Base
""
end
end
def pinTime
if self.win_type == "Pin"
time = self.score.delete("")
@@ -54,7 +54,7 @@ class Match < ActiveRecord::Base
end
def advance_wrestlers
if self.w1 && self.w2
if self.w1 && self.w2
AdvanceWrestler.new(wrestler1).advance
AdvanceWrestler.new(wrestler2).advance
end
@@ -117,7 +117,7 @@ class Match < ActiveRecord::Base
def weight_max
self.weight.max
end
def replaceLoserNameWithWrestler(w,loserName)
if self.loser1_name == loserName
self.w1 = w.id
@@ -133,6 +133,12 @@ class Match < ActiveRecord::Base
wrestler1.pool
end
end
def list_w2_stats
"#{w2_name}: #{w2_stat}"
end
def list_w1_stats
"#{w1_name}: #{w1_stat}"
end
end

View File

@@ -1,22 +1,22 @@
<%= link_to "Back to #{@school.name}", "/schools/#{@school.id}", :class=>"btn btn-default" %>
<% if can? :manage, @school %>
| <%= link_to "Edit #{@wrestler.name}", edit_wrestler_path(@wrestler), :class=>"btn btn-primary" %>
<% end %>
<% cache ["#{@wrestler.id}", @wrestler] do %>
<% cache ["#{@wrestler.id}", @wrestler] do %>
<br>
<br>
<p>
<strong>Name:</strong>
<%= @wrestler.name %>
</p>
<p>
<strong>School:</strong>
<%= @wrestler.school.name %>
</p>
<p>
<strong>Weight:</strong>
<%= @wrestler.weight.max %>
@@ -33,12 +33,18 @@
<strong>Total Team Points Scored:</strong>
<%= @wrestler.totalTeamPoints %>
</p>
<br>
<br>
<h4>Matches</h4>
<br>
<% @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 %>