{% extends 'trosnoth/base.html' %}
{% block head %}
  <title>{{ settings.serverName }} :: {{ tournament.name }}</title>
{% endblock %}

{% block main %}
  <div id="container">
    <h1><a href="/">{{ settings.serverName }}</a></h1>
    <h2>{{ tournament.name }}</h2>
    <h3>Tournament Match Standings</h3>
    {% if mainStandings|length == 0 %}
      <p>No tournament matches have been played.</p>
    {% else %}
      <p class="shiftup explanatory-note">Loss=0–5 points, draw=10 points, win=15–20 points</p>
      <table class="standings">
        <tr>
          <th>Rank</th>
          <th>Player</th>
          <th>Score</th>
          <th>Won / Played</th>
        </tr>
        {% for row in mainStandings %}<tr>
          <td>{{ row.rank }}</td>
          <td>
            {% if row.user.nick %}
              <a href="{% url 'trosnoth:profile' userId=row.user.pk nick=row.user.nick %}">
              {{ row.nick }}</a>
            {% else %}
              {{ row.nick }}
            {% endif %}
          </td>
          <td>{{ row.score|stringformat:".1f" }}</td>
          <td>{{ row.winCount }} / {{ row.playCount }}</td>
        </tr>{% endfor %}
      </table>
    {% endif %}

    {% if hvmStandings %}
      <h3>Humans vs. Machines Standings</h3>
      <p class="shiftup explanatory-note">Loss=0–5 points, draw=10 points, win=15–20 points</p>
      <table class="standings">
        <tr>
          <th>Rank</th>
          <th>Team</th>
          <th>Score</th>
          <th>Won / Played</th>
        </tr>
        {% for row in hvmStandings %}<tr>
          <td>{{ row.rank }}</td>
          <td>{{ row.team }}</td>
          <td>{{ row.score|stringformat:".1f" }}</td>
          <td>{{ row.winCount }} / {{ row.playCount }}</td>
        </tr>{% endfor %}
      </table>
    {% endif %}

    {% if noveltyStandings %}
      <h3>Novelty Game Standings</h3>
      <p class="shiftup explanatory-note">First place=1 point, other=0 points</p>
      <table class="standings">
        <tr>
          <th>Rank</th>
          <th>Player</th>
          <th>Score</th>
          <th>Best Setting</th>
        </tr>
        {% for row in noveltyStandings %}<tr>
          <td>{{ row.rank }}</td>
          <td>
            {% if row.user.nick %}
              <a href="{% url 'trosnoth:profile' userId=row.user.pk nick=row.user.nick %}">
              {{ row.nick }}</a>
            {% else %}
              {{ row.nick }}
            {% endif %}
          </td>
          <td>{{ row.score|floatformat }}</td>
          <td>{{ row.bestScenario }}</td>
        </tr>{% endfor %}
      </table>
    {% endif %}

    <h3>Game by Game</h3>
    {% if gameByGame|length == 0 %}
      <p>No matches have been played.</p>
    {% else %}
      {% for row in gameByGame %}
        <a href="{% url 'trosnoth:viewgame' gameId=row.game.pk %}">
          #{{ row.game.pk }}: {{ row.game.scenario|default:"Game" }}</a>:
        {{ row.description }}<br>
      {% endfor %}
    {% endif %}
  </div>
{% endblock %}
