<% back_to_school_path = school_path(@wrestler.school) %>
<% back_to_school_path += "?school_permission_key=#{params[:school_permission_key]}" if params[:school_permission_key].present? %>

<%= link_to "Back to #{@wrestler.school.name}", back_to_school_path, class: "btn btn-default" %>
  <br>
  <br>
  <p>
    <strong>Name:</strong>
    <%= @wrestler.name %> <% if can? :manage, @school %><%= link_to " Edit", edit_wrestler_path(@wrestler), :class=>"fas fa-edit" %><% end %>
  </p>
<% cache ["#{@wrestler.id}", @wrestler] do %>
  <p>
    <strong>School:</strong>
    <%= @wrestler.school.name %>
  </p>

  <p>
    <strong>Weight:</strong>
    <%= @wrestler.weight.max %>
  </p>
  <p>
    <strong>Extra?:</strong>
    <%= @wrestler.extra %>
  </p>
  <br>
  <br>
  <h4>Point Breakdown</h4>
  <br>
  <table class="table">
    <thead>
      <tr>
        <th>Point Modifier</th>
        <th>Points</th>
      </tr>
    </thead>
    <tbody>
      <tr>
        <td>Pool Win Points</td>
        <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.placement_points %></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>
  <h4>Matches</h4>
  <br>
  <table class="table">
    <thead>
      <tr>
        <th>Bout</th>
        <th>Match Bracket Position</th>
        <th>Stats</th>
        <th>Result</th>
      </tr>
    </thead>
    <tbody>
      <% @wrestler.all_matches.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.result_by_id(m.id) %></td>
        </tr>
      <% end %>
    </tbody>
  </table>
<% end %>
