#include <GameServ/GameServException.h>\r
using GameServ::Exceptions::GameServException;\r
\r
+\r
+#include <boost/random/linear_congruential.hpp>\r
+#include <boost/random/uniform_int.hpp>\r
+#include <boost/random/uniform_real.hpp>\r
+#include <boost/random/variate_generator.hpp>\r
+\r
+// This is a typedef for a random number generator.\r
+// Try boost::mt19937 or boost::ecuyer1988 instead of boost::minstd_rand\r
+typedef boost::minstd_rand base_generator_type;\r
+\r
namespace GameServ \r
{ \r
namespace Types\r
} modifierinfo;\r
static const modifierinfo mModifierInfoTable[];\r
}; // Modifiers class\r
+\r
+ class Range\r
+ {\r
+ public:\r
+ Range(const unsigned int &high, const unsigned int &low);\r
+ ~Range();\r
+\r
+ //! Generate a random number within the range\r
+ unsigned int Random();\r
+\r
+ //! Property get - High\r
+ unsigned int High(void) const;\r
+ \r
+ //! Property set - High\r
+ void High(const unsigned int &value);\r
+\r
+ //! Property get - Low\r
+ unsigned int Low(void) const;\r
+\r
+ //! Property set - Low\r
+ void Low(const unsigned int &value);\r
+ \r
+ private:\r
+ unsigned int mHigh;\r
+ unsigned int mLow;\r
+ base_generator_type generator;\r
+ };\r
} \r
}\r
#endif
\ No newline at end of file
#include <GameServ/Types.h>\r
using GameServ::Types::ItemTypes;\r
using GameServ::Types::Modifiers;\r
+using GameServ::Types::Range;\r
using GameServ::Types::Exceptions::TypeException;\r
\r
#include <string>\r
using boost::format;\r
using boost::str;\r
\r
+#include <ctime>\r
+#include <boost/random/linear_congruential.hpp>\r
+#include <boost/random/uniform_int.hpp>\r
+#include <boost/random/uniform_real.hpp>\r
+#include <boost/random/variate_generator.hpp>\r
+// Sun CC doesn't handle boost::iterator_adaptor yet\r
+#if !defined(__SUNPRO_CC) || (__SUNPRO_CC > 0x530)\r
+#include <boost/generator_iterator.hpp>\r
+#endif\r
+\r
+#ifdef BOOST_NO_STDC_NAMESPACE\r
+namespace std {\r
+ using ::time;\r
+}\r
+#endif\r
+\r
+\r
TypeException::TypeException(const string &ErrorMsg, const char *pFilename, int SourceLine)\r
: GameServException(ErrorMsg, pFilename, SourceLine)\r
{ }\r
}\r
\r
throw TypeException(str(format("No modifier enumeration found for %1%") % modifier), __FILE__, __LINE__);\r
+}\r
+\r
+Range::Range(const unsigned int &high, const unsigned int &low)\r
+{\r
+ mHigh = high;\r
+ mLow = low;\r
+ generator.seed(static_cast<unsigned int>(std::time(0)));\r
+}\r
+\r
+Range::~Range()\r
+{\r
+}\r
+\r
+void Range::High(const unsigned int &value)\r
+{\r
+ if (mHigh > mLow)\r
+ mHigh = value;\r
+}\r
+\r
+unsigned int Range::High(void) const\r
+{\r
+ return mHigh;\r
+}\r
+\r
+void Range::Low(const unsigned int &value)\r
+{\r
+ if (mLow < mHigh)\r
+ mLow = value;\r
+}\r
+\r
+unsigned int Range::Low(void) const\r
+{\r
+ return mLow;\r
+}\r
+\r
+unsigned int Range::Random()\r
+{\r
+ boost::uniform_int<> uni_dist(mHigh, mLow);\r
+ boost::variate_generator<base_generator_type&, boost::uniform_int<> > uni(generator, uni_dist);\r
+ return static_cast<unsigned int>(uni());\r
}
\ No newline at end of file
--- /dev/null
+#ifndef __GS__LEVEL_H__\r
+#define __GS__LEVEL_H__\r
+#include <GameServ/GameLayer/GameObjects/GameObject.h>\r
+using GameServ::GameLayer::GameObjects::GameObject;\r
+#include <GameServ/GameLayer/GameObjects/MasterGO.h>\r
+using GameServ::GameLayer::GameObjects::MasterGO;\r
+#include <GameServ/GameLayer/GameObjects/MonsterGO.h>\r
+using GameServ::GameLayer::GameObjects::MonsterGO;\r
+\r
+#include <string>\r
+using std::string;\r
+#include <vector>\r
+using std::vector;\r
+\r
+#include <boost/smart_ptr/shared_ptr.hpp>\r
+using boost::shared_ptr;\r
+\r
+namespace GameServ { namespace GameLayer { namespace GameObjects\r
+{\r
+ class LevelGO : public GameObject\r
+ {\r
+ public:\r
+\r
+ LevelGO();\r
+ LevelGO(const string &Id);\r
+\r
+ virtual ~LevelGO();\r
+\r
+ bool operator==(const LevelGO &right) const;\r
+ bool operator!=(const LevelGO &right) const;\r
+\r
+ virtual LevelGO *Clone(void) const;\r
+\r
+ private:\r
+\r
+ vector< shared_ptr<MonsterGO> > mspMonsters;\r
+ shared_ptr<MasterGO> mspMaster;\r
+ \r
+ };\r
+}}} // GameServ::GameLayer::GameObjects\r
+#endif
\ No newline at end of file
--- /dev/null
+#ifndef __GS__MASTER_H__\r
+#define __GS__MASTER_H__\r
+#include <GameServ/GameLayer/GameObjects/GameObject.h>\r
+using GameServ::GameLayer::GameObjects::GameObject;\r
+\r
+#include <string>\r
+using std::string;\r
+\r
+namespace GameServ { namespace GameLayer { namespace GameObjects\r
+{\r
+ class MasterGO : public GameObject\r
+ {\r
+ public:\r
+\r
+ MasterGO();\r
+ MasterGO(const string &Id);\r
+\r
+ virtual ~MasterGO();\r
+\r
+ //! Property get - Name\r
+ string Name(void) const;\r
+ //! Property set - Name\r
+ void Name(const string &value);\r
+\r
+ //! Property get - Gold\r
+ unsigned long int Gold(void) const;\r
+ //! Property set - Gold\r
+ void Gold(const unsigned long int &value);\r
+\r
+ //! Property get - Health\r
+ int Health(void) const;\r
+ //! Property set - Health\r
+ void Health(const int &value);\r
+\r
+ //! Property get - Max Health\r
+ int MaxHealth(void) const;\r
+ //! Property set - Max Health\r
+ void MaxHealth(const int &value);\r
+\r
+ //! Property get - Strength\r
+ int Strength(void) const;\r
+ //! Property set - Strength\r
+ void Strength(const int &value);\r
+\r
+ //! Property get - Defense\r
+ int Defense(void) const;\r
+ //! Property set - Defense\r
+ void Defense(const int &value);\r
+\r
+ //! Property get - Weapon Name\r
+ string WeaponName(void) const;\r
+\r
+ //! Property set - Weapon Name\r
+ void WeaponName(const string &value);\r
+\r
+ //! Property get - Death Cry\r
+ string DeathCry(void) const;\r
+\r
+ //! Property set - Death Cry\r
+ void DeathCry(const string &value);\r
+\r
+ bool operator==(const MasterGO &right) const;\r
+ bool operator!=(const MasterGO &right) const;\r
+\r
+ virtual MasterGO *Clone(void) const;\r
+\r
+ private:\r
+ string mName;\r
+ unsigned long int mGold;\r
+ int mHealth;\r
+ int mMaxHealth;\r
+ int mStrength;\r
+ int mDefense;\r
+ string mWeaponName;\r
+ string mDeathCry;\r
+ };\r
+}}} // GameServ::GameLayer::GameObjects\r
+#endif
\ No newline at end of file
--- /dev/null
+#ifndef __GS__MONSTER_H__\r
+#define __GS__MONSTER_H__\r
+#include <GameServ/GameLayer/GameObjects/GameObject.h>\r
+using GameServ::GameLayer::GameObjects::GameObject;\r
+\r
+#include <string>\r
+using std::string;\r
+\r
+namespace GameServ { namespace GameLayer { namespace GameObjects\r
+{\r
+ class MonsterGO : public GameObject\r
+ {\r
+ public:\r
+\r
+ MonsterGO();\r
+ MonsterGO(const string &Id);\r
+\r
+ virtual ~MonsterGO();\r
+\r
+ //! Property get - Name\r
+ string Name(void) const;\r
+ //! Property set - Name\r
+ void Name(const string &value);\r
+\r
+ //! Property get - Gold\r
+ unsigned long int Gold(void) const;\r
+ //! Property set - Gold\r
+ void Gold(const unsigned long int &value);\r
+\r
+ //! Property get - Health\r
+ int Health(void) const;\r
+ //! Property set - Health\r
+ void Health(const int &value);\r
+\r
+ //! Property get - Max Health\r
+ int MaxHealth(void) const;\r
+ //! Property set - Max Health\r
+ void MaxHealth(const int &value);\r
+\r
+ //! Property get - Strength\r
+ int Strength(void) const;\r
+ //! Property set - Strength\r
+ void Strength(const int &value);\r
+\r
+ //! Property get - Defense\r
+ int Defense(void) const;\r
+ //! Property set - Defense\r
+ void Defense(const int &value);\r
+\r
+ //! Property get - Weapon Name\r
+ string WeaponName(void) const;\r
+\r
+ //! Property set - Weapon Name\r
+ void WeaponName(const string &value);\r
+\r
+ //! Property get - Death Cry\r
+ string DeathCry(void) const;\r
+\r
+ //! Property set - Death Cry\r
+ void DeathCry(const string &value);\r
+\r
+ bool operator==(const MonsterGO &right) const;\r
+ bool operator!=(const MonsterGO &right) const;\r
+\r
+ virtual MonsterGO *Clone(void) const;\r
+\r
+ private:\r
+ string mName;\r
+ unsigned long int mGold;\r
+ int mHealth;\r
+ int mMaxHealth;\r
+ int mStrength;\r
+ int mDefense;\r
+ string mWeaponName;\r
+ string mDeathCry;\r
+ };\r
+}}} // GameServ::GameLayer::GameObjects\r
+#endif
\ No newline at end of file
RelativePath=".\include\GameServ\GameLayer\GameObjects\ItemGO.h"\r
>\r
</File>\r
+ <File\r
+ RelativePath=".\src\GameLayer\GameObjects\LevelGO.cpp"\r
+ >\r
+ </File>\r
+ <File\r
+ RelativePath=".\include\GameServ\GameLayer\GameObjects\LevelGO.h"\r
+ >\r
+ </File>\r
+ <File\r
+ RelativePath=".\src\GameLayer\GameObjects\MasterGO.cpp"\r
+ >\r
+ </File>\r
+ <File\r
+ RelativePath=".\include\GameServ\GameLayer\GameObjects\MasterGO.h"\r
+ >\r
+ </File>\r
+ <File\r
+ RelativePath=".\src\GameLayer\GameObjects\MonsterGO.cpp"\r
+ >\r
+ </File>\r
+ <File\r
+ RelativePath=".\include\GameServ\GameLayer\GameObjects\MonsterGO.h"\r
+ >\r
+ </File>\r
<File\r
RelativePath=".\src\GameLayer\GameObjects\PlayerGO.cpp"\r
>\r
--- /dev/null
+#include <GameServ/GameLayer/GameObjects/GameObject.h>\r
+using GameServ::GameLayer::GameObjects::GameObject;\r
+#include <GameServ/GameLayer/GameObjects/MasterGO.h>\r
+using GameServ::GameLayer::GameObjects::MasterGO;\r
+\r
+#include <string>\r
+using std::string;\r
+\r
+MasterGO::MasterGO()\r
+{\r
+}\r
+\r
+MasterGO::MasterGO(const string &Id) : GameObject(Id)\r
+{\r
+}\r
+\r
+MasterGO::~MasterGO()\r
+{\r
+}\r
+\r
+MasterGO *MasterGO::Clone(void) const\r
+{\r
+ return new MasterGO(*this);\r
+}\r
+\r
+void MasterGO::Name(const string &value)\r
+{\r
+ assert(!value.empty());\r
+ mName = value;\r
+}\r
+\r
+string MasterGO::Name(void) const\r
+{\r
+ return mName;\r
+}\r
+\r
+void MasterGO::Strength(const int &value)\r
+{\r
+ assert(value > 0);\r
+ mStrength = value;\r
+}\r
+\r
+int MasterGO::Strength(void) const\r
+{\r
+ return mStrength;\r
+}\r
+\r
+void MasterGO::Defense(const int &value)\r
+{\r
+ assert(value > 0);\r
+ mDefense = value;\r
+}\r
+\r
+int MasterGO::Defense(void) const\r
+{\r
+ return mDefense;\r
+}\r
+\r
+void MasterGO::Gold(const unsigned long &value)\r
+{\r
+ mGold = value;\r
+}\r
+\r
+unsigned long MasterGO::Gold(void) const\r
+{\r
+ return mGold;\r
+}\r
+\r
+void MasterGO::Health(const int &value)\r
+{\r
+ mHealth = value;\r
+}\r
+\r
+int MasterGO::Health(void) const\r
+{\r
+ return mHealth;\r
+}\r
+\r
+void MasterGO::MaxHealth(const int &value)\r
+{\r
+ mMaxHealth = value;\r
+}\r
+\r
+int MasterGO::MaxHealth(void) const\r
+{\r
+ return mMaxHealth;\r
+}\r
+\r
+void MasterGO::WeaponName(const string &value)\r
+{\r
+ assert(!value.empty());\r
+ mWeaponName = value;\r
+}\r
+\r
+string MasterGO::WeaponName(void) const\r
+{\r
+ return mWeaponName;\r
+}\r
+\r
+void MasterGO::DeathCry(const string &value)\r
+{\r
+ assert(!value.empty());\r
+ mDeathCry = value;\r
+}\r
+\r
+string MasterGO::DeathCry(void) const\r
+{\r
+ return mDeathCry;\r
+}\r
+\r
+bool MasterGO::operator==(const MasterGO &right) const\r
+{\r
+ return mId == right.mId && mHealth == right.mHealth &&\r
+ mDefense == right.mDefense && mDeathCry == right.mDeathCry &&\r
+ mGold == right.mGold && mHealth == right.mHealth && \r
+ mMaxHealth == right.mMaxHealth && mName == right.mName &&\r
+ mStrength == right.mStrength && mWeaponName == right.mWeaponName;\r
+}\r
+\r
+bool MasterGO::operator!=(const MasterGO &right) const\r
+{\r
+ return (!(*this == right));\r
+}
\ No newline at end of file
--- /dev/null
+#include <GameServ/GameLayer/GameObjects/GameObject.h>\r
+using GameServ::GameLayer::GameObjects::GameObject;\r
+#include <GameServ/GameLayer/GameObjects/MonsterGO.h>\r
+using GameServ::GameLayer::GameObjects::MonsterGO;\r
+\r
+#include <string>\r
+using std::string;\r
+\r
+MonsterGO::MonsterGO()\r
+{\r
+}\r
+\r
+MonsterGO::MonsterGO(const string &Id) : GameObject(Id)\r
+{\r
+}\r
+\r
+MonsterGO::~MonsterGO()\r
+{\r
+}\r
+\r
+MonsterGO *MonsterGO::Clone(void) const\r
+{\r
+ return new MonsterGO(*this);\r
+}\r
+\r
+void MonsterGO::Name(const string &value)\r
+{\r
+ assert(!value.empty());\r
+ mName = value;\r
+}\r
+\r
+string MonsterGO::Name(void) const\r
+{\r
+ return mName;\r
+}\r
+\r
+void MonsterGO::Strength(const int &value)\r
+{\r
+ assert(value > 0);\r
+ mStrength = value;\r
+}\r
+\r
+int MonsterGO::Strength(void) const\r
+{\r
+ return mStrength;\r
+}\r
+\r
+void MonsterGO::Defense(const int &value)\r
+{\r
+ assert(value > 0);\r
+ mDefense = value;\r
+}\r
+\r
+int MonsterGO::Defense(void) const\r
+{\r
+ return mDefense;\r
+}\r
+\r
+void MonsterGO::Gold(const unsigned long &value)\r
+{\r
+ mGold = value;\r
+}\r
+\r
+unsigned long MonsterGO::Gold(void) const\r
+{\r
+ return mGold;\r
+}\r
+\r
+void MonsterGO::Health(const int &value)\r
+{\r
+ mHealth = value;\r
+}\r
+\r
+int MonsterGO::Health(void) const\r
+{\r
+ return mHealth;\r
+}\r
+\r
+void MonsterGO::MaxHealth(const int &value)\r
+{\r
+ mMaxHealth = value;\r
+}\r
+\r
+int MonsterGO::MaxHealth(void) const\r
+{\r
+ return mMaxHealth;\r
+}\r
+\r
+void MonsterGO::WeaponName(const string &value)\r
+{\r
+ assert(!value.empty());\r
+ mWeaponName = value;\r
+}\r
+\r
+string MonsterGO::WeaponName(void) const\r
+{\r
+ return mWeaponName;\r
+}\r
+\r
+void MonsterGO::DeathCry(const string &value)\r
+{\r
+ assert(!value.empty());\r
+ mDeathCry = value;\r
+}\r
+\r
+string MonsterGO::DeathCry(void) const\r
+{\r
+ return mDeathCry;\r
+}\r
+\r
+bool MonsterGO::operator==(const MonsterGO &right) const\r
+{\r
+ return mId == right.mId && mHealth == right.mHealth &&\r
+ mDefense == right.mDefense && mDeathCry == right.mDeathCry &&\r
+ mGold == right.mGold && mHealth == right.mHealth && \r
+ mMaxHealth == right.mMaxHealth && mName == right.mName &&\r
+ mStrength == right.mStrength && mWeaponName == right.mWeaponName;\r
+}\r
+\r
+bool MonsterGO::operator!=(const MonsterGO &right) const\r
+{\r
+ return (!(*this == right));\r
+}
\ No newline at end of file
#include <GameServ/GameServException.h>\r
using GameServ::Exceptions::GameServException;\r
\r
+#include <GameServ/Types.h>\r
+using GameServ::Types::Range;\r
+\r
int main()\r
{\r
try\r
{\r
- PlayerGL pgl;\r
+ /* PlayerGL pgl;\r
shared_ptr<PlayerGO> spPlayer = pgl.GetById("Kain");\r
cout << spPlayer->Name() << endl;\r
spPlayer->Name("Kainazzzo");\r
- pgl.Insert(spPlayer);\r
+ pgl.Insert(spPlayer);*/\r
+\r
+ Range testrange(20, 100);\r
+\r
+ for (int x = 0; x < 100; x++)\r
+ {\r
+ cout << testrange.Random() << endl;\r
+ }\r
}\r
catch (GameServException &e)\r
{\r