aboutsummaryrefslogtreecommitdiff
path: root/scripts
diff options
context:
space:
mode:
authorFlorian Fischer <florian.fl.fischer@fau.de>2021-03-01 11:19:34 +0100
committerFlorian Fischer <florian.fl.fischer@fau.de>2021-03-01 11:19:34 +0100
commit898ccaaf393ccd20f4b105ac59af74c35ea93bb2 (patch)
treea849ac451075b4ef93d1dfc2cab1720988366cfc /scripts
parent130c80b40454015e988de29f92eb020aa25fa91b (diff)
downloadmuhqs-game-898ccaaf393ccd20f4b105ac59af74c35ea93bb2.tar.gz
muhqs-game-898ccaaf393ccd20f4b105ac59af74c35ea93bb2.zip
[html] generate cards listing
Diffstat (limited to 'scripts')
-rwxr-xr-xscripts/generate_card.py27
1 files changed, 23 insertions, 4 deletions
diff --git a/scripts/generate_card.py b/scripts/generate_card.py
index c11c039b..9d5ac7c7 100755
--- a/scripts/generate_card.py
+++ b/scripts/generate_card.py
@@ -29,9 +29,9 @@ LATEX_ROOT = pathlib.Path(os.getcwd())
ASSETS_DIR = LATEX_ROOT / '../assets'
CARDS_DIR = LATEX_ROOT / 'cards'
-def file_for_card(card_name: str) -> pathlib.Path:
+def file_for_card(card_name: str, suffix = '.tex') -> pathlib.Path:
"""Return the corresponding latex file name for a card"""
- return pathlib.Path(f'{card_name.lower().replace(" ", "_")}.tex')
+ return pathlib.Path(f'{card_name.lower().replace(" ", "_")}{suffix}')
def get_latex_field(card: MutableMapping, field: str) -> str:
"""Return the latex_ prefixed field from card or the field itself"""
@@ -41,7 +41,22 @@ def get_latex_field(card: MutableMapping, field: str) -> str:
else:
return card[field]
-def generate_card(card: MutableMapping):
+def generate_markdown(card: MutableMapping, indentation=3):
+ """Output a markdown enumeration"""
+
+ formatted_keys = {'ai': 'AI', 'full_action': 'Full Action'}
+
+ print(f'{"#" * indentation} {card["name"]}')
+
+ built_card_path = f'cards/{card["set"]}/{file_for_card(card["name"], "")}'
+ print(f'\n[pdf]({built_card_path}.pdf) [png]({built_card_path}.png)\n')
+
+ for key in ['type', 'token', 'buy', 'upkeep', 'play', 'ai', 'health', 'movement', 'attack', 'full_action', 'effect']:
+ if key in card:
+ formatted_key = formatted_keys.get(key, key.capitalize())
+ print(f'* **{formatted_key}**: {card[key]}')
+
+def generate_latex(card: MutableMapping):
"""Generate a standalone tikz picture with the card data"""
card_content = ""
@@ -133,6 +148,7 @@ def main():
parser = argparse.ArgumentParser(description='generate latex standalone cards')
parser.add_argument('data', help='yaml file or directory containing yaml files defining the cards to generate')
parser.add_argument('--latex-root', help='path to the latex root directory')
+ parser.add_argument('--format', choices=['latex', 'markdown'], default='latex', help='output format')
args = parser.parse_args()
@@ -158,7 +174,10 @@ def main():
card = yaml.full_load(yaml_file)
card['set'] = card_set
- generate_card(card)
+ if args.format == 'latex':
+ generate_latex(card)
+ elif args.format == 'markdown':
+ generate_markdown(card)
if __name__ == '__main__':