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

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


\newcommand\rations{%
  \ifcase\value{treasure}\relax%
  \or%
    smoked ham%
  \or%
    dried fruits%
  \or%
    auroch tongue%
  \or%
    carrot-biscuits%
  \or%
    sack of oats%
  \or%
    stinky cheese%
  \or%
    honey-walnut cake%
  \or%
    lisk-strips%
  \or%
    flaggon o' porry%
  \or%
    goat cheese%
  \else%
    \setcounter{treasure}{0}%
    rye bread%
  \fi%
  \stepcounter{treasure}%
}%

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

\newcommand{\lootGoblin}{%
  \ifnum\value{goblinLoot}>20%
    \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, dark, humanoid hair%
  \or%
    rotten mushrooms%
  \or%
    tiny brass bell%
  \or%
    flask of lantern oil%
  \or%
    leather pouch filled with colorful egg shells%
  \or%
    small torch%
  \or%
    small shaker filled with dried beans%
  \or%
    tobacco pipe%
  \or%
    \arabic{r2t3}~sacks%
  \or%
    a horse's tail%
  \or%
    lump of clay with an ex-lover's bitemarks%
  \or%
    20' of rope%
  \or%
    polished sphere of snow-white quartz%
  \or%
    tinder box%
  \or%
    ratking shaul%
  \or%
    empty~sack%
  \or%
    bag of 4 rocks%
  \or%
    lock-picking set%
  \or%
    1~\gls{gp} from the far \ifodd\value{r2}West (looks like a map)\else East (face looks like \ifodd\value{r4b} an elf\else a gnoll\fi?)\fi%
  \else%
    empty wine bottle filled with dead spiders%
  \fi%
}

\newcommand\goblinLight{%
  \ifcase\value{r3}\relax%
  \or%
    glowing belly from eating \glsfmtplural{glowshroom}%
  \or%
    shroom-candle%
  \else%
    fat candle%
  \fi%
}

\newcommand{\lootSmall}{%
	\iftoggle{genExamples}{%
		\ifodd\value{r2}%
			$3D6$\else$2D6$%
		\fi~\glspl{cp}}{%
      \randomize%
      \arabic{r12}~\glspl{cp}%
  }%
}

\newcommand{\lootMedium}{%
	\iftoggle{genExamples}{%
		\ifodd\value{r2}%
			$3D6$%
		\else%
			$2D6$%
		\fi~\glspl{sp}}{%
    \randomize%
		\setcounter{gold}{\value{r12}}%
    \multiply\value{gold} by 3 \arabic{gold}~\glspl{sp}}%
}

\newcommand{\lootBig}{%
  \iftoggle{genExamples}{%
      $3D6-2$~\glspl{gp}%
    }{%
      \randomize\addtocounter{r12}{8}%
      \arabic{r12}\glspl{gp}%
    }%
}

\newcommand{\lootTalisman}{%
  \iftoggle{genExamples}{}%
    {%
      \ifcase\value{treasure}\relax%
      \or%
        \scrollOfFriendship%
      \or%
        \verdantBerries%
      \or%
        \oceanPhial%
      \or%
        \wotWosFungus%
      \or%
        \hagFinger%
      \or%
        \safetyScroll%
      \or%
        \minersWeed%
      \else%
        \bloodCandle%
        \setcounter{treasure}{0}%
      \fi%
      \ignorespaces\spellName%
      \setcounter{track}{\value{treasure}}%
      \stepcounter{treasure}%
    }%
}

\newcommand{\lootMagic}{%
  \iftoggle{genExamples}{%
    elemental \glsentrytext{boon}%
    }%
    {%
      \ifnum\value{diceNo2}>10\setcounter{diceNo2}{1}\fi%
      \ifcase\value{diceNo2}\relax%
        auroch hooves%
      \or%1
        sack of griffin feathers%
      \or%2
        marching mushrooms%
      \or%3
        Earth \gls{boon}%
      \or%4
        Air \gls{boon}%
      \or%5
        stirge queen in a phial%
      \or%6
        woodspy beak%
      \or%7
        Fire \gls{boon}%
      \or%8
        Water \gls{boon}%
      \else%9
        Fate \gls{boon}%
      \fi%
      \stepcounter{diceNo2}%
    }%
}

\newcommand{\lootJewellery}{%
\iftoggle{genExamples}{jewellery worth~\ifodd\value{r2}$3D6$~\glspl{sp}\else$1D6+2$~\glspl{gp}\fi}%
	{%
    \randomize%
    \stepcounter{treasure}%
    \ifnum\value{treasure}>10\addtocounter{treasure}{-10}\fi%
    \ifcase\value{treasure}\relax%
			golden necklace worth~\arabic{r12}~\glspl{sp}%
    \or%1
			golden ring worth~\arabic{r12}~\glspl{sp}%
    \or%2
      jewel encrusted dagger worth~\arabic{r12}~\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%
  }%
}

