{% for t in tournaments %} {% set fallback_name = "Tournament #" ~ t.id %} {% set custom_name = (t.config or {}).get("name") %} {% set name = custom_name or fallback_name %} {% set show_id_badge = custom_name and custom_name != fallback_name %} {% set active_players = t.participants | selectattr("released_at", "none") | list | length %} {% set total_players = t.participants | length %} {% set completed_rounds = t.rounds | selectattr("status", "equalto", "completed") | list | length %} {% set scores = t.participants | sort(attribute="id") %} {{ name }} {% if show_id_badge %}#{{ t.id }}{% endif %}
{{ t.game_type }}
{% if t.status in ("pending", "active") and t.game_type == "el_farol" %} Watch live {% endif %} {% if t.status in ("pending", "active") and user and (user.is_admin or t.created_by == user.id) %} Cancel {% endif %} {% if t.status in ("pending", "active") %} {{ active_players }} / {{ t.num_players }} {% else %} {{ total_players }} / {{ t.num_players }} {% endif %} {% if completed_rounds > 0 %} {{ completed_rounds }} / {{ t.total_rounds }} {% else %} — / {{ t.total_rounds }} {% endif %} {% if scores | length == 2 %} {% set s0 = scores[0].total_score %} {% set s1 = scores[1].total_score %} {% if s0 is not none or s1 is not none %} {{ s0 if s0 is not none else "—" }} : {{ s1 if s1 is not none else "—" }} {% else %} — {% endif %} {% elif scores | length > 2 %} {% set best = scores | map(attribute="total_score") | reject("none") | sort(reverse=true) | first %} {% if best is defined %}{{ best }} (best){% else %}—{% endif %} {% else %} — {% endif %} {% if t.status == "completed" %} completed {% elif t.status == "active" %} active {% elif t.status == "pending" %} pending {% elif t.status == "cancelled" %} cancelled {% if t.cancelled_reason %}
{% if t.cancelled_reason.value == "pending_timeout" %}Expired before full roster {% elif t.cancelled_reason.value == "admin_action" %}Cancelled by admin {% elif t.cancelled_reason.value == "abandoned" %}All participants left {% endif %}
{% endif %} {% else %} {{ t.status }} {% endif %} {{ creators.get(t.created_by, "—") }} {{ t.created_at.strftime("%b %d, %H:%M") if t.created_at else "—" }} {% endfor %}