HUHUHUHUHU

This commit is contained in:
Peder Bergebakken Sundt 2019-10-15 21:20:37 +02:00
parent d86c7c8a81
commit c1701f2a10
6 changed files with 73 additions and 51 deletions

View File

@ -19,7 +19,7 @@ style: build/style.xsl
dev: dev:
git ls-files | entr bash -c "make style" git ls-files | entr bash -c "make style"
.PHONY: dev_all .PHONY: dev_cards
dev_cards: dev_cards:
git ls-files | entr bash -c "make cards" git ls-files | entr bash -c "make cards"
@ -45,6 +45,8 @@ with open(sys.argv[2], "w") as f:
e = Environment(trim_blocks=True, lstrip_blocks=True, loader=FileSystemLoader('')) e = Environment(trim_blocks=True, lstrip_blocks=True, loader=FileSystemLoader(''))
f.write(e.get_template("templates/card_header.html.j2").render(is_local=True, css_data=css_data)) f.write(e.get_template("templates/card_header.html.j2").render(is_local=True, css_data=css_data))
e.filters.update({ e.filters.update({
"is_number":lambda x: str(x).isnumeric(),
"is_string":lambda x: isinstance(x, str),
"markdown":markdown, "markdown":markdown,
"any":any, "any":any,
"all":all, "all":all,
@ -52,8 +54,7 @@ with open(sys.argv[2], "w") as f:
"startswith":str.startswith, "startswith":str.startswith,
"tail": lambda x: x[1:], "tail": lambda x: x[1:],
"cull_whitespace":(lambda x: " ".join(x.split())) }) "cull_whitespace":(lambda x: " ".join(x.split())) })
for filename in ([sys.argv[1]] if sys.argv[1] != "ALL" else sorted(glob.glob("cards/*.yaml") + glob.glob("cards/*.xml"))): for n, filename in enumerate([sys.argv[1]] if sys.argv[1] != "ALL" else sorted(glob.glob("cards/*.yaml") + glob.glob("cards/*.xml"))):
if sys.argv[1] == "ALL": f.write(f"\n\n<h1>{filename}</h1>\n")
with open(filename) as f2: with open(filename) as f2:
if filename.endswith("yaml"): if filename.endswith("yaml"):
yaml_data = yaml.load(f2.read()) yaml_data = yaml.load(f2.read())
@ -67,7 +68,10 @@ with open(sys.argv[2], "w") as f:
except Exception as ex: except Exception as ex:
data = f"<pre style=\"color:red;\">{ex}</pre>" data = f"<pre style=\"color:red;\">{ex}</pre>"
traceback.print_exc() traceback.print_exc()
f.write("\n" + data) if sys.argv[1] == "ALL":
f.write(f"\n\n<div id='card_container_{n}'>\n<h1>{filename}</h1>\n\n{data}\n</div>")
else:
f.write(f"\n<div id='card_container_{n}'>\n{data}\n</div>")
endef endef
export PYTHON_MAKE_JINJA2_RENDERED_CARD export PYTHON_MAKE_JINJA2_RENDERED_CARD

View File

@ -129,34 +129,7 @@
}) }} }) }}
{% endif %} {% endif %}
</figure> </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"> <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 [ {% for label, data in [
["Difficulty", xml.difficulty or yaml.difficulty], ["Difficulty", xml.difficulty or yaml.difficulty],
["Power", xml.power or yaml.power], ["Power", xml.power or yaml.power],
@ -171,15 +144,40 @@
</section> </section>
{% endif %} {% endif %}
{% endfor %} {% 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>
<div class="description"> <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 %} {% if yaml.flavor %}
<center><i>"{{ yaml.flavor }}"</i></center> <center><i>"{{ yaml.flavor }}"</i></center>
{% endif %} {% endif %}
{% if yaml.description %} {% if yaml.description %}
<center>{{ yaml.description | markdown | safe }}</center> <center>{{ yaml.description | markdown | safe }}</center>
{% elif xml.description %} {% endif %}
{% if xml.description %}
<center>{{ xml.description | markdown | safe }}</center> <center>{{ xml.description | markdown | safe }}</center>
{% endif %} {% endif %}

View File

@ -40,7 +40,16 @@ env.addFilter('startswith', function(string, match) {
return string.slice(0, match.length) === match; return string.slice(0, match.length) === match;
}); });
env.addFilter('tail', function(sequence) { env.addFilter('tail', function(sequence) {
return sequence.slice(1) return sequence.slice(1);
});
env.addFilter('split', function(string, delimiter) {
return string.split(delimiter);
});
env.addFilter('is_number', function(string) {
return !isNaN(string);
});
env.addFilter('is_string', function(string) {
return String(string) === string;
}); });
try { try {

View File

@ -1,5 +1,7 @@
.fjomp_card { .fjomp_card {
--figure-size: 0.9in; --figure-size: 0.9in;
--figure-size: 1.35in;
--figure-size: 1.5in;
width: 2.5in; width: 2.5in;
height: 3.5in; height: 3.5in;
box-sizing: border-box; box-sizing: border-box;
@ -14,13 +16,14 @@
font-family: sans-serif; font-family: sans-serif;
display: grid; display: grid;
grid-template-columns: auto 1fr 0.9in; grid-template-columns: auto 1fr;
grid-template-rows: 1.9em var(--figure-size) 2.1em auto; grid-template-rows: 1.9em var(--figure-size) 2.1em auto;
grid-template-areas: grid-template-areas:
"symbol title title" "symbol title"
"figure figure playcosts" "figure figure"
"costbar costbar costbar" "costbar costbar"
"description description description"; "description description";
header { header {
grid-area: title; grid-area: title;
font-size: 1.8em; font-size: 1.8em;
@ -134,14 +137,6 @@
.fjomp_card.item { .fjomp_card.item {
--figure-size: 1.35in;
--figure-size: 1.5in;
grid-template-columns: auto 1fr;
grid-template-areas:
"symbol title"
"figure figure"
"costbar costbar"
"description description";
.playcosts { .playcosts {
display: none; display: none;
} }

View File

@ -6,6 +6,25 @@
<meta http-equiv="refresh" content="1.0"> <meta http-equiv="refresh" content="1.0">
<script type="text/javascript" src="http://livejs.com/live.js"></script> <script type="text/javascript" src="http://livejs.com/live.js"></script>
#} #}
<script type="text/javascript">
var selected = 0;
document.onkeydown = function(e) {
if (e.which == 39) {
if (document.getElementById("card_container_" + (selected+1))) {
selected += 1;
}
document.getElementById("card_container_" + selected).scrollIntoView();
}
if (e.which == 37) {
if (selected > 0) {
selected -= 1;
}
document.getElementById("card_container_" + selected).scrollIntoView();
}
};
</script>
{% endif %} {% endif %}
<script type="text/javascript" src="https://cdnjs.cloudflare.com/ajax/libs/js-yaml/3.13.1/js-yaml.min.js"></script> <script type="text/javascript" src="https://cdnjs.cloudflare.com/ajax/libs/js-yaml/3.13.1/js-yaml.min.js"></script>

View File

@ -1,12 +1,9 @@
name: Hit enemy name: Hit enemy
symbol: defence symbol: defence
style: white item #style: item
tags: tags:
- combat - combat
costs: playcost:
- 2 ACT
- 1 COMBO
playcosts:
- 'Element: fire' - 'Element: fire'
- BODY+5 POWER - BODY+5 POWER
flavor: Enemies sure are squishy flavor: Enemies sure are squishy