]> jfr.im git - irc/gameservirc.git/blame - gameserv-2.0/libgameservcore/include/GameServ/Types.h
Revisited GameServ 2.0 and got it compiling in VS 2010!
[irc/gameservirc.git] / gameserv-2.0 / libgameservcore / include / GameServ / Types.h
CommitLineData
e0d3cb09 1#ifndef __GS__TYPES_H__\r
2#define __GS__TYPES_H__\r
3\r
33ae7ca7 4#include <ctime>\r
e0d3cb09 5#include <string>\r
6using std::string;\r
7#include <GameServ/GameServException.h>\r
8using GameServ::Exceptions::GameServException;\r
9\r
10namespace GameServ \r
11{ \r
12 namespace Types\r
13 {\r
2a8a990d 14\r
15 //! Holds the exceptions related to types and their conversions\r
16 namespace Exceptions\r
17 {\r
18 //! Generic type exception possibly due to conversion or improper usage\r
19 class TypeException : public GameServException\r
20 {\r
21 public:\r
22 TypeException(const string &ErrorMsg, const char *pFilename, int SourceLine);\r
23 TypeException(const string &ErrorMsg);\r
24 TypeException(void);\r
25 };\r
e0d3cb09 26 }\r
27\r
28 class ItemTypes\r
29 {\r
30 public:\r
31 //! Logical ItemType enumerator\r
32 enum ItemType \r
33 { \r
34 Weapon, Armor, Potion, NOTYPE\r
35 };\r
36\r
37 //! Get the name of an item type\r
38 static string GetName(ItemType itemtype);\r
39\r
40 //! Parse the name and return the enumeration value\r
41 static ItemType Parse(const string &itemtype);\r
42\r
43 private:\r
44 //! Internal struct to hold type information statically in a table\r
45 typedef struct itemtypeinfo\r
46 {\r
47 ItemTypes::ItemType itemtype; //!< The ItemType enumeration value\r
cce88913 48 string name; //!< The Name of the type\r
e0d3cb09 49 } itemtypeinfo;\r
50\r
51 static const itemtypeinfo mItemTypeInfoTable[];\r
52\r
53 }; // ItemTypes class\r
cce88913 54\r
1134c368 55 class ObjectTypes\r
56 {\r
57 public:\r
58 //! Logical ObjectType enumerator\r
59 enum ObjectType \r
60 { \r
61 Player, Item, Level, Master, Monster\r
62 };\r
63\r
64 //! Get the name of an object type\r
65 static string GetName(ObjectType objecttype);\r
66\r
67 //! Parse the name and return the enumeration value\r
68 static ObjectType Parse(const string &objecttype);\r
69\r
70 private:\r
71 //! Internal struct to hold type information statically in a table\r
72 typedef struct objecttypeinfo\r
73 {\r
74 ObjectTypes::ObjectType objecttype; //!< The ObjectType enumeration value\r
75 string name; //!< The Name of the type\r
76 } objecttypeinfo;\r
77\r
78 static const objecttypeinfo mObjectTypeInfoTable[];\r
79\r
80 }; // ObjectTypes class\r
81\r
cce88913 82 class Modifiers\r
83 {\r
84 public:\r
85 //! Logical Modifer enumerator\r
86 enum Modifier\r
87 {\r
24f452e8 88 strength, defense, maxhealth, health, forestfights, playerfights, gold, bank, experience\r
cce88913 89 };\r
90\r
91 //! Get the name of a modifier\r
92 static string GetName(Modifier modifier);\r
93\r
94 //! Parse the name and return the modifier enumeration value\r
95 static Modifier Parse(const string &modifier);\r
96 private:\r
97 typedef struct modifierinfo\r
98 {\r
99 Modifiers::Modifier modifier; //!< The modifier enumeration value\r
100 string name; //!< The name of the modifier\r
101 } modifierinfo;\r
102 static const modifierinfo mModifierInfoTable[];\r
103 }; // Modifiers class\r
3d5a42ee 104\r
33ae7ca7 105 class IntRange\r
3d5a42ee 106 {\r
107 public:\r
fadef98f 108\r
33ae7ca7 109 IntRange();\r
fadef98f 110\r
33ae7ca7 111 IntRange(const int &high, const int &low);\r
fadef98f 112\r
33ae7ca7 113 ~IntRange();\r
3d5a42ee 114\r
33ae7ca7 115 //! Generate a random number within the IntRange\r
116 int Random();\r
3d5a42ee 117\r
118 //! Property get - High\r
33ae7ca7 119 int High(void) const;\r
3d5a42ee 120 \r
121 //! Property set - High\r
33ae7ca7 122 void High(const int &value);\r
3d5a42ee 123\r
124 //! Property get - Low\r
33ae7ca7 125 int Low(void) const;\r
126 \r
3d5a42ee 127\r
128 //! Property set - Low\r
33ae7ca7 129 void Low(const int &value);\r
1134c368 130\r
131 //! Property get - Last random number to be generated\r
33ae7ca7 132 int LastRandom(void) const;\r
133 \r
134 \r
135 private:\r
136 int mHigh;\r
137 int mLow;\r
138 int mLastRandom;\r
139 };\r
140\r
141 class UIntRange\r
142 {\r
143 public:\r
144\r
145 UIntRange();\r
146\r
147 UIntRange(const unsigned int &high, const unsigned int &low);\r
148\r
149 ~UIntRange();\r
150\r
151 //! Generate a random number within the IntRange\r
152 unsigned int Random();\r
153\r
154 //! Property get - High\r
155 unsigned int High(void) const;\r
156\r
157 //! Property set - High\r
158 void High(const unsigned int &value);\r
159\r
160 //! Property get - Low\r
161 unsigned int Low(void) const;\r
162\r
163 //! Property set - Low\r
164 void Low(const unsigned int &value);\r
165\r
166 //! Property get - Last random number to be generated\r
167 unsigned int LastRandom(void) const;\r
3d5a42ee 168 \r
169 private:\r
33ae7ca7 170 unsigned int mHigh;\r
171 unsigned int mLow;\r
172 unsigned int mLastRandom;\r
3d5a42ee 173 };\r
cce88913 174 } \r
e0d3cb09 175}\r
176#endif