From: kainazzzo Date: Mon, 12 May 2008 19:28:28 +0000 (+0000) Subject: Added some initial Game Objects with the start of a namespace hierarchy X-Git-Url: https://jfr.im/git/irc/gameservirc.git/commitdiff_plain/4534c364c3ee5654415e852c298941d1d8ad374b Added some initial Game Objects with the start of a namespace hierarchy git-svn-id: https://svn.code.sf.net/p/gameservirc/code/trunk@497 bc333340-6410-0410-a689-9d09f3c113fa --- diff --git a/gameserv-2.0/libgameservgldl/include/GameServ/GameLayer/GameObjects/Armor.h b/gameserv-2.0/libgameservgldl/include/GameServ/GameLayer/GameObjects/Armor.h new file mode 100644 index 0000000..9726586 --- /dev/null +++ b/gameserv-2.0/libgameservgldl/include/GameServ/GameLayer/GameObjects/Armor.h @@ -0,0 +1,14 @@ +#ifndef __GS__ARMOR_H__ +#define __GS__ARMOR_H__ + +#include +using GameServ::GameLayer::GameObjects::ItemGO; + +namespace GameServ { namespace GameLayer { namespace GameObjects + +class ArmorBO : public ItemGO +{ +}; + +}}} +#endif diff --git a/gameserv-2.0/libgameservgldl/include/GameServ/GameLayer/GameObjects/ArmorGO.h b/gameserv-2.0/libgameservgldl/include/GameServ/GameLayer/GameObjects/ArmorGO.h new file mode 100644 index 0000000..9726586 --- /dev/null +++ b/gameserv-2.0/libgameservgldl/include/GameServ/GameLayer/GameObjects/ArmorGO.h @@ -0,0 +1,14 @@ +#ifndef __GS__ARMOR_H__ +#define __GS__ARMOR_H__ + +#include +using GameServ::GameLayer::GameObjects::ItemGO; + +namespace GameServ { namespace GameLayer { namespace GameObjects + +class ArmorBO : public ItemGO +{ +}; + +}}} +#endif diff --git a/gameserv-2.0/libgameservgldl/include/GameServ/GameLayer/GameObjects/GameObject.h b/gameserv-2.0/libgameservgldl/include/GameServ/GameLayer/GameObjects/GameObject.h new file mode 100644 index 0000000..ed6b5fc --- /dev/null +++ b/gameserv-2.0/libgameservgldl/include/GameServ/GameLayer/GameObjects/GameObject.h @@ -0,0 +1,62 @@ +#ifndef __GS__GAMEOBJECT_H__ +#define __GS__GAMEOBJECT_H__ +#include +#include +using std::string; +using std::unary_function; + +#include +using boost::shared_ptr; + +namespace GameServ { namespace GameLayer { namespace GameObjects +{ + class GameObject + { + public: + GameObject(void); + GameObject(const string &Id); + virtual ~GameObject(); + + //! Returns the Id of this Game Object + string Id(void) const; + //! Set the Id for this Game Object + void Id(const string &value); + + //! Clone the entire game object + /*! + Overridden to allow deep cloning to prevent slicing. + \return Pointer to new Game object + */ + virtual GameObject *Clone(void) const = 0; + + bool operator==(const GameObject &right) const; + bool operator!=(const GameObject &right) const; + + private: + string mId; + friend class GameObjectIds_Eq; + }; + + //! Functor to compare Id's of Game Objects + class GameObjectIds_Eq : public unary_function, bool> + { + public: + explicit GameObjectIds_Eq(const string &Id); + + //! Comparison against shared_ptr types + bool operator()(const shared_ptr &BO) const; + + private: + string mId; + }; +}}} +#endif + + + + + + + + + diff --git a/gameserv-2.0/libgameservgldl/include/GameServ/GameLayer/GameObjects/ItemGO.h b/gameserv-2.0/libgameservgldl/include/GameServ/GameLayer/GameObjects/ItemGO.h new file mode 100644 index 0000000..95e2c7e --- /dev/null +++ b/gameserv-2.0/libgameservgldl/include/GameServ/GameLayer/GameObjects/ItemGO.h @@ -0,0 +1,58 @@ +#ifndef __GS__ITEM_H__ +#define __GS__ITEM_H__ +#include +using GameServ::GameLayer::GameObjects::GameObject; + +#include +using std::string; +#include +using std::vector; + +namespace GameServ { namespace GameLayer { namespace GameObjects +{ + enum ItemType { NOTYPE, WEAPON, ARMOR, POTION }; + + class ItemGO : public GameObject + { + public: + ItemGO(); + ItemGO(const string &name, const unsigned long int &price, const int &uses, const vector &modifiers); + virtual ~ItemGO(); + + //! Property get - Name + string Name(void) const; + //! Property set - Name + void Name(const string &value); + + //! Property get - Price + unsigned long int Price(void) const; + //! Property set - Price + void Price(const unsigned long int &value); + + //! Property get - Uses + int Uses(void) const; + //! Property set - Uses + void Uses(const int &value); + + //! Property get - Item Type + ItemType Type(void) const; + + //! Property set - Item Type + void Type(const ItemType &value); + + //! Property get - Modifiers + vector Modifiers(void) const; + //! Property set - Modifiers + void Modifiers(const vector &value); + + virtual ItemGO *Clone(void) const; + + private: + string mName; + unsigned long int mPrice; + int mUses; + ItemType mType; + vector mModifiers; + }; +}}} +#endif \ No newline at end of file diff --git a/gameserv-2.0/libgameservgldl/include/GameServ/GameLayer/GameObjects/PlayerGO.h b/gameserv-2.0/libgameservgldl/include/GameServ/GameLayer/GameObjects/PlayerGO.h new file mode 100644 index 0000000..e266ce3 --- /dev/null +++ b/gameserv-2.0/libgameservgldl/include/GameServ/GameLayer/GameObjects/PlayerGO.h @@ -0,0 +1,93 @@ +#ifndef __GS__PLAYER_H__ +#define __GS__PLAYER_H__ +#include +using GameServ::GameLayer::GameObjects::GameObject; + +#include +using boost::shared_ptr; + +#include +using std::string; + +namespace GameServ { namespace GameLayer { namespace GameObjects +{ + class PlayerGO : public GameObject + { + public: + Player(); + ~Player(); + + //! Property get - Name + string Name(void) const; + //! Property set - Name + void Name(const string &value); + + //! Property get - Level + int Level(void) const; + //! Property set - Level + void Level(const int &value); + + //! Property get - Experience + unsigned long int Experience(void) const; + //! Property set - Experience + void Experience(const unsigned long int &value); + + //! Property get - Gold + unsigned long int Gold(void) const; + //! Property set - Gold + void Gold(const unsigned long int &gold); + + //! Property get - Health + int Health(void) const; + //! Property set - Health + void Health(const int &value); + + //! Property get - Max Health + int MaxHealth(void) const; + //! Property set - Max Health + void MaxHealth(const int &value); + + //! Property get - Strength + int Strength(void) const; + //! Property set - Strength + void Strength(const int &value); + + //! Property get - Defense + int Defense(void) const; + //! Property set - Defense + void Defense(const int &value); + + //! Property get - Forest Fights + int ForestFights(void) const; + //! Propety set - Forest Fights + void ForestFights(const int &value); + + //! Property get - Player Fights + int PlayerFights(void) const; + //! Property set - Player Fights + void PlayerFights(const int &value); + + //! Property get - Weapon + shared_ptr Weapon(void) const; + //! Property set - Weapon + void Weapon(const shared_ptr spWeapon); + + + private: + string mName; + int mLevel; + unsigned long int mExperience; + unsigned long int mGold; + int mHealth; + int mMaxHealth; + int mStrength; + int mDefense; + int mForestFights; + int mPlayerFights; + string mPassword; + shared_ptr mWeapon; + shared_ptr mArmor; + + }; +}}} // GameServ::GameLayer::GameObjects +#endif \ No newline at end of file diff --git a/gameserv-2.0/libgameservgldl/include/GameServ/GameLayer/GameObjects/WeaponGO.h b/gameserv-2.0/libgameservgldl/include/GameServ/GameLayer/GameObjects/WeaponGO.h new file mode 100644 index 0000000..e69de29 diff --git a/gameserv-2.0/libgameservgldl/libgameservgldl.vcproj b/gameserv-2.0/libgameservgldl/libgameservgldl.vcproj index 199a392..2e0a62e 100644 --- a/gameserv-2.0/libgameservgldl/libgameservgldl.vcproj +++ b/gameserv-2.0/libgameservgldl/libgameservgldl.vcproj @@ -18,7 +18,7 @@ Name="Debug|Win32" OutputDirectory="$(SolutionDir)$(ConfigurationName)" IntermediateDirectory="$(ConfigurationName)" - ConfigurationType="1" + ConfigurationType="4" CharacterSet="2" > - @@ -75,12 +72,6 @@ - - @@ -161,22 +152,56 @@ - - + + + + + + + + + + + + + + + + + + + + + + diff --git a/gameserv-2.0/libgameservgldl/src/GameLayer/GameObjects/ArmorGO.cpp b/gameserv-2.0/libgameservgldl/src/GameLayer/GameObjects/ArmorGO.cpp new file mode 100644 index 0000000..e69de29 diff --git a/gameserv-2.0/libgameservgldl/src/GameLayer/GameObjects/GameObject.cpp b/gameserv-2.0/libgameservgldl/src/GameLayer/GameObjects/GameObject.cpp new file mode 100644 index 0000000..93daa5c --- /dev/null +++ b/gameserv-2.0/libgameservgldl/src/GameLayer/GameObjects/GameObject.cpp @@ -0,0 +1,60 @@ +#include +using GameServ::GameLayer::GameObjects::GameObject; +using GameServ::GameLayer::GameObjects::GameObjectIds_Eq; + +#include +using std::string; + +#include +using boost::shared_ptr; + +GameObject::GameObject(void) : mId() +{ +} + +GameObject::GameObject(const string &Id) : mId(Id) +{ +} + +GameObject::~GameObject(void) +{ +} + +bool GameObject::operator==(const GameObject &right) const +{ + return mId == right.mId; +} + +bool GameObject::operator!=(const GameObject &right) const +{ + return !(right == *this); +} + +string GameObject::Id(void) const +{ + return mId; +} + +void GameObject::Id(const string &value) +{ + mId = value; +} + + +GameObjectIds_Eq::GameObjectIds_Eq(const string &Id) : mId(Id) +{ +} + +bool GameObjectIds_Eq::operator ()(const shared_ptr &BO) const +{ + return mId == BO->mId; +} + + + + + + + + + diff --git a/gameserv-2.0/libgameservgldl/src/GameLayer/GameObjects/ItemGO.cpp b/gameserv-2.0/libgameservgldl/src/GameLayer/GameObjects/ItemGO.cpp new file mode 100644 index 0000000..2fcafa8 --- /dev/null +++ b/gameserv-2.0/libgameservgldl/src/GameLayer/GameObjects/ItemGO.cpp @@ -0,0 +1,86 @@ +#include +using GameServ::GameLayer::GameObjects::ItemGO; + +#include +using std::string; +#include +using std::vector; + +ItemGO::ItemGO() : GameObject(), mName(""), mPrice(0), mUses(1), mType(NOTYPE) +{ + mModifiers.resize(8); +} + +ItemGO::ItemGO(const string &name, const unsigned long &price, const int &uses, const vector &modifiers) : GameObject(), +mName(name), mPrice(price), mUses(uses), mType(NOTYPE) +{ + mModifiers.clear(); + mModifiers.insert(mModifiers.begin(), modifiers.begin(), modifiers.end()); +} + +ItemGO::~ItemGO() +{ +} + +string ItemGO::Name(void) const +{ + return mName; +} + +void ItemGO::Name(const string &value) +{ + mName = value; +} + +unsigned long int ItemGO::Price(void) const +{ + return mPrice; +} + +void ItemGO::Price(const unsigned long int &price) +{ + mPrice = price; +} + +int ItemGO::Uses(void) const +{ + return mUses; +} + +void ItemGO::Uses(const int &value) +{ + mUses = value; +} + +GameServ::GameLayer::GameObjects::ItemType ItemGO::Type(void) const +{ + return mType; +} + +void ItemGO::Type(const GameServ::GameLayer::GameObjects::ItemType &value) +{ + mType = value; +} + +vector ItemGO::Modifiers(void) const +{ + return mModifiers; +} + +void ItemGO::Modifiers(const vector &value) +{ + mModifiers.clear(); + mModifiers.insert(mModifiers.begin(), value.begin(), value.end()); +} + +ItemGO *ItemGO::Clone(void) const +{ + return new ItemGO(*this); +} + + + + + + + diff --git a/gameserv-2.0/libgameservgldl/src/GameLayer/GameObjects/PlayerGO.cpp b/gameserv-2.0/libgameservgldl/src/GameLayer/GameObjects/PlayerGO.cpp new file mode 100644 index 0000000..e69de29 diff --git a/gameserv-2.0/libgameservgldl/src/GameLayer/GameObjects/WeaponGO.cpp b/gameserv-2.0/libgameservgldl/src/GameLayer/GameObjects/WeaponGO.cpp new file mode 100644 index 0000000..e69de29