-
Notifications
You must be signed in to change notification settings - Fork 30
/
dice.h
59 lines (45 loc) · 985 Bytes
/
dice.h
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
#ifndef _DICE_H_
#define _DICE_H_
#include <istream>
#include <string>
#include <vector>
struct Dice
{
int number;
int sides;
int bonus;
bool negative; // Used in others; if true, we SUBTRACT this!
std::vector<Dice> others;
Dice(int N = 0, int S = 1, int B = 0, bool G = false);
~Dice() { }
int roll();
Dice base() const; // Strip off all others
Dice& operator= (const Dice& rhs);
Dice& operator+=(const Dice& rhs);
Dice& operator-=(const Dice& rhs);
Dice& operator+=(const int& rhs);
Dice& operator-=(const int& rhs);
std::string str();
bool load_data(std::istream &data, std::string owner = "Unknown");
};
inline Dice operator+(Dice lhs, const Dice& rhs)
{
lhs += rhs;
return lhs;
}
inline Dice operator-(Dice lhs, const Dice& rhs)
{
lhs -= rhs;
return lhs;
}
inline Dice operator-(Dice lhs, const int& rhs)
{
lhs -= rhs;
return lhs;
}
inline Dice operator+(Dice lhs, const int& rhs)
{
lhs += rhs;
return lhs;
}
#endif