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