]> jfr.im git - irc/gameservirc.git/blob - gameserv-2.0/libgameservcore/include/GameServ/Types.h
83e6bd99e8e5d7a6cc57586301d5a3356a18ac41
[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 Modifiers
55 {
56 public:
57 //! Logical Modifer enumerator
58 enum Modifier
59 {
60 strength, defense, maxhealth, health, forestfights, playerfights, gold, bank
61 };
62
63 //! Get the name of a modifier
64 static string GetName(Modifier modifier);
65
66 //! Parse the name and return the modifier enumeration value
67 static Modifier Parse(const string &modifier);
68 private:
69 typedef struct modifierinfo
70 {
71 Modifiers::Modifier modifier; //!< The modifier enumeration value
72 string name; //!< The name of the modifier
73 } modifierinfo;
74 static const modifierinfo mModifierInfoTable[];
75 }; // Modifiers class
76
77 class Range
78 {
79 public:
80 Range();
81 Range(const int &high, const int &low);
82 ~Range();
83
84 //! Generate a random number within the range
85 int Random();
86
87 //! Property get - High
88 int High(void) const;
89
90 //! Property set - High
91 void High(const int &value);
92
93 //! Property get - Low
94 int Low(void) const;
95
96 //! Property set - Low
97 void Low(const int &value);
98
99 private:
100 int mHigh;
101 int mLow;
102 };
103 }
104 }
105 #endif