forked from slithy/rpg_module
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathrpg-dcc-stats.sty
180 lines (160 loc) · 4.91 KB
/
rpg-dcc-stats.sty
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
%% rpg-dcc-stats.sty
%
% Dungeon Crawl Classics-style stat blocks for the Role-Playing Game Module class
%
% Copyright 2023 Michael C. Davis
%
% LICENSE FOR THE WORK
%
% This work consists of the following files:
% rpg-module.cls
% rpg-basic-stats.sty
% rpg-basic-stats.def
% rpg-1e-stats.sty
% rpg-1e-stats.def
% rpg-dcc-stats.sty
% rpg-dcc-stats.def
% doc/rpg-module.tex
%
% This work may be distributed and/or modified under the conditions of the LaTeX
% Project Public License, either version 1.3 of this license or (at your option)
% any later version. The latest version of this license can be found at:
% http://www.latex-project.org/lppl.txt
% and version 1.3 or later is part of all distributions of LaTeX version
% 2005/12/01 or later.
%
% This work has the LPPL maintenance status `author-maintained'.
%
% The Author and Maintainer of this work is Michael C. Davis
%
%
% LICENSE FOR COMPILED WORKS
%
% You may distribute compiled works generated using the work as specified in
% Clause 3 of the LaTeX Project Public License. If you incorporate Open Gaming
% Content into the compiled work, you must also comply with the terms of that
% license.
%
%
% USAGE
%
% See the file rpg-module.pdf (source file doc/rpg-module.tex) for documentation.
% There are a number of worked examples in the examples/ directory.
%
% Technical support is provided on GitHub:
%
% https://github.com/slithy/rpg_module
%
% and on the Dragonsfoot Forums:
%
% http://www.dragonsfoot.org/forums/viewtopic.php?f=87&t=73823
\ProvidesPackage{rpg-dcc-stats}[2023/04/11 Dungeon Crawl Classics Stat Blocks for the Role-Playing Game Module class]
% DCC fonts
\RequirePackage{fontspec}
\defaultfontfeatures{Ligatures=TeX}
\newfontfamily\titlefont{DuvallSmallCaps}
\newfontfamily\souvenir{Souvenir SSi}
\newfontfamily\souvenirbold{Souvenir SSi Semi Bold}
\setmainfont{TeX Gyre Pagella}
% PART
\renewcommand{\partname}{AREA}
% Map area macro
\newcommand{\area}[2]{%
{\souvenirbold Area #1 --- #2:}%
\phantomsection\label{area#1}%
}
\newcommand{\arearef}[1]{%
Area \hyperref[area#1]{#1}%
}
\renewcommand{\subsection}[1]{%
{\souvenirbold #1.}%
\phantomsection\label{#1}%
}
% DC spacing macro
\newcommand{\dc}[1]{DC\,#1}
\RequirePackage{tabularx}
% Redefine which environment will be displayed
\includecomment{ifdccstats}
% DCC stat block key-value pairs
\newcommand{\setstatdcc}[2]{%
\ifcase\thecurrentstat
\pgfkeys{/#1/Init/.initial = {#2}}
\or
\pgfkeys{/#1/Atk/.initial = {#2}}
\or
\pgfkeys{/#1/AC/.initial = {#2}}
\or
\pgfkeys{/#1/HD/.initial = {#2}}
\or
\pgfkeys{/#1/MV/.initial = {#2}}
\or
\pgfkeys{/#1/Act/.initial = {#2}}
\or
\pgfkeys{/#1/SP/.initial = {#2}}
\or
\pgfkeys{/#1/CritTable/.initial = {#2}}
\or
\pgfkeys{/#1/CritDie/.initial = {#2}}
\or
\pgfkeys{/#1/Fort/.initial = {#2}}
\or
\pgfkeys{/#1/Ref/.initial = {#2}}
\or
\pgfkeys{/#1/Will/.initial = {#2}}
\or
\pgfkeys{/#1/AL/.initial = {#2}}
\fi
}
% Define monsters using \setstatdcc
\def\scan@stats#1|{%
\ifnum\pdfstrcmp{#1}{\relax}=\z@
\let\next\relax
\else
\setstatdcc{\currentmonster}{#1}\let\next\scan@stats
\stepcounter{currentstat}
\fi\next
}
% Display monster stats inline
%
% Usage: \stats[monster name]{monster key}{no. appearing}{hit points}
\newcommand{\stats}[4][default]{%
\textbf{%
\ifnum\pdfstrcmp{#1}{default}=\z@
\ifnum\pdfstrcmp{#3}{1}=\z@
\pgfkeys{/#2/SingleName}: % Use the generic name defined for this monster (single instance)
\else
\pgfkeys{/#2/PluralName} (#3): % Use the generic name defined for this monster (plural + number appearing)
\fi
\else
#1 % Override the generic name with the optional argument
\fi
}
Init~\pgfkeys{/#2/Init};
Atk~\pgfkeys{/#2/Atk};
AC~\pgfkeys{/#2/AC};
HD~\pgfkeys{/#2/HD};
hp~#4;
MV~\pgfkeys{/#2/MV};
Act~\pgfkeys{/#2/Act};
Crit~\pgfkeys{/#2/CritTable}/\pgfkeys{/#2/CritDie};
SP~\pgfkeys{/#2/SP};
SV Fort~\pgfkeys{/#2/Fort}, Ref~\pgfkeys{/#2/Ref}, Will~\pgfkeys{/#2/Will};
AL~\pgfkeys{/#2/AL}.%
}
% Display monster stats in a stat block
%
% Usage: \statblock[monster name]{monster key}{no. appearing}{hit points}
\newcommand{\statblock}[4][default]{%
\begin{statblockfreestyle}
\stats[#1]{#2}{#3}{#4}
\end{statblockfreestyle}
}
% A few special macros for stat blocks
\newcommand\x{$\times$} % Text-mode multiplication symbol
\newcommand\minus{$-$} % Text-mode minus sign
\newcommand{\?}{\discretionary{/}{}{/}} % Breaking slash
\newcommand{\+}{\discretionary{\,+}{}{\,+\,}} % Breaking + with 1/6 em space either side
%
% Load pre-defined monster stats
%
\input{rpg-dcc-stats.def}