Download this file
\NeedsTeXFormat{LaTeX2e}
\ProvidesClass{cartes}[2006/03/13 1.0 Planche de cartes (9x9)]
\typeout{Planche de cartes (9x9)}

\LoadClass[a4paper,draft]{article}

\RequirePackage[top=0pt, bottom=0pt, left=0pt, right=0pt]{geometry}
\RequirePackage[latin9]{inputenc}
\RequirePackage{graphicx}
\RequirePackage[T1]{fontenc}
\RequirePackage{corsiva}
\RequirePackage{multido}
\RequirePackage{lettrine}
\RequirePackage[frenchb]{babel}

\setlength{\unitlength}{1mm}
\setlength{\parindent}{0pt}
\setlength{\lineskip}{0pt}
\setlength{\fboxsep}{0pt}

\def\cartes@nom@personnage{Personnage}
\def\cartes@nom@objet{Objet}
\def\cartes@nom@lieu{Lieu}
\def\cartes@nom@position{Position}
\def\cartes@nom@aspect{Aspect}
\def\cartes@nom@evenement{Événement}

\def\cartes@dos{dos-carte}
\newcommand\setdos[1]{\gdef\cartes@dos{#1}}

\def\cartes@icon{}
\def\cartes@nom{}
\newcommand\type[1]{%
\gdef\cartes@nom{\csname cartes@nom@#1\endcsname}%
\gdef\cartes@icon{icon-#1}}

\newcounter{ligne}
\newcounter{carte}[ligne]
\newcounter{totalcartes}
\newif\ifface\facetrue

%% Place les cartes en 3 lignes de 3 cartes. Après chaque série de 9
%% (planche), insère une planche de dos de cartes.
\newcommand\espacement{%
\ifface\stepcounter{totalcartes}\fi%
\ifnum\thecarte < 2
  \stepcounter{carte}\ignorespaces
\else
  \par
  \stepcounter{ligne}%
  \ifnum\theligne = 3
    \ifface\dosplanche\fi
  \fi
\fi}

\newcommand\putfond{%
\put(0,0){\includegraphics[width=70mm,height=99mm]{fond}}
\put(0.1,0.1){\linethickness{0.10mm}\framebox(69.8,98.8){}}
}

\newcommand{\carte}[2]{%
\begin{picture}(70,99)
\putfond
\put(3,75){\parbox[b][20mm][c]{15mm}{\includegraphics[width=15mm,height=20mm,keepaspectratio]{\cartes@icon}}}
\put(14,15){\parbox{39mm}{\LARGE\centering #1}}
\if#2\relax\else\put(14,24){\parbox[b][50mm][c]{45mm}{\centering\includegraphics[width=45mm,height=50mm,keepaspectratio]{#2}}}\fi
\put(30,6){\parbox{35mm}{\large\hfill\cartes@nom}}
\end{picture}\espacement}

\newcommand\setlettrineparam[2]{\expandafter\gdef\csname cartes@#1\endcsname{#2}}
\newcommand\resetlettrineparams{%
\setlettrineparam{lhang}{0.40}%
\setlettrineparam{loversize}{0.40}%
\setlettrineparam{lraise}{0.0}%
\setlettrineparam{findent}{0.25em}%
\setlettrineparam{nindent}{0em}%
}
\resetlettrineparams%
\renewcommand{\LettrineTextFont}{\relax}
\def\L{\lettrine[lhang=\cartes@lhang,loversize=\cartes@loversize,lraise=\cartes@lraise,findent=\cartes@findent,nindent=\cartes@nindent]}
\newcommand{\denouement}[1]{%
\begin{picture}(70,99)
\putfond
\put(12,20){\parbox[b][59mm][c]{48mm}{\raggedright\LARGE \L#1}}
\end{picture}\espacement}

\newcommand{\interruption}[1]{%
\begin{picture}(70,99)
\putfond
\put(10,80){\parbox{50mm}{\LARGE\centering Interruption}}
\put(15,33){\parbox[b][40mm][c]{40mm}{\centering\includegraphics[width=40mm,height=40mm,keepaspectratio]{\cartes@icon}}}
\put(10,22){\parbox{50mm}{\normalsize\centering Peut être utilisé comme}}
\put(14,15){\parbox{39mm}{\LARGE\centering #1}}
\put(30,6){\parbox{35mm}{\large\hfill\cartes@nom}}
\end{picture}\espacement}

\newcommand{\dos}{%
\begin{picture}(70,99)
\put(10,10){\includegraphics[width=50mm,height=79mm,keepaspectratio]{\cartes@dos}}
\end{picture}\espacement}

\newcommand{\vide}{%
\begin{picture}(70,99)
\end{picture}\espacement}

\newcommand{\dosplanche}{%
\setcounter{carte}{0}%
\setcounter{ligne}{0}%
\facefalse%
\clearpage

\multido{}{\thetotalcartes}{%
\ifnum\thecarte=0
  \ifnum\value{totalcartes}=1
    \vide\vide%
  \fi
  \ifnum\value{totalcartes}=2
    \vide%
  \fi
\fi
\addtocounter{totalcartes}{-1}%
\dos}
\setcounter{carte}{0}%
\setcounter{ligne}{0}%
\setcounter{totalcartes}{0}%
\facetrue%
\clearpage

}

\AtEndDocument{\ifodd\thepage\dosplanche\fi}