{% extends "simpl/base.html" %}
{% load static %}
{% load i18n %}
{% load includecontents %}

{% block main_wrap_classes %}v-nav-page-layout{% endblock %}

{% block page_header %}
<header class="page-header">
  <div class="player-grid">
    <div class="player-col">
      <div class="page-header-flex-wrap h-pad">
        <h1 class="page-heading">Review Players</h1>
        {% includecontents "simpl/includes/search_form.html" with value=request.GET.q %}
        Filter players
        {% endincludecontents %}
      </div>
    </div>
  </div>

  {% include "simpl/includes/messages.html" %}
</header>
{% endblock page_header %}


{% block content_inner %}
<div class="player-grid">

  <div class="player-col">
    <div class="team-scroll is-taller">
      {% if not players and not inactive_players and not invites %}
      <p>No players found.</p>
      {% endif %}

      {% if run.status >= run.STATUS.PLAY %}

        {% if players %}
        <div class="player-header is-nested">
          <p class="walkthrough-chapter-heading">Active Players
            ({{ players|length }}{% if players|length != players_count %}/{{ players_count }}{% endif %})</p>
        </div>
        {% endif %}

        {% if run.multiplayer %}
          {% for team, team_players in teams.items %}
            <div class="card player-card glow-shadow team-card">
              <div class="player-item is-header">
                <h2 class="player-card-heading">
                  {{ team }}
                </h2>
              </div>
              {% for player in team_players %}
                {% include "simpl/includes/players_list/multiplayer_in_play.html" %}
              {% endfor %}
            </div>
          {% endfor %}
        {% else %}{% comment %} Single player {% endcomment %}
          <div class="card player-card glow-shadow team-card">
            {% for player in players %}
                {% include "simpl/includes/players_list/singleplayer_in_play.html" %}
            {% endfor %}
          </div>
        {% endif %}

      {% else %}{% comment %} Setup {% endcomment %}
        {% if players %}
        <div class="player-header is-nested">
          <p class="walkthrough-chapter-heading">Ready to Play
          ({{ players|length }}{% if players|length != players_count %}/{{ players_count }}{% endif %})</p>
        </div>
        {% endif %}

        {% if run.multiplayer %}
          {% for team, team_players in teams.items %}
            <div class="card player-card glow-shadow team-card">
              <div class="player-item is-header">
                <h2 class="player-card-heading">
                  {{ team }}
                </h2>
              </div>
              {% for player in team_players %}
                {% include "simpl/includes/players_list/active_player_in_setup.html" %}
              {% endfor %}
            </div>
          {% endfor %}
        {% else %}{% comment %} Single player {% endcomment %}
          <div class="card player-card glow-shadow team-card">
            {% for player in players %}
              {% include "simpl/includes/players_list/active_player_in_setup.html" %}
            {% endfor %}
          </div>
        {% endif %}

      {% endif %}

      {% if inactive_players %}
      <div class="player-header is-nested">
        <p class="walkthrough-chapter-heading">Inactive Players
        ({{ inactive_players|length }}{% if inactive_players|length != inactive_count %}/{{ inactive_count }}{% endif %})</p>
      </div>
      <div class="card player-card team-card is-inactive-player">
        {% for player in inactive_players %}
          {% include "simpl/includes/players_list/inactive_player.html" %}
        {% endfor %}
      </div>
      {% endif %}{% comment %} Inactive {% endcomment %}

      {% if invites %}
      <div class="player-header is-nested">
        <p class="walkthrough-chapter-heading">Invites Sent
        ({{ invites|length }}{% if invites|length != invites_count %}/{{ invites_count }}{% endif %})</p>
      </div>
      <div class="card player-card glow-shadow team-card is-inactive-player">
        {% for player in invites %}
          {% include "simpl/includes/players_list/invite.html" %}
        {% endfor %}
      </div>
      {% endif %}{% comment %} Invites {% endcomment %}
    </div>

  </div>

  <div class="player-col">
    {% include "simpl/includes/players_list/instructions.html" %}
  </div>

</div>
{% endblock %}
