1 #ifndef __GS__TYPES_H__
2 #define __GS__TYPES_H__
6 #include <GameServ/GameServException.h>
7 using GameServ::Exceptions::GameServException
;
10 #include <boost/random/linear_congruential.hpp>
11 #include <boost/random/uniform_int.hpp>
12 #include <boost/random/uniform_real.hpp>
13 #include <boost/random/variate_generator.hpp>
14 // Sun CC doesn't handle boost::iterator_adaptor yet
15 #if !defined(__SUNPRO_CC) || (__SUNPRO_CC > 0x530)
16 #include <boost/generator_iterator.hpp>
19 #ifdef BOOST_NO_STDC_NAMESPACE
25 // This is a typedef for a random number generator.
26 // Try boost::mt19937 or boost::ecuyer1988 instead of boost::minstd_rand
27 typedef boost::minstd_rand base_generator_type
;
35 //! Holds the exceptions related to types and their conversions
38 //! Generic type exception possibly due to conversion or improper usage
39 class TypeException
: public GameServException
42 TypeException(const string
&ErrorMsg
, const char *pFilename
, int SourceLine
);
43 TypeException(const string
&ErrorMsg
);
51 //! Logical ItemType enumerator
54 Weapon
, Armor
, Potion
, NOTYPE
57 //! Get the name of an item type
58 static string
GetName(ItemType itemtype
);
60 //! Parse the name and return the enumeration value
61 static ItemType
Parse(const string
&itemtype
);
64 //! Internal struct to hold type information statically in a table
65 typedef struct itemtypeinfo
67 ItemTypes::ItemType itemtype
; //!< The ItemType enumeration value
68 string name
; //!< The Name of the type
71 static const itemtypeinfo mItemTypeInfoTable
[];
78 //! Logical ObjectType enumerator
81 Player
, Item
, Level
, Master
, Monster
84 //! Get the name of an object type
85 static string
GetName(ObjectType objecttype
);
87 //! Parse the name and return the enumeration value
88 static ObjectType
Parse(const string
&objecttype
);
91 //! Internal struct to hold type information statically in a table
92 typedef struct objecttypeinfo
94 ObjectTypes::ObjectType objecttype
; //!< The ObjectType enumeration value
95 string name
; //!< The Name of the type
98 static const objecttypeinfo mObjectTypeInfoTable
[];
100 }; // ObjectTypes class
105 //! Logical Modifer enumerator
108 strength
, defense
, maxhealth
, health
, forestfights
, playerfights
, gold
, bank
, experience
111 //! Get the name of a modifier
112 static string
GetName(Modifier modifier
);
114 //! Parse the name and return the modifier enumeration value
115 static Modifier
Parse(const string
&modifier
);
117 typedef struct modifierinfo
119 Modifiers::Modifier modifier
; //!< The modifier enumeration value
120 string name
; //!< The name of the modifier
122 static const modifierinfo mModifierInfoTable
[];
123 }; // Modifiers class
134 Range(const T
&high
, const T
&low
)
145 //! Generate a random number within the range
148 static base_generator_type
generator(static_cast<T
>(std::time(0)));
155 boost::uniform_int
<> uni_dist(mLow
, mHigh
);
156 boost::variate_generator
<base_generator_type
&, boost::uniform_int
<> > uni(generator
, uni_dist
);
162 //! Property get - High
168 //! Property set - High
169 void High(const T
&value
)
177 //! Property get - Low
183 //! Property set - Low
184 void Low(const T
&value
)
192 //! Property get - Last random number to be generated
193 T
LastRandom(void) const