{% extends "mahjong_ranking/page.html" %}
{% load i18n comments humanize thumbnail %}

{% block title %}Mahjong Ladder - {{ season }}{% endblock %}

{% block teaser %}
<h1>Mahjong Ladder - {{ season }}</h1>
<div id="teaser_text">
<ul class="info">
<li><span class="fa fa-calendar-o"></span> {% trans 'Start' %}: {{ season_start|date:'SHORT_DATE_FORMAT' }}</li>
<li><span class="fa fa-calendar-o"></span> {% trans 'End' %}: {{ season_end|date:'SHORT_DATE_FORMAT' }}</li>
<li><span class="fa fa-users"></span> {% trans 'Participants' %}: {{ seasonranking_list.count }}</li>
</ul>
</div>
{% endblock %}

{% block redbox %}{% include 'mahjong_ranking/ladder_redbox.html' %}{% endblock %}

{% block content %}
    <table>
        <thead>
        <tr>
            <th rowspan="2">{% trans "Rank" %}</th>
            <th rowspan="2">{% trans "Avatar" %}</th>
            <th rowspan="2">{% trans "Nickname" %}</th>
            <th rowspan="2">{% trans "Name" %}</th>
            <th colspan="2">{% trans 'Average' %}</th>
            <th colspan="3">Hanchans</th>
        </tr>
        <tr>
            <th>{% trans 'Placement' %}</th>
            <th>{% trans "Score" %}</th>
            <th>{% trans "count" %}</th>
            <th>{% trans "good" %}</th>
            <th>{% trans "won" %}</th>
        </tr>
        </thead>
        {% for player in seasonranking_list %}
        <tr>
            <td class="center">{{player.placement}}.</td>
            <td><a href="{{ player.get_absolute_url }}?season={{season}}"><img
                   src="{% thumbnail player.user.avatar|default:'unknown_profile.jpg' 'avatar' %}"
                   width="70" height="70" class="avatar" alt=""/></a></td>
            <td><a href="{{ player.get_absolute_url }}?season={{season}}">{{player.user}}</a></td>
            <td>{% if user.is_authenticated %}{{player.user.last_name}} {{player.user.first_name}}{% else %}---{% endif %}</td>
            <td class="center">{{player.avg_placement|floatformat:2 }}</td>
            <td class="right">{{player.avg_score|floatformat:0|intcomma }}</td>
            <td class="right">{{player.hanchan_count}}</td>
            <td class="right">{{player.good_hanchans}}</td>
            <td class="right">{{player.won_hanchans}}</td>
        </tr>
        {% empty %}
        <tr>
            <td colspan="9">Leider hat es noch niemand in das Ranking geschafft.
                Ein Spieler wird erst ins Ranking genommen wenn er 5 Hanchans absolviert hat.
            </td>
        </tr>
        {% endfor %}
    </table>
{% endblock %}