]>
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 | |
9 | namespace GameServ \r | |
10 | { \r | |
11 | namespace Types\r | |
12 | {\r | |
2a8a990d | 13 | \r |
14 | //! Holds the exceptions related to types and their conversions\r | |
15 | namespace Exceptions\r | |
16 | {\r | |
17 | //! Generic type exception possibly due to conversion or improper usage\r | |
18 | class TypeException : public GameServException\r | |
19 | {\r | |
20 | public:\r | |
21 | TypeException(const string &ErrorMsg, const char *pFilename, int SourceLine);\r | |
22 | TypeException(const string &ErrorMsg);\r | |
23 | TypeException(void);\r | |
24 | };\r | |
e0d3cb09 | 25 | }\r |
26 | \r | |
27 | class ItemTypes\r | |
28 | {\r | |
29 | public:\r | |
30 | //! Logical ItemType enumerator\r | |
31 | enum ItemType \r | |
32 | { \r | |
33 | Weapon, Armor, Potion, NOTYPE\r | |
34 | };\r | |
35 | \r | |
36 | //! Get the name of an item type\r | |
37 | static string GetName(ItemType itemtype);\r | |
38 | \r | |
39 | //! Parse the name and return the enumeration value\r | |
40 | static ItemType Parse(const string &itemtype);\r | |
41 | \r | |
42 | private:\r | |
43 | //! Internal struct to hold type information statically in a table\r | |
44 | typedef struct itemtypeinfo\r | |
45 | {\r | |
46 | ItemTypes::ItemType itemtype; //!< The ItemType enumeration value\r | |
cce88913 | 47 | string name; //!< The Name of the type\r |
e0d3cb09 | 48 | } itemtypeinfo;\r |
49 | \r | |
50 | static const itemtypeinfo mItemTypeInfoTable[];\r | |
51 | \r | |
52 | }; // ItemTypes class\r | |
cce88913 | 53 | \r |
1134c368 | 54 | class ObjectTypes\r |
55 | {\r | |
56 | public:\r | |
57 | //! Logical ObjectType enumerator\r | |
58 | enum ObjectType \r | |
59 | { \r | |
60 | Player, Item, Level, Master, Monster\r | |
61 | };\r | |
62 | \r | |
63 | //! Get the name of an object type\r | |
64 | static string GetName(ObjectType objecttype);\r | |
65 | \r | |
66 | //! Parse the name and return the enumeration value\r | |
67 | static ObjectType Parse(const string &objecttype);\r | |
68 | \r | |
69 | private:\r | |
70 | //! Internal struct to hold type information statically in a table\r | |
71 | typedef struct objecttypeinfo\r | |
72 | {\r | |
73 | ObjectTypes::ObjectType objecttype; //!< The ObjectType enumeration value\r | |
74 | string name; //!< The Name of the type\r | |
75 | } objecttypeinfo;\r | |
76 | \r | |
77 | static const objecttypeinfo mObjectTypeInfoTable[];\r | |
78 | \r | |
79 | }; // ObjectTypes class\r | |
80 | \r | |
cce88913 | 81 | class Modifiers\r |
82 | {\r | |
83 | public:\r | |
84 | //! Logical Modifer enumerator\r | |
85 | enum Modifier\r | |
86 | {\r | |
23f6e925 | 87 | strength, defense, maxhealth, health, forestfights, playerfights, gold, bank\r |
cce88913 | 88 | };\r |
89 | \r | |
90 | //! Get the name of a modifier\r | |
91 | static string GetName(Modifier modifier);\r | |
92 | \r | |
93 | //! Parse the name and return the modifier enumeration value\r | |
94 | static Modifier Parse(const string &modifier);\r | |
95 | private:\r | |
96 | typedef struct modifierinfo\r | |
97 | {\r | |
98 | Modifiers::Modifier modifier; //!< The modifier enumeration value\r | |
99 | string name; //!< The name of the modifier\r | |
100 | } modifierinfo;\r | |
101 | static const modifierinfo mModifierInfoTable[];\r | |
102 | }; // Modifiers class\r | |
3d5a42ee | 103 | \r |
104 | class Range\r | |
105 | {\r | |
106 | public:\r | |
8e6e952d | 107 | Range();\r |
16655a31 | 108 | Range(const int &high, const int &low);\r |
3d5a42ee | 109 | ~Range();\r |
110 | \r | |
111 | //! Generate a random number within the range\r | |
16655a31 | 112 | int Random();\r |
3d5a42ee | 113 | \r |
114 | //! Property get - High\r | |
16655a31 | 115 | int High(void) const;\r |
3d5a42ee | 116 | \r |
117 | //! Property set - High\r | |
16655a31 | 118 | void High(const int &value);\r |
3d5a42ee | 119 | \r |
120 | //! Property get - Low\r | |
16655a31 | 121 | int Low(void) const;\r |
3d5a42ee | 122 | \r |
123 | //! Property set - Low\r | |
16655a31 | 124 | void Low(const int &value);\r |
1134c368 | 125 | \r |
126 | //! Property get - Last random number to be generated\r | |
127 | int LastRandom(void) const;\r | |
3d5a42ee | 128 | \r |
129 | private:\r | |
16655a31 | 130 | int mHigh;\r |
131 | int mLow;\r | |
1134c368 | 132 | int mLastRandom;\r |
3d5a42ee | 133 | };\r |
cce88913 | 134 | } \r |
e0d3cb09 | 135 | }\r |
136 | #endif |