]>
Commit | Line | Data |
---|---|---|
e0d3cb09 | 1 | #ifndef __GS__TYPES_H__\r |
2 | #define __GS__TYPES_H__\r | |
3 | \r | |
4 | #include <string>\r | |
5 | using std::string;\r | |
6 | #include <GameServ/GameServException.h>\r | |
7 | using GameServ::Exceptions::GameServException;\r | |
8 | \r | |
3d5a42ee | 9 | \r |
10 | #include <boost/random/linear_congruential.hpp>\r | |
11 | #include <boost/random/uniform_int.hpp>\r | |
12 | #include <boost/random/uniform_real.hpp>\r | |
13 | #include <boost/random/variate_generator.hpp>\r | |
14 | \r | |
15 | // This is a typedef for a random number generator.\r | |
16 | // Try boost::mt19937 or boost::ecuyer1988 instead of boost::minstd_rand\r | |
17 | typedef boost::minstd_rand base_generator_type;\r | |
18 | \r | |
e0d3cb09 | 19 | namespace GameServ \r |
20 | { \r | |
21 | namespace Types\r | |
22 | {\r | |
2a8a990d | 23 | \r |
24 | //! Holds the exceptions related to types and their conversions\r | |
25 | namespace Exceptions\r | |
26 | {\r | |
27 | //! Generic type exception possibly due to conversion or improper usage\r | |
28 | class TypeException : public GameServException\r | |
29 | {\r | |
30 | public:\r | |
31 | TypeException(const string &ErrorMsg, const char *pFilename, int SourceLine);\r | |
32 | TypeException(const string &ErrorMsg);\r | |
33 | TypeException(void);\r | |
34 | };\r | |
e0d3cb09 | 35 | }\r |
36 | \r | |
37 | class ItemTypes\r | |
38 | {\r | |
39 | public:\r | |
40 | //! Logical ItemType enumerator\r | |
41 | enum ItemType \r | |
42 | { \r | |
43 | Weapon, Armor, Potion, NOTYPE\r | |
44 | };\r | |
45 | \r | |
46 | //! Get the name of an item type\r | |
47 | static string GetName(ItemType itemtype);\r | |
48 | \r | |
49 | //! Parse the name and return the enumeration value\r | |
50 | static ItemType Parse(const string &itemtype);\r | |
51 | \r | |
52 | private:\r | |
53 | //! Internal struct to hold type information statically in a table\r | |
54 | typedef struct itemtypeinfo\r | |
55 | {\r | |
56 | ItemTypes::ItemType itemtype; //!< The ItemType enumeration value\r | |
cce88913 | 57 | string name; //!< The Name of the type\r |
e0d3cb09 | 58 | } itemtypeinfo;\r |
59 | \r | |
60 | static const itemtypeinfo mItemTypeInfoTable[];\r | |
61 | \r | |
62 | }; // ItemTypes class\r | |
cce88913 | 63 | \r |
64 | class Modifiers\r | |
65 | {\r | |
66 | public:\r | |
67 | //! Logical Modifer enumerator\r | |
68 | enum Modifier\r | |
69 | {\r | |
23f6e925 | 70 | strength, defense, maxhealth, health, forestfights, playerfights, gold, bank\r |
cce88913 | 71 | };\r |
72 | \r | |
73 | //! Get the name of a modifier\r | |
74 | static string GetName(Modifier modifier);\r | |
75 | \r | |
76 | //! Parse the name and return the modifier enumeration value\r | |
77 | static Modifier Parse(const string &modifier);\r | |
78 | private:\r | |
79 | typedef struct modifierinfo\r | |
80 | {\r | |
81 | Modifiers::Modifier modifier; //!< The modifier enumeration value\r | |
82 | string name; //!< The name of the modifier\r | |
83 | } modifierinfo;\r | |
84 | static const modifierinfo mModifierInfoTable[];\r | |
85 | }; // Modifiers class\r | |
3d5a42ee | 86 | \r |
87 | class Range\r | |
88 | {\r | |
89 | public:\r | |
90 | Range(const unsigned int &high, const unsigned int &low);\r | |
91 | ~Range();\r | |
92 | \r | |
93 | //! Generate a random number within the range\r | |
94 | unsigned int Random();\r | |
95 | \r | |
96 | //! Property get - High\r | |
97 | unsigned int High(void) const;\r | |
98 | \r | |
99 | //! Property set - High\r | |
100 | void High(const unsigned int &value);\r | |
101 | \r | |
102 | //! Property get - Low\r | |
103 | unsigned int Low(void) const;\r | |
104 | \r | |
105 | //! Property set - Low\r | |
106 | void Low(const unsigned int &value);\r | |
107 | \r | |
108 | private:\r | |
109 | unsigned int mHigh;\r | |
110 | unsigned int mLow;\r | |
111 | base_generator_type generator;\r | |
112 | };\r | |
cce88913 | 113 | } \r |
e0d3cb09 | 114 | }\r |
115 | #endif |