RPGs3_card_insanity/style.html.j2

193 lines
7.7 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="costbar">
{% 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 %}
{% for playcosts in [xml.playcost, yaml.playcost] %}
{% if playcosts %}
{% for playcost in (playcosts.split(",") if playcosts | is_string else playcosts ) %}
{% if playcost | trim | split(" ") | first | is_number %}
<section>
<big>{{ playcost | trim | split(" ") | first }}</big><br>
<small>{{ playcost | trim | split(" ") | tail | join(" ") }}</small>
</section>
{% endif %}
{% endfor %}
{% endif %}
{% endfor %}
</div>
<div class="description">
<ul>
{% for playcosts in [xml.playcost, yaml.playcost] %}
{% if playcosts %}
{% for playcost in (playcosts.split(",") if playcosts | is_string else playcosts ) %}
{% if not playcost | trim | split(" ") | first | is_number %}
<li>{{ playcost | trim }}</li>
{% endif %}
{% endfor %}
{% endif %}
{% endfor %}
</ul>
{% if yaml.flavor %}
<center><i>"{{ yaml.flavor }}"</i></center>
{% endif %}
{% if yaml.description %}
<center>{{ yaml.description | markdown | safe }}</center>
{% endif %}
{% if 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>