![]() |
Gamedev Framework (gf) 1.2.0
A C++17 framework for 2D games
|
A set of dice that can be rolled. More...
#include <gf/Dice.h>
Public Member Functions | |
constexpr | Dice (int faces, int count=1, int modifier=0) |
Constructor. More... | |
constexpr | Dice (std::string_view str) |
Constructor. More... | |
constexpr int | getFaces () const |
Get the number of faces. More... | |
constexpr int | getCount () const |
Get the count of dice. More... | |
constexpr int | getModifier () const |
Get the modifier. More... | |
int | roll (gf::Random &random) const |
Roll the dice. More... | |
Related Functions | |
(Note that these are not member functions.) | |
constexpr gf::Dice | operator""_dice (const char *str, std::size_t sz) |
User defined operator for creating dice with common dice notation. More... | |
constexpr gf::Dice | operator""_d4 (unsigned long long int count) |
User defined operator for creating some d4. More... | |
constexpr gf::Dice | operator""_d6 (unsigned long long int count) |
User defined operator for creating some d6. More... | |
constexpr gf::Dice | operator""_d8 (unsigned long long int count) |
User defined operator for creating some d6. More... | |
constexpr gf::Dice | operator""_d10 (unsigned long long int count) |
User defined operator for creating some d10. More... | |
constexpr gf::Dice | operator""_d12 (unsigned long long int count) |
User defined operator for creating some d12. More... | |
constexpr gf::Dice | operator""_d20 (unsigned long long int count) |
User defined operator for creating some d20. More... | |
constexpr gf::Dice | operator""_d100 (unsigned long long int count) |
User defined operator for creating some d100. More... | |
A set of dice that can be rolled.
The set of dice is composed of several dice with the same number of faces. After a roll a modifier can be added to the sum.
|
inlineexplicitconstexpr |
Constructor.
With this constructor, you can set the number of faces, the count of dice and the modifier directly.
faces | The number of faces of each dice |
count | The count of dice |
modifier | The modifier to apply after a roll |
|
inlineconstexpr |
Constructor.
str | The string representing a dice notation |
|
inlineconstexpr |
Get the count of dice.
|
inlineconstexpr |
Get the number of faces.
|
inlineconstexpr |
Get the modifier.
int gf::Dice::roll | ( | gf::Random & | random | ) | const |
Roll the dice.
|
related |
User defined operator for creating some d10.
|
related |
User defined operator for creating some d100.
|
related |
User defined operator for creating some d12.
|
related |
User defined operator for creating some d20.
|
related |
User defined operator for creating some d4.
|
related |
User defined operator for creating some d6.
|
related |
User defined operator for creating some d6.
|
related |
User defined operator for creating dice with common dice notation.
The notation is the classical \( XdY+Z \) where \( X \) is the count of dice (1 if omitted), \( Y \) is the number of faces (mandatory), \( Z \) is the modifier (0 if omitted).