# Making cards for Magic: The Gathering and similar card games

I'm creating cards for a card game. They will be similar to cards in Magic: The Gathering (left-hand image below). What I have is in the right-hand image below.

The problem is that the code doesn't generate the image in a modifiable/maintainable way, in the following respect. The image essentially consists of four juxtaposed blocks of varying shapes ('Fury', the white square, 'Persistent' and the final text square). There is then a red border (as it happens, with a drop shadow) drawn around these blocks and along the boundaries between them. At the moment I am manually specifying the path of the border.

Now, I want to be able to change the number and position of the various blocks (for different types of cards) and have the border automatically adapt. It seems that it might be possible to do this by taking the union of the blocks, and 'expanding' it a little to form a red object which sits behind the blocks. So something like a drop shadow operation, but more complex. (Then that red object would itself need a drop shadow.)

Is this feasible?

NB. Any other visual improvements would be gratefully received!

Edit: I've realised that drawing the 4 boxes with thick red lines at the borders might have the desired effect. Or more exactly, I need the following in order:

1. the drop shadows (thickened lines, black, translated) and (thickened lines, white, translated)
2. the border (thickened lines, red)
3. the original material.

A key problem is that applying 1,2,3 for the first block, then the second, etc. will fail -- all step 1s need to happen before all step 2s, and so on.

Is it possible to make a style that does this?

Code:

\documentclass[a4paper,11pt]{article}
\usepackage[T1]{fontenc}
\usepackage[margin=2mm]{geometry}
\usepackage{tikz,nopageno}
\usepackage{wasysym}
\usepackage{expl3}
\usepackage{ifthen}
\usepackage{etoolbox}
\usepackage{color}
\usepackage{blindtext}
%\usepackage{contour}

\usepackage{libertine}
\usepackage{multicol}

\ExplSyntaxOn
\cs_new_eq:NN \Repeat \prg_replicate:nn
\ExplSyntaxOff

%\renewcommand\Repeat[2]{#2}

\setlength\parskip{0mm}
\setlength\parindent{0mm}

\newcommand{\rounding}{3mm}
\newcommand{\cardheight}{88mm}
\newcommand{\cardwidth}{63mm}
\newcommand{\backgroundthickness}{5mm}
\newcommand{\framethickness}{0.6mm}
\newcommand{\attbartop}{42mm}
\newcommand{\attbarbottom}{35mm}
\newcommand{\topbarbottom}{76mm}

\begin{document}

\newcommand{\highlight}[2]{%
\begin{tikzpicture}[baseline = (text.base)]
\node[inner sep=0pt] (text) {#2};
\begin{pgfinterruptboundingbox}
\begin{pgfonlayer}{background}
\node[fit=(text), rounded corners, fill=#1, draw=none] {};
\end{pgfonlayer}
\end{pgfinterruptboundingbox}
\end{tikzpicture}%
}

\tikzset{path image/.style={
path picture={
\node at (path picture bounding box.center) {
\includegraphics[height=90mm]{#1}
};}}}

}}

\newcommand{\card}[7]{%
\begin{tikzpicture}
\fill[black,rounded corners=\rounding] (0,0) rectangle (\cardwidth,\cardheight);

%\draw[path image=texture_#1.png,rounded corners=1mm] (\rounding,\rounding) rectangle (\cardwidth-\rounding,\cardheight-\rounding);

\fill[#1!75!black, %Draw red frame
(\backgroundthickness,\backgroundthickness)
-- (\backgroundthickness,\attbarbottom)
to[bend left] (\backgroundthickness,\attbartop)
-- (\backgroundthickness,\topbarbottom)
to[bend left] (\backgroundthickness,\cardheight-\backgroundthickness)
-- (\cardwidth-\backgroundthickness,\cardheight-\backgroundthickness)
to[bend left] (\cardwidth-\backgroundthickness,\topbarbottom)
-- (\cardwidth-\backgroundthickness,\attbartop)
to[bend left] (\cardwidth-\backgroundthickness,\attbarbottom)
-- (\cardwidth-\backgroundthickness,\backgroundthickness)
-- cycle;

(\backgroundthickness+\framethickness,\backgroundthickness+\framethickness) rectangle
(\cardwidth-\backgroundthickness-\framethickness,\attbarbottom);

\draw[black,thick,fill=#1!40] %Draw center bar
(\backgroundthickness+\framethickness,\attbarbottom+\framethickness)
to[bend left] (\backgroundthickness+\framethickness,\attbartop-\framethickness)
-- (\cardwidth-\backgroundthickness-\framethickness,\attbartop-\framethickness)
to[bend left] (\cardwidth-\backgroundthickness-\framethickness,\attbarbottom+\framethickness)
-- cycle;

\draw[black,thick,fill=white] %Draw Image placeholder
(\backgroundthickness+\framethickness,\attbartop) rectangle
(\cardwidth-\backgroundthickness-\framethickness,\topbarbottom);

\draw[black,thick,fill=#1!40] %Draw top bar
(\backgroundthickness+\framethickness,\topbarbottom+\framethickness)
to[bend left] (\backgroundthickness+\framethickness,\cardheight-\backgroundthickness-\framethickness)
-- (\cardwidth-\backgroundthickness-\framethickness,\cardheight-\backgroundthickness-\framethickness)
to[bend left] (\cardwidth-\backgroundthickness-\framethickness,\topbarbottom+\framethickness)
-- cycle;

\node[anchor=south west] at (\backgroundthickness,\topbarbottom+1mm) {\raisebox{0pt}[\height][0pt]{\bf #2}};
\node[anchor=east] at (\cardwidth-\backgroundthickness-\framethickness+0.5mm,\topbarbottom+3.5mm) {\raisebox{0pt}[\height][0pt]{\bf #3}};
\node[anchor=south west] at (\backgroundthickness,\attbarbottom+1mm) {\raisebox{0pt}[\height][0pt]{#5}};

\node[anchor=north west,text width=\cardwidth-2*\backgroundthickness-2*\framethickness-2mm,font=\footnotesize] at (\backgroundthickness+\framethickness,\attbarbottom-0.5mm) {#6};

\node[anchor=south east,font=\tiny] at (\cardwidth-\backgroundthickness-\framethickness,\backgroundthickness+\framethickness) {\raisebox{0pt}[\height][0pt]{\bf Tier #7}};

\end{tikzpicture}}

\newcommand{\cost}[2]{%
\begin{tikzpicture}
\node[fill=#1!75!black,shape=circle,inner sep=0.3mm,draw=black,text=white,text width={}] (TEXT) {\raisebox{0pt}[\height][0pt]{\bf #2}};
\end{tikzpicture}}

\newcommand{\inlinecost}[2]{%
\begin{tikzpicture}[baseline={(TEXT.base)}]
\node[fill=#1!75!black,shape=circle,inner sep=0.3mm,draw=black,text=white,text width={}] (TEXT) {\raisebox{0pt}[\height][0pt]{\bf #2}};
\end{tikzpicture}}

\card{red}{Fury}{\cost{red}{1}}{}{Persistent}{You gain a \textbf{Bonus} of 1 to all melee attack rolls.\\\  \\Effect ends when a double is rolled on a melee attack.\\\  \\\textit{Bonuses do not stack.}}{1}

\end{document}


(I've commented out a line that uses a red texture, but just in case: it's here and must be renamed to texture_red.png.)

-
Not that this is a bad question to ask, but in practice, why not use Magic Set Editor? Despite the name I believe it can work with customized templates for other card games. – David Z Jun 19 '14 at 1:31
You should have a look at this answer, which explains how to draw shadows on different layers. – TonioElGringo Jun 24 '14 at 13:44