\newcommand{\lineDots}[1][1]{%
  \foreach \n in {1,...,#1}%
    {\leavevmode\cleaders\hb@xt@1.5em{\hss \textcolor{\pageSideColor}{.}\hss }\hfill\kern\z@\par\vspace{1em}\noindent}%
  }

\newcommand\race{}
\newcommand\concept{}
\newcommand\code{}
\newcommand\culture{}
\newcommand\rank{}
\newcommand\characterDebt{}

\newcommand\csComments{}
\newcommand\mapLabels{}

\newcommand\XPboxEmpty{\medcirc}
\newcommand\XPboxEarned{\oslash}
\newcommand\XPboxSpent{\otimes}

\newcounter{Strength}
\newcounter{Dexterity}
\newcounter{Speed}
\newcounter{Intelligence}
\newcounter{Wits}
\newcounter{Charisma}

\newcounter{Academics}
  \setcounter{Academics}{0}
\newcounter{Alchemy}
  \setcounter{Alchemy}{0}
\newcounter{Athletics}
  \setcounter{Athletics}{0}
\newcounter{Caving}
  \setcounter{Caving}{0}
\newcounter{Crafts}
  \setcounter{Crafts}{0}
\newcounter{Cultivation}
  \setcounter{Cultivation}{0}
\newcounter{Deceit}
  \setcounter{Deceit}{0}
\newcounter{Empathy}
  \setcounter{Empathy}{0}
\newcounter{Flight}
  \setcounter{Flight}{0}
\newcounter{Medicine}
  \setcounter{Medicine}{0}
\newcounter{Performance}
  \setcounter{Performance}{0}
\newcounter{Larceny}
  \setcounter{Larceny}{0}
\newcounter{Seafaring}
  \setcounter{Seafaring}{0}
\newcounter{Stealth}
  \setcounter{Stealth}{0}
\newcounter{Survival}
  \setcounter{Survival}{0}
\newcounter{Vigilance}
  \setcounter{Vigilance}{0}
\newcounter{Xenomology}
  \setcounter{Xenomology}{0}

\newcounter{Brawl}
  \setcounter{Brawl}{0}
\newcounter{Melee}
  \setcounter{Melee}{0}
\newcounter{Projectiles}
  \setcounter{Projectiles}{0}
\newcounter{Air}
  \setcounter{Air}{0}
\newcounter{Earth}
  \setcounter{Earth}{0}
\newcounter{Fire}
  \setcounter{Fire}{0}
\newcounter{Water}
  \setcounter{Water}{0}
\newcounter{Fate}
  \setcounter{Fate}{0}
\newcounter{Mind}
  \setcounter{Mind}{0}
\newcounter{Light}
  \setcounter{Light}{0}
\newcounter{Life}
  \setcounter{Life}{0}
\newcounter{Death}
  \setcounter{Death}{0}
\newcounter{Force}
  \setcounter{Force}{0}


\newcommand\characterWeapon{}
\newcommand\characterArmour{}
\newcommand\characterEquipment{}
\newcommand\knackOne{}
\newcommand\knackTwo{}

\newcommand\charSpellList{}
\newcommand\charSpells{}


%%%%% Show Dots Commands %%%%%

\newcounter{statCircles}
\newcounter{statDots}

\newcommand\statCircle[1][\large]{{#1\textbf{\Circle}}}
\newcommand\statDot[1][\large]{#1\textbf{\CIRCLE}}
\newcommand\currentCircle{}
\newcommand{\weeline}{\textcolor{\pageSideColor}{\line(1,0){30} \hspace{.6cm}}}

\newcommand\showAttribute[1]{
  \setcounter{track}{-4}%
  {#1}\qquad~%
  \whileboolexpr{%
    test {\ifnumcomp{\value{track}}{<}{5}}%
  }%
  {%
    &%
    \ifnum\value{track}>0%
      \ifnum\value{track}>\value{#1}%
        \statCircle%
      \else%
        \statDot%
      \fi%
    \else%
      \ifnum\value{track}=0%
        \raisebox{2pt}{\statDot[\footnotesize]}%
      \else%
        \ifnum\value{#1}>\value{track}%
          {\Large\Square}%
        \else%
          {\Large\XBox}%
        \fi%
      \fi%
    \fi%
    \stepcounter{track}%
  }%
  \\%
}

\newcommand{\showDots}[2][3]{%
  \setcounter{statCircles}{#1}%
  \addtocounter{statCircles}{-\value{#2}}%
  \Repeat{\value{#2}}{\statDot}\Repeat{\value{statCircles}}{\statCircle}%
}

\newcommand{\showSkill}[1]{%
  \setcounter{statCircles}{3}%
  \addtocounter{statCircles}{-\value{#1}}%
  #1 \lightDots &%
  \Repeat{\value{#1}}{\statDot}\Repeat{\value{statCircles}}{\statCircle}%
}

\newcommand{\skill}[1]{%
  \showSkill{#1} \\%
  \stepcounter{track}%
}

\newcommand\lightDots{%
  \textcolor{\pageSideColor}{\titlerule*[1pc]{.}}%
}

\newcommand\emptySkill{%
    \lightDots & %
    \Repeat{3}{\statCircle}%
    \\%
}

\newcommand\setXtoLowestOf[3]{%
  \ifnum\value{#2}<\value{#3}%
    \setcounter{#1}{\value{#2}}%
  \else%
    \setcounter{#1}{\value{#3}}%
  \fi%
}

\newcommand\setHighSpheres{%
  \setXtoLowestOf{Mind}{Water}{Fate}%
  \setXtoLowestOf{Death}{Air}{Fate}%
  \setXtoLowestOf{Light}{Air}{Fire}%
  \setXtoLowestOf{Force}{Fire}{Earth}%
  \setXtoLowestOf{Life}{Earth}{Water}%
}

\newcommand\setAgeAndAbilities{
  \setcounter{age}{0}%
  \foreach \x in {Strength,Dexterity,Speed,Intelligence,Wits,Charisma}{%
    \ifnum\value{\x}>0%
      \addtocounter{age}{\value{\x}}%
    \fi%
  }%
  \ifStrSame{\race}{Dwarf}{\addAbility{Tenacity: Half penalties from poison}%
    \multiply\value{age} by 2%
    \addtocounter{age}{30}%
  }{}%
  \ifStrSame{\race}{Elf}{\addAbility{Thermal Apathy: take no \glsentrylongpl{ep} from natural heat variations}%
    \multiply\value{age} by 4%
    \addtocounter{age}{60}%
  }{}%
  \ifStrSame{\race}{Gnoll}{\addAbility{Teeth: grab and grapple in a single manoeuvre}%
    \multiply\value{age} by 2%
    \addtocounter{age}{10}%
  }{}%
  \ifStrSame{\race}{Gnome}{\addAbility{Attentiveness: Roll 2D6+3 for \glsfmtplural{restingaction}}%
    \multiply\value{age} by 4%
    \addtocounter{age}{30}%
  }{}%
  \ifStrSame{\race}{Human}{\addAbility{Marching Legs: each \glsentrylong{ep} spent to march gains an extra~mile}%
    \multiply\value{age} by 4%
    \addtocounter{age}{15}%
  }{}%
}


\newcommand\resetCS{
  \clean
  \renewcommand\knackOne{}
  \renewcommand\knackTwo{}
  \renewcommand\Abilities{}

  \renewcommand\race{}
  \renewcommand\concept{}
  \renewcommand\culture{}
  \renewcommand\rank{}
  \renewcommand\name{}
  \renewcommand\code{}
  \foreach \Att in {Strength, Dexterity, Speed, Intelligence, Wits, Charisma}%
    {\setcounter{\Att}{0}}

  \renewcommand\characterWeapon{}
  \renewcommand\characterArmour{}
  \renewcommand\characterEquipment{}
  \renewcommand\charSpells{}
  \renewcommand\charSpellList{}
}

\newcommand\filledCS[9]{
  \resetCS
  \assignHumanName
  \settoggle{examplecharacter}{true}
  \settoggle{allyCharacter}{true}
  \renewcommand\name{#1}
  \renewcommand\race{#2}
  \renewcommand\concept{#3}
  \renewcommand\code{#4}
  \setAgeAndAbilities
  \traits{}%
    {#5}%
    {#6}%
    {%
      #7
    }%
    {#8}% SKILLS
    {#9}% KNACKS
    {}% ABILITIES
  \colourWheel[r6]
  \input{config/character_sheets/front.tex}
  \iftoggle{allyCharacter}{
    \input{config/character_sheets/back.tex}
  }{}
}

\newcommand\placeCScircle[1]{
  \stepcounter{diceNo}%
  \addtocounter{list}{2}%
  \posterbox[
    blankest,
  ]{name=csCircles,
  column=8,
  row=\arabic{list},
  span=1,
  rowspan=3,
  }{%
    \begin{picture}(50,40)(0,0)
      \put(-20,30){\parbox{11em}{\raggedright#1}}
      \ifnum\value{diceNo}<9%
        \put(-20,0){\parbox{11em}{\lineDots}}
      \fi%
      \put(100,5){\tikz \draw[anchor=north, dotted] (0,0) node[minimum size=21mm,draw,circle] {\textcolor{\ifnum\value{diceNo}>\value{weight}%
        \pageOppositeColor%
      \else%
        \pageSideColor%
      \fi}{\Large\ifnum\value{diceNo}>\value{hp}%
        \stepcounter{diceNo2}%
        --\arabic{diceNo2}%
      \else%
        \Roman{diceNo}%
      \fi}};}
    \end{picture}
  }
}

\newcommand\pencilWriting[1]{%
  \textcolor{lightgray}{\sffamily\slshape#1}%
}