\LoadClass{standalone}

\ProvidesClass{iditacard}[2017/05/12 Class for Iditacard cards]

\RequirePackage{fontspec}
\RequirePackage{xcolor}
\RequirePackage{xstring}

\RequirePackage[none]{hyphenat}

\RequirePackage{tikz}
\usetikzlibrary{positioning,shapes,shadows,arrows,backgrounds,fit}
\RequirePackage{pgfplots}
\RequirePackage{shapepar}
\RequirePackage{microtype}
\RequirePackage{mathtools}
\let\mttext\text

\graphicspath{{images/}}

\newfontfamily\bebas{Bebas Neue Regular}
\newfontfamily\alegreya{Alegreya}

\definecolor{energy}{HTML}{003FFF}
\definecolor{health}{HTML}{FF0000}
\definecolor{risk}{HTML}{000000}

% Card Type
\definecolor{utility}{HTML}{FFFFFF}
\definecolor{attachment}{HTML}{5FAFCF}
\definecolor{dog}{HTML}{BF9F7F}
\definecolor{stretch}{HTML}{9F9F9F}
\definecolor{personal}{HTML}{AF5FCF}
\definecolor{movement}{HTML}{7F7FDF}
\definecolor{damage}{HTML}{FF6F6F}
\definecolor{sled}{HTML}{7FDF7F}
\definecolor{food}{HTML}{CFCF4F}

% Rarity
\definecolor{info}{HTML}{FFFFFF}
\definecolor{starting}{HTML}{777777}
\definecolor{common}{HTML}{000000}
\definecolor{rare}{HTML}{000077}
\definecolor{epic}{HTML}{007700}
\definecolor{legendary}{HTML}{770077}

\newcommand{\cardtype}[1]{\newcommand{\backgroundcolor}{#1}}
\newcommand{\rarity}[1]{\newcommand{\edgecolor}{#1}}
\newcommand{\deck}[1]{\newcommand{\whichdeck}{#1}}

\newcommand{\energy}[1]{%
\node [minimum width=0.5in, minimum height=0.5in, anchor=center, inner sep=0mm] at (125.0/300.0,825.0/300.0) {\includegraphics[width=0.5in,height=0.5in]{icons/hand.png}};
\StrLen{#1}[\arglen]
\ifnum\arglen>1%
    \node [text=black, minimum width=0.5in, minimum height=0.5in, text centered, text width=0.5in, anchor=center, inner sep=0mm] at (125.0/300.0,825.0/300.0) {\bf\fontsize{14}{14}\bebas #1};%
\else
    \node [text=black, minimum width=0.5in, minimum height=0.5in, text centered, text width=0.5in, anchor=center, inner sep=0mm] at (125.0/300.0,825.0/300.0) {\bf\fontsize{25}{30}\bebas #1};%
\fi
}

\newcommand{\health}[1]{%
\node [minimum width=0.5in, minimum height=0.5in, anchor=center, inner sep=0mm] at (125.0/300.0,700.0/300.0) {\includegraphics[width=0.5in, height=0.5in]{icons/deck.png}};
\StrLen{#1}[\arglen]
\ifnum\arglen>1%
    \node [text=black, minimum width=0.5in, minimum height=0.5in, text centered, text width=0.5in, anchor=center, inner sep=0mm] at (125.0/300.0, 700.0/300.0) {\bf\fontsize{14}{14}\bebas #1};%
\else
    \node [text=black, minimum width=0.5in, minimum height=0.5in, text centered, text width=0.5in, anchor=center, inner sep=0mm] at (125.0/300.0, 700.0/300.0) {\bf\fontsize{25}{30}\bebas #1};%
\fi
}

\newcommand{\risk}[1]{%
\node [minimum width=0.5in, minimum height=0.5in, anchor=center, inner sep=0mm] at (125.0/300.0, 538.0/300.0) {\includegraphics[width=0.5in, height=0.5in]{icons/risk.png}};
\StrLen{#1}[\arglen]
\ifnum\arglen>1%
    \node [text=white, minimum width=0.5in, minimum height=0.5in, text centered, text width=0.5in, anchor=center, inner sep=0mm] at (125.0/300.0, 538.0/300.0) {\bf\fontsize{14}{14}\bebas #1};%
\else
    \node [text=white, minimum width=0.5in, minimum height=0.5in, text centered, text width=0.5in, anchor=center, inner sep=0mm] at (125.0/300.0, 538.0/300.0) {\bf\fontsize{25}{30}\bebas #1};%
\fi
}

\newcommand{\name}[1]{%
\node [rectangle, anchor=north, minimum width=2.15in, minimum height=2.0/3.0in, text centered, text width=1.833333in, inner sep=0mm] at (375.0/300.0,975.0/300.0) {\bf\fontsize{20}{30}\bebas#1\par};
}

\renewcommand{\text}[1]{%
\node [rectangle, minimum width=1.833333in, minimum height=200.0/300.0, text centered, text width=1.833333in, inner sep=0mm, anchor=north] at (375.0/300.0,450.0/300) {\fontsize{16}{16}\bebas#1\par};
}

\newcommand{\helptext}[1]{%
\node [rectangle, minimum width=1.833333in, minimum height=200.0/300.0, text centered, text width=1.833333in, inner sep=0mm, anchor=north] at (375.0/300.0, 800.0/300.0) {\fontsize{16}{16}\bebas#1\par};
}

\newcommand{\flava}[1]{%
\node [rectangle, minimum width=1.833333in, minimum height=100.0/300.0, text centered, text width=1.833333in, inner sep=0mm, anchor=north] at (375.0/300.0,150.0/300.0) {\fontsize{6}{6}\alegreya"#1"\par};
}

\newcommand{\type}[1]{%
\node [rectangle, minimum width=1.833333in, minimum height=100.0/300.0, text centered, text width=1.833333in, inner sep=0mm, anchor=north] at (375.0/300.0,100.0/300.0) {\fontsize{12}{12}\bebas#1\par};
}

% Aspect ratio of about 3:2
\newcommand{\art}[1]{%
\node [rectangle, minimum width=649.8/300.0, minimum height=425.0/300.0, inner sep=0, anchor=north west] at (49.2/300.0, 888.0/300.0) {\noindent\includegraphics*[width=2.1664in, height=1.416667in]{#1}};
}

\newcommand{\useicon}[1]{\raisebox{-0.1em}{\includegraphics[height=1em]{icons/#1.png}}}

% Arguments are: Baseline, Text Xcm, Text Ycm, iconfile, amount
\newcommand{\texticon}[5]{%
    \begin{tikzpicture}[baseline=#1,x=1cm,y=1cm]
        \node[centered, minimum width=0pt, text width=1cm, inner sep=0pt, outer sep=0pt] at (0,0) {\includegraphics[width=1cm,height=1.6cm]{icons/#4.png}};
        \node[centered, minimum width=0pt, text width=0.6cm, inner sep=0pt, outer sep=0pt] at (#2,#3) {#5};
    \end{tikzpicture}%
}

\newcommand{\daydraw}[1]{\texticon{-0.4cm}{0}{-0.2}{daydraw}{#1}}
\newcommand{\draw}[1]{\texticon{-0.28cm}{-0.1}{-0.08}{draw}{#1}}
\newcommand{\supply}[1]{\texticon{-0.4cm}{0}{-0.2}{supply}{#1}}
\newcommand{\take}[1]{\texticon{-0.4cm}{0}{-0.2}{take}{#1}}
\newcommand{\see}[1]{\texticon{-0.4cm}{0}{-0.2}{see}{#1}}
\newcommand{\destroy}[1]{\texticon{-0.4cm}{0}{-0.2}{destroy}{#1}}
\newcommand{\speed}[1]{\raisebox{-0.1em}{\includegraphics[height=1em]{icons/speed.png}} #1}
\newcommand{\move}[1]{\raisebox{-0.1em}{\includegraphics[height=1em]{icons/move.png}} #1}

\newcommand{\discardonkill}{Discarded when killed}
\newcommand{\inplayatstart}{Play when the game starts}
\newcommand{\immortal}{Cannot Die}
\newcommand{\safepass}{Passing does not incur damage}
\newcommand{\passdie}{Dies when passing}
\newcommand{\nohold}{Cannot hold attachments}
\newcommand{\nostarvation}{Remove your \useicon{starve}}
\newcommand{\nohypothermia}{Remove your \useicon{hypo}}
\newcommand{\damage}[1]{Take #1 damage}
\newcommand{\doubledistance}{Double the final distance}
\newcommand{\damagetext}{Destroy this card  \vskip 0.5em When you discard this card, end your turn immediately}

\newenvironment{card}
{% Begin
\noindent\begin{tikzpicture}[x=1in,y=1in]
\fill [\edgecolor] (0,0) rectangle (2.5,3.5);
\fill[rounded corners=10pt] [\backgroundcolor] (50.0/300.0,50.0/300.0) rectangle (700.0/300.0,1000.0/300.0);
\node at (645.0/300.0,95.0/300.0) {\includegraphics[width=0.25in, height=0.25in]{deck/\whichdeck.png}};
}
{% End
\end{tikzpicture}}

% Draws a straight, vertical 15mm segment centered at 0,0 going down
\newcommand{\straightspace}{%
    \fill [black] (-0.85,-0.85) rectangle (-0.65,0.85);
    \fill [black] (0.65,-0.85) rectangle (0.85,0.85);
    \fill [black] (-0.5,-0.725) rectangle (0.5,-0.775);
}

% Draws an 'L' shaped 15mm segment centered at 0,0
\newcommand{\Lspace}{%
    \fill [black] (-0.85,-0.85) rectangle (-0.65,0.85);
    \fill [black] (-0.85,-0.85) rectangle (0.85,-0.65);
    \fill [black] (0.65,0.65) rectangle (0.85,0.85);
    \fill [black] (0.725,-0.5) rectangle (0.775,0.5);
}

\newenvironment{leg}
{% Begin
\noindent\begin{tikzpicture}[x=1cm,y=1cm]
    \fill [black] (0,0) rectangle (6.35,8.89);
    \fill[rounded corners=10pt] [white] (0.423333,0.0) rectangle (5.92666,8.4666);

    % Draw the path itself
    \scoped[shift={(1.675,0.85)},yscale=-1.0]{\straightspace}
    \scoped[shift={(1.675,2.35)},yscale=-1.0]{\straightspace}
    \scoped[shift={(1.675,3.85)},yscale=-1.0]{\straightspace}
    \scoped[shift={(1.675,5.35)},yscale=-1.0]{\straightspace}
    \scoped[shift={(1.675,6.85)},yscale=-1.0]{\Lspace}
    \scoped[shift={(3.175,6.85)},rotate=90]{\straightspace}
    \scoped[shift={(4.675,6.85)},xscale=-1.0,rotate=-90]{\Lspace}
    \scoped[shift={(4.675,5.35)}]{\straightspace}
    \scoped[shift={(4.675,3.85)}]{\straightspace}
    \scoped[shift={(4.675,2.35)}]{\straightspace}
    \scoped[shift={(4.675,0.85)}]{\straightspace}
}
{% End
\end{tikzpicture}}

\newcommand{\legname}[1]{%
\node [rectangle, anchor=north, minimum width=2.15in, minimum height=2.0/3.0in, text centered, text width=1.833333in, inner sep=0mm] at (3.175,8.35) {\bf\fontsize{20}{30}\bebas#1\par};
}

% Returns the center of the argument'th space on a leg (0-indexed)
\newcommand{\legcoordx}[1]{%
    \ifnum#1=0 1.675 \fi
    \ifnum#1=1 1.675 \fi
    \ifnum#1=2 1.675 \fi
    \ifnum#1=3 1.675 \fi
    \ifnum#1=4 1.675 \fi
    \ifnum#1=5 3.175 \fi
    \ifnum#1=6 4.675 \fi
    \ifnum#1=7 4.675 \fi
    \ifnum#1=8 4.675 \fi
    \ifnum#1=9 4.675 \fi
    \ifnum#1=10 4.675 \fi
}
\newcommand{\legcoordy}[1]{%
    \ifnum#1=0 0.85 \fi
    \ifnum#1=1 2.35 \fi
    \ifnum#1=2 3.85 \fi
    \ifnum#1=3 5.35 \fi
    \ifnum#1=4 6.85 \fi
    \ifnum#1=5 6.85 \fi
    \ifnum#1=6 6.85 \fi
    \ifnum#1=7 5.35 \fi
    \ifnum#1=8 3.85 \fi
    \ifnum#1=9 2.35 \fi
    \ifnum#1=10 0.85 \fi
}

\newcommand{\onlegspace}[2]{%
    \node [rectangle, anchor=center, minimum width=1.5cm, minimum height=1.5cm, text centered, text width=1.5cm, inner sep=0mm] at (\legcoordx{#1},\legcoordy{#1}) {#2};
}

\newenvironment{board}
{% Begin
\noindent\begin{tikzpicture}[x=1cm,y=1cm]
%\fill [white] (0,0) rectangle (41.275,26.035);
}
{% End
\end{tikzpicture}}
