diff options
Diffstat (limited to 'src/being.h')
-rw-r--r-- | src/being.h | 277 |
1 files changed, 118 insertions, 159 deletions
diff --git a/src/being.h b/src/being.h index 80b73012..f19df9c0 100644 --- a/src/being.h +++ b/src/being.h @@ -34,10 +34,6 @@ const unsigned int MAX_EQUIP_SLOTS = 5; /**< Maximum number of equipped slots */ -namespace tmwserv -{ - - struct PATH_NODE { /** * Constructor. @@ -48,225 +44,192 @@ struct PATH_NODE { }; /** - * Structure type for the raw statistics of a Being. + * Raw statistics of a Player + */ + +enum { STAT_STR = 0, STAT_AGI, STAT_VIT, STAT_INT, STAT_DEX, STAT_LUK, NB_RSTAT }; + +/** + * Structure types for the raw statistics of a Player */ + struct RawStatistics { - unsigned short strength; - unsigned short agility; - unsigned short vitality; - unsigned short intelligence; - unsigned short dexterity; - unsigned short luck; + unsigned short stats[NB_RSTAT]; }; +/* + * Computed statistics of a Being + */ + +enum { STAT_HEA = 0, STAT_ATT, STAT_DEF, STAT_MAG, STAT_ACC, STAT_SPD, NB_CSTAT }; + +/** + * Structure type for the computed statistics of a Being. + */ +struct Statistics +{ + unsigned short stats[NB_CSTAT]; +}; /** * Generic Being (living object). * Used for players & monsters (all animated objects). */ -class Being: public Object +class Being: public MovingObject { public: /** - * Constructor. - */ - Being(const std::string& name, - const Genders gender, - const unsigned short hairStyle, - const unsigned short hairColor, - const unsigned short level, - const unsigned int money, - const RawStatistics& stats); - - /** - * Destructor. - */ - ~Being(void) - throw(); - - /** - * Gets the name. - * - * @return the name. - */ - const std::string& - getName(void) const; - - /** - * Gets the hair Style. - * - * @return the Hair style value. - */ - unsigned short - getHairStyle(void) const; - - /** - * Gets the Hair Color. - * - * @return the Hair Color value. + * Proxy constructor. */ - unsigned short - getHairColor(void) const; + Being(int type) + : MovingObject(type) + {} /** - * Gets the gender. + * Sets a computed statistic. * - * @return the gender. + * @param numStat the statistic number. + * @param value the new value. */ - Genders - getGender(void) const; - + void setStat(int numStat, unsigned short value) + { mStats.stats[numStat] = value; } /** - * Sets the level. + * Gets a computed statistic. * - * @param level the new level. + * @param numStat the statistic number. + * @return the statistic value. */ - void - setLevel(const unsigned short level); + unsigned short getStat(int numStat) + { return mStats.stats[numStat]; } - /** - * Gets the level. - * - * @return the level. - */ - unsigned short - getLevel(void) const; + private: + Being(Being const &rhs); + Being &operator=(Being const &rhs); - /** - * Sets the money. - * - * @param amount the new amount. - */ - void - setMoney(const unsigned int amount); + Statistics mStats; /**< stats modifiers or computed stats */ +}; - /** - * Gets the amount of money. - * - * @return the amount of money. - */ - unsigned int - getMoney(void) const; +class Player: public Being +{ + public: - /** - * Sets the strength. - * - * @param strength the new strength. - */ - void - setStrength(const unsigned short strength); + Player(std::string const &name) + : Being(OBJECT_PLAYER), + mName(name) + {} /** - * Gets the strength. + * Gets the name. * - * @return the strength. + * @return the name. */ - unsigned short - getStrength(void) const; + std::string const &getName() const + { return mName; } /** - * Sets the agility. + * Sets the hair style. * - * @param agility the new agility. + * @param style the new hair style. */ - void - setAgility(const unsigned short agility); + void setHairStyle(unsigned char style) + { mHairStyle = style; } /** - * Gets the agility. + * Gets the hair style. * - * @return the agility. + * @return the hair style value. */ - unsigned short - getAgility(void) const; + unsigned char getHairStyle() const + { return mHairStyle; } /** - * Sets the vitality. + * Sets the hair color. * - * @param vitality the new vitality. + * @param color the new hair color. */ - void - setVitality(const unsigned short vitality); + void setHairColor(unsigned char color) + { mHairColor = color; } /** - * Gets the vitality. + * Gets the hair color. * - * @return the vitality. + * @return the hair color value. */ - unsigned short - getVitality(void) const; + unsigned char getHairColor() const + { return mHairColor; } /** - * Sets the intelligence. + * Sets the gender. * - * @param intelligence the new intelligence. + * @param gender the new gender. */ - void - setIntelligence(const unsigned short intelligence); + void setGender(Genders gender) + { mGender = gender; } /** - * Gets the intelligence. + * Gets the gender. * - * @return the intelligence. + * @return the gender. */ - unsigned short - getIntelligence(void) const; + Genders getGender() const + { return mGender; } /** - * Sets the dexterity. + * Sets the level. * - * @param dexterity the new dexterity. + * @param level the new level. */ - void - setDexterity(const unsigned short dexterity); + void setLevel(unsigned char level) + { mLevel = level; } /** - * Gets the dexterity. + * Gets the level. * - * @return the dexterity. + * @return the level. */ - unsigned short - getDexterity(void) const; + unsigned char getLevel() const + { return mLevel; } /** - * Sets the luck. + * Sets the money. * - * @param luck the new luck. + * @param amount the new amount. */ - void - setLuck(const unsigned short luck); + void setMoney(unsigned int amount) + { mMoney = amount; } /** - * Gets the luck. + * Gets the amount of money. * - * @return the luck. + * @return the amount of money. */ - unsigned short - getLuck(void) const; + unsigned int getMoney() const + { return mMoney; } /** - * Sets the raw statistics. + * Sets a raw statistic. * - * @param stats the new raw statistics. + * @param numStat the statistic number. + * @param value the new value. */ - void - setRawStatistics(const RawStatistics& stats); + void setRawStat(int numStat, unsigned short value) + { mRawStats.stats[numStat] = value; } /** - * Gets the raw statistics. + * Gets a raw statistic. * - * @return the raw statistics. + * @param numStat the statistic number. + * @return the statistic value. */ - RawStatistics& - getRawStatistics(void); + unsigned short getRawStat(int numStat) + { return mRawStats.stats[numStat]; } /** * Updates the internal status. */ - void - update(void); + void update(); /** * Sets inventory. @@ -315,43 +278,39 @@ class Being: public Object unequip(unsigned char slot); private: - /** - * Copy constructor. - */ - Being(const Being& rhs); - - /** - * Assignment operator. - */ - Being& - operator=(const Being& rhs); + Player(Player const &); + Player &operator=(Player const &); std::string mName; /**< name of the being */ Genders mGender; /**< gender of the being */ - unsigned short mHairStyle;/**< Hair Style of the being */ - unsigned short mHairColor;/**< Hair Color of the being */ - unsigned short mLevel; /**< level of the being */ + unsigned char mHairStyle;/**< Hair Style of the being */ + unsigned char mHairColor;/**< Hair Color of the being */ + unsigned char mLevel; /**< level of the being */ unsigned int mMoney; /**< wealth of the being */ RawStatistics mRawStats; /**< raw stats of the being */ std::vector<unsigned int> inventory; /**< Player inventory */ unsigned int equipment[MAX_EQUIP_SLOTS]; /**< Equipped item ID's (from inventory) */ -}; - +}; /** * Type definition for a smart pointer to Being. */ typedef utils::CountedPtr<Being> BeingPtr; - /** * Type definition for a list of Beings. */ typedef std::vector<BeingPtr> Beings; +/** + * Type definition for a smart pointer to Player. + */ +typedef utils::CountedPtr<Player> PlayerPtr; -} // namespace tmwserv - +/** + * Type definition for a list of Players. + */ +typedef std::vector<PlayerPtr> Players; #endif // _TMWSERV_BEING_H_ |