diff options
Diffstat (limited to 'Master/texmf-dist/tex/latex/logicpuzzle/battleship.sty')
-rw-r--r-- | Master/texmf-dist/tex/latex/logicpuzzle/battleship.sty | 338 |
1 files changed, 72 insertions, 266 deletions
diff --git a/Master/texmf-dist/tex/latex/logicpuzzle/battleship.sty b/Master/texmf-dist/tex/latex/logicpuzzle/battleship.sty index af5715ab8a1..3dfde6d9a5a 100644 --- a/Master/texmf-dist/tex/latex/logicpuzzle/battleship.sty +++ b/Master/texmf-dist/tex/latex/logicpuzzle/battleship.sty @@ -23,269 +23,75 @@ % http://en.wikipedia.org/wiki/Battleship_%28puzzle%29 % http://de.wikipedia.org/wiki/Bimaru % -\ProvidesPackage{battleship}[2013/02/28 battleship.sty v1.3 - Josef Kleber (C) 2013]% +\ProvidesPackage{battleship}[2013/03/25 battleship.sty v1.4 - Josef Kleber (C) 2013]% % \RequirePackage{logicpuzzle}% -\tikzstyle{island} = [fill=yellow!30,draw, decorate, decoration={random steps,segment length=2.7pt,amplitude=1.7pt}]% -% -% options -\newcommand*\BS@width{6cm}% -\newcommand*\BS@fontsize\Large% -\newcommand*\BS@rows{5}% -\newcommand*\BS@columns{5}% -\newcommand*\BS@scale{1}% -\newcommand*\BS@bgcolor{}% -\newcommand*\BS@shipcolor{green}% -\newcommand*\BS@title{}% -\newcommand*\BS@titleindent{0.75cm}% -\newcommand*\BS@titlewidth{5.15cm}% -\newcommand*\BS@cvoffset{-23pt}% -\newcommand*\BS@SB@indent{0.75cm}% -\newcommand*\BS@SB@width{5.15cm}% -\newcommand*\BS@SB@shipboxscale{1}% -% -\newcounter{BS@rows}% -\newcounter{BS@columns}% -% -\setcounter{BS@rows}{\BS@rows}% -\setcounter{BS@columns}{\BS@columns}% -\stepcounter{BS@rows}% -\stepcounter{BS@columns}% -% -\define@key{battleship.sty}{rows}[5]% -{% - \renewcommand*\BS@rows{#1}% -}% -% -\define@key{battleship.sty}{columns}[5]% -{% - \renewcommand*\BS@columns{#1}% -}% -% -\define@key{battleship.sty}{shipcolor}[green]% -{% - \renewcommand*\BS@shipcolor{#1}% -}% -% -\define@key{battleship.sty}{scale}[1]% -{% - \renewcommand*\BS@scale{#1}% -}% -% -\define@key{battleship.sty}{counterstyle}[none]% -{% - \renewcommand*\LP@counterstyle{#1}% -}% -% -\define@key{battleship.sty}{bgcolor}[]% -{% - \renewcommand*\BS@bgcolor{#1}% -}% -% -\define@choicekey*{battleship.sty}{fontsize}[\BS@fontsize\nr]{tiny,scriptsize,footnotesize,small,normalsize,large,Large,LARGE,huge,Huge}[Large]% -{% - \ifcase\nr\relax% - \renewcommand*\BS@fontsize{\tiny}% - \or% - \renewcommand*\BS@fontsize{\scriptsize}% - \or% - \renewcommand*\BS@fontsize{\footnotesize}% - \or% - \renewcommand*\BS@fontsize{\small}% - \or% - \renewcommand*\BS@fontsize{\normalsize}% - \or% - \renewcommand*\BS@fontsize{\large}% - \or% - \renewcommand*\BS@fontsize{\Large}% - \or% - \renewcommand*\BS@fontsize{\LARGE}% - \or% - \renewcommand*\BS@fontsize{\huge}% - \or% - \renewcommand*\BS@fontsize{\Huge}% - \fi% -}% -% -\define@key{battleship.sty}{width}[6cm]% -{% - \renewcommand*\BS@width{#1}% -}% -% -\define@key{battleship.sty}{title}[]% -{% - \renewcommand*\BS@title{#1}% -}% -% -\define@key{battleship.sty}{cvoffset}[-23pt]% -{% - \renewcommand*\BS@cvoffset{#1}% -}% -% -\define@key{battleship.sty}{titleindent}[0.75cm]% -{% - \renewcommand*\BS@titleindent{#1}% -}% -% -\define@key{battleship.sty}{titlewidth}[5.15cm]% -{% - \renewcommand*\BS@titlewidth{#1}% -}% -% -\define@key{battleship.sty}{sbindent}[0.75cm]% -{% - \renewcommand*\BS@SB@indent{#1}% -}% -% -\define@key{battleship.sty}{sbwidth}[5.15cm]% -{% - \renewcommand*\BS@SB@width{#1}% -}% -% -\define@key{battleship.sty}{sbshipscale}[1]% -{% - \renewcommand*\BS@SB@shipboxscale{#1}% -}% -% -\define@key{battleship}{rows}% -{% - \renewcommand*\BS@rows{#1}% -}% -% -\define@key{battleship}{columns}% -{% - \renewcommand*\BS@columns{#1}% -}% -% -\define@key{battleship}{shipcolor}% -{% - \renewcommand*\BS@shipcolor{#1}% -}% -% -\define@key{battleship}{scale}% -{% - \renewcommand*\BS@scale{#1}% -}% -% -\define@key{battleship}{bgcolor}% -{% - \renewcommand*\BS@bgcolor{#1}% -}% -% -\define@key{battleship}{counterstyle}% -{% - \renewcommand*\LP@counterstyle{#1}% -}% % -\define@choicekey*{battleship}{fontsize}[\BS@fontsize\nr]{tiny,scriptsize,footnotesize,small,normalsize,large,Large,LARGE,huge,Huge}[Large]% -{% - \ifcase\nr\relax% - \renewcommand*\BS@fontsize{\tiny}% - \or% - \renewcommand*\BS@fontsize{\scriptsize}% - \or% - \renewcommand*\BS@fontsize{\footnotesize}% - \or% - \renewcommand*\BS@fontsize{\small}% - \or% - \renewcommand*\BS@fontsize{\normalsize}% - \or% - \renewcommand*\BS@fontsize{\large}% - \or% - \renewcommand*\BS@fontsize{\Large}% - \or% - \renewcommand*\BS@fontsize{\LARGE}% - \or% - \renewcommand*\BS@fontsize{\huge}% - \or% - \renewcommand*\BS@fontsize{\Huge}% - \fi% -}% -% -\define@key{battleship}{width}% -{% - \renewcommand*\BS@width{#1}% -}% -% -\define@key{battleship}{title}% -{% - \renewcommand*\BS@title{#1}% -}% -% -\define@key{battleship}{cvoffset}% -{% - \renewcommand*\BS@cvoffset{#1}% -}% -% -\define@key{battleship}{titleindent}% -{% - \renewcommand*\BS@titleindent{#1}% -}% -% -\define@key{battleship}{titlewidth}% -{% - \renewcommand*\BS@titlewidth{#1}% -}% -% -\define@key{battleship}{sbindent}% -{% - \renewcommand*\BS@SB@indent{#1}% -}% -% -\define@key{battleship}{sbwidth}% -{% - \renewcommand*\BS@SB@width{#1}% -}% -% -\define@key{battleship}{sbshipscale}% -{% - \renewcommand*\BS@SB@shipboxscale{#1}% -}% +\newcommand*\LP@BS@init@prefix{LP@BS}% +\newcommand*\LP@BS@init@package{battleship}% +% +\LP@define@key{\LP@BS@init@prefix}{\LP@BS@init@package}{rows}{5}% +\LP@define@key{\LP@BS@init@prefix}{\LP@BS@init@package}{columns}{5}% +\LP@define@key{\LP@BS@init@prefix}{\LP@BS@init@package}{shipcolor}{green}% +\LP@define@key{\LP@BS@init@prefix}{\LP@BS@init@package}{scale}{1}% +\LP@define@key{\LP@BS@init@prefix}{\LP@BS@init@package}{counterstyle}{none}% +\LP@define@key{\LP@BS@init@prefix}{\LP@BS@init@package}{bgcolor}{}% +\LP@define@key{\LP@BS@init@prefix}{\LP@BS@init@package}{width}{6cm}% +\LP@define@key{\LP@BS@init@prefix}{\LP@BS@init@package}{cvoffset}{-23pt}% +\LP@define@key{\LP@BS@init@prefix}{\LP@BS@init@package}{title}{}% +\LP@define@key{\LP@BS@init@prefix}{\LP@BS@init@package}{titleindent}{0.75cm}% +\LP@define@key{\LP@BS@init@prefix}{\LP@BS@init@package}{titlewidth}{5.15cm}% +\LP@define@key{\LP@BS@init@prefix}{\LP@BS@init@package}{sbindent}{0.75cm}% +\LP@define@key{\LP@BS@init@prefix}{\LP@BS@init@package}{sbwidth}{5.15cm}% +\LP@define@key{\LP@BS@init@prefix}{\LP@BS@init@package}{sbshipscale}{1}% +\LP@define@choicekey@fontsize{\LP@BS@init@prefix}{\LP@BS@init@package}{{Large}}% % \ExecuteOptionsX{rows,columns,width,fontsize,shipcolor,scale,bgcolor,cvoffset,counterstyle,title,titleindent,titlewidth,sbindent,sbwidth,sbshipscale}% -% \ProcessOptionsX\relax% % -\gdef\BS@shipbox{}% +\LP@init@counter{\LP@BS@init@prefix}% % -\newcommand*\Ship{\tikz[scale=\BS@scale]\draw[scale=.36,fill=\BS@shipcolor] (0,0) circle (1);}% -\newcommand*\ShipC{\tikz[scale=\BS@scale]\draw[scale=.36,fill=\BS@shipcolor] (0,0)--(0,2)--(2,2)--(2,0)--cycle;}% -\newcommand*\ShipT{\tikz[scale=\BS@scale]\draw[scale=.36,fill=\BS@shipcolor](2,1)--(2,0)--(0,0)--(0,1) arc (180:0:1);}% -\newcommand*\ShipB{\tikz[scale=\BS@scale]\draw[scale=.36,fill=\BS@shipcolor](2,1)--(2,2)--(0,2)--(0,1) arc (180:360:1);}% -\newcommand*\ShipL{\tikz[scale=\BS@scale]\draw[scale=.36,fill=\BS@shipcolor](1,2)--(2,2)--(2,0)--(1,0) arc (270:90:1);}% -\newcommand*\ShipR{\tikz[scale=\BS@scale]\draw[scale=.36,fill=\BS@shipcolor](1,2)--(0,2)--(0,0)--(1,0) arc (270:450:1);}% -\newcommand*\Island{\tikz[scale=\BS@scale]\draw[scale=.36,island] (0,0) rectangle (2,2);}% -\newcommand*\Water{\tikz[scale=\BS@scale]\draw[scale=.36,fill,blue!40] (1,1) circle (0.2);}% -% versions for \shipbox without second scale -\newcommand*\@Ship{\tikz\draw[scale=.144,fill=\BS@shipcolor] (0,0) circle (1);}% -\newcommand*\@ShipC{\tikz\draw[scale=.144,fill=\BS@shipcolor] (0,0)--(0,2)--(2,2)--(2,0)--cycle;}% -\newcommand*\@ShipT{\tikz\draw[scale=.144,fill=\BS@shipcolor](2,1)--(2,0)--(0,0)--(0,1) arc (180:0:1);}% -\newcommand*\@ShipB{\tikz\draw[scale=.144,fill=\BS@shipcolor](2,1)--(2,2)--(0,2)--(0,1) arc (180:360:1);}% -\newcommand*\@ShipL{\tikz\draw[scale=.144,fill=\BS@shipcolor](1,2)--(2,2)--(2,0)--(1,0) arc (270:90:1);}% -\newcommand*\@ShipR{\tikz\draw[scale=.144,fill=\BS@shipcolor](1,2)--(0,2)--(0,0)--(1,0) arc (270:450:1);}% -% -\newcommand*\BS@printship[1]% -{% - \ifthenelse{\equal{#1}{1}}{\scalebox{\BS@SB@shipboxscale}{\@Ship}\space\allowbreak}{}% - \ifthenelse{\equal{#1}{2}}{\scalebox{\BS@SB@shipboxscale}{\@ShipL\,\@ShipR}\space\allowbreak}{}% - \ifthenelse{\equal{#1}{3}}{\scalebox{\BS@SB@shipboxscale}{\@ShipL\,\@ShipC\,\@ShipR}\space\allowbreak}{}% - \ifthenelse{\equal{#1}{4}}{\scalebox{\BS@SB@shipboxscale}{\@ShipL\,\@ShipC\,\@ShipC\,\@ShipR}\space\allowbreak}{}% - \ifthenelse{\equal{#1}{5}}{\scalebox{\BS@SB@shipboxscale}{\@ShipL\,\@ShipC\,\@ShipC\,\@ShipC\,\@ShipR}\space\allowbreak}{}% - \ifthenelse{\equal{#1}{6}}{\scalebox{\BS@SB@shipboxscale}{\@ShipL\,\@ShipC\,\@ShipC\,\@ShipC\,\@ShipC\,\@ShipR}\space\allowbreak}{}% - \ifthenelse{\equal{#1}{7}}{\scalebox{\BS@SB@shipboxscale}{\@ShipL\,\@ShipC\,\@ShipC\,\@ShipC\,\@ShipC\,\@ShipC\,\@ShipR}\space\allowbreak}{}% - \ifthenelse{\equal{#1}{8}}{\scalebox{\BS@SB@shipboxscale}{\@ShipL\,\@ShipC\,\@ShipC\,\@ShipC\,\@ShipC\,\@ShipC\,\@ShipC\,\@ShipR}\space\allowbreak}{}% - \ifthenelse{\equal{#1}{9}}{\scalebox{\BS@SB@shipboxscale}{\@ShipL\,\@ShipC\,\@ShipC\,\@ShipC\,\@ShipC\,\@ShipC\,\@ShipC\,\@ShipC\,\@ShipR}\space\allowbreak}{}% - \ifthenelse{\equal{#1}{10}}{\scalebox{\BS@SB@shipboxscale}{\@ShipL\,\@ShipC\,\@ShipC\,\@ShipC\,\@ShipC\,\@ShipC\,\@ShipC\,\@ShipC\,\@ShipC\,\@ShipR}\space\allowbreak}{}% -}% +\gdef\LP@BS@shipbox{}% +\tikzstyle{island} = [fill=yellow!30,draw, decorate, decoration={random steps,segment length=2.7pt,amplitude=1.7pt}]% % -\newcommand*\BS@printshipbox[1]% +\newcommand*\Ship{\tikz[scale=\LP@BS@scale]\draw[scale=.36,fill=\LP@BS@shipcolor] (0,0) circle (1);}% +\newcommand*\ShipC{\tikz[scale=\LP@BS@scale]\draw[scale=.36,fill=\LP@BS@shipcolor] (0,0)--(0,2)--(2,2)--(2,0)--cycle;}% +\newcommand*\ShipT{\tikz[scale=\LP@BS@scale]\draw[scale=.36,fill=\LP@BS@shipcolor](2,1)--(2,0)--(0,0)--(0,1) arc (180:0:1);}% +\newcommand*\ShipB{\tikz[scale=\LP@BS@scale]\draw[scale=.36,fill=\LP@BS@shipcolor](2,1)--(2,2)--(0,2)--(0,1) arc (180:360:1);}% +\newcommand*\ShipL{\tikz[scale=\LP@BS@scale]\draw[scale=.36,fill=\LP@BS@shipcolor](1,2)--(2,2)--(2,0)--(1,0) arc (270:90:1);}% +\newcommand*\ShipR{\tikz[scale=\LP@BS@scale]\draw[scale=.36,fill=\LP@BS@shipcolor](1,2)--(0,2)--(0,0)--(1,0) arc (270:450:1);}% +\newcommand*\Island{\tikz[scale=\LP@BS@scale]\draw[scale=.36,island] (0,0) rectangle (2,2);}% +\newcommand*\Water{\tikz[scale=\LP@BS@scale]\draw[scale=.36,fill,blue!40] (1,1) circle (0.2);}% +% versions for \shipbox without second scale +\newcommand*\@Ship{\tikz\draw[scale=.144,fill=\LP@BS@shipcolor] (0,0) circle (1);}% +\newcommand*\@ShipC{\tikz\draw[scale=.144,fill=\LP@BS@shipcolor] (0,0)--(0,2)--(2,2)--(2,0)--cycle;}% +\newcommand*\@ShipT{\tikz\draw[scale=.144,fill=\LP@BS@shipcolor](2,1)--(2,0)--(0,0)--(0,1) arc (180:0:1);}% +\newcommand*\@ShipB{\tikz\draw[scale=.144,fill=\LP@BS@shipcolor](2,1)--(2,2)--(0,2)--(0,1) arc (180:360:1);}% +\newcommand*\@ShipL{\tikz\draw[scale=.144,fill=\LP@BS@shipcolor](1,2)--(2,2)--(2,0)--(1,0) arc (270:90:1);}% +\newcommand*\@ShipR{\tikz\draw[scale=.144,fill=\LP@BS@shipcolor](1,2)--(0,2)--(0,0)--(1,0) arc (270:450:1);}% +% +\newcommand*\LP@BS@printship[1]% +{% + \ifthenelse{\equal{#1}{1}}{\scalebox{\LP@BS@sbshipscale}{\@Ship}\space\allowbreak}{}% + \ifthenelse{\equal{#1}{2}}{\scalebox{\LP@BS@sbshipscale}{\@ShipL\,\@ShipR}\space\allowbreak}{}% + \ifthenelse{\equal{#1}{3}}{\scalebox{\LP@BS@sbshipscale}{\@ShipL\,\@ShipC\,\@ShipR}\space\allowbreak}{}% + \ifthenelse{\equal{#1}{4}}{\scalebox{\LP@BS@sbshipscale}{\@ShipL\,\@ShipC\,\@ShipC\,\@ShipR}\space\allowbreak}{}% + \ifthenelse{\equal{#1}{5}}{\scalebox{\LP@BS@sbshipscale}{\@ShipL\,\@ShipC\,\@ShipC\,\@ShipC\,\@ShipR}\space\allowbreak}{}% + \ifthenelse{\equal{#1}{6}}{\scalebox{\LP@BS@sbshipscale}{\@ShipL\,\@ShipC\,\@ShipC\,\@ShipC\,\@ShipC\,\@ShipR}\space\allowbreak}{}% + \ifthenelse{\equal{#1}{7}}{\scalebox{\LP@BS@sbshipscale}{\@ShipL\,\@ShipC\,\@ShipC\,\@ShipC\,\@ShipC\,\@ShipC\,\@ShipR}\space\allowbreak}{}% + \ifthenelse{\equal{#1}{8}}{\scalebox{\LP@BS@sbshipscale}{\@ShipL\,\@ShipC\,\@ShipC\,\@ShipC\,\@ShipC\,\@ShipC\,\@ShipC\,\@ShipR}\space\allowbreak}{}% + \ifthenelse{\equal{#1}{9}}{\scalebox{\LP@BS@sbshipscale}{\@ShipL\,\@ShipC\,\@ShipC\,\@ShipC\,\@ShipC\,\@ShipC\,\@ShipC\,\@ShipC\,\@ShipR}\space\allowbreak}{}% + \ifthenelse{\equal{#1}{10}}{\scalebox{\LP@BS@sbshipscale}{\@ShipL\,\@ShipC\,\@ShipC\,\@ShipC\,\@ShipC\,\@ShipC\,\@ShipC\,\@ShipC\,\@ShipC\,\@ShipR}\space\allowbreak}{}% +}% +% +\newcommand*\LP@BS@printshipbox[1]% {% \expandafters needed because csv list is stored in macro - \expandafter\forcsvlist\expandafter\BS@printship\expandafter{#1}% + \expandafter\forcsvlist\expandafter\LP@BS@printship\expandafter{#1}% }% % \newcommand*\shipH[1]% {% - \LP@setrowcontents{#1}{1}{\value{BS@rows}}% + \LP@setrowcontents{#1}{1}{\value{LP@BS@rows}}% }% % \newcommand*\shipV[1]% @@ -295,7 +101,7 @@ % \newcommand*\placesegment[3]% {% - \LP@ingrid{#1}{#2}{\BS@columns}{\BS@rows}{battleship}% + \LP@ingrid{#1}{#2}{\LP@BS@columns}{\LP@BS@rows}{battleship}% \LP@setcellcontent{#1}{#2}{#3}% }% % @@ -303,20 +109,20 @@ % \newcommand*\placeisland[2]% {% - \LP@ingrid{#1}{#2}{\BS@columns}{\BS@rows}{battleship}% + \LP@ingrid{#1}{#2}{\LP@BS@columns}{\LP@BS@rows}{battleship}% \LP@setcellcontent{#1}{#2}{\Island}% }% % \newcommand*\placewater[2]% {% - \LP@ingrid{#1}{#2}{\BS@columns}{\BS@rows}{battleship}% + \LP@ingrid{#1}{#2}{\LP@BS@columns}{\LP@BS@rows}{battleship}% \LP@setcellcontent{#1}{#2}{\Water}% }% % \newcommand*\shipbox[2][]% {% \setkeys{shipbox}{#1}% - \gdef\BS@shipbox{#2}% + \gdef\LP@BS@shipbox{#2}% }% % \newcommand*\placeship[4]% @@ -411,24 +217,24 @@ {% \setkeys{battleship}{#1}% \LP@set@package{battleship}% - \LP@set@env@prefix{BS}% + \LP@set@env@prefix{LP@BS}% \shipbox{}% clear shipbox - \setcounter{BS@rows}{\BS@rows}% - \setcounter{BS@columns}{\BS@columns}% - \stepcounter{BS@rows}% - \stepcounter{BS@columns}% - \begin{minipage}[t]{\BS@width}% - \ifthenelse{\equal{\BS@title}{}}% + \setcounter{LP@BS@rows}{\LP@BS@rows}% + \setcounter{LP@BS@columns}{\LP@BS@columns}% + \stepcounter{LP@BS@rows}% + \stepcounter{LP@BS@columns}% + \begin{minipage}[t]{\LP@BS@width}% + \ifthenelse{\equal{\LP@BS@title}{}}% {\par\enspace\par}% empty - {\enspace\par\noindent\hspace{\BS@titleindent}\parbox{\BS@titlewidth}{\strut\LP@titleformat\BS@title}\vspace{3mm}\par}% - \begin{tikzpicture}[scale=\BS@scale]% - \LP@drawbackground{1}{1}{\BS@columns}{\BS@rows}{\BS@bgcolor}% - \LP@drawgrid{1}{1}{\BS@columns}{\BS@rows}{1cm}% + {\enspace\par\noindent\hspace{\LP@BS@titleindent}\parbox{\LP@BS@titlewidth}{\strut\LP@titleformat\LP@BS@title}\vspace{3mm}\par}% + \begin{tikzpicture}[scale=\LP@BS@scale]% + \LP@drawbackground{1}{1}{\LP@BS@columns}{\LP@BS@rows}{\LP@BS@bgcolor}% + \LP@drawgrid{1}{1}{\LP@BS@columns}{\LP@BS@rows}{1cm}% }% {% \end{tikzpicture}% - \LP@drawcounter{\LP@counterstyle}% - \par\hbadness=10000\medskip\noindent\hspace{\BS@SB@indent}\begin{minipage}{\BS@SB@width}{\hbadness=10000\RaggedRight\BS@printshipbox{\BS@shipbox}}\end{minipage}% + \LP@drawcounter{\LP@BS@counterstyle}% + \par\hbadness=10000\medskip\noindent\hspace{\LP@BS@sbindent}\begin{minipage}{\LP@BS@sbwidth}{\hbadness=10000\RaggedRight\LP@BS@printshipbox{\LP@BS@shipbox}}\end{minipage}% \stepcounter{LP@puzzlecounter}% \end{minipage}% }% |