diff options
| author | Florian Fischer <florian.fl.fischer@fau.de> | 2020-09-16 14:35:21 +0200 |
|---|---|---|
| committer | Florian Fischer <florian.fl.fischer@fau.de> | 2020-10-18 14:28:12 +0200 |
| commit | 9394103e42aec8d8348ad0c19e70c0fd635d3e3c (patch) | |
| tree | ad942f8c668506746be03348e61332fd3473c76a | |
| parent | bfc1b8d83b4a3a9e1e8925d4144d2baad7dd2c98 (diff) | |
| download | muhqs-game-9394103e42aec8d8348ad0c19e70c0fd635d3e3c.tar.gz muhqs-game-9394103e42aec8d8348ad0c19e70c0fd635d3e3c.zip | |
improve how card content is drawn
* Card content is always bottom aligned at \contentBottom
* Only use one node instead of two to draw \splitcontent
* Draw content background relative to the content size
* Remove now obsolete \contentsplit variants
| -rw-r--r-- | latex/cards/armor.tex | 3 | ||||
| -rw-r--r-- | latex/cards/cloak.tex | 3 | ||||
| -rw-r--r-- | latex/cards/gear.tex | 3 | ||||
| -rw-r--r-- | latex/cards/mace.tex | 3 | ||||
| -rw-r--r-- | latex/cards/missionary.tex | 2 | ||||
| -rw-r--r-- | latex/cards/pioneer.tex | 2 | ||||
| -rw-r--r-- | latex/cards/plate_armor.tex | 3 | ||||
| -rw-r--r-- | latex/cards/poisoned_dagger.tex | 3 | ||||
| -rw-r--r-- | latex/cards/shield.tex | 3 | ||||
| -rw-r--r-- | latex/cards/smith.tex | 2 | ||||
| -rw-r--r-- | latex/cards/spear.tex | 3 | ||||
| -rw-r--r-- | latex/cards/sword.tex | 3 | ||||
| -rw-r--r-- | latex/cards/tax_collector.tex | 2 | ||||
| -rw-r--r-- | latex/cards/tower_shield.tex | 3 | ||||
| -rw-r--r-- | latex/libs.tex | 3 | ||||
| -rw-r--r-- | latex/tikzcards.tex | 80 | ||||
| -rwxr-xr-x | scripts/generate_latex.py | 16 |
17 files changed, 64 insertions, 73 deletions
diff --git a/latex/cards/armor.tex b/latex/cards/armor.tex index 6959e2dd..406482bc 100644 --- a/latex/cards/armor.tex +++ b/latex/cards/armor.tex @@ -12,9 +12,8 @@ \cardtypeEquipment \cardtitle{Armor} \cardbuycost{7} -\cardsplitcontentsingleline{Durability: 3}{Equipped unit gains + 1 Armor} +\cardsplitcontent{Durability: 3}{Equipped unit gains + 1 Armor} \cardplaycost{2} - \cardborder \end{tikzpicture} \end{document} diff --git a/latex/cards/cloak.tex b/latex/cards/cloak.tex index 1ccd3973..c2f4c633 100644 --- a/latex/cards/cloak.tex +++ b/latex/cards/cloak.tex @@ -12,9 +12,8 @@ \cardtypeEquipment \cardtitle{Cloak} \cardbuycost{3} -\cardsplitcontentsingleline{Durability: 2}{equiped unit gains shroud (can't be targeted)} +\cardsplitcontent{Durability: 2}{Equipped unit gains shroud (can't be targeted)} \cardplaycost{7} - \cardborder \end{tikzpicture} \end{document} diff --git a/latex/cards/gear.tex b/latex/cards/gear.tex index 0caff14a..d4863937 100644 --- a/latex/cards/gear.tex +++ b/latex/cards/gear.tex @@ -12,9 +12,8 @@ \cardtypeEquipment \cardtitle{Gear} \cardbuycost{2} -\cardsplitcontentsingleline{Durability: 3}{equipped unit gain +1 movement} +\cardsplitcontent{Durability: 3}{Equipped unit gain +1 movement} \cardplaycost{3} - \cardborder \end{tikzpicture} \end{document} diff --git a/latex/cards/mace.tex b/latex/cards/mace.tex index 1bcb0ab0..bacbddec 100644 --- a/latex/cards/mace.tex +++ b/latex/cards/mace.tex @@ -12,9 +12,8 @@ \cardtypeEquipment \cardtitle{Mace} \cardbuycost{2} -\cardsplitcontentsingleline{Durability: 3}{equipped unit afflicts Paralysis when dealing damage in melee combat} +\cardsplitcontent{Durability: 3}{Equipped unit afflicts Paralysis when dealing damage in melee combat} \cardplaycost{6} - \cardborder \end{tikzpicture} \end{document} diff --git a/latex/cards/missionary.tex b/latex/cards/missionary.tex index 2f2ae456..36de2825 100644 --- a/latex/cards/missionary.tex +++ b/latex/cards/missionary.tex @@ -12,7 +12,7 @@ \cardtypeUnit \cardtitle{Missionary} \cardbuycost{10} -\cardsplitcontenttwolines{Health: 1\\ Movement: 2}{\faRedo: put two faith counters on target Unit. If there are more faith counters than the units buying cost you control target unit.} +\cardsplitcontent{Health: 1\\ Movement: 2}{\faRedo: Put two faith counters on target Unit. If there are more faith counters than the units buying cost you control target unit.} \cardplaycost{2} \cardborder \end{tikzpicture} diff --git a/latex/cards/pioneer.tex b/latex/cards/pioneer.tex index 3e20ddaf..6c95277b 100644 --- a/latex/cards/pioneer.tex +++ b/latex/cards/pioneer.tex @@ -12,7 +12,7 @@ \cardtypeUnit \cardtitle{Pioneer} \cardbuycost{7} -\cardsplitcontenttwolines{Health: 5\\ Movement: 1}{\faRedo: Neutralize adjacent tile} +\cardsplitcontent{Health: 5\\ Movement: 1}{\faRedo: Neutralize adjacent tile} \cardplaycost{1} \cardborder \end{tikzpicture} diff --git a/latex/cards/plate_armor.tex b/latex/cards/plate_armor.tex index fcea7e39..070be2b7 100644 --- a/latex/cards/plate_armor.tex +++ b/latex/cards/plate_armor.tex @@ -12,9 +12,8 @@ \cardtypeEquipment \cardtitle{Plate Armor} \cardbuycost{8} -\cardsplitcontentsingleline{Durability: 1}{equiped unit has +2 Armor and can't move} +\cardsplitcontent{Durability: 1}{Equipped unit has +2 Armor and can't move} \cardplaycost{3} - \cardborder \end{tikzpicture} \end{document} diff --git a/latex/cards/poisoned_dagger.tex b/latex/cards/poisoned_dagger.tex index d4939924..fc3066ba 100644 --- a/latex/cards/poisoned_dagger.tex +++ b/latex/cards/poisoned_dagger.tex @@ -12,9 +12,8 @@ \cardtypeEquipment \cardtitle{Poisoned Dagger} \cardbuycost{3} -\cardsplitcontentsingleline{Durability: 2}{equipped unit deals damage as poison counters in melee combat} +\cardsplitcontent{Durability: 2}{Equipped unit deals damage as poison counters in melee combat} \cardplaycost{7} - \cardborder \end{tikzpicture} \end{document} diff --git a/latex/cards/shield.tex b/latex/cards/shield.tex index b5843f3b..19377742 100644 --- a/latex/cards/shield.tex +++ b/latex/cards/shield.tex @@ -12,9 +12,8 @@ \cardtypeEquipment \cardtitle{Shield} \cardbuycost{5} -\cardsplitcontentsingleline{Durability: 3}{equipped unit gains +1 Health} +\cardsplitcontent{Durability: 3}{Equipped unit gains +1 Health} \cardplaycost{1} - \cardborder \end{tikzpicture} \end{document} diff --git a/latex/cards/smith.tex b/latex/cards/smith.tex index 103503b0..78fda7da 100644 --- a/latex/cards/smith.tex +++ b/latex/cards/smith.tex @@ -12,7 +12,7 @@ \cardtypeUnit \cardtitle{Smith} \cardbuycost{10} -\cardsplitcontenttwolines{Health: 1\\ Movement: 1}{\faRedo: Pay X: Create Copy of artifact with buy cost = X in range 1 on empty tile in range 1} +\cardsplitcontent{Health: 1\\ Movement: 1}{\faRedo: Pay X: Create Copy of artifact with buy cost = X in range 1 on empty tile in range 1} \cardplaycost{2} \cardborder \end{tikzpicture} diff --git a/latex/cards/spear.tex b/latex/cards/spear.tex index f450af87..ba0f570e 100644 --- a/latex/cards/spear.tex +++ b/latex/cards/spear.tex @@ -12,9 +12,8 @@ \cardtypeEquipment \cardtitle{Spear} \cardbuycost{2} -\cardsplitcontentsingleline{Durability: 3}{Equipped unit gains +1 Attack and Range 2 against unit with M >= 3} +\cardsplitcontent{Durability: 3}{Equipped unit gains +1 Attack and Range 2 against unit with M >= 3} \cardplaycost{7} - \cardborder \end{tikzpicture} \end{document} diff --git a/latex/cards/sword.tex b/latex/cards/sword.tex index 5e61e8f5..acfb5dd7 100644 --- a/latex/cards/sword.tex +++ b/latex/cards/sword.tex @@ -12,9 +12,8 @@ \cardtypeEquipment \cardtitle{Sword} \cardbuycost{5} -\cardsplitcontentsingleline{Durability: 3}{equipped unit gains +1 Melee Damage} +\cardsplitcontent{Durability: 3}{Equipped unit gains +1 Melee Damage} \cardplaycost{2} - \cardborder \end{tikzpicture} \end{document} diff --git a/latex/cards/tax_collector.tex b/latex/cards/tax_collector.tex index 48e96290..8f104004 100644 --- a/latex/cards/tax_collector.tex +++ b/latex/cards/tax_collector.tex @@ -12,7 +12,7 @@ \cardtypeUnit \cardtitle{Tax Collector} \cardbuycost{5} -\cardsplitcontenttwolines{Health: 1\\ Movement: 2}{\faRedo: get 2 additional ressource} +\cardsplitcontent{Health: 1\\ Movement: 2}{\faRedo: Get 2 additional Ressource} \cardplaycost{1} \cardborder \end{tikzpicture} diff --git a/latex/cards/tower_shield.tex b/latex/cards/tower_shield.tex index 25c6ba79..e28cb91c 100644 --- a/latex/cards/tower_shield.tex +++ b/latex/cards/tower_shield.tex @@ -12,9 +12,8 @@ \cardtypeEquipment \cardtitle{Tower Shield} \cardbuycost{7} -\cardsplitcontentsingleline{Durability: 3}{Equipped unit has +2 Health} +\cardsplitcontent{Durability: 3}{Equipped unit has +2 Health} \cardplaycost{2} - \cardborder \end{tikzpicture} \end{document} diff --git a/latex/libs.tex b/latex/libs.tex index 93717882..96496f12 100644 --- a/latex/libs.tex +++ b/latex/libs.tex @@ -25,6 +25,9 @@ \usepackage{tikz} \usetikzlibrary{patterns} \usetikzlibrary{shadows} +\usetikzlibrary{fit, calc} % for getnodedim macro + +\usepackage{xparse} % for getnodedim macro \usepackage{amssymb} % Rsh diff --git a/latex/tikzcards.tex b/latex/tikzcards.tex index 3890de4b..e6389f75 100644 --- a/latex/tikzcards.tex +++ b/latex/tikzcards.tex @@ -10,6 +10,9 @@ \pgfmathsetmacro{\strippadding}{0.2} \pgfmathsetmacro{\textpadding}{0.1} \pgfmathsetmacro{\titley}{\cardheight-\strippadding-1.5*\textpadding-0.5*\stripwidth} +\pgfmathsetmacro{\contentTextWidth}{(\cardwidth-2*\strippadding-\stripwidth-2*\textpadding-0.3)*1cm} +\pgfmathsetmacro{\contentLeft}{2*\strippadding + \stripwidth + \textpadding} +\pgfmathsetmacro{\contentBottom}{1 + \textpadding} % Formen der einzelnen Kartenelemente/-bestandteile @@ -19,9 +22,22 @@ \def\shapeRightStripShortHigh{(\cardwidth-\stripwidth-\strippadding,\cardheight-\strippadding-1) rectangle (\cardwidth-\strippadding,\cardheight+0.2)} \def\shapeRightStripShortLow{(\cardwidth-\stripwidth-\strippadding,-0.2) rectangle (\cardwidth-\strippadding,1)} \def\shapeTitleArea{(2*\strippadding+\stripwidth,\cardheight-\strippadding) rectangle (\cardwidth-2*\strippadding-\stripwidth,\cardheight-2*\stripwidth)} -\def\shapeContentArea{(2*\strippadding+\stripwidth,0.5*\cardheight) rectangle (\cardwidth+0.2,-0.2)} +% macro to get the height of an node +% https://tex.stackexchange.com/questions/554237/how-can-i-get-the-height-of-a-tikz-node-and-store-it-in-a-length +\makeatletter % allow use of @ +\NewDocumentCommand {\getnodedimen} {O{\nodewidth} O{\nodeheight} m} { + \begin{pgfinterruptboundingbox} + \begin{scope}[local bounding box=bb@temp] + \node[inner sep=0pt, fit=(#3)] {}; + \end{scope} + \path ($(bb@temp.north east)-(bb@temp.south west)$); + \end{pgfinterruptboundingbox} + \pgfgetlastxy{#1}{#2} +} +\makeatother % end use of @ + % Stylings für die Elemente definieren \tikzset{ % runde Ecken für die Karten @@ -96,47 +112,25 @@ % Inhalt der Karte \newcommand{\cardsplitcontent}[2]{ - \begin{scope}[even odd rule] - \clip[cardcorners] \shapeCard; - \fill[elementcorners,contentbg] \shapeContentArea; - \end{scope} - % \node[draw, below right, text width=(\cardwidth-2*\strippadding-\stripwidth-2*\textpadding-0.3)*1cm] at (2*\strippadding+\stripwidth+\textpadding, 0.5*\cardheight-\textpadding + \heightof{)#1}) { - \node[below right, text width=(\cardwidth-2*\strippadding-\stripwidth-2*\textpadding-0.3)*1cm] at (2*\strippadding+\stripwidth+\textpadding, 0.5*\cardheight-\textpadding + 0.8) { - \textit{\normalsize #1} - }; - \node[below right, text width=(\cardwidth-2*\strippadding-\stripwidth-2*\textpadding-0.3)*1cm] at (2*\strippadding+\stripwidth+\textpadding, 0.5*\cardheight - 0.8) { - \vrule width \textwidth height 2pt \\[-2pt] - \vspace{0.2cm} - {\normalsize #2} - }; -} + % \begin{scope}[even odd rule] + % \clip[cardcorners] \shapeCard; + % \end{scope} -\newcommand{\cardsplitcontentsingleline}[2]{ - \begin{scope}[even odd rule] - \clip[cardcorners] \shapeCard; - \fill[elementcorners,contentbg] \shapeContentArea; - \end{scope} - % \node[draw, below right, text width=(\cardwidth-2*\strippadding-\stripwidth-2*\textpadding-0.3)*1cm] at (2*\strippadding+\stripwidth+\textpadding, 0.5*\cardheight-\textpadding + \heightof{)#1}) { - \node[below right, text width=(\cardwidth-2*\strippadding-\stripwidth-2*\textpadding-0.3)*1cm] at (2*\strippadding+\stripwidth+\textpadding, 0.5*\cardheight-\textpadding) { + % draw content node just to get its dimensions + \node(content)[above right, minimum width=\cardwidth, text width=\contentTextWidth] at (\contentLeft, \contentBottom) { \textit{\normalsize #1} - }; - \node[below right, text width=(\cardwidth-2*\strippadding-\stripwidth-2*\textpadding-0.3)*1cm] at (2*\strippadding+\stripwidth+\textpadding, 0.5*\cardheight - 0.8) { \vrule width \textwidth height 2pt \\[-2pt] \vspace{0.2cm} {\normalsize #2} }; -} -\newcommand{\cardsplitcontenttwolines}[2]{ - \begin{scope}[even odd rule] - \clip[cardcorners] \shapeCard; - \fill[elementcorners,contentbg] \shapeContentArea; - \end{scope} - % \node[draw, below right, text width=(\cardwidth-2*\strippadding-\stripwidth-2*\textpadding-0.3)*1cm] at (2*\strippadding+\stripwidth+\textpadding, 0.5*\cardheight-\textpadding + \heightof{)#1}) { - \node[below right, text width=(\cardwidth-2*\strippadding-\stripwidth-2*\textpadding-0.3)*1cm] at (2*\strippadding+\stripwidth+\textpadding, 0.5*\cardheight-\textpadding + 0.4) { + % draw content background using dimensions of the content node + \getnodedimen{content} + \node[fill=contentbg, above right, elementcorners, minimum height=\nodeheight, minimum width=\nodewidth + 1] at (\contentLeft - \textpadding, \contentBottom) {}; + + % redraw content so it is on top of the background + \node()[above right, minimum width=\cardwidth, text width=\contentTextWidth] at (\contentLeft, \contentBottom) { \textit{\normalsize #1} - }; - \node[below right, text width=(\cardwidth-2*\strippadding-\stripwidth-2*\textpadding-0.3)*1cm] at (2*\strippadding+\stripwidth+\textpadding, 0.5*\cardheight - 0.8) { \vrule width \textwidth height 2pt \\[-2pt] \vspace{0.2cm} {\normalsize #2} @@ -145,11 +139,19 @@ % Inhalt der Karte \newcommand{\cardcontent}[1]{ - \begin{scope}[even odd rule] - \clip[cardcorners] \shapeCard; - \fill[elementcorners,contentbg] \shapeContentArea; - \end{scope} - \node[below right, text width=(\cardwidth-2*\strippadding-\stripwidth-2*\textpadding-0.3)*1cm] at (2*\strippadding+\stripwidth+\textpadding, 3) { + % \begin{scope}[even odd rule] + % \clip[cardcorners] \shapeCard; + % \end{scope} + \node(content)[above right, text width=\contentTextWidth] at (\contentLeft, \contentBottom) { + \textit{\normalsize #1} + }; + + % draw content background using dimensions of the content node + \getnodedimen{content} + \node[fill=contentbg, above right, elementcorners, minimum height=\nodeheight, minimum width=\nodewidth + 1] at (\contentLeft - \textpadding, \contentBottom) {}; + + % redraw content so it is on top of the background + \node[above right, text width=\contentTextWidth] at (\contentLeft, \contentBottom) { \textit{\normalsize #1} }; } diff --git a/scripts/generate_latex.py b/scripts/generate_latex.py index 6b35d8fc..c8407eca 100755 --- a/scripts/generate_latex.py +++ b/scripts/generate_latex.py @@ -76,7 +76,7 @@ def generate_card(card_name: str, card: MutableMapping): movement = card['movement'] # stats = f'\\faHeart: {health}\\\\ \\faShoePrints: {movement}' - stats = [f'Health: {health}', f'Movement: {movement}'] + stats = f'Health: {health}\\\\ Movement: {movement}' attack = card.get('attack', None) if attack: @@ -84,9 +84,8 @@ def generate_card(card_name: str, card: MutableMapping): if "Range" in attack: attack_sym = '\\ding{246}' # stats += f'\\\\ {attack_sym}: {attack}' - stats.append(f'Attack: {attack}') + stats += f'\\\\ Attack: {attack}' - stats_str = '\\\\ '.join(stats) if 'effect' in card or 'full_action' in card: ability_block = "" @@ -100,12 +99,9 @@ def generate_card(card_name: str, card: MutableMapping): ability_block += '\\\\ ' ability_block += f'\\faRotateRight: {full_action}' - if len(stats) == 2: - card_content += f'\cardsplitcontenttwolines{{{stats_str}}}{{{ability_block}}}' - else: - card_content += f'\cardsplitcontent{{{stats_str}}}{{{ability_block}}}' + card_content += f'\cardsplitcontent{{{stats}}}{{{ability_block}}}' else: - card_content += f'\cardcontent{{{stats_str}}}' + card_content += f'\cardcontent{{{stats}}}' card_content += '\n' @@ -121,8 +117,8 @@ def generate_card(card_name: str, card: MutableMapping): elif card['type'] == 'equipment': # card_content += f'\cardsplitcontent{{\\faRecycle: {card["durability"]}}}{{{card["effect"]}}}' - card_content += f'\cardsplitcontentsingleline{{Durability: {card["durability"]}}}{{{card["effect"]}}}\n' - card_content += f'\cardplaycost{{{card["play"]}}}\n' + card_content += f'\cardsplitcontent{{Durability: {card["durability"]}}}{{{card["effect"]}}}\n' + card_content += f'\cardplaycost{{{card["play"]}}}' else: print('WARNING: unknown card type {card["type"]}!') |
