<table id="matches" class="<%= 'contest' if defined? contest and contest %> striped">
  <tr>
    <% if defined? contest and contest %>
      <th class="contest">Contest</th>
      <th class="opponent">Opponent</th>
    <% else %>
      <th class="opponent">Opponent</th>
    <% end %>
    <th class="date">Date</th>
    <% unless defined? exclude_maps %>
      <th class="maps">Maps</th>
    <% end %>
    <th class="score">Score</th>
    <% if matches.first&.contest&.contest_type == Contest::TYPE_LADDER %>
      <th class="points">Points</th>
    <% end %>
  </tr>

  <% matches.each do |match| %>
    <% match.friendly = defined? friendly ? friendly : nil %>
    <tr>
      <% if defined? contest and contest %>
        <td>
          <%= namelink match.contest %>
        </td>
      <% end %>
      <td>
        <%= namelink (match.get_opponent.team) %>
      </td>
      <td>
        <%= shorttime match.match_time %>
      </td>
      <% unless defined? exclude_maps %>
        <td>
          <%= match.map1 %>, <%= match.map2 %>
        </td>
      <% end %>
      <td class="score">
        <%= link_to match, :class => "bold #{match.score_color}" do %>
          <% if match.friendly == match.contester1.team %>
            <%=h match.score1 %> - <%=h match.score2 %>
          <% else %>
            <%=h match.score2 %> - <%=h match.score1 %>
          <% end %>
        <% end %>
      </td>
      <% if match.contest.contest_type == Contest::TYPE_LADDER and !(max_columns < 4 if (defined? max_columns)) %>
        <td>
          <% if match.get_friendly(:points) > 0 %>
            <%= icon 'chevron-up' %>
          <% elsif match.get_friendly(:points) < 0 %>
            <%= icon 'chevron-down' %>
          <% end %>
          <%= match.get_friendly(:points) %>
        </td>
      <% end %>
    </tr>
  <% end %>
</table>