\documentclass[letterpaper,twocolumn,openany,nodeprecatedcode]{rpgbook}

% Use babel or polyglossia to automatically redefine macros for terms
% Armor Class, Level, etc...
% Default output is in English; captions are located in lib/rpgstrings.sty.
% If no captions exist for a language, English will be used.
%1. To load a language with babel:
%	\usepackage[<lang>]{babel}
%2. To load a language with polyglossia:
%	\usepackage{polyglossia}
%	\setdefaultlanguage{<lang>}
\usepackage[english]{babel}
%\usepackage[italian]{babel}
% For further options (multilanguage documents, hypenations, language environments...)
% please refer to babel/polyglossia's documentation.

\usepackage[utf8]{inputenc}
\usepackage[singlelinecheck=false]{caption}
\usepackage{lipsum}
\usepackage{listings}
\usepackage{shortvrb}
\usepackage{stfloats}

\captionsetup[table]{labelformat=empty,font={sf,sc,bf,},skip=0pt}

\MakeShortVerb{|}

\lstset{%
  basicstyle=\ttfamily,
  language=[LaTeX]{TeX},
  breaklines=true,
}

\title{The Dark \LaTeX{} \\
\large An Example of the rpgbook Class}
\author{The rpgTeX Team}
\date{2020/04/21}

\begin{document}

\frontmatter

\maketitle

\tableofcontents

\mainmatter%

\part{Layout}

\chapter{Sections}

\RpgDropCapLine{T}{his package is designed to aid you in} writing beautifully typeset documents for the fifth edition of the world's greatest roleplaying game. It starts by adjusting the section formatting from the defaults in \LaTeX{} to something a bit more familiar to the reader. The chapter formatting is displayed above.

\section{Section}
Sections break up chapters into large groups of associated text.

\subsection{Subsection}
Subsections further break down the information for the reader.

\subsubsection{Subsubsection}
Subsubsections are the furthest division of text that still have a block header. Below this level, headers are displayed inline.

\paragraph{Paragraph}
The paragraph format is seldom used in the core books, but is available if you prefer it to the ``normal'' style.

\subparagraph{Subparagraph}
The subparagraph format with the paragraph indent is likely going to be more familiar to the reader.

\section{Special Sections}
The module also includes functions to aid in the proper typesetting of multi-line section headers: |\RpgFeatHeader| for feats, |\RpgItemHeader| magic items and traps, and |\RpgSpellHeader| for spells.

\RpgFeatHeader{Typesetting Savant}[Prerequisite: \LaTeX{} distribution]
You have acquired a package which aids in typesetting source material for one of your favorite games, giving you the following benefits:

\begin{itemize}
  \item You have advantage on Intelligence checks to typeset new content.
  \item When you fail an Intelligence check to typeset new content, you can ask questions online at the package's website.
\end{itemize}

\RpgItemHeader{Foo's Quill}{Wondrous item, rare}
This quill has 3 charges. While holding it, you can use an action to expend 1 of its charges. The quill leaps from your hand and writes a contract applicable to your situation.

The quill regains 1d3 expended charges daily at dawn.

\RpgSpellHeader%
  {Beautiful Typesetting}
  {4th-level illusion}
  {1 action}
  {5 feet}
  {S, M (ink and parchment, which the spell consumes)}
  {Until dispelled}
You are able to transform a written message of any length into a beautiful scroll. All creatures within range that can see the scroll must make a wisdom saving throw or be charmed by you until the spell ends.

While the creature is charmed by you, they cannot take their eyes off the scroll and cannot willingly move away from the scroll. Also, the targets can make a wisdom saving throw at the end of each of their turns. On a success, they are no longer charmed.

\section{Map Regions}
The map region functions |\RpgArea| and |\RpgSubArea| provide automatic numbering of areas.

\RpgArea{Village of Hommlet}
This is the village of hommlet.

\RpgSubArea{Inn of the Welcome Wench}
Inside the village is the inn of the Welcome Wench.

\RpgSubArea{Blacksmith's Forge}
There's a blacksmith in town, too.

\RpgArea{Foo's Castle}
This is foo's home, a hovel of mud and sticks.

\RpgSubArea{Moat}
This ditch has a board spanning it.

\RpgSubArea{Entrance}
A five-foot hole reveals the dirt floor illuminated by a hole in the roof.

\chapter{Text Boxes}

The module has three environments for setting text apart so that it is drawn to the reader's attention. |RpgReadAloud| is used for text that a game master would read aloud.

\begin{RpgReadAloud}
  As you approach this module you get a sense that the blood and tears of many generations went into its making. A warm feeling welcomes you as you type your first words.
\end{RpgReadAloud}

\section{As an Aside}
The other two environments are the |RpgComment| and the |RpgSidebar|. The |RpgComment| is breakable and can safely be used inline in the text.

\begin{RpgComment}{This Is a Comment Box!}
  A |RpgComment| is a box for minimal highlighting of text. It lacks the ornamentation of |RpgSidebar|, but it can handle being broken over a column.
\end{RpgComment}

The |RpgSidebar| is not breakable and is best used floated toward a page corner as it is below.

\begin{RpgSidebar}[float=!b]{Behold the RpgSidebar!}
  The |RpgSidebar| is used as a sidebar. It does not break over columns and is best used with a figure environment to float it to one corner of the page where the surrounding text can then flow around it.
\end{RpgSidebar}

\section{Tables}
The |RpgTable| colors the even rows and is set to the width of a line by default.

\begin{RpgTable}[header=Nice Table]{XX}
    Table head  & Table head \\
    Some value  & Some value \\
    Some value  & Some value \\
    Some value  & Some value
\end{RpgTable}

\chapter{Monsters and NPCs}

% Monster stat block
\begin{RpgMonster}[float*=b,width=\textwidth + 8pt]{Monster Foo}
  \begin{multicols}{2}
    \RpgMonsterType{Medium aberration (metasyntactic variable), neutral evil}

    % If you want to use commas in the key values, enclose the values in braces.
    \RpgMonsterBasics[
        armor-class = {9 (12 with \emph{mage armor})},
        hit-points  = {\RpgDice{3d8 + 3}},
        speed       = {30 ft., fly 30 ft.},
      ]

    \RpgMonsterAbilityScores[
        str = 12,
        dex = 8,
        con = 13,
        int = 10,
        wis = 14,
        cha = 15,
      ]

    \RpgMonsterDetails[
        %saving-throws = {Str +0, Dex +0, Con +0, Int +0, Wis +0, Cha +0},
        %skills = {Acrobatics +0, Animal Handling +0, Arcana +0, Athletics +0, Deception +0, History +0, Insight +0, Intimidation +0, Investigation +0, Medicine +0, Nature +0, Perception +0, Performance +0, Persuasion +0, Religion +0, Sleight of Hand +0, Stealth +0, Survival +0},
        %damage-vulnerabilities = {cold},
        %damage-resistances = {bludgeoning, piercing, and slashing from nonmagical attacks},
        %damage-immunities = {poison},
        %condition-immunities = {poisoned},
        senses = {darkvision 60 ft., passive Perception 10},
        languages = {Common, Goblin, Undercommon},
        challenge = 1,
        proficiency-bonus, % = +2
      ]
    % Traits
    \RpgMonsterAction{Innate Spellcasting}
    Foo's spellcasting ability is Charisma (spell save DC 12, +4 to hit with spell attacks). It can innately cast the following spells, requiring no material components:
    \begin{RpgMonsterSpells}
      \RpgInnateSpellLevel{misty step}
      \RpgInnateSpellLevel[3]{fog cloud, rope trick}
      \RpgInnateSpellLevel[1]{identify}
    \end{RpgMonsterSpells}

    \RpgMonsterAction{Spellcasting}
    Foo is a 2nd-level spellcaster. Its spellcasting ability is Charisma (spell save DC 12, +4 to hit with spell attacks). It has the following sorcerer spells prepared:
    \begin{RpgMonsterSpells}
      \RpgMonsterSpellLevel{blade ward, fire bolt, light, shocking grasp}
      \RpgMonsterSpellLevel[1][3]{burning hands, mage armor, shield}
    \end{RpgMonsterSpells}

    \RpgMonsterSection{Actions}
    \RpgMonsterAction{Multiattack}
    The foo makes two melee attacks.

    %Default values are shown commented out
    \RpgMonsterAttack[
      name=Dagger,
      %distance=both, % valid options are in the set {both,melee,ranged},
      %type=weapon, %valid options are in the set {weapon,spell}
      mod=+3,
      %reach=5,
      %range=20/60,
      %targets=one target,
      dmg=\RpgDice{1d4+1},
      dmg-type=piercing,
      %plus-dmg=,
      %plus-dmg-type=,
      %or-dmg=,
      %or-dmg-when=,
      %extra=,
    ]

    %\RpgMonsterMelee calls \RpgMonsterAttack with the melee option
    \RpgMonsterMelee[
      name=Flame Tongue Longsword,
      mod=+3,
      %reach=5,
      %targets=one target,
      dmg=\RpgDice{1d8+1},
      dmg-type=slashing,
      plus-dmg=\RpgDice{2d6},
      plus-dmg-type=fire,
      or-dmg=\RpgDice{1d10+1},
      or-dmg-when=if used with two hands,
      %extra=,
    ]

    %\RpgMonsterRanged calls \RpgMonsterAttack with the ranged option
    \RpgMonsterRanged[
      name=Assassin's Light Crossbow,
      mod=+1,
      range=80/320,
      dmg=\RpgDice{1d8},
      dmg-type=piercing,
      %plus-dmg=,
      %plus-dmg-type=,
      %or-dmg=,
      %or-dmg-when=,
      extra={, and the target must make a DC 15 Constitution saving throw, taking 24 (7d6) poison damage on a failed save, or half as much damage on a successful one}
    ]

    % Legendary Actions
    \RpgMonsterSection{Legendary Actions}
    The foo can take 3 legendary actions, choosing from the options below. Only one legendary action option can be used at a time and only at the end of another creature's turn. The foo regains spent legendary actions at the start of its turn.

    \begin{RpgMonsterLegendaryActions}
      \RpgMonsterLegendaryAction{Move}{The foo moves up to its speed.}
      \RpgMonsterLegendaryAction{Dagger Attack}{The foo makes a dagger attack.}
      \RpgMonsterLegendaryAction{Create Contract (Costs 3 Actions)}{The foo presents a contract in a language it knows and waves it in the face of a creature within 10 feet. The creature must make a DC 10 Intelligence saving throw. On a failure, the creature is incapacitated until the start of the foo's next turn. A creature who cannot read the language in which the contract is written has advantage on this saving throw.}
    \end{RpgMonsterLegendaryActions}
  \end{multicols}
\end{RpgMonster}

The |RpgMonster| environment is used to typeset monster and NPC stat blocks. The module supplies many functions to easily typeset the contents of the stat block

\part{Customization}

\chapter{Colors}

\begin{table*}[b]
  \caption{\RpgFontTableTitle{}Colors Supported by this Package}\label{tab:colors}

  \begin{tabularx}{\linewidth}{lX}
    \textbf{Color}                  & \textbf{Description} \\
    \rowcolor{PhbLightGreen}
    |PhbLightGreen|                 & Light green used in PHB Part 1 (Default) \\
    \rowcolor{PhbLightCyan}
    |PhbLightCyan|                  & Light cyan used in PHB Part 2 \\
    \rowcolor{PhbMauve}
    |PhbMauve|                      & Pale purple used in PHB Part 3 \\
    \rowcolor{PhbTan}
    |PhbTan|                        & Light brown used in PHB appendix \\
    \rowcolor{DmgLavender}
    |DmgLavender|                   & Pale purple used in DMG Part 1 \\
    \rowcolor{DmgCoral}
    |DmgCoral|                      & Orange-pink used in DMG Part 2 \\
    \rowcolor{DmgSlateGray}
    |DmgSlateGray| (|DmgSlateGrey|) & Blue-gray used in PHB Part 3 \\
    \rowcolor{DmgLilac}
    |DmgLilac|                      & Purple-gray used in DMG appendix \\
    \rowcolor{BrGreen}
    |BrGreen|                       & Gray-green used for tables in Basic Rules\\
  \end{tabularx}
\end{table*}

This package provides several global color variables to style |RpgComment|, |RpgReadAloud|, |RpgSidebar|, and |RpgTable| environments.

\begin{RpgTable}[header=Box Colors]{lX}
  Color            &  Description \\
  |commentcolor|   & |RpgComment| background \\
  |readaloudcolor| & |RpgReadAloud| background \\
  |sidebarcolor|   & |RpgSidebar| background \\
  |tablecolor|     & background of even |RpgTable| rows \\
\end{RpgTable}

They also accept an optional color argument to set the color for a single instance. See Table~\ref{tab:colors} for a list of core book accent colors.

\begin{lstlisting}
\begin{RpgTable}[color=PhbLightCyan]{cX}
  d8 & Item \\
  1  & Small wooden button \\
  2  & Red feather \\
  3  & Human tooth \\
  4  & Vial of green liquid \\
  5  & Loaded dice \\
  6  & Tasty biscuit \\
  7  & Broken axe handle \\
  8  & Tarnished silver locket \\
\end{RpgTable}
\end{lstlisting}

\begin{RpgTable}[color=PhbLightCyan]{cX}
  d8 & Item \\
  1  & Small wooden button \\
  2  & Red feather \\
  3  & Human tooth \\
  4  & Vial of green liquid \\
  5  & Loaded dice \\
  6  & Tasty biscuit \\
  7  & Broken axe handle \\
  8  & Tarnished silver locket \\
\end{RpgTable}

\section{Themed Colors}
Use |\RpgSetThemeColor[<color>]| to set |commentcolor|, |readaloudcolor|, |sidebarcolor|, and |tablecolor| to a specific color. Calling |\RpgSetThemeColor| without an argument sets those colors to the current |themecolor|. In the following example the group limits the change to just a few boxes; after the group finishes, the colors are reverted to what they were before the group started.

\begin{lstlisting}
\begingroup
\RpgSetThemeColor[PhbMauve]

\begin{RpgComment}{This Comment Is in Mauve}
  This comment is in the the new color.
\end{RpgComment}

\begin{RpgSidebar}{This Sidebar Is Also Mauve}
  The sidebar is also using the new theme color.
\end{RpgSidebar}
\endgroup
\end{lstlisting}

\begingroup
\RpgSetThemeColor[PhbMauve]

\begin{RpgComment}{This Comment Is in Mauve}
  This comment is in the the new color.
\end{RpgComment}

\begin{RpgSidebar}{This Sidebar Is Also Mauve}
  The sidebar is also using the new theme color.
\end{RpgSidebar}
\endgroup

\end{document}
