\ProvidesPackage{config/loot}
\newcounter{treasure}
\setcounter{treasure}{\month}

%%%%%%%%%%%%%%%%%%%% LOOT %%%%%%%%%%%%%%%%%%%%

\newcounter{goblinLoot}
\setcounter{goblinLoot}{\value{r4}}

\newcommand{\lootGoblin}{%
  \iftoggle{genExamples}{no loot}%
    {%
      \ifnum\value{goblinLoot}>13%
        \setcounter{goblinLoot}{0}%
      \else%
        \stepcounter{goblinLoot}%
      \fi%
      \ifcase\value{goblinLoot}\relax%
        \stepcounter{r4}%
        tinder box and \arabic{r4} candles%
      \or%
        1 \gls{sp} from the far North%
      \or%
        pouch of long, humanoid hair%
      \or%
        rotten mushrooms%
      \or%
        flask of lantern oil%
      \or%
        leather pouch filled with colorful egg shells%
      \or%
        small torch%
      \or%
        small shaker filled with dried beans%
      \or%
        a horse's tail%
      \or%
        lump of clay with an ex-lover's bitemarks%
      \or%
        polished sphere of snow-white quartz%
      \or%
        tinder box%
      \or%
        ratking shaul%
      \or%
        1 \gls{gp} from the far East%
      \else%
        empty wine bottle filled with dead spiders%
      \fi%
    }%
}

\newcommand{\lootSmall}{%
	\iftoggle{genExamples}{%
		\ifodd\value{r2}%
			$3D6$\else$2D6$%
		\fi \glspl{cp}}{%
		\randomdozen\multiply\value{r12} by \value{r4}\arabic{r12} \glspl{cp}}%
}

\newcommand{\lootMedium}{%
	\iftoggle{genExamples}{%
		\ifodd\value{r2}%
			$3D6$%
		\else%
			$2D6$%
		\fi~\glspl{sp}}{%
		\addtocounter{gold}{\thepage}%
		\divide\value{gold} by \value{r4}%
		\ifnum\value{gold}<4%
			\setcounter{gold}{7}%
		\fi%
		\arabic{gold}~\glspl{sp}}%
}

\newcommand{\lootBig}{%
\iftoggle{genExamples}{%
	\ifodd\thepage $3D6-2$\else$2D6+4$\fi \glspl{gp}}{%
	\randomdozen\addtocounter{r12}{8}\arabic{r12}\glspl{gp}%
	}%
}

\newcommand{\lootMagic}{%
  \iftoggle{verbose}{
    \ifnum\value{noAppearing}>1%
    Mana stone holding 2 MP%
    \else%
    \iftoggle{genExamples}{}%
      {%
        \ifnum\value{treasure}>8\setcounter{treasure}{0}\fi%
        \ifcase\value{treasure}\relax%
          \scrollOfFriendship%
        \or%1
          \bloodCandle%
        \or%2
          \minersWeed%
        \or%3
          \oceanPhial%
        \or%4
          \hagFinger%
        \or%4
          \safetyScroll%
        \or%4
          \snacklet%
        \else%11
          \homeScroll%
        \fi%
        \setcounter{track}{\value{treasure}}%
        \stepcounter{treasure}%
      }%
    \fi%
  }{}
}

\newcommand{\lootJewellery}{%
\iftoggle{genExamples}{jewellery worth \ifodd\value{r2}$3D6$sp\else$1D6+2$\glspl{gp}\fi}%
	{%
    \stepcounter{treasure}%
    \ifnum\value{treasure}>10\setcounter{treasure}{0}\fi%
    \ifcase\value{treasure}\relax%
			golden necklace worth \arabic{r12}~\glspl{sp}%
    \or%1
			golden ring worth \thechapter~\glspl{sp}%
    \or%2
      jewel encrusted dagger worth \thepage~\glspl{sp}%
    \or%3
      ornate silver earrings worth 1 \glspl{gp}%
    \or%4
      gem encrusted broach worth \arabic{r4b} \glspl{gp}
    \or%5
      saphire pendant worth \arabic{r3b}\glspl{gp}%
    \or%6
      gem-encrusted headband, worth \arabic{r4b}~\glspl{gp}%
    \or%7
      gold-looking necklage made from fool's gold (worthless)%
    \or%8
      gem-studded ring, worth \arabic{r12}~\glspl{sp}%
    \or%9
      signet ring, worth \arabic{r2}~\glspl{gp}%
    \else%10
      gem-studded ring, worth \arabic{r12}~\glspl{sp}%
    \fi%
  }%
}