From 401d9f47e5c67c5d99af572246753a4134441d37 Mon Sep 17 00:00:00 2001 From: Florian Fischer Date: Sun, 10 Oct 2021 14:47:20 +0200 Subject: [scripts/generate_card] support multiple full_actions --- scripts/generate_card.py | 47 +++++++++++++++++++++++++++++++++-------------- 1 file changed, 33 insertions(+), 14 deletions(-) (limited to 'scripts') diff --git a/scripts/generate_card.py b/scripts/generate_card.py index 69af713b..509cca25 100755 --- a/scripts/generate_card.py +++ b/scripts/generate_card.py @@ -110,6 +110,13 @@ def generate_markdown(card: MutableMapping, language='en', indentation=3): if key in card: formatted_key = get_formatted_key(key, language) value = get_field(card, key, language) + + if isinstance(value, list): + value_txt = '\n' + for v in value: + value_txt += f' * {v}\n' + value = value_txt[:-1] + print(f'* **{formatted_key}**: {value}') @@ -132,32 +139,44 @@ def generate_latex(card: MutableMapping, language='en'): card_content += f'\\cardbuycost{{{card["buy"]}}}\n' if card['type'] == 'unit': - stats = [] + unit_stats = [] abilities = [] for key in ['ai', 'health', 'movement', 'attack']: if key in card: formatted_key = get_formatted_key(key, language) value = get_field(card, key, language) - stats.append(f'{formatted_key}: {value}') + unit_stats.append(f'{formatted_key}: {value}') if 'effect' in card: effect, _ = get_latex_field(card, 'effect', language) abilities.append(effect) if 'full_action' in card: - full_action, is_latex = get_latex_field(card, 'full_action', - language) - if not is_latex: - full_action = f'\\faRedo: {full_action}' - - abilities.append(full_action) - - stats_str = '\\\\'.join(stats) + full_actions: Union[str, list[str]] = '' + full_action_txt = '' + full_actions, is_latex = get_latex_field(card, 'full_action', + language) + if not isinstance(full_actions, list): + full_actions = [full_actions] + + for full_action in full_actions: + assert full_action + if not is_latex: + full_action_txt += f'\\faRedo: {full_action}\\\\ ' + else: + full_action_txt += f'{full_action}' + + # strip last '\\ ' + if full_action_txt.endswith('\\\\ '): + full_action_txt = full_action_txt[:-3] + abilities.append(full_action_txt) + + unit_stats_str = '\\\\'.join(unit_stats) ability_block = '\\\\ \\vspace{0.2cm} '.join(abilities) - if stats and abilities: - card_content += f'\\cardsplitcontent{{{stats_str}}}{{{ability_block}}}' - elif stats: - card_content += f'\\cardcontent{{{stats_str}}}' + if unit_stats and abilities: + card_content += f'\\cardsplitcontent{{{unit_stats_str}}}{{{ability_block}}}' + elif unit_stats: + card_content += f'\\cardcontent{{{unit_stats_str}}}' card_content += '\n' -- cgit v1.2.3