% \iffalse
% <*chit>
% --------------------------------------------------------------------
% \fi
% \subsubsection{Some utilities}
%
% This style allows us to add a fading drop-shadow to chits.
%
%    \begin{macrocode}
\usetikzlibrary{shadows.blur}
\newif\ifwg@chit@drop\wg@chit@dropfalse
\tikzset{
  chit has drop/.is if=wg@chit@drop,
  chit has drop/.default=true,
  chit has drop/.initial=false,
  /tikz/render blur shadow/.add code={%
    \chit@dbg{2}{Number of blur steps: \pgfbs@steps}%
    \ifnum\pgfbs@steps=0\else
    \chit@dbg{2}{Making shadow blur}%
    }{\fi}}
\tikzset{%
  chit drop/.code={%
    %% \message{^^J Args `#1'}%
    \pgfkeysalso{%
      chit has drop=true,
      /tikz/blur shadow={shadow blur steps=5,
        shadow opacity=30,
        shadow xshift=.05cm,
        shadow yshift=-.05cm,
        shadow blur radius=.05cm,
        #1}}%
    \ifnum\pgfbs@steps=0%
      \gdef\wg@drop@margin{0pt}%
    \else%
      \ifwg@chit@drop%
        \pgfmathparse{
          \pgfbs@radius+
          veclen(
          \pgfkeysvalueof{/tikz/shadow xshift},
          \pgfkeysvalueof{/tikz/shadow yshift})}
        \xdef\wg@drop@margin{\pgfmathresult pt}%
      \else%
        \gdef\wg@drop@margin{0pt}%
      \fi
      %% \message{^^J Drop margin is `\wg@drop@margin'
      %%   `\pgfbs@radius'
      %%   `\pgfkeysvalueof{/tikz/shadow xshift}',
      %%   `\pgfkeysvalueof{/tikz/shadow yshift}'}%
    \fi%
  },%
  chit drop/.default=,%
  no chit drop/.code={%
    \pgfkeysalso{
      /tikz/blur shadow={shadow blur steps=0}}
    \gdef\wg@drop@margin{0pt}%
  }  
}%
%    \end{macrocode}
%
% Game turn marker
%
%    \begin{macrocode}
\tikzset{
  chit/text base/.style={
    shape=rectangle,
    inner sep=0pt,
    align=center,
    text width=1.1cm},
  chit/number/.style={
    chit/text base,
    font=\sffamily\bfseries\fontsize{12}{14}\selectfont},
  chit/game turn/.style={
    chit/text base,
    font=\sffamily\bfseries},
  chit/text/.style={
    chit/text base,
    font=\sffamily\bfseries},
  chit/small text/.style={
    chit/text base,
    font=\sffamily\bfseries\fontsize{9}{10}\selectfont},
  chit/number/.pic={\node[chit/number]{#1};},
  chit/game turn/.pic={\node[chit/game turn]{Game\\Turn};},
  chit/text/.pic={\node[chit/text]{#1};},
  chit/small text/.pic={\node[chit/small text]{#1};},
  game turn chit/.style={
    /chit/full={chit/game turn},
    color=black,
    fill=white},
  game turn chit flipped/.style={game turn chit},
  dummy chit/.style={fill=white},
}
%    \end{macrocode}
%
% Marks of chits
% 
%    \begin{macrocode}
\providecommand\chitmark[2][]{\tikz[scale=.25,#1]{\chit[#2]}}
%    \end{macrocode}
%
% Stacking mark
% 
%    \begin{macrocode}
\tikzset{
  wg stacking/.style={fill=white,
    /chit/symbol={[faction=friendly,command=land]}},
}
\DeclareRobustCommand\stackmark[1][]{%
  \tikz[baseline=(current bounding box.center),scale=.3,#1]{
    \stackchits(0,0)(.3,-.3){%
      \noexpand\chit[wg stacking],
      \noexpand\chit[wg stacking],
      \noexpand\chit[wg stacking]}}}
%    \end{macrocode}
%
%  ZOC mark
%
%    \begin{macrocode}
\DeclareRobustCommand\zocmark[1][]{%
  \tikz[baseline=($(current bounding box.center)!.5!(current bounding box.south)$),scale=.1,#1]{%
    \begin{scope}[hex/first row and column are=0,
      hex/row direction is=normal,
      hex/column direction is=normal,
      hex/short columns=none]
      \hex[label=,fill=gray](c=1,r=1)%
      \hex[label=,fill=white](c=1,r=2)%
      \hex[label=,fill=white](c=1,r=0)%
      \hex[label=,fill=white](c=0,r=0)%
      \hex[label=,fill=white](c=0,r=1)%
      \hex[label=,fill=white](c=2,r=1)%
      \hex[label=,fill=white](c=2,r=0)
    \end{scope}}}
%    \end{macrocode}
%
% Dummy implementations of zones hooks when exporting.  Here, these do
% nothing, but in the \textsf{wgexport} class these are
% re-implemented.
% 
%    \begin{macrocode}
\tikzset{
  zone point/.code n args={3}{},
  zone oob point/.code n args={3}{}}
%    \end{macrocode}
%
% \iffalse
% </chit>
% \fi
