aboutsummaryrefslogtreecommitdiff
path: root/scripts
diff options
context:
space:
mode:
authorFlorian Fischer <florian.fischer@muhq.space>2021-10-10 14:47:20 +0200
committerFlorian Fischer <florian.fischer@muhq.space>2021-10-10 14:47:20 +0200
commit401d9f47e5c67c5d99af572246753a4134441d37 (patch)
treeaa5129622f652d3bd4e5a452d0fc11c0d01a62e6 /scripts
parentfe676476c93d1cc2070364d5fddca7228553a499 (diff)
downloadmuhqs-game-401d9f47e5c67c5d99af572246753a4134441d37.tar.gz
muhqs-game-401d9f47e5c67c5d99af572246753a4134441d37.zip
[scripts/generate_card] support multiple full_actions
Diffstat (limited to 'scripts')
-rwxr-xr-xscripts/generate_card.py47
1 files changed, 33 insertions, 14 deletions
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'