32#ifndef DOXYGEN_SHOULD_SKIP_THIS
55 constexpr explicit Dice(
int faces,
int count = 1,
int modifier = 0)
58 , m_modifier(modifier)
68 constexpr Dice(std::string_view str)
74 std::size_t sz = str.size();
76 while (i < sz &&
'0' <= str[i] && str[i] <=
'9') {
77 m_count = m_count * 10 + (str[i] -
'0');
85 if (str[i] !=
'd' && str[i] !=
'D') {
95 while (i < sz &&
'0' <= str[i] && str[i] <=
'9') {
96 m_faces = m_faces * 10 + (str[i] -
'0');
110 while (i < sz &&
'0' <= str[i] && str[i] <=
'9') {
111 m_modifier = m_modifier * 10 + (str[i] -
'0');
169 constexpr gf::Dice operator"" _dice(
const char *str, std::size_t sz) {
170 return gf::Dice(std::string_view(str, sz));
179 constexpr gf::Dice operator"" _d4(
unsigned long long int count) {
180 assert(count <= INT_MAX);
181 return gf::Dice(4,
static_cast<int>(count));
190 constexpr gf::Dice operator"" _d6(
unsigned long long int count) {
191 assert(count <= INT_MAX);
192 return gf::Dice(6,
static_cast<int>(count));
201 constexpr gf::Dice operator"" _d8(
unsigned long long int count) {
202 assert(count <= INT_MAX);
203 return gf::Dice(8,
static_cast<int>(count));
212 constexpr gf::Dice operator"" _d10(
unsigned long long int count) {
213 assert(count <= INT_MAX);
214 return gf::Dice(10,
static_cast<int>(count));
223 constexpr gf::Dice operator"" _d12(
unsigned long long int count) {
224 assert(count <= INT_MAX);
225 return gf::Dice(12,
static_cast<int>(count));
234 constexpr gf::Dice operator"" _d20(
unsigned long long int count) {
235 assert(count <= INT_MAX);
236 return gf::Dice(20,
static_cast<int>(count));
245 constexpr gf::Dice operator"" _d100(
unsigned long long int count) {
246 assert(count <= INT_MAX);
247 return gf::Dice(100,
static_cast<int>(count));
251#ifndef DOXYGEN_SHOULD_SKIP_THIS
A set of dice that can be rolled.
Definition: Dice.h:43
constexpr int getModifier() const
Get the modifier.
Definition: Dice.h:139
int roll(gf::Random &random) const
Roll the dice.
constexpr Dice(std::string_view str)
Constructor.
Definition: Dice.h:68
constexpr int getCount() const
Get the count of dice.
Definition: Dice.h:130
constexpr int getFaces() const
Get the number of faces.
Definition: Dice.h:121
constexpr Dice(int faces, int count=1, int modifier=0)
Constructor.
Definition: Dice.h:55
A set of random utilities.
Definition: Random.h:83
The namespace for gf classes.