X-Git-Url: http://git.localhorst.tv/?a=blobdiff_plain;f=src%2Fcommon%2FStats.h;h=f2eed68089d991ef884838f20e6a645bc172bb2c;hb=b9e715649b41cb69ea1b2d2a588522541eb87b46;hp=f07528a2f5db86331cf9cd088eb51d9da66b8cdb;hpb=3d69f521b593457304b282e5f23e36ab165288b6;p=l2e.git diff --git a/src/common/Stats.h b/src/common/Stats.h index f07528a..f2eed68 100644 --- a/src/common/Stats.h +++ b/src/common/Stats.h @@ -1,6 +1,11 @@ #ifndef COMMON_STATS_H_ #define COMMON_STATS_H_ +namespace loader { + class TypeDescription; +} + +#include #include namespace common { @@ -34,6 +39,21 @@ public: static void CreateTypeDescription(); static void Construct(void *); +public: + Stats &operator +=(const Stats &other) { + attack += other.attack; + defense += other.defense; + strength += other.strength; + agility += other.agility; + intelligence += other.intelligence; + magicResistance += other.magicResistance; + gut += other.gut; + return *this; + } + +protected: + static void AddFields(loader::TypeDescription &, const Stats &, std::ptrdiff_t offset); + private: int attack; int defense; @@ -47,14 +67,9 @@ private: inline Stats operator +(const Stats &lhs, const Stats &rhs) { - return Stats( - lhs.Attack() + rhs.Attack(), - lhs.Defense() + rhs.Defense(), - lhs.Strength() + rhs.Strength(), - lhs.Agility() + rhs.Agility(), - lhs.Intelligence() + rhs.Intelligence(), - lhs.Gut() + rhs.Gut(), - lhs.MagicResistance() + rhs.MagicResistance()); + Stats temp(lhs); + temp = rhs; + return temp; } }