RPGs3_card_insanity/style.html.j2

195 lines
7.6 KiB
Django/Jinja

{% macro figure_layer(figure) %}
{% set figure_style %}{% filter cull_whitespace %}
{% if figure.opacity!=1 %}
opacity: {{ figure.opacity }};
{% endif %}
{% if figure.color!=1 %}
color: {{ figure.color }};
{% endif %}
transform:
{% if figure.offset and figure.offset|any %}
translate({{ figure.offset[0]*100 }}%, {{ figure.offset[1]*100 }}%)
{% endif %}
{% if figure.rotation %}
rotate({{ figure.rotation }}deg)
{% endif %}
{% if figure.flip_x %}
scaleX(-1)
{% endif %}
{% if figure.flip_y %}
scaleY(-1)
{% endif %}
{% if figure.scale and figure.scale!=1 %}
scale({{figure.scale | string | replace("[", "") | replace("]", "") }})
{% endif %}
;
{% endfilter %}{% endset %}
<div class="layer" style="{{ figure_style }}">
{% if figure.source == "material-icons" %}
{# https://material.io/icons/ #}
<i class="material-icons figure">{{ figure.name }}</i>
{% elif figure.source == "mdi" %}
{# https://materialdesignicons.com/ #}
<i class="mdi mdi-{{ figure.name }}"></i>
{% elif figure.source == "fa" %}
{# http://fontawesome.io/icons/ #}
<i class="fa fa-{{ figure.name }}"></i>
{% elif figure.source == "lnr" %}
{# https://linearicons.com/free #}
<span class="lnr lnr-{{ figure.name }}"></span>
{% elif figure.source == "oi" %}
{# https://useiconic.com/open #}
<span class="oi" data-glyph="{{ figure.name }}"></span>
{% elif figure.source == "svg" %}
{# pvv.ntnu.no/~pederbs/cards/svg #}
{% if figure.color == true %}
<img src="https://pvv.ntnu.no/~pederbs/cards/svg/data/{{ figure.name }}">
{% elif figure.color %}
<img src="https://pvv.ntnu.no/~pederbs/cards/svg/data/{{ figure.name }}" class="colored" style="--figure-color: {{ figure.color }}">
{% else %}
<img src="https://pvv.ntnu.no/~pederbs/cards/svg/data/{{ figure.name }}" class="colored">
{% endif %}
{% elif figure.source in ["img", "emoji"] %}
{# pvv.ntnu.no/~pederbs/cards/img #}
{# /cards/emoji #}
{% if figure.color == true %}
<img src="https://pvv.ntnu.no/~pederbs/cards/{{ figure.source }}/data/{{ figure.name }}" class="colored">
{% elif figure.color %}
<img src="https://pvv.ntnu.no/~pederbs/cards/{{ figure.source }}/data/{{ figure.name }}" class="colored" style="--figure-color: {{ figure.color }}">
{% else %}
<img src="https://pvv.ntnu.no/~pederbs/cards/{{ figure.source }}/data/{{ figure.name }}">
{% endif %}
{% elif figure.source == "url" %}
{% if figure.color == true %}
<img src="{{ figure.name }}" class="colored">
{% elif figure.color %}
<img src="{{ figure.name }}" class="colored" style="--figure-color: {{ figure.color }}">
{% else %}
<img src="{{ figure.name }}">
{% endif %}
{% endif %}
</div>
{% endmacro %}
{% macro named_symbol_to_emoji(name) %}
{% if "AIR" in name | upper %} 🌪
{% elif "ALCHEMY" in name | upper %} ⚗️
{% elif "ANIMAL" in name | upper %} 🐾
{% elif "COMBAT" in name | upper %} ⚔️
{% elif "CRAFTING" in name | upper %}
{% elif "DARK" in name | upper %} 💀
{% elif "DEFENCE" in name | upper %} 🛡
{% elif "EARTH" in name | upper %} 🌱
{% elif "FIRE" in name | upper %} 🔥
{% elif "HOLY" in name | upper %} ☀️
{% elif "INNATE" in name | upper %} 🧙
{% elif "MAGIC" in name | upper %} 🔮
{% elif "MARKSMANSHIP" in name | upper %} 🎯
{% elif "MARTIAL" in name | upper %} 🥊
{% elif "META" in name | upper %} 🧩
{% elif "PERFORMANCE" in name | upper %} 🎺
{% elif "SHAPESHIFTING" in name | upper %} 🐻
{% elif "SKULLDUGGERY" in name | upper %} ⚰️
{% elif "TECHNIQUE" in name | upper %} 🎲
{% elif "WATER" in name | upper %} 🌊
{% elif "WEAPONMASTER" in name | upper %} 🤺
{% else %} {{name}}
{% endif %}
{% endmacro %}
<div class="fjomp_card{{" " + yaml.style if yaml.style}}">
<header>
{{ yaml.name or xml.name }}
</header>
{% if yaml.symbol %}
<div class="symbol">
{% if " " in yaml.symbol %}
{% for symbol in yaml.symbol | split(" ") %}
{{ named_symbol_to_emoji(symbol) }}
{% endfor %}
{% else %}
{{ named_symbol_to_emoji(yaml.symbol) }}
{% endif %}
</div>
{% elif xml.symbol %}
<div class="symbol">
{{ xml.symbol }}
</div>
{% endif %}
<figure>
{% for figure in yaml.figures %}
{{ figure_layer(figure) }}
{% endfor %}
{% if xml.image %}
{{ figure_layer({
'name': xml.image if xml.image | startswith("http") else xml.image | split(":") | tail | join(":"),
'source': "url" if xml.image | startswith("http") else xml.image | split(":") | first
}) }}
{% endif %}
</figure>
<div class="playcosts">
<ul>
{% if xml.playcost %}
{% for playcost in xml.playcost.split(",") %}
<li>{{ playcost }}</li>
{% endfor %}
{% endif %}
{% if yaml.playcost %}
{% for playcost in yaml.playcost.split(",") %}
<li>{{ playcost }}</li>
{% endfor %}
{% endif %}
{% for playcost in yaml.playcosts %}
<li>{{ playcost }}</li>
{% endfor %}
</ul>
</div>
<div class="costbar">
{% for cost in yaml.costs %}
<section>
{% if cost.split(" ") | length == 2 and cost.split(" ")[0] | int(-1) != -1 %}
<big>{{ cost.split(" ")[0] }}</big><br>
<small>{{ cost.split(" ")[1] }}</small>
{% else %}
{{ cost }}
{% endif %}
</section>
{% endfor %}
{% for label, data in [
["Difficulty", xml.difficulty or yaml.difficulty],
["Power", xml.power or yaml.power],
["Range", xml.range or yaml.range],
["Duration", xml.duration or yaml.duration],
["CP", xml.cp or yaml.cp]
] %}
{% if data %}
<section>
<big>{{ data }}</big><br>
<small>{{ label }}</small>
</section>
{% endif %}
{% endfor %}
</div>
<div class="description">
{% if yaml.flavor %}
<center><i>"{{ yaml.flavor }}"</i></center>
{% endif %}
{% if yaml.description %}
<center>{{ yaml.description | markdown | safe }}</center>
{% elif xml.description %}
<center>{{ xml.description | markdown | safe }}</center>
{% endif %}
{% if yaml.steps %}
<ul>
{% for step in yaml.steps %}
<li>{{ step }}</li>
{% endfor %}
</ul>
{% endif %}
</div>
</div>