WebHost/Factorio: use "better" jinja practices in web tracker (#2257)
This commit is contained in:
parent
c3c6a7eb86
commit
5591879547
|
@ -1,46 +1,42 @@
|
|||
{% extends "multiTracker.html" %}
|
||||
{% block custom_table_headers %}
|
||||
{# establish the to be tracked data. Display Name, factorio/AP internal name, display image #}
|
||||
{%- set science_packs = [
|
||||
("Logistic Science Pack", "logistic-science-pack",
|
||||
"https://wiki.factorio.com/images/thumb/Logistic_science_pack.png/32px-Logistic_science_pack.png"),
|
||||
("Military Science Pack", "military-science-pack",
|
||||
"https://wiki.factorio.com/images/thumb/Military_science_pack.png/32px-Military_science_pack.png"),
|
||||
("Chemical Science Pack", "chemical-science-pack",
|
||||
"https://wiki.factorio.com/images/thumb/Chemical_science_pack.png/32px-Chemical_science_pack.png"),
|
||||
("Production Science Pack", "production-science-pack",
|
||||
"https://wiki.factorio.com/images/thumb/Production_science_pack.png/32px-Production_science_pack.png"),
|
||||
("Utility Science Pack", "utility-science-pack",
|
||||
"https://wiki.factorio.com/images/thumb/Utility_science_pack.png/32px-Utility_science_pack.png"),
|
||||
("Space Science Pack", "space-science-pack",
|
||||
"https://wiki.factorio.com/images/thumb/Space_science_pack.png/32px-Space_science_pack.png"),
|
||||
] -%}
|
||||
{%- block custom_table_headers %}
|
||||
{#- macro that creates a table header with display name and image -#}
|
||||
{%- macro make_header(name, img_src) %}
|
||||
<th class="center-column">
|
||||
<img src="https://wiki.factorio.com/images/thumb/Logistic_science_pack.png/32px-Logistic_science_pack.png"
|
||||
alt="Logistic Science Pack">
|
||||
</th>
|
||||
<th class="center-column">
|
||||
<img src="https://wiki.factorio.com/images/thumb/Military_science_pack.png/32px-Military_science_pack.png"
|
||||
alt="Military Science Pack">
|
||||
</th>
|
||||
<th class="center-column">
|
||||
<img src="https://wiki.factorio.com/images/thumb/Chemical_science_pack.png/32px-Chemical_science_pack.png"
|
||||
alt="Chemical Science Pack">
|
||||
</th>
|
||||
<th class="center-column">
|
||||
<img src="https://wiki.factorio.com/images/thumb/Production_science_pack.png/32px-Production_science_pack.png"
|
||||
alt="Production Science Pack">
|
||||
</th>
|
||||
<th class="center-column">
|
||||
<img src="https://wiki.factorio.com/images/thumb/Utility_science_pack.png/32px-Utility_science_pack.png"
|
||||
alt="Utility Science Pack">
|
||||
</th>
|
||||
<th class="center-column">
|
||||
<img src="https://wiki.factorio.com/images/thumb/Space_science_pack.png/32px-Space_science_pack.png"
|
||||
alt="Space Science Pack">
|
||||
<img src="{{ img_src}}"
|
||||
alt="{{ name }}">
|
||||
</th>
|
||||
{% endmacro -%}
|
||||
{#- call the macro to build the table header -#}
|
||||
{%- for name, internal_name, img_src in science_packs %}
|
||||
{{ make_header(name, img_src) }}
|
||||
{% endfor -%}
|
||||
{% endblock %}
|
||||
{% block custom_table_row scoped %}
|
||||
{% if games[player] == "Factorio" %}
|
||||
{% set player_inventory = named_inventory[team][player] %}
|
||||
{% set prog_science = player_inventory["progressive-science-pack"] %}
|
||||
<td class="center-column">{% if player_inventory["logistic-science-pack"] or prog_science %}✔{% endif %}</td>
|
||||
<td class="center-column">{% if player_inventory["military-science-pack"] or prog_science > 1%}✔{% endif %}</td>
|
||||
<td class="center-column">{% if player_inventory["chemical-science-pack"] or prog_science > 2%}✔{% endif %}</td>
|
||||
<td class="center-column">{% if player_inventory["production-science-pack"] or prog_science > 3%}✔{% endif %}</td>
|
||||
<td class="center-column">{% if player_inventory["utility-science-pack"] or prog_science > 4%}✔{% endif %}</td>
|
||||
<td class="center-column">{% if player_inventory["space-science-pack"] or prog_science > 5%}✔{% endif %}</td>
|
||||
{%- set player_inventory = named_inventory[team][player] -%}
|
||||
{%- set prog_science = player_inventory["progressive-science-pack"] -%}
|
||||
{%- for name, internal_name, img_src in science_packs %}
|
||||
<td class="center-column">{% if player_inventory[internal_name] or prog_science > loop.index0 %}✔{% endif %}</td>
|
||||
{% endfor -%}
|
||||
{% else %}
|
||||
<td class="center-column">❌</td>
|
||||
<td class="center-column">❌</td>
|
||||
<td class="center-column">❌</td>
|
||||
<td class="center-column">❌</td>
|
||||
<td class="center-column">❌</td>
|
||||
<td class="center-column">❌</td>
|
||||
{%- for _ in science_packs %}
|
||||
<td class="center-column">❌</td>
|
||||
{% endfor -%}
|
||||
{% endif %}
|
||||
{% endblock%}
|
||||
|
|
Loading…
Reference in New Issue