Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Mar2024 improve template layout and style #385

Draft
wants to merge 2 commits into
base: main
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .vscode/settings.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,5 +12,5 @@
"[python]": {
"editor.defaultFormatter": "ms-python.black-formatter"
},
"conventionalCommits.scopes": ["changelog"]
"python.defaultInterpreterPath": "${workspaceFolder}/.venv/bin/python"
}
3 changes: 2 additions & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -45,8 +45,9 @@ script-nrb: TARGET:="No Roles Barred"
script-gmv: TARGET:="Grind My Viz"
script-cs: TARGET:="Clean Sweep"
script-jinx: TARGET="Let's Test Some Jinxes"
script-strings: TARGET="Strings Pulling"

script-tb script-nrb script-gmv script-cs script-jinx: poetry
script-tb script-nrb script-gmv script-cs script-jinx script-strings: poetry
$(MAKE_PDF) scripts/$(TARGET).json
ifeq ($(shell uname),Darwin)
@open -a Preview "pdfs/just-baked.pdf"
Expand Down
40 changes: 16 additions & 24 deletions botcpdf/role.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
""" Holds information about a BOTC role """

import re
from typing import Optional
from botcpdf.jinx import Jinx

Expand Down Expand Up @@ -53,34 +54,25 @@ def stylize(self, text: str) -> str:
if not self.stylized:
return text

# this looks weird to me, and as we fetch this data from the json
# we modify it here to suit our desired
text = text.replace(
# we need to match parts of strings that look like:
# - "[+1 Outsider]"
# - "[-2 Outsiders]"
# and wrap the matches in <strong>
match_re = r"(\[[+-\u2212]\d+ .+\])"
# replace ALL matches
text = re.sub(match_re, r"&nbsp;<strong>\1</strong>&nbsp;", text)

easy_replacements = [
"[Most players are Legion]",
"&nbsp;<strong>[Most players are Legion]</strong>",
)
text = text.replace(
"(Travellers don’t count)",
"&nbsp;<strong>[Travellers don’t count]</strong>",
)
text = text.replace(
"(not yourself)",
"&nbsp;<strong>[not yourself]</strong>",
)
text = text.replace(
"[1 Townsfolk is evil]",
"&nbsp;<strong>[1 Townsfolk is evil]</strong>",
)

# replace '[+N Outsider]' with '<strong>[+N Outsider]</strong>'
text = text.replace("[+", "&nbsp; <strong>[+")
# the next two likes look visually similar, but are different
# the json appears to have a unicode minus sign
text = text.replace("[-", "&nbsp; <strong>[-")
text = text.replace("[\u2212", "&nbsp; <strong>[-")

# and close
text = text.replace("]", "]</strong>")
"[You neighbour the Demon]",
]
for match_string in easy_replacements:
text = text.replace(
match_string, f"&nbsp;<strong>{match_string}</strong>&nbsp;"
)

return text

Expand Down
235 changes: 135 additions & 100 deletions data/imported/roles-combined.json

Large diffs are not rendered by default.

286 changes: 143 additions & 143 deletions poetry.lock

Large diffs are not rendered by default.

58 changes: 34 additions & 24 deletions templates/full-fat-night-order.jinja
Original file line number Diff line number Diff line change
Expand Up @@ -13,18 +13,23 @@
</header>

<!-- First Night Info -->
{%- for character in first_night %}
<div class="character-block character-block-nightinfo">
<img src="{{character.remote_image}}" alt="{{ character.name }}" class="character-icon-nightinfo"/>
<span class="character-name character-name-{{ character.team }}">{{ character.name }}</span>
<span class="character-ability-reminder">{{ character.ability }}</span>
<div class="character-reminder">{{ character.first_night_reminder }}</div>
</div>

{%- if not loop.last %}
<div class="line-nightinfo"></div>
{%- endif %}
{%- endfor %}
<div class="role-container">
{%- for role in first_night %}
<div class="night-role-block">
<img src="{{role.remote_image}}" alt="{{ role.name }}" class="role-icon-nightinfo"/>
<div class="night-role-info">
<div class="night-role-title-line">
<div class="role-name role-name-{{role.team}}">{{ role.name }}</div>
<div class="role-ability-reminder">{{ role.ability }}</div>
</div>
<div class="night-role-reminder">{{ role.first_night_reminder }}</div>
</div>
</div>
{%- if not loop.last %}
<div class="line-nightinfo"></div>
{%- endif %}
{%- endfor %}
</div>

{# if we have at most 15 items in first_night #}
{% if first_night|length <= 15 %}
Expand All @@ -46,18 +51,23 @@
</header>

<!-- Other Night Info -->
{%- for character in other_nights %}
<div class="character-block character-block-nightinfo">
<img src="{{character.remote_image}}" alt="{{ character.name }}" class="character-icon-nightinfo"/>
<span class="character-name character-name-{{ character.team }}">{{ character.name }}</span>
<span class="character-ability-reminder">{{ character.ability }}</span>
<div class="character-reminder">{{ character.other_night_reminder }}</div>
</div>

{%- if not loop.last %}
<div class="line-nightinfo"></div>
{%- endif %}
{%- endfor %}
<div class="role-container">
{%- for role in other_nights %}
<div class="night-role-block">
<img src="{{role.remote_image}}" alt="{{ role.name }}" class="role-icon-nightinfo"/>
<div class="night-role-info">
<div class="night-role-title-line">
<div class="role-name role-name-{{role.team}}">{{ role.name }}</div>
<div class="role-ability-reminder">{{ role.ability }}</div>
</div>
<div class="night-role-reminder">{{ role.other_night_reminder }}</div>
</div>
</div>
{%- if not loop.last %}
<div class="line-nightinfo"></div>
{%- endif %}
{%- endfor %}
</div>

{# if we have at most 15 items in other_nights #}
{% if other_nights|length <= 15 %}
Expand Down
28 changes: 12 additions & 16 deletions templates/player-reference.jinja
Original file line number Diff line number Diff line change
Expand Up @@ -15,24 +15,20 @@
{%- for type in characters %}
{%- set type_plural = type + 's' if type != 'townsfolk' else type %}

<h2 class="character-type character-type-{{type}}">{{ type_plural | upper }}</h2>
<div class="cols-2">
{%- for character in characters[type] %}
<div class="character-block character-block-player">
<img src="{{character.remote_image}}" alt="{{ character.name }}" class="character-icon"/>
<div class="character-name character-name-{{type}}">
{{ character.name }}
{%- if hatred[character.id_slug] %}
<div class="jinxes">
<span class="jinxes-label-text">JINXES</span>
{%- for hater in hatred[character.id_slug] %}
<img src="{{hater.remote_image}}" alt="{{ hater }}" class="hatred-icon"/>
{%- endfor %}
</div>
{%- endif %}
<h2 class="role-type role-type-{{type}}">{{ type_plural | upper }}</h2>
<div class="role-container">
{%- for role in characters[type] %}
<div class="role-block">
<img src="{{role.remote_image}}" alt="{{ role.name }}" class="role-icon" />
<div class="role-info">
<div class="role-name role-name-{{type}}">
{{ role.name }}
</div>
<div class="role-ability">
{{ role.ability }}
</div>
<div class="character-ability">{{ character.ability }}</div>
</div>
</div>
{%- endfor %}
</div>

Expand Down
6 changes: 3 additions & 3 deletions templates/script.jinja
Original file line number Diff line number Diff line change
Expand Up @@ -27,19 +27,19 @@
<div class="footer-right">
<a href="https://make.arcane-scripts.net">make.arcane-scripts.net</a>
(v{{ _project._version }})
{% include "options.jinja" %}
{%- include "options.jinja" %}
</div>
</footer>

{% include 'player-reference-easyloop.jinja' %}
{%- include 'player-reference-easyloop.jinja' %}

{%- if script_options.simple_night_order == True %}
{%- set night_include = "simple-night-order.jinja" -%}
{%- else -%}
{%- set night_include = "full-fat-night-order.jinja" -%}
{%- endif %}

{% include night_include %}
{%- include night_include %}



Expand Down
16 changes: 8 additions & 8 deletions templates/simple-night-order.jinja
Original file line number Diff line number Diff line change
@@ -1,20 +1,20 @@
<div class="full-page">
<div class="first-night">
<h2 class="simple-first-night">First Night</h2>
{%- for character in first_night %}
<div class="character-block character-block-nightinfo">
<img src="{{character.remote_image}}" alt="{{ character.name }}" class="character-icon-nightinfo"/>
<span class="character-name character-name-{{ character.team }}">{{ character.name }}</span>
{%- for role in first_night %}
<div class="role-block role-block-nightinfo">
<img src="{{role.remote_image}}" alt="{{ role.name }}" class="role-icon-nightinfo"/>
<span class="role-name role-name-{{ role.team }}">{{ role.name }}</span>
</div>
{%- endfor %}
</div>

<div class="other-nights">
<h2 class="simple-first-night">Other Nights</h2>
{%- for character in other_nights %}
<div class="character-block character-block-nightinfo">
<img src="{{character.remote_image}}" alt="{{ character.name }}" class="character-icon-nightinfo"/>
<span class="character-name character-name-{{ character.team }}">{{ character.name }}</span>
{%- for role in other_nights %}
<div class="role-block role-block-nightinfo">
<img src="{{role.remote_image}}" alt="{{ role.name }}" class="role-icon-nightinfo"/>
<span class="role-name role-name-{{ role.team }}">{{ role.name }}</span>
</div>
{%- endfor %}
</div>
Expand Down
Loading
Loading