\ProvidesPackage{combatcards}

% Make cinematic combat cards.
%
% If you decide to rearrange combat cards, you'll want to frob with
% the definition of \@cine, but you can probably just leave everything
% else alone.  Exception:  to change the # of attack/defense slots,
% you want to modify \@column and \@blankcol at the end (it's a pretty
% trivial change).


\RequirePackage{extractable}
\RequirePackage[double]{cards}
\RequirePackage{color}

% set width/height of each slot and of the center in terms of single scale
\newcommand\@setnewlength[2]{\newlength{#1}\setlength{#1}{#2}}
\@setnewlength{\@scale}{1cm}
\@setnewlength{\@hitwide}{1.5\@scale}
\@setnewlength{\@hittall}{1.0\@scale}
\@setnewlength{\@cenwide}{6.0\@scale}

% we'll want to be able to tell if we're doing the front or the back
\newif\if@front

% args:  attack, defense, title, requires, desc, roleplay
\newdef\combatcard[6]{\makecard
	{\@fronttrue\@cine{#1}{#2}{#3}{#4}{#5}{#6}}%   you see (front)
	{\@frontfalse\@cine{#1}{#2}{#3}{#4}{#5}{#6}}%  they see (not front)
}


% we'll want thick horizontal and vertical lines
\newdimen\@thickness \@thickness=4pt
\newcommand\@hthick{\hrule height\@thickness} % thick horizontal line
\newcommand\@vthick{\vrule width\@thickness}  % thick vertical line

% make this side (front or not front) of the card
\newcommand\@cine[6]{%
  \parindent=0pt  % don't indent paragraphs
  \fboxsep=0pt    % no separation from framebox to contents
  \fboxrule=\@thickness  % frame lines as thick as the others
  \leftskip=2ex plus1fil   \rightskip=2ex plus1fil  % center text, with margin
  \fbox{% framed box
    \valign{##\cr   % line up the *columns* properly
      \hsize=\@hitwide #1\relax             % attack
      \cr % end column
      \noalign{\@vthick}% thick vertical line after attack column
      \hsize=\@cenwide
        \vfil
        \textbf{#3}\break\vfil              % title
        #5\break\vfil                       % description
        \if@front \emph{Requires: #4}%      % requirements on front,
        \else \emph{If hit:} #6\relax \fi   % effects on back
        \break\vfil 
        {\small \gamename}\break \vfil
      \cr % end column
      \if@front \vfil\llap{\rotatebox{90}{\emph{Compare this side}}}\vfil \fi
      \cr % end column
      \noalign{\@vthick}% thick vertical line before defense column
      \hsize=\@hitwide #2\relax             % defense
      \cr
    }%
  }%
}

% hits *optionally* have a single digit
\newcommand\h{\futurelet\@NEXT\@h}
\newcommand\@h{\ifcat\@NEXT1\def\@tmp##1{\@hit{##1}}%
               \else\def\@tmp{\@hit{}}\fi\@tmp}
\newcommand\@hit[1]{\@greybox{\LARGE HIT~#1}}

\newcommand\m{\@whitebox{miss}}
\newcommand\bl{\@whitebox{block}}
\newcommand\nb{\@greybox{\large$\mbox{NO}\atop\mbox{BLOCK}$}}

\newcommand\@entry[1]{\vbox to \@hittall{\vfil#1\vfil}}

\newcommand\@whitebox[1]{\@entry{#1}}
\newcommand\@greybox[1]{\colorbox[gray]{.75}{\@entry{#1}}}


\newcommand\attack{\@column}
\newcommand\defend{\if@front \let\@NEXT=\@column
                   \else \let\@NEXT=\@blankcol \fi\@NEXT}

% to change how many attack/defense slots there are, just change 
% \@column to take and use N and \@blankcol to take N --- you'll also
% probably have to adjust the #rows of cards and/or their height 
\newdef\@column[5]{\centering #1\@hthick#2\@hthick#3\@hthick#4\@hthick#5}

\newdef\@blankcol[5]{~}

\input Lists/combatcards.tex
