+\r
+ class ObjectTypes\r
+ {\r
+ public:\r
+ //! Logical ObjectType enumerator\r
+ enum ObjectType \r
+ { \r
+ Player, Item, Level, Master, Monster\r
+ };\r
+\r
+ //! Get the name of an object type\r
+ static string GetName(ObjectType objecttype);\r
+\r
+ //! Parse the name and return the enumeration value\r
+ static ObjectType Parse(const string &objecttype);\r
+\r
+ private:\r
+ //! Internal struct to hold type information statically in a table\r
+ typedef struct objecttypeinfo\r
+ {\r
+ ObjectTypes::ObjectType objecttype; //!< The ObjectType enumeration value\r
+ string name; //!< The Name of the type\r
+ } objecttypeinfo;\r
+\r
+ static const objecttypeinfo mObjectTypeInfoTable[];\r
+\r
+ }; // ObjectTypes class\r
+\r
+ class Modifiers\r
+ {\r
+ public:\r
+ //! Logical Modifer enumerator\r
+ enum Modifier\r
+ {\r
+ strength, defense, maxhealth, health, forestfights, playerfights, gold, bank\r
+ };\r
+\r
+ //! Get the name of a modifier\r
+ static string GetName(Modifier modifier);\r
+\r
+ //! Parse the name and return the modifier enumeration value\r
+ static Modifier Parse(const string &modifier);\r
+ private:\r
+ typedef struct modifierinfo\r
+ {\r
+ Modifiers::Modifier modifier; //!< The modifier enumeration value\r
+ string name; //!< The name of the modifier\r
+ } modifierinfo;\r
+ static const modifierinfo mModifierInfoTable[];\r
+ }; // Modifiers class\r
+\r
+ template <class T>\r
+ class Range\r
+ {\r
+ public:\r
+\r
+ Range()\r
+ {\r
+ }\r
+\r
+ Range(const T &high, const T &low)\r
+ {\r
+ mHigh = high;\r
+ mLow = low;\r
+ }\r
+\r
+ ~Range()\r
+ {\r
+ }\r
+\r
+ //! Generate a random number within the range\r
+ T Random()\r
+ {\r
+ static base_generator_type generator(static_cast<T>(std::time(0)));\r
+ if (mLow == mHigh)\r
+ {\r
+ return mLow;\r
+ }\r
+ else\r
+ {\r
+ boost::uniform_int<> uni_dist(mLow, mHigh);\r
+ boost::variate_generator<base_generator_type&, boost::uniform_int<> > uni(generator, uni_dist);\r
+ mLastRandom = uni();\r
+ return mLastRandom;\r
+ }\r
+ }\r
+\r
+ //! Property get - High\r
+ T High(void) const\r
+ {\r
+ return mHigh;\r
+ }\r
+ \r
+ //! Property set - High\r
+ void High(const T &value)\r
+ {\r
+ if (value >= mLow)\r
+ {\r
+ mHigh = value;\r
+ }\r
+ }\r
+\r
+ //! Property get - Low\r
+ T Low(void) const\r
+ {\r
+ return mLow;\r
+ }\r
+\r
+ //! Property set - Low\r
+ void Low(const T &value)\r
+ {\r
+ if (value <= mHigh)\r
+ {\r
+ mLow = value;\r
+ }\r
+ }\r
+\r
+ //! Property get - Last random number to be generated\r
+ T LastRandom(void) const\r
+ {\r
+ return mLastRandom;\r
+ }\r
+ \r
+ private:\r
+ T mHigh;\r
+ T mLow;\r
+ T mLastRandom;\r
+ };\r
+ } \r